windowscodecs: Add support for generating WICBitmapPaletteTypeFixedHalftone216 palette.
This commit is contained in:
parent
97464c508f
commit
87b23de9bb
|
@ -232,6 +232,34 @@ static WICColor *generate_halftone125_palette(UINT *count)
|
|||
return entries;
|
||||
}
|
||||
|
||||
static WICColor *generate_halftone216_palette(UINT *count)
|
||||
{
|
||||
WICColor *entries;
|
||||
UINT i;
|
||||
|
||||
*count = 224;
|
||||
entries = HeapAlloc(GetProcessHeap(), 0, 224 * sizeof(WICColor));
|
||||
if (!entries) return NULL;
|
||||
|
||||
for (i = 0; i < 216; i++)
|
||||
{
|
||||
static const BYTE halftone_values[6] = { 0x00,0x33,0x66,0x99,0xcc,0xff };
|
||||
entries[i] = 0xff000000;
|
||||
entries[i] |= halftone_values[i%6];
|
||||
entries[i] |= halftone_values[(i/6)%6] << 8;
|
||||
entries[i] |= halftone_values[(i/36)%6] << 16;
|
||||
}
|
||||
|
||||
for (i = 216; i < 224; i++)
|
||||
{
|
||||
static const DWORD halftone[8] = { 0xc0c0c0, 0x808080, 0x800000, 0x008000,
|
||||
0x000080, 0x808000, 0x800080, 0x008080 };
|
||||
entries[i] = 0xff000000;
|
||||
entries[i] |= halftone[i-216];
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
static WICColor *generate_halftone256_palette(UINT *count)
|
||||
{
|
||||
WICColor *entries;
|
||||
|
@ -312,6 +340,11 @@ static HRESULT WINAPI PaletteImpl_InitializePredefined(IWICPalette *iface,
|
|||
if (!colors) return E_OUTOFMEMORY;
|
||||
break;
|
||||
|
||||
case WICBitmapPaletteTypeFixedHalftone216:
|
||||
colors = generate_halftone216_palette(&count);
|
||||
if (!colors) return E_OUTOFMEMORY;
|
||||
break;
|
||||
|
||||
case WICBitmapPaletteTypeFixedHalftone256:
|
||||
colors = generate_halftone256_palette(&count);
|
||||
if (!colors) return E_OUTOFMEMORY;
|
||||
|
|
|
@ -259,6 +259,30 @@ static void generate_halftone125_palette(DWORD *entries, UINT count)
|
|||
entries[i] = 0xffc0c0c0;
|
||||
}
|
||||
|
||||
static void generate_halftone216_palette(DWORD *entries, UINT count)
|
||||
{
|
||||
static const BYTE halftone_values[6] = { 0x00,0x33,0x66,0x99,0xcc,0xff };
|
||||
UINT i;
|
||||
|
||||
assert(count == 224);
|
||||
|
||||
for (i = 0; i < 216; i++)
|
||||
{
|
||||
entries[i] = 0xff000000;
|
||||
entries[i] |= halftone_values[i%6];
|
||||
entries[i] |= halftone_values[(i/6)%6] << 8;
|
||||
entries[i] |= halftone_values[(i/36)%6] << 16;
|
||||
}
|
||||
|
||||
for (i = 216; i < 224; i++)
|
||||
{
|
||||
static const DWORD halftone[8] = { 0xc0c0c0, 0x808080, 0x800000, 0x008000,
|
||||
0x000080, 0x808000, 0x800080, 0x008080 };
|
||||
entries[i] = 0xff000000;
|
||||
entries[i] |= halftone[i-216];
|
||||
}
|
||||
}
|
||||
|
||||
static void generate_halftone256_palette(DWORD *entries, UINT count)
|
||||
{
|
||||
static const BYTE halftone_values_b[4] = { 0x00,0x55,0xaa,0xff };
|
||||
|
@ -295,6 +319,7 @@ static void test_predefined_palette(void)
|
|||
{ WICBitmapPaletteTypeFixedHalftone27, 0, 0, 28, { 0 } },
|
||||
{ WICBitmapPaletteTypeFixedHalftone64, 0, 0, 72, { 0 } },
|
||||
{ WICBitmapPaletteTypeFixedHalftone125, 0, 0, 126, { 0 } },
|
||||
{ WICBitmapPaletteTypeFixedHalftone216, 0, 0, 224, { 0 } },
|
||||
{ WICBitmapPaletteTypeFixedHalftone256, 0, 0, 256, { 0 } },
|
||||
};
|
||||
IWICImagingFactory *factory;
|
||||
|
@ -358,6 +383,8 @@ static void test_predefined_palette(void)
|
|||
generate_halftone64_palette(td[i].color, td[i].count);
|
||||
else if (td[i].type == WICBitmapPaletteTypeFixedHalftone125)
|
||||
generate_halftone125_palette(td[i].color, td[i].count);
|
||||
else if (td[i].type == WICBitmapPaletteTypeFixedHalftone216)
|
||||
generate_halftone216_palette(td[i].color, td[i].count);
|
||||
else if (td[i].type == WICBitmapPaletteTypeFixedHalftone256)
|
||||
generate_halftone256_palette(td[i].color, td[i].count);
|
||||
|
||||
|
|
Loading…
Reference in New Issue