From 3aa1366e034b2db90a0b8d8c1d56b8ae5b92c963 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Mon, 9 Jan 2017 17:01:42 +0100 Subject: thumbnailer: Cleanup the cleanups Commit 6afda9c removed the separate height and width arguments, as we always want to keep the original image's aspect ratio. The cleanup wasn't quite finished though, and ended up with slightly non-sensical checks (like doing comparisons twice). Coverity CID 1388524 https://bugzilla.gnome.org/show_bug.cgi?id=768062 --- thumbnailer/gdk-pixbuf-thumbnailer.c | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) (limited to 'thumbnailer') diff --git a/thumbnailer/gdk-pixbuf-thumbnailer.c b/thumbnailer/gdk-pixbuf-thumbnailer.c index a10483e15..2fe728d40 100644 --- a/thumbnailer/gdk-pixbuf-thumbnailer.c +++ b/thumbnailer/gdk-pixbuf-thumbnailer.c @@ -46,31 +46,14 @@ size_prepared_cb (GdkPixbufLoader *loader, info->input_height = height; if (width < info->size && height < info->size) return; + if (info->size <= 0) return; - if ((info->size > 0 || info->size > 0)) { - if (info->size < 0) - { - width = width * (double)info->size/(double)height; - height = info->size; - } - else if (info->size < 0) - { - height = height * (double)info->size/(double)width; - width = info->size; - } - else if ((double)height * (double)info->size > - (double)width * (double)info->size) { - width = 0.5 + (double)width * (double)info->size / (double)height; - height = info->size; - } else { - height = 0.5 + (double)height * (double)info->size / (double)width; - width = info->size; - } + if (height > width) { + width = 0.5 + (double)width * (double)info->size / (double)height; + height = info->size; } else { - if (info->size > 0) - width = info->size; - if (info->size > 0) - height = info->size; + height = 0.5 + (double)height * (double)info->size / (double)width; + width = info->size; } gdk_pixbuf_loader_set_size (loader, width, height); -- cgit v1.2.1