Enlightenment CVS committal

Author  : raster
Project : e17
Module  : libs/imlib2

Dir     : e17/libs/imlib2/src/lib


Modified Files:
        grab.c 


Log Message:


this SHOULD fix cross-endianness issues (serve and client not same endianess)
...

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/imlib2/src/lib/grab.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- grab.c      1 Nov 2004 09:45:31 -0000       1.1
+++ grab.c      28 Jul 2005 04:15:11 -0000      1.2
@@ -55,6 +55,63 @@
    /* go thru the XImage and convert */
    if (xim->bits_per_pixel == 32)
       depth = 32;
+   /* data needs swapping */
+#define SWAP32(x) (x) = \
+   ((((int)(x) & 0x000000ff ) << 24) |\
+       (((int)(x) & 0x0000ff00 ) << 8) |\
+       (((int)(x) & 0x00ff0000 ) >> 8) |\
+       (((int)(x) & 0xff000000 ) >> 24))
+#define SWAP16(x) (x) = \
+   ((((short)(x) & 0x00ff ) << 8) |\
+       (((short)(x) & 0xff00 ) >> 8))
+   
+#ifdef WORDS_BIGENDIAN
+   if (xim->bitmap_bit_order == LSBFirst)
+#else
+   if (xim->bitmap_bit_order == MSBFirst)
+#endif
+       {
+         switch (depth)
+           {
+            case 0:
+            case 1:
+            case 2:
+            case 3:
+            case 4:
+            case 5:
+            case 6:
+            case 7:
+            case 8:
+              break;
+            case 15:
+            case 16:
+              for (y = 0; y < h; y++)
+                {
+                   unsigned short *tmp;
+                   tmp = (unsigned short *)(xim->data + (xim->bytes_per_line * 
y));
+                   for (x = 0; x < w; x++)
+                     {
+                        SWAP16(*tmp);
+                        tmp++;
+                     }
+                }
+            case 24:
+            case 32:
+              for (y = 0; y < h; y++)
+                {
+                   unsigned int *tmp;
+                   tmp = (unsigned int *)(xim->data + (xim->bytes_per_line * 
y));
+                   for (x = 0; x < w; x++)
+                     {
+                        SWAP32(*tmp);
+                        tmp++;
+                     }
+                }
+              break;
+            default:
+              break;
+           }
+       }
    switch (depth)
      {
        case 0:




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September
19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to