Dash:
[t2.git] / package / graphic / fbgrab / 565-fixup.patch
blobe061e8cb3e4de3cf37155fac57f4d6fb6d056522
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
3 #
4 # T2 SDE: package/.../fbgrab/565-fixup.patch
5 # Copyright (C) 2004 - 2005 The T2 SDE Project
6 #
7 # More information can be found in the files COPYING and README.
8 #
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
15 # --- T2-COPYRIGHT-NOTE-END ---
17 Fixed fbgrab for big-endian systems, including a code cleanup on the way.
19 - Rene Rebe
21 --- fbgrab-1.0/fbgrab.c 2002-04-15 22:22:54.000000000 +0200
22 +++ fbgrab-1.0-fixed/fbgrab.c 2004-09-05 16:12:42.874276472 +0200
23 @@ -166,15 +166,17 @@
25 for (i=0; i < (unsigned int) height*width*2; i+=2)
27 - /* BLUE = 0 */
28 - outbuffer[(i<<1)+0] = (inbuffer[i] & 0x1f) << 3;
29 - /* GREEN = 1 */
30 - outbuffer[(i<<1)+1] = (((inbuffer[i+1] & 0x7) << 3) |
31 - (inbuffer[i] & 0xE0) >> 5) << 2;
32 - /* RED = 2 */
33 - outbuffer[(i<<1)+2] = (inbuffer[i+1] & 0xF8);
34 - /* ALPHA = 3 */
35 - outbuffer[(i<<1)+3] = '\0';
36 + int16_t v =
37 +#ifdef __BIG_ENDIAN__
38 + (inbuffer[i] << 8) + inbuffer[i+1];
39 +#else
40 + (inbuffer[i+1] << 8) + inbuffer[i];
41 +#endif
43 + outbuffer[(i<<1)+0] = (v << 3) & 0xf8; /* B */
44 + outbuffer[(i<<1)+1] = (v >> 3) & 0xfc; /* G */
45 + outbuffer[(i<<1)+2] = (v >> 8) & 0xf8; /* R */
46 + outbuffer[(i<<1)+3] = 0; /* A */