windowscodecs: Add support for generating WICBitmapPaletteTypeFixedHalftone252 palette.
This commit is contained in:
parent
87b23de9bb
commit
0be2718baa
|
@ -260,6 +260,27 @@ static WICColor *generate_halftone216_palette(UINT *count)
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static WICColor *generate_halftone252_palette(UINT *count)
|
||||||
|
{
|
||||||
|
WICColor *entries;
|
||||||
|
UINT i;
|
||||||
|
|
||||||
|
*count = 252;
|
||||||
|
entries = HeapAlloc(GetProcessHeap(), 0, 252 * sizeof(WICColor));
|
||||||
|
if (!entries) return NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < 252; i++)
|
||||||
|
{
|
||||||
|
static const BYTE halftone_values_rb[6] = { 0x00,0x33,0x66,0x99,0xcc,0xff };
|
||||||
|
static const BYTE halftone_values_g[7] = { 0x00,0x2b,0x55,0x80,0xaa,0xd5,0xff };
|
||||||
|
entries[i] = 0xff000000;
|
||||||
|
entries[i] |= halftone_values_rb[i%6];
|
||||||
|
entries[i] |= halftone_values_g[(i/6)%7] << 8;
|
||||||
|
entries[i] |= halftone_values_rb[(i/42)%6] << 16;
|
||||||
|
}
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
static WICColor *generate_halftone256_palette(UINT *count)
|
static WICColor *generate_halftone256_palette(UINT *count)
|
||||||
{
|
{
|
||||||
WICColor *entries;
|
WICColor *entries;
|
||||||
|
@ -345,6 +366,11 @@ static HRESULT WINAPI PaletteImpl_InitializePredefined(IWICPalette *iface,
|
||||||
if (!colors) return E_OUTOFMEMORY;
|
if (!colors) return E_OUTOFMEMORY;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WICBitmapPaletteTypeFixedHalftone252:
|
||||||
|
colors = generate_halftone252_palette(&count);
|
||||||
|
if (!colors) return E_OUTOFMEMORY;
|
||||||
|
break;
|
||||||
|
|
||||||
case WICBitmapPaletteTypeFixedHalftone256:
|
case WICBitmapPaletteTypeFixedHalftone256:
|
||||||
colors = generate_halftone256_palette(&count);
|
colors = generate_halftone256_palette(&count);
|
||||||
if (!colors) return E_OUTOFMEMORY;
|
if (!colors) return E_OUTOFMEMORY;
|
||||||
|
|
|
@ -283,6 +283,23 @@ static void generate_halftone216_palette(DWORD *entries, UINT count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void generate_halftone252_palette(DWORD *entries, UINT count)
|
||||||
|
{
|
||||||
|
static const BYTE halftone_values_rb[6] = { 0x00,0x33,0x66,0x99,0xcc,0xff };
|
||||||
|
static const BYTE halftone_values_g[7] = { 0x00,0x2b,0x55,0x80,0xaa,0xd5,0xff };
|
||||||
|
UINT i;
|
||||||
|
|
||||||
|
assert(count == 252);
|
||||||
|
|
||||||
|
for (i = 0; i < 252; i++)
|
||||||
|
{
|
||||||
|
entries[i] = 0xff000000;
|
||||||
|
entries[i] |= halftone_values_rb[i%6];
|
||||||
|
entries[i] |= halftone_values_g[(i/6)%7] << 8;
|
||||||
|
entries[i] |= halftone_values_rb[(i/42)%6] << 16;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void generate_halftone256_palette(DWORD *entries, UINT count)
|
static void generate_halftone256_palette(DWORD *entries, UINT count)
|
||||||
{
|
{
|
||||||
static const BYTE halftone_values_b[4] = { 0x00,0x55,0xaa,0xff };
|
static const BYTE halftone_values_b[4] = { 0x00,0x55,0xaa,0xff };
|
||||||
|
@ -320,6 +337,7 @@ static void test_predefined_palette(void)
|
||||||
{ WICBitmapPaletteTypeFixedHalftone64, 0, 0, 72, { 0 } },
|
{ WICBitmapPaletteTypeFixedHalftone64, 0, 0, 72, { 0 } },
|
||||||
{ WICBitmapPaletteTypeFixedHalftone125, 0, 0, 126, { 0 } },
|
{ WICBitmapPaletteTypeFixedHalftone125, 0, 0, 126, { 0 } },
|
||||||
{ WICBitmapPaletteTypeFixedHalftone216, 0, 0, 224, { 0 } },
|
{ WICBitmapPaletteTypeFixedHalftone216, 0, 0, 224, { 0 } },
|
||||||
|
{ WICBitmapPaletteTypeFixedHalftone252, 0, 0, 252, { 0 } },
|
||||||
{ WICBitmapPaletteTypeFixedHalftone256, 0, 0, 256, { 0 } },
|
{ WICBitmapPaletteTypeFixedHalftone256, 0, 0, 256, { 0 } },
|
||||||
};
|
};
|
||||||
IWICImagingFactory *factory;
|
IWICImagingFactory *factory;
|
||||||
|
@ -385,6 +403,8 @@ static void test_predefined_palette(void)
|
||||||
generate_halftone125_palette(td[i].color, td[i].count);
|
generate_halftone125_palette(td[i].color, td[i].count);
|
||||||
else if (td[i].type == WICBitmapPaletteTypeFixedHalftone216)
|
else if (td[i].type == WICBitmapPaletteTypeFixedHalftone216)
|
||||||
generate_halftone216_palette(td[i].color, td[i].count);
|
generate_halftone216_palette(td[i].color, td[i].count);
|
||||||
|
else if (td[i].type == WICBitmapPaletteTypeFixedHalftone252)
|
||||||
|
generate_halftone252_palette(td[i].color, td[i].count);
|
||||||
else if (td[i].type == WICBitmapPaletteTypeFixedHalftone256)
|
else if (td[i].type == WICBitmapPaletteTypeFixedHalftone256)
|
||||||
generate_halftone256_palette(td[i].color, td[i].count);
|
generate_halftone256_palette(td[i].color, td[i].count);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue