From 78ff715d39432e44fd57ce91c940ceeaa6b76a23 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= Date: Wed, 14 Nov 2012 19:26:12 +0100 Subject: [PATCH] wIconValidateIconSize checks the width and height The function wIconValidateIconSize checks if the width size and height size are less than the preference size (and left space for the border). If the width size or height size is greater than the preference, then checks what is the bigger size of them. Then resize it using the bigger value and holding the aspect ratio. Before this patch, wIconValidateIconSize didn't check if height was bigger than width and always suppose that width was greater than height. --- src/icon.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/icon.c b/src/icon.c index 166c8272..1ed90bd6 100644 --- a/src/icon.c +++ b/src/icon.c @@ -359,10 +359,14 @@ RImage *wIconValidateIconSize(RImage *icon, int max_size) return NULL; /* We should hold "ICON_BORDER" (~2) pixels to include the icon border */ - if ((icon->width - max_size) > -ICON_BORDER || - (icon->height - max_size) > -ICON_BORDER) { - nimage = RScaleImage(icon, max_size - ICON_BORDER, - (icon->height * (max_size - ICON_BORDER) / icon->width)); + if (((max_size + ICON_BORDER) < icon->width) || + ((max_size + ICON_BORDER) < icon->height)) { + if (icon->width > icon->height) + nimage = RScaleImage(icon, max_size - ICON_BORDER, + (icon->height * (max_size - ICON_BORDER) / icon->width)); + else + nimage = RScaleImage(icon, (icon->width * (max_size - ICON_BORDER) / icon->height), + max_size - ICON_BORDER); RReleaseImage(icon); icon = nimage; } -- 2.11.4.GIT