comparison src/gtkimhtml.c @ 11867:ff02464a079f

[gaim-migrate @ 14158] SF Patch #1339095 from sadrul "This patch resizes images in GtkIMHtml that had previously been resized to a smaller size." This fixes the image resizing bug I had with maximizing Get Info windows. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Thu, 27 Oct 2005 21:36:19 +0000
parents a0956e22fdde
children 52f27ffe68a5
comparison
equal deleted inserted replaced
11866:2bee8d023e23 11867:ff02464a079f
3148 return GTK_IMHTML_SCALABLE(im_image); 3148 return GTK_IMHTML_SCALABLE(im_image);
3149 } 3149 }
3150 3150
3151 void gtk_imhtml_image_scale(GtkIMHtmlScalable *scale, int width, int height) 3151 void gtk_imhtml_image_scale(GtkIMHtmlScalable *scale, int width, int height)
3152 { 3152 {
3153 GtkIMHtmlImage *image = (GtkIMHtmlImage *)scale; 3153 GtkIMHtmlImage *im_image = (GtkIMHtmlImage *)scale;
3154 3154
3155 if(image->width > width || image->height > height){ 3155 if (im_image->width > width || im_image->height > height) {
3156 double ratio_w, ratio_h, ratio; 3156 double ratio_w, ratio_h, ratio;
3157 int new_h, new_w; 3157 int new_h, new_w;
3158 GdkPixbuf *new_image = NULL; 3158 GdkPixbuf *new_image = NULL;
3159 3159
3160 ratio_w = ((double)width - 2) / image->width; 3160 ratio_w = ((double)width - 2) / im_image->width;
3161 ratio_h = ((double)height - 2) / image->height; 3161 ratio_h = ((double)height - 2) / im_image->height;
3162 3162
3163 ratio = (ratio_w < ratio_h) ? ratio_w : ratio_h; 3163 ratio = (ratio_w < ratio_h) ? ratio_w : ratio_h;
3164 3164
3165 new_w = (int)(image->width * ratio); 3165 new_w = (int)(im_image->width * ratio);
3166 new_h = (int)(image->height * ratio); 3166 new_h = (int)(im_image->height * ratio);
3167 3167
3168 new_image = gdk_pixbuf_scale_simple(image->pixbuf, new_w, new_h, GDK_INTERP_BILINEAR); 3168 new_image = gdk_pixbuf_scale_simple(im_image->pixbuf, new_w, new_h, GDK_INTERP_BILINEAR);
3169 gtk_image_set_from_pixbuf(image->image, new_image); 3169 gtk_image_set_from_pixbuf(im_image->image, new_image);
3170 g_object_unref(G_OBJECT(new_image));
3171 } else if (gdk_pixbuf_get_width(gtk_image_get_pixbuf(im_image->image)) != im_image->width) {
3172 /* Enough space to show the full-size of the image. */
3173 GdkPixbuf *new_image;
3174
3175 new_image = gdk_pixbuf_scale_simple(im_image->pixbuf, im_image->width, im_image->height, GDK_INTERP_BILINEAR);
3176 gtk_image_set_from_pixbuf(im_image->image, new_image);
3170 g_object_unref(G_OBJECT(new_image)); 3177 g_object_unref(G_OBJECT(new_image));
3171 } 3178 }
3172 } 3179 }
3173 3180
3174 static void 3181 static void