don't resize the station logo image if we don't have to

This commit is contained in:
fgerlits 2006-12-06 16:42:04 +00:00
parent b3d8e4bf76
commit cdfd1db671
1 changed files with 12 additions and 11 deletions

View File

@ -802,17 +802,18 @@ resizeImage(Gtk::Image* image, int width, int height) throw ()
int imageWidth = pixbuf->get_width();
int imageHeight = pixbuf->get_height();
// this is integerese for (logoWidth/logoHeight > width/height)
if (imageWidth * height > imageHeight * width) {
// image is wide: squash horizontally
image->set(pixbuf->scale_simple(width,
(imageHeight * width)/imageWidth,
Gdk::INTERP_HYPER ));
} else {
// image is tall: squash vertically
image->set(pixbuf->scale_simple((imageWidth * height)/imageHeight,
height,
Gdk::INTERP_HYPER ));
if (imageWidth > width || imageHeight > height) {
if (imageWidth * height > imageHeight * width) {
// image is wide: squash horizontally
image->set(pixbuf->scale_simple(width,
(imageHeight * width)/imageWidth,
Gdk::INTERP_HYPER ));
} else {
// image is tall: squash vertically
image->set(pixbuf->scale_simple((imageWidth * height)/imageHeight,
height,
Gdk::INTERP_HYPER ));
}
}
}