1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-20 21:08:08 +01:00

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.
This commit is contained in:
Rodolfo García Peñas (kix)
2012-11-14 19:26:12 +01:00
committed by Carlos R. Mafra
parent 5956d71d77
commit 78ff715d39

View File

@@ -359,10 +359,14 @@ RImage *wIconValidateIconSize(RImage *icon, int max_size)
return NULL; return NULL;
/* We should hold "ICON_BORDER" (~2) pixels to include the icon border */ /* We should hold "ICON_BORDER" (~2) pixels to include the icon border */
if ((icon->width - max_size) > -ICON_BORDER || if (((max_size + ICON_BORDER) < icon->width) ||
(icon->height - max_size) > -ICON_BORDER) { ((max_size + ICON_BORDER) < icon->height)) {
nimage = RScaleImage(icon, max_size - ICON_BORDER, if (icon->width > icon->height)
(icon->height * (max_size - ICON_BORDER) / icon->width)); 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); RReleaseImage(icon);
icon = nimage; icon = nimage;
} }