color reduction toolDigby wrote:Why would you want to convert an image to 12 bits?
Dan East wrote:It's a shame to compromise the quality for all devices, just for a limitation found on only 10% of the devices. 12 bit really looks bad compared to 16 bit in most cases.
Dan East
Dan East wrote:Even so, I would prefer to do the dithering at load-time for the devices that need it (assuming I could find such an algorithm).
Thierry wrote:Dan East wrote:Even so, I would prefer to do the dithering at load-time for the devices that need it (assuming I could find such an algorithm).
I would also like to do that. But how does one detect such devices? The only way I know is to explicitely detect the iPAQ 36xx devices. Are there any others with 12 bits display?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Uint32 dither4[4][4] = { {0, 4, 1, 5}, {6, 2, 7, 3}, {1, 5, 0, 4}, {7, 3, 6, 2} };
PIXEL Dither16(Uint32 x, Uint32 y, Uint32 Red, Uint32 Green, Uint32 Blue)
{
Uint32 dither;
Uint32 pRed, pGreen, pBlue;
dither = dither4[y&3][x&3];
pRed = Red >>3;
pGreen = Green>>2;
pBlue = Blue >>3;
if((dither < Red&7) && pRed < 31) { pRed = pRed++; }
if((dither < Green&3) && pGreen < 63) { pGreen = pGreen++; }
if((dither < Blue&7) && pBlue < 31) { pBlue = pBlue++; }
return (pRed << 11) | (pGreen << 5) | (pBlue );
}
/////////////////////////////////////////////////////////////////////////////////
PIXEL Dither12(Uint32 x, Uint32 y, Uint32 Red, Uint32 Green, Uint32 Blue)
{
Uint32 dither;
Uint32 pRed, pGreen, pBlue;
dithy = y & 0x3;
dithx = x & 0x3;
dither = 2*dither4[y&3][x&3];
pRed = Red >>4;
pGreen = Green>>4;
pBlue = Blue >>4;
if((dither < Red&15) && pRed < 15) { pRed = pRed++; }
if((dither < Green&15) && pGreen < 15) { pGreen = pGreen++; }
if((dither < Blue&15) && pBlue < 15) { pBlue = pBlue++; }
return (pRed << 12) | (pGreen << 7) | (pBlue<<1 );
}
43 lines; 8 keywds; 48 nums; 220 ops; 0 strs; 1 coms Syntactic Coloring v0.4 - Dan East