SOURCES: fbgrab-bigendian.patch (NEW) -- fix for big-endian machin...

sparky sparky at pld-linux.org
Fri Jul 14 02:58:15 CEST 2006


Author: sparky                       Date: Fri Jul 14 00:58:14 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
-- fix for big-endian machines
- 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

---- Files affected:
SOURCES:
   fbgrab-bigendian.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/fbgrab-bigendian.patch
diff -u /dev/null SOURCES/fbgrab-bigendian.patch:1.1
--- /dev/null	Fri Jul 14 02:58:14 2006
+++ SOURCES/fbgrab-bigendian.patch	Fri Jul 14 02:58:07 2006
@@ -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);
================================================================


More information about the pld-cvs-commit mailing list