Some code reformatting.

Fixed pixmap creating issue for 24-bit displays.
This commit is contained in:
Sanel Zukan 2009-11-23 12:52:03 +00:00
parent b25a148298
commit a324dc2eb0

View File

@ -38,7 +38,7 @@
if(bshift >= 0) \
tmp |= (((int)b << bshift) & bmask); \
else \
tmp |= (((int)b >> (-bshift)) & bmask);
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,17 +135,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 & 0xff000000) >> 24;
*destptr++ = (tmp & 0xff0000) >> 16;
*destptr++ = (tmp & 0xff00) >> 8;
// FIXME: check this somehow !
if(id == 4)
*destptr++ = (tmp & 0xff);
} else {
// little endian
if(id == 4)
*destptr++ = (tmp & 0xff);
*destptr++ = (tmp & 0xff00) >> 8;
*destptr++ = (tmp & 0xff0000) >> 16;
@ -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;
}