Commit 2ed1aaa9 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

gdiplus: Add support for converting RGB formats to 8bpp indexed.

parent d9f4df06
......@@ -541,6 +541,16 @@ GpStatus convert_pixels(INT width, INT height,
return Ok; \
} while (0);
#define convert_rgb_to_indexed(getpixel_function, setpixel_function) do { \
for (x=0; x<width; x++) \
for (y=0; y<height; y++) { \
BYTE r, g, b, a; \
getpixel_function(&r, &g, &b, &a, src_bits+src_stride*y, x); \
setpixel_function(r, g, b, a, dst_bits+dst_stride*y, x, palette); \
} \
return Ok; \
} while (0);
switch (src_format)
{
case PixelFormat1bppIndexed:
......@@ -627,6 +637,8 @@ GpStatus convert_pixels(INT width, INT height,
case PixelFormat16bppGrayScale:
switch (dst_format)
{
case PixelFormat8bppIndexed:
convert_rgb_to_indexed(getpixel_16bppGrayScale, setpixel_8bppIndexed);
case PixelFormat16bppRGB555:
convert_rgb_to_rgb(getpixel_16bppGrayScale, setpixel_16bppRGB555);
case PixelFormat16bppRGB565:
......@@ -652,6 +664,8 @@ GpStatus convert_pixels(INT width, INT height,
case PixelFormat16bppRGB555:
switch (dst_format)
{
case PixelFormat8bppIndexed:
convert_rgb_to_indexed(getpixel_16bppRGB555, setpixel_8bppIndexed);
case PixelFormat16bppGrayScale:
convert_rgb_to_rgb(getpixel_16bppRGB555, setpixel_16bppGrayScale);
case PixelFormat16bppRGB565:
......@@ -677,6 +691,8 @@ GpStatus convert_pixels(INT width, INT height,
case PixelFormat16bppRGB565:
switch (dst_format)
{
case PixelFormat8bppIndexed:
convert_rgb_to_indexed(getpixel_16bppRGB565, setpixel_8bppIndexed);
case PixelFormat16bppGrayScale:
convert_rgb_to_rgb(getpixel_16bppRGB565, setpixel_16bppGrayScale);
case PixelFormat16bppRGB555:
......@@ -702,6 +718,8 @@ GpStatus convert_pixels(INT width, INT height,
case PixelFormat16bppARGB1555:
switch (dst_format)
{
case PixelFormat8bppIndexed:
convert_rgb_to_indexed(getpixel_16bppARGB1555, setpixel_8bppIndexed);
case PixelFormat16bppGrayScale:
convert_rgb_to_rgb(getpixel_16bppARGB1555, setpixel_16bppGrayScale);
case PixelFormat16bppRGB555:
......@@ -727,6 +745,8 @@ GpStatus convert_pixels(INT width, INT height,
case PixelFormat24bppRGB:
switch (dst_format)
{
case PixelFormat8bppIndexed:
convert_rgb_to_indexed(getpixel_24bppRGB, setpixel_8bppIndexed);
case PixelFormat16bppGrayScale:
convert_rgb_to_rgb(getpixel_24bppRGB, setpixel_16bppGrayScale);
case PixelFormat16bppRGB555:
......@@ -752,6 +772,8 @@ GpStatus convert_pixels(INT width, INT height,
case PixelFormat32bppRGB:
switch (dst_format)
{
case PixelFormat8bppIndexed:
convert_rgb_to_indexed(getpixel_32bppRGB, setpixel_8bppIndexed);
case PixelFormat16bppGrayScale:
convert_rgb_to_rgb(getpixel_32bppRGB, setpixel_16bppGrayScale);
case PixelFormat16bppRGB555:
......@@ -777,6 +799,8 @@ GpStatus convert_pixels(INT width, INT height,
case PixelFormat32bppARGB:
switch (dst_format)
{
case PixelFormat8bppIndexed:
convert_rgb_to_indexed(getpixel_32bppARGB, setpixel_8bppIndexed);
case PixelFormat16bppGrayScale:
convert_rgb_to_rgb(getpixel_32bppARGB, setpixel_16bppGrayScale);
case PixelFormat16bppRGB555:
......@@ -801,6 +825,8 @@ GpStatus convert_pixels(INT width, INT height,
case PixelFormat32bppPARGB:
switch (dst_format)
{
case PixelFormat8bppIndexed:
convert_rgb_to_indexed(getpixel_32bppPARGB, setpixel_8bppIndexed);
case PixelFormat16bppGrayScale:
convert_rgb_to_rgb(getpixel_32bppPARGB, setpixel_16bppGrayScale);
case PixelFormat16bppRGB555:
......@@ -826,6 +852,8 @@ GpStatus convert_pixels(INT width, INT height,
case PixelFormat48bppRGB:
switch (dst_format)
{
case PixelFormat8bppIndexed:
convert_rgb_to_indexed(getpixel_48bppRGB, setpixel_8bppIndexed);
case PixelFormat16bppGrayScale:
convert_rgb_to_rgb(getpixel_48bppRGB, setpixel_16bppGrayScale);
case PixelFormat16bppRGB555:
......@@ -851,6 +879,8 @@ GpStatus convert_pixels(INT width, INT height,
case PixelFormat64bppARGB:
switch (dst_format)
{
case PixelFormat8bppIndexed:
convert_rgb_to_indexed(getpixel_64bppARGB, setpixel_8bppIndexed);
case PixelFormat16bppGrayScale:
convert_rgb_to_rgb(getpixel_64bppARGB, setpixel_16bppGrayScale);
case PixelFormat16bppRGB555:
......@@ -876,6 +906,8 @@ GpStatus convert_pixels(INT width, INT height,
case PixelFormat64bppPARGB:
switch (dst_format)
{
case PixelFormat8bppIndexed:
convert_rgb_to_indexed(getpixel_64bppPARGB, setpixel_8bppIndexed);
case PixelFormat16bppGrayScale:
convert_rgb_to_rgb(getpixel_64bppPARGB, setpixel_16bppGrayScale);
case PixelFormat16bppRGB555:
......
......@@ -3388,7 +3388,6 @@ static void test_bitmapbits(void)
0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77
};
#if 0 /* FIXME: these tests crash gdiplus in Wine */
static const BYTE pixels_8[16] =
{
0x01,0,0x01,0,0x01,0,0x01,0,
......@@ -3405,6 +3404,7 @@ static void test_bitmapbits(void)
0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77
};
#if 0 /* FIXME: these tests crash gdiplus in Wine */
static const BYTE pixels_1_77[64] =
{
0xaa,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
......@@ -3438,7 +3438,6 @@ static void test_bitmapbits(void)
{ PixelFormat24bppRGB, 24, ImageLockModeRead|ImageLockModeUserInputBuf, 32, 64, pixels_24_77, pixels_24 },
{ PixelFormat24bppRGB, 24, ImageLockModeWrite|ImageLockModeUserInputBuf, 32, 64, pixels_77, pixels_00 },
{ PixelFormat24bppRGB, 24, ImageLockModeUserInputBuf, 32, 64, pixels_77, pixels_24 },
#if 0 /* FIXME: these tests crash gdiplus in Wine */
/* 8 */
{ PixelFormat8bppIndexed, 8, 0, 8, 16, pixels_8, pixels_24 },
{ PixelFormat8bppIndexed, 8, ImageLockModeRead, 8, 16, pixels_8, pixels_24 },
......@@ -3447,6 +3446,7 @@ static void test_bitmapbits(void)
{ PixelFormat8bppIndexed, 8, ImageLockModeRead|ImageLockModeUserInputBuf, 32, 64, pixels_8_77, pixels_24 },
{ PixelFormat8bppIndexed, 8, ImageLockModeWrite|ImageLockModeUserInputBuf, 32, 64, pixels_77, pixels_00 },
{ PixelFormat8bppIndexed, 8, ImageLockModeUserInputBuf, 32, 64, pixels_77, pixels_24 },
#if 0 /* FIXME: these tests crash gdiplus in Wine */
/* 15 */
{ PixelFormat1bppIndexed, 1, 0, 4, 8, pixels_1, pixels_24 },
{ PixelFormat1bppIndexed, 1, ImageLockModeRead, 4, 8, pixels_1, pixels_24 },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment