Don't scale images that are small enough to fit. Avoid using incompatibly
2004-03-02 Morten Welinder <terra@gnome.org> * tests/testfilechooser.c (size_prepared_cb): Don't scale images that are small enough to fit. Avoid using incompatibly typed data pointer.
This commit is contained in:
committed by
Morten Welinder
parent
c0b55fe0d8
commit
e4cec76b6d
@ -1,5 +1,9 @@
|
|||||||
2004-03-02 Morten Welinder <terra@gnome.org>
|
2004-03-02 Morten Welinder <terra@gnome.org>
|
||||||
|
|
||||||
|
* tests/testfilechooser.c (size_prepared_cb): Don't scale images
|
||||||
|
that are small enough to fit. Avoid using incompatibly typed data
|
||||||
|
pointer.
|
||||||
|
|
||||||
* gtk/gtkfilechooserdefault.c
|
* gtk/gtkfilechooserdefault.c
|
||||||
(gtk_file_chooser_default_get_resizable_hints): Test the
|
(gtk_file_chooser_default_get_resizable_hints): Test the
|
||||||
resize_horizontally pointer, not the deferenced pointer.
|
resize_horizontally pointer, not the deferenced pointer.
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
2004-03-02 Morten Welinder <terra@gnome.org>
|
2004-03-02 Morten Welinder <terra@gnome.org>
|
||||||
|
|
||||||
|
* tests/testfilechooser.c (size_prepared_cb): Don't scale images
|
||||||
|
that are small enough to fit. Avoid using incompatibly typed data
|
||||||
|
pointer.
|
||||||
|
|
||||||
* gtk/gtkfilechooserdefault.c
|
* gtk/gtkfilechooserdefault.c
|
||||||
(gtk_file_chooser_default_get_resizable_hints): Test the
|
(gtk_file_chooser_default_get_resizable_hints): Test the
|
||||||
resize_horizontally pointer, not the deferenced pointer.
|
resize_horizontally pointer, not the deferenced pointer.
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
2004-03-02 Morten Welinder <terra@gnome.org>
|
2004-03-02 Morten Welinder <terra@gnome.org>
|
||||||
|
|
||||||
|
* tests/testfilechooser.c (size_prepared_cb): Don't scale images
|
||||||
|
that are small enough to fit. Avoid using incompatibly typed data
|
||||||
|
pointer.
|
||||||
|
|
||||||
* gtk/gtkfilechooserdefault.c
|
* gtk/gtkfilechooserdefault.c
|
||||||
(gtk_file_chooser_default_get_resizable_hints): Test the
|
(gtk_file_chooser_default_get_resizable_hints): Test the
|
||||||
resize_horizontally pointer, not the deferenced pointer.
|
resize_horizontally pointer, not the deferenced pointer.
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
2004-03-02 Morten Welinder <terra@gnome.org>
|
2004-03-02 Morten Welinder <terra@gnome.org>
|
||||||
|
|
||||||
|
* tests/testfilechooser.c (size_prepared_cb): Don't scale images
|
||||||
|
that are small enough to fit. Avoid using incompatibly typed data
|
||||||
|
pointer.
|
||||||
|
|
||||||
* gtk/gtkfilechooserdefault.c
|
* gtk/gtkfilechooserdefault.c
|
||||||
(gtk_file_chooser_default_get_resizable_hints): Test the
|
(gtk_file_chooser_default_get_resizable_hints): Test the
|
||||||
resize_horizontally pointer, not the deferenced pointer.
|
resize_horizontally pointer, not the deferenced pointer.
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
2004-03-02 Morten Welinder <terra@gnome.org>
|
2004-03-02 Morten Welinder <terra@gnome.org>
|
||||||
|
|
||||||
|
* tests/testfilechooser.c (size_prepared_cb): Don't scale images
|
||||||
|
that are small enough to fit. Avoid using incompatibly typed data
|
||||||
|
pointer.
|
||||||
|
|
||||||
* gtk/gtkfilechooserdefault.c
|
* gtk/gtkfilechooserdefault.c
|
||||||
(gtk_file_chooser_default_get_resizable_hints): Test the
|
(gtk_file_chooser_default_get_resizable_hints): Test the
|
||||||
resize_horizontally pointer, not the deferenced pointer.
|
resize_horizontally pointer, not the deferenced pointer.
|
||||||
|
|||||||
@ -138,20 +138,19 @@ static void
|
|||||||
size_prepared_cb (GdkPixbufLoader *loader,
|
size_prepared_cb (GdkPixbufLoader *loader,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
gpointer data)
|
int *data)
|
||||||
{
|
{
|
||||||
struct {
|
int des_width = data[0];
|
||||||
int width;
|
int des_height = data[1];
|
||||||
int height;
|
|
||||||
} *info = data;
|
|
||||||
|
|
||||||
if ((double)height * (double)info->width >
|
if (des_height >= height && des_width >= width) {
|
||||||
(double)width * (double)info->height) {
|
/* Nothing */
|
||||||
width = 0.5 + (double)width * (double)info->height / (double)height;
|
} else if ((double)height * des_width > (double)width * des_height) {
|
||||||
height = info->height;
|
width = 0.5 + (double)width * des_height / (double)height;
|
||||||
|
height = des_height;
|
||||||
} else {
|
} else {
|
||||||
height = 0.5 + (double)height * (double)info->width / (double)width;
|
height = 0.5 + (double)height * des_width / (double)width;
|
||||||
width = info->width;
|
width = des_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdk_pixbuf_loader_set_size (loader, width, height);
|
gdk_pixbuf_loader_set_size (loader, width, height);
|
||||||
@ -165,10 +164,7 @@ my_new_from_file_at_size (const char *filename,
|
|||||||
{
|
{
|
||||||
GdkPixbufLoader *loader;
|
GdkPixbufLoader *loader;
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
struct {
|
int info[2];
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
} info;
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
guchar buffer [4096];
|
guchar buffer [4096];
|
||||||
@ -204,9 +200,9 @@ my_new_from_file_at_size (const char *filename,
|
|||||||
#ifdef DONT_PRESERVE_ASPECT
|
#ifdef DONT_PRESERVE_ASPECT
|
||||||
gdk_pixbuf_loader_set_size (loader, width, height);
|
gdk_pixbuf_loader_set_size (loader, width, height);
|
||||||
#else
|
#else
|
||||||
info.width = width;
|
info[0] = width;
|
||||||
info.height = height;
|
info[1] = height;
|
||||||
g_signal_connect (loader, "size-prepared", G_CALLBACK (&size_prepared_cb), &info);
|
g_signal_connect (loader, "size-prepared", G_CALLBACK (size_prepared_cb), info);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (!feof (f)) {
|
while (!feof (f)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user