From: Christophe CURIS <[email protected]>
---
WINGs/WINGs/WINGs.h | 5 +++++
WINGs/wpixmap.c | 20 ++++++++++++++++++--
src/dialog.c | 3 ++-
src/dockedapp.c | 2 +-
4 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/WINGs/WINGs/WINGs.h b/WINGs/WINGs/WINGs.h
index d3b4f28..3004d2d 100644
--- a/WINGs/WINGs/WINGs.h
+++ b/WINGs/WINGs/WINGs.h
@@ -841,6 +841,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 55c457b..d5800a4 100644
--- a/WINGs/wpixmap.c
+++ b/WINGs/wpixmap.c
@@ -119,6 +119,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;
- RCombineImageWithColor(image, color);
+ /* scale it if needed to fit in the specified box */
+ if ((width > 0) && (height > 0) && ((image->width > width) ||
(image->height > height))) {
+ RImage *tmp;
- pixPtr = WMCreatePixmapFromRImage(scrPtr, image, 0);
+ 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 69fd31d..fd43cfb 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);
diff --git a/src/dockedapp.c b/src/dockedapp.c
index 19d55bb..63a4864 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 {
--
1.8.5.3
--
To unsubscribe, send mail to [email protected].