mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
Some code reformatting.
Fixed pixmap creating issue for 24-bit displays.
This commit is contained in:
parent
b25a148298
commit
a324dc2eb0
@ -29,16 +29,16 @@
|
||||
tmp |= (((int)r << rshift) & rmask); \
|
||||
else \
|
||||
tmp |= (((int)r >> (-rshift)) & rmask); \
|
||||
\
|
||||
\
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user