[gdk-pixbuf] thumbnailer: Cleanup the cleanups
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdk-pixbuf] thumbnailer: Cleanup the cleanups
- Date: Mon, 9 Jan 2017 17:14:36 +0000 (UTC)
commit 3aa1366e034b2db90a0b8d8c1d56b8ae5b92c963
Author: Bastien Nocera <hadess hadess net>
Date: Mon Jan 9 17:01:42 2017 +0100
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 files changed, 6 insertions(+), 23 deletions(-)
---
diff --git a/thumbnailer/gdk-pixbuf-thumbnailer.c b/thumbnailer/gdk-pixbuf-thumbnailer.c
index a10483e..2fe728d 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]