From a324dc2eb0edb58d66280fa070a8f80230fcf685 Mon Sep 17 00:00:00 2001 From: Sanel Zukan Date: Mon, 23 Nov 2009 12:52:03 +0000 Subject: [PATCH] Some code reformatting. Fixed pixmap creating issue for 24-bit displays. --- ede-desktop/Wallpaper.cpp | 46 +++++++++++++++------------------------ 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/ede-desktop/Wallpaper.cpp b/ede-desktop/Wallpaper.cpp index 67a96bd..5b732a7 100644 --- a/ede-desktop/Wallpaper.cpp +++ b/ede-desktop/Wallpaper.cpp @@ -24,21 +24,21 @@ #include "Utils.h" #define CALC_PIXEL(tmp, rshift, rmask, gshift, gmask, bshift, bmask) \ - tmp = 0; \ - if(rshift >= 0) \ - tmp |= (((int)r << rshift) & rmask); \ - else \ + tmp = 0; \ + if(rshift >= 0) \ + tmp |= (((int)r << rshift) & rmask); \ + else \ tmp |= (((int)r >> (-rshift)) & rmask); \ -\ - if(gshift >= 0) \ - tmp |= (((int)g << gshift) & gmask); \ - else \ + \ + if(gshift >= 0) \ + tmp |= (((int)g << gshift) & gmask); \ + else \ tmp |= (((int)g >> (-gshift)) & gmask); \ -\ - if(bshift >= 0) \ - tmp |= (((int)b << bshift) & bmask); \ - else \ - tmp |= (((int)b >> (-bshift)) & bmask); + \ + if(bshift >= 0) \ + tmp |= (((int)b << bshift) & bmask); \ + else \ + tmp |= (((int)b >> (-bshift)) & bmask) static Pixmap create_xpixmap(Fl_Image* img, XImage** xim, Pixmap pix, int wp_w, int wp_h) { @@ -116,7 +116,8 @@ static Pixmap create_xpixmap(Fl_Image* img, XImage** xim, Pixmap pix, int wp_w, msb = false; unsigned int r, g, b, tmp; - unsigned char* dest = (unsigned char*)malloc(sizeof(unsigned char) * iw * ih * id); + //unsigned char* dest = (unsigned char*)malloc(sizeof(unsigned char) * iw * ih * id); + unsigned char* dest = (unsigned char*)malloc(ih * (*xim)->bytes_per_line); unsigned char* destptr = dest; unsigned char* src = (unsigned char*)img->data()[0]; @@ -134,18 +135,12 @@ static Pixmap create_xpixmap(Fl_Image* img, XImage** xim, Pixmap pix, int wp_w, CALC_PIXEL(tmp, rshift, rmask, gshift, gmask, bshift, bmask); if(msb) { - // big endian *destptr++ = (tmp & 0xff000000) >> 24; *destptr++ = (tmp & 0xff0000) >> 16; *destptr++ = (tmp & 0xff00) >> 8; - - // FIXME: check this somehow ! - if(id == 4) - *destptr++ = (tmp & 0xff); + *destptr++ = (tmp & 0xff); } else { - // little endian - if(id == 4) - *destptr++ = (tmp & 0xff); + *destptr++ = (tmp & 0xff); *destptr++ = (tmp & 0xff00) >> 8; *destptr++ = (tmp & 0xff0000) >> 16; *destptr++ = (tmp & 0xff000000) >> 24; @@ -187,13 +182,11 @@ static Pixmap create_xpixmap(Fl_Image* img, XImage** xim, Pixmap pix, int wp_w, CALC_PIXEL(tmp, rshift, rmask, gshift, gmask, bshift, bmask); if(msb) { - // big endian *destptr++ = (tmp & 0xff0000) >> 16; *destptr++ = (tmp & 0xff00) >> 8; *destptr++ = (tmp & 0xff); } else { - // little endian *destptr++ = (tmp & 0xff); *destptr++ = (tmp & 0xff00) >> 8; *destptr++ = (tmp & 0xff0000) >> 16; @@ -208,12 +201,10 @@ static Pixmap create_xpixmap(Fl_Image* img, XImage** xim, Pixmap pix, int wp_w, b = *src++; if(msb) { - // big endian *destptr++ = b; *destptr++ = g; *destptr++ = r; } else { - // little endian *destptr++ = r; *destptr++ = g; *destptr++ = b; @@ -235,12 +226,9 @@ static Pixmap create_xpixmap(Fl_Image* img, XImage** xim, Pixmap pix, int wp_w, CALC_PIXEL(tmp, rshift, rmask, gshift, gmask, bshift, bmask); if(msb) { - // big endian *destptr++ = (tmp >> 8) & 0xff; *destptr++ = (tmp & 0xff); - } else { - // little endian *destptr++ = (tmp & 0xff); *destptr++ = (tmp >> 8) & 0xff; }