Mercurial > vba-clojure
comparison temp-c-stuff @ 487:09df21060be6
merge
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 07 May 2012 11:15:49 -0500 |
parents | cd6a96a07d2e |
children |
comparison
equal
deleted
inserted
replaced
486:3f0156038802 | 487:09df21060be6 |
---|---|
1 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
2 | |
3 | |
4 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
5 | |
6 | |
7 // This section of code is used to convert an RGB (pc) triplet into a RGB (gameboy) | |
8 // triplet. This section of code was kindly donated by Brett Bibby (GameBrains). | |
9 | |
10 BYTE intensity[32] = | |
11 { | |
12 0x00,0x10,0x20,0x30,0x40,0x50,0x5e,0x6c,0x7a,0x88,0x94,0xa0,0xae,0xb7,0xbf,0xc6, | |
13 0xce,0xd3,0xd9,0xdf,0xe3,0xe7,0xeb,0xef,0xf3,0xf6,0xf9,0xfb,0xfd,0xfe,0xff,0xff | |
14 }; | |
15 | |
16 unsigned char influence[3][3] = | |
17 { | |
18 {16,4,4}, | |
19 {8,16,8}, | |
20 {0,8,16} | |
21 }; | |
22 | |
23 RGBQUAD translate(BYTE rgb[3]) | |
24 { | |
25 RGBQUAD color; | |
26 BYTE tmp[3]; | |
27 BYTE m[3][3]; | |
28 BYTE i,j; | |
29 | |
30 for (i=0;i<3;i++) | |
31 for (j=0;j<3;j++) | |
32 m[i][j] = (intensity[rgb[i]>>3]*influence[i][j]) >> 5; | |
33 | |
34 for (i=0;i<3;i++) | |
35 { | |
36 if (m[0][i]>m[1][i]) | |
37 { | |
38 j=m[0][i]; | |
39 m[0][i]=m[1][i]; | |
40 m[1][i]=j; | |
41 } | |
42 | |
43 if (m[1][i]>m[2][i]) | |
44 { | |
45 j=m[1][i]; | |
46 m[1][i]=m[2][i]; | |
47 m[2][i]=j; | |
48 } | |
49 | |
50 if (m[0][i]>m[1][i]) | |
51 { | |
52 j=m[0][i]; | |
53 m[0][i]=m[1][i]; | |
54 m[1][i]=j; | |
55 } | |
56 | |
57 tmp[i]=(((m[0][i]+m[1][i]*2+m[2][i]*4)*5) >> 4)+32; | |
58 } | |
59 | |
60 color.rgbRed = tmp[0]; | |
61 color.rgbGreen = tmp[1]; | |
62 color.rgbBlue = tmp[2]; | |
63 | |
64 return color; | |
65 } | |
66 | |
67 | |
68 | |
69 | |
70 | |
71 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
72 |