diff --git a/WINGs/WINGs/WINGs.h b/WINGs/WINGs/WINGs.h index 7149aeb6..dd3fac54 100644 --- a/WINGs/WINGs/WINGs.h +++ b/WINGs/WINGs/WINGs.h @@ -843,6 +843,11 @@ WMPixmap* WMCreateBlendedPixmapFromRImage(WMScreen *scrPtr, RImage *image, WMPixmap* WMCreateBlendedPixmapFromFile(WMScreen *scrPtr, const char *fileName, const RColor *color); +WMPixmap* WMCreateScaledBlendedPixmapFromFile(WMScreen *scrPtr, const char *fileName, + const RColor *color, + unsigned int width, + unsigned int height); + void WMDrawPixmap(WMPixmap *pixmap, Drawable d, int x, int y); Pixmap WMGetPixmapXID(WMPixmap *pixmap); diff --git a/WINGs/wpixmap.c b/WINGs/wpixmap.c index 55c457b4..d5800a4d 100644 --- a/WINGs/wpixmap.c +++ b/WINGs/wpixmap.c @@ -118,6 +118,12 @@ WMPixmap *WMCreateBlendedPixmapFromRImage(WMScreen * scrPtr, RImage * image, con } WMPixmap *WMCreateBlendedPixmapFromFile(WMScreen * scrPtr, const char *fileName, const RColor * color) +{ + return WMCreateScaledBlendedPixmapFromFile(scrPtr, fileName, color, 0, 0); +} + +WMPixmap *WMCreateScaledBlendedPixmapFromFile(WMScreen *scrPtr, const char *fileName, const RColor *color, + unsigned int width, unsigned int height) { WMPixmap *pixPtr; RImage *image; @@ -126,10 +132,20 @@ WMPixmap *WMCreateBlendedPixmapFromFile(WMScreen * scrPtr, const char *fileName, if (!image) return NULL; + /* scale it if needed to fit in the specified box */ + if ((width > 0) && (height > 0) && ((image->width > width) || (image->height > height))) { + RImage *tmp; + + tmp = image; + if (image->width > image->height) + image = RScaleImage(tmp, width, image->height * height / image->width); + else + image = RScaleImage(tmp, image->width * width / image->height, height); + RReleaseImage(tmp); + } + RCombineImageWithColor(image, color); - pixPtr = WMCreatePixmapFromRImage(scrPtr, image, 0); - RReleaseImage(image); return pixPtr; diff --git a/src/dialog.c b/src/dialog.c index 4ca4d84d..1341af8c 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -619,7 +619,8 @@ static void setViewedImage(IconPanel *panel, const char *file) color.green = 0xaa; color.blue = 0xae; color.alpha = 0; - pixmap = WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel->win), file, &color); + pixmap = WMCreateScaledBlendedPixmapFromFile(WMWidgetScreen(panel->win), file, &color, 75, 75); + if (!pixmap) { WMSetButtonEnabled(panel->okButton, False); @@ -742,7 +743,7 @@ static void drawIconProc(WMList * lPtr, int index, Drawable d, char *text, int s color.blue = WMBlueComponentOfColor(back) >> 8; color.alpha = WMGetColorAlpha(back) >> 8; - pixmap = WMCreateBlendedPixmapFromFile(wmscr, file, &color); + pixmap = WMCreateScaledBlendedPixmapFromFile(wmscr, file, &color, width - 2, height - 2); wfree(file); if (!pixmap) { diff --git a/src/dockedapp.c b/src/dockedapp.c index 19d55bbd..63a4864d 100644 --- a/src/dockedapp.c +++ b/src/dockedapp.c @@ -103,7 +103,7 @@ static void updateSettingsPanelIcon(AppSettingsPanel * panel) color.green = 0xaa; color.blue = 0xae; color.alpha = 0; - pixmap = WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel->win), path, &color); + pixmap = WMCreateScaledBlendedPixmapFromFile(WMWidgetScreen(panel->win), path, &color, 64, 64); if (!pixmap) { WMSetLabelImage(panel->iconLabel, NULL); } else {