/* Returns a scaled copy of pixbuf, preserving aspect ratio. The copy will * be scaled as large as possible without exceeding the specified width and height. */ GdkPixbuf * eel_gdk_pixbuf_scale_to_fit (GdkPixbuf *pixbuf, int max_width, int max_height) { int scaled_width; int scaled_height; eel_gdk_scale_to_fit_factor (gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf), max_width, max_height, &scaled_width, &scaled_height); return gdk_pixbuf_scale_simple (pixbuf, scaled_width, scaled_height, GDK_INTERP_BILINEAR); }
/* Returns a copy of pixbuf scaled down, preserving aspect ratio, to fit * within the specified width and height. If it already fits, a copy of * the original, without scaling, is returned. */ GdkPixbuf * eel_gdk_pixbuf_scale_down_to_fit (GdkPixbuf *pixbuf, int max_width, int max_height) { int scaled_width; int scaled_height; double scale_factor; scale_factor = eel_gdk_scale_to_fit_factor (gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf), max_width, max_height, &scaled_width, &scaled_height); if (scale_factor >= 1.0) { return gdk_pixbuf_copy (pixbuf); } else { return eel_gdk_pixbuf_scale_down (pixbuf, scaled_width, scaled_height); } }