X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Fglx%2Fgrab-ximage.c;h=c0b5a2f01082a4c90f6655e6a5fbcb363bede846;hp=d1e920794a0acdbdfeeee93153378274fadbdaf4;hb=6a1da724858673ac40aa13a9612340d8bed8c7b9;hpb=96bdd7cf6ea60c418a76921acaf0e34d6f5be930 diff --git a/hacks/glx/grab-ximage.c b/hacks/glx/grab-ximage.c index d1e92079..c0b5a2f0 100644 --- a/hacks/glx/grab-ximage.c +++ b/hacks/glx/grab-ximage.c @@ -85,6 +85,15 @@ spread_bits (unsigned char value, unsigned char width) } +static Bool +bigendian (void) +{ + union { int i; char c[sizeof(int)]; } u; + u.i = 1; + return !u.c[0]; +} + + /* Returns an XImage structure containing an image of the desktop. (As a side-effect, that image *may* be painted onto the given Window.) This XImage will be 32 bits per pixel, 8 each per R, G, and B, with the @@ -146,10 +155,10 @@ screen_to_ximage (Screen *screen, Window window) */ { int x, y; - int crpos, cgpos, cbpos, capos; /* bitfield positions */ - int srpos, sgpos, sbpos; - int srmsk, sgmsk, sbmsk; - int srsiz, sgsiz, sbsiz; + unsigned int crpos=0, cgpos=0, cbpos=0, capos=0; /* bitfield positions */ + unsigned int srpos=0, sgpos=0, sbpos=0; + unsigned int srmsk=0, sgmsk=0, sbmsk=0; + unsigned int srsiz=0, sgsiz=0, sbsiz=0; int i; unsigned char spread_map[3][256]; @@ -171,7 +180,10 @@ screen_to_ximage (Screen *screen, Window window) we need to pack things in "RGBA" order on the client machine, regardless of its endianness. */ - crpos = 0, cgpos = 8, cbpos = 16, capos = 24; + if (bigendian()) + crpos = 24, cgpos = 16, cbpos = 8, capos = 0; + else + crpos = 0, cgpos = 8, cbpos = 16, capos = 24; if (colors == 0) /* truecolor */ {