Dmitry Timoshkov : gdiplus: Add support for converting RGB formats to 8bpp indexed.
Alexandre Julliard
julliard at winehq.org
Tue Jul 17 11:05:34 CDT 2012
Module: wine
Branch: master
Commit: 2ed1aaa930654e3e4bbbbf13992cf6abbded6780
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2ed1aaa930654e3e4bbbbf13992cf6abbded6780
Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date: Tue Jul 17 15:01:51 2012 +0900
gdiplus: Add support for converting RGB formats to 8bpp indexed.
---
dlls/gdiplus/image.c | 32 ++++++++++++++++++++++++++++++++
dlls/gdiplus/tests/image.c | 4 ++--
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index d14fca0..2e3c164 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -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:
diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c
index 482dfd9..da17b5d 100644
--- a/dlls/gdiplus/tests/image.c
+++ b/dlls/gdiplus/tests/image.c
@@ -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 },
More information about the wine-cvs
mailing list