]> git.pld-linux.org Git - packages/fbgrab.git/commitdiff
-- fix for big-endian machines
authorsparky <sparky@pld-linux.org>
Fri, 14 Jul 2006 00:58:07 +0000 (00:58 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
- 565 fix found somewhere in the net, I'll assume it's correct but it isn't
  working for me (my 16bit fb is very strange: rrrrrugggggbbbbb u==unused)
- in 32bit mode swap bytes on big-endian to match gbra

Changed files:
    fbgrab-bigendian.patch -> 1.1

fbgrab-bigendian.patch [new file with mode: 0644]

diff --git a/fbgrab-bigendian.patch b/fbgrab-bigendian.patch
new file mode 100644 (file)
index 0000000..e2a14fd
--- /dev/null
@@ -0,0 +1,66 @@
+--- fbgrab-1.0/fbgrab.c        2002-04-15 22:22:54.000000000 +0200
++++ fbgrab-1.0/fbgrab.c.new    2006-07-14 02:46:49.000000000 +0200
+@@ -163,15 +163,17 @@
+     for (i=0; i < (unsigned int) height*width*2; i+=2)
+     {
+-      /* BLUE  = 0 */
+-      outbuffer[(i<<1)+0] = (inbuffer[i] & 0x1f) << 3;
+-      /* GREEN = 1 */
+-        outbuffer[(i<<1)+1] = (((inbuffer[i+1] & 0x7) << 3) | 
+-                           (inbuffer[i] & 0xE0) >> 5) << 2;   
+-        /* RED   = 2 */
+-      outbuffer[(i<<1)+2] = (inbuffer[i+1] & 0xF8);
+-      /* ALPHA = 3 */
+-      outbuffer[(i<<1)+3] = '\0'; 
++      int16_t v =
++#ifdef __BIG_ENDIAN__
++              (inbuffer[i] << 8) + inbuffer[i+1];
++#else
++              (inbuffer[i+1] << 8) + inbuffer[i];
++#endif
++
++      outbuffer[(i<<1)+0] = (v << 3) & 0xf8; /* B */
++      outbuffer[(i<<1)+1] = (v >> 3) & 0xfc; /* G */
++      outbuffer[(i<<1)+2] = (v >> 8) & 0xf8; /* R */
++      outbuffer[(i<<1)+3] = 0; /* A */
+     }
+ }
+@@ -194,6 +196,22 @@
+     }
+ }
++static void convertARGBtoBGRA(int width, int height, 
++                         unsigned char *inbuffer, 
++                         unsigned char *outbuffer)
++{
++    unsigned int i;
++
++    for (i=0; i < (unsigned int) height*width*4; i+=4)
++    {
++        outbuffer[i+0] = inbuffer[i+3];
++        outbuffer[i+1] = inbuffer[i+2];
++        outbuffer[i+2] = inbuffer[i+1];
++        outbuffer[i+3] = inbuffer[i+0];
++    }
++}
++
++
+ static void write_PNG(unsigned char *outbuffer, char *filename, 
+                               int width, int height, int interlace)
+ {
+@@ -283,8 +301,13 @@
+       write_PNG(outbuffer, filename, width, height, interlace);
+       break;
+     case 32:
++#ifdef __BIG_ENDIAN__
++      convertARGBtoBGRA(width, height, inbuffer, outbuffer);
++      write_PNG(outbuffer, filename, width, height, interlace);
++#else
+       /* No conversion needed */
+       write_PNG(inbuffer, filename, width, height, interlace);
++#endif
+       break;
+     default:
+       fprintf(stderr, "%d bits per pixel are not supported! ", bits);
This page took 0.062302 seconds and 4 git commands to generate.