>From 8ff93eb33a3737f28516301cede3d16930c31a31 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
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 9b40e76..2a5fcaa 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;
}
--
1.7.10.4
--
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
>From 8ff93eb33a3737f28516301cede3d16930c31a31 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
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 9b40e76..2a5fcaa 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;
}
--
1.7.10.4