gdiplus: Implement GdipGetImageAttributesAdjustedPalette.
Vincent Povirk
madewokherd at gmail.com
Mon Jun 13 16:42:28 CDT 2016
From: Vincent Povirk <vincent at codeweavers.com>
For bug 40747.
Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
---
dlls/gdiplus/gdiplus.spec | 2 +-
dlls/gdiplus/gdiplus_private.h | 3 ++
dlls/gdiplus/graphics.c | 2 +-
dlls/gdiplus/imageattributes.c | 15 ++++++++++
dlls/gdiplus/tests/image.c | 66 ++++++++++++++++++++++++++++++++++++++++++
include/gdiplusflat.h | 2 ++
6 files changed, 88 insertions(+), 2 deletions(-)
diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index 9f7ce5f..c163ef9 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -264,7 +264,7 @@
264 stdcall GdipGetHatchForegroundColor(ptr ptr)
265 stdcall GdipGetHatchStyle(ptr ptr)
266 stdcall GdipGetHemfFromMetafile(ptr ptr)
-267 stub GdipGetImageAttributesAdjustedPalette
+267 stdcall GdipGetImageAttributesAdjustedPalette(ptr ptr long)
268 stdcall GdipGetImageBounds(ptr ptr ptr)
269 stdcall GdipGetImageDecoders(long long ptr)
270 stdcall GdipGetImageDecodersSize(ptr ptr)
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h
index 9b29d88..22478a3 100644
--- a/dlls/gdiplus/gdiplus_private.h
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -176,6 +176,9 @@ extern GpStatus convert_pixels(INT width, INT height,
INT dst_stride, BYTE *dst_bits, PixelFormat dst_format,
INT src_stride, const BYTE *src_bits, PixelFormat src_format, ColorPalette *palette) DECLSPEC_HIDDEN;
+extern PixelFormat apply_image_attributes(const GpImageAttributes *attributes, LPBYTE data,
+ UINT width, UINT height, INT stride, ColorAdjustType type, PixelFormat fmt) DECLSPEC_HIDDEN;
+
struct GpMatrix{
REAL matrix[6];
};
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 8353809..c74f2eb 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -661,7 +661,7 @@ static BOOL color_is_gray(ARGB color)
}
/* returns preferred pixel format for the applied attributes */
-static PixelFormat apply_image_attributes(const GpImageAttributes *attributes, LPBYTE data,
+PixelFormat apply_image_attributes(const GpImageAttributes *attributes, LPBYTE data,
UINT width, UINT height, INT stride, ColorAdjustType type, PixelFormat fmt)
{
UINT x, y;
diff --git a/dlls/gdiplus/imageattributes.c b/dlls/gdiplus/imageattributes.c
index 2917b46..a76fe3b 100644
--- a/dlls/gdiplus/imageattributes.c
+++ b/dlls/gdiplus/imageattributes.c
@@ -77,6 +77,21 @@ GpStatus WINGDIPAPI GdipDisposeImageAttributes(GpImageAttributes *imageattr)
return Ok;
}
+GpStatus WINGDIPAPI GdipGetImageAttributesAdjustedPalette(GpImageAttributes *imageattr,
+ ColorPalette *palette, ColorAdjustType type)
+{
+ TRACE("(%p,%p,%u)\n", imageattr, palette, type);
+
+ if (!imageattr || !palette || !palette->Count ||
+ type >= ColorAdjustTypeCount || type == ColorAdjustTypeDefault)
+ return InvalidParameter;
+
+ apply_image_attributes(imageattr, (LPBYTE)palette->Entries, palette->Count, 1, 0,
+ type, PixelFormat32bppARGB);
+
+ return Ok;
+}
+
GpStatus WINGDIPAPI GdipSetImageAttributesColorKeys(GpImageAttributes *imageattr,
ColorAdjustType type, BOOL enableFlag, ARGB colorLow, ARGB colorHigh)
{
diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c
index 6a51714..be93a20 100644
--- a/dlls/gdiplus/tests/image.c
+++ b/dlls/gdiplus/tests/image.c
@@ -4725,6 +4725,71 @@ static void test_createeffect(void)
}
}
+static void test_getadjustedpalette(void)
+{
+ ColorMap colormap;
+ GpImageAttributes *imageattributes;
+ ColorPalette *palette;
+ GpStatus stat;
+
+ stat = GdipCreateImageAttributes(&imageattributes);
+ expect(Ok, stat);
+
+ colormap.oldColor.Argb = 0xffffff00;
+ colormap.newColor.Argb = 0xffff00ff;
+ stat = GdipSetImageAttributesRemapTable(imageattributes, ColorAdjustTypeBitmap,
+ TRUE, 1, &colormap);
+ expect(Ok, stat);
+
+ colormap.oldColor.Argb = 0xffffff80;
+ colormap.newColor.Argb = 0xffff80ff;
+ stat = GdipSetImageAttributesRemapTable(imageattributes, ColorAdjustTypeDefault,
+ TRUE, 1, &colormap);
+ expect(Ok, stat);
+
+ palette = GdipAlloc(sizeof(*palette) + sizeof(ARGB) * 2);
+ palette->Count = 0;
+
+ stat = GdipGetImageAttributesAdjustedPalette(imageattributes, palette, ColorAdjustTypeBitmap);
+ expect(InvalidParameter, stat);
+
+ palette->Count = 3;
+ palette->Entries[0] = 0xffffff00;
+ palette->Entries[1] = 0xffffff80;
+ palette->Entries[2] = 0xffffffff;
+
+ stat = GdipGetImageAttributesAdjustedPalette(imageattributes, palette, ColorAdjustTypeBitmap);
+ expect(Ok, stat);
+ expect(0xffff00ff, palette->Entries[0]);
+ expect(0xffffff80, palette->Entries[1]);
+ expect(0xffffffff, palette->Entries[2]);
+
+ palette->Entries[0] = 0xffffff00;
+ palette->Entries[1] = 0xffffff80;
+ palette->Entries[2] = 0xffffffff;
+
+ stat = GdipGetImageAttributesAdjustedPalette(imageattributes, palette, ColorAdjustTypeBrush);
+ expect(Ok, stat);
+ expect(0xffffff00, palette->Entries[0]);
+ expect(0xffff80ff, palette->Entries[1]);
+ expect(0xffffffff, palette->Entries[2]);
+
+ stat = GdipGetImageAttributesAdjustedPalette(NULL, palette, ColorAdjustTypeBitmap);
+ expect(InvalidParameter, stat);
+
+ stat = GdipGetImageAttributesAdjustedPalette(imageattributes, NULL, ColorAdjustTypeBitmap);
+ expect(InvalidParameter, stat);
+
+ stat = GdipGetImageAttributesAdjustedPalette(imageattributes, palette, -1);
+ expect(InvalidParameter, stat);
+
+ stat = GdipGetImageAttributesAdjustedPalette(imageattributes, palette, ColorAdjustTypeDefault);
+ expect(InvalidParameter, stat);
+
+ GdipFree(palette);
+ GdipDisposeImageAttributes(imageattributes);
+}
+
START_TEST(image)
{
struct GdiplusStartupInput gdiplusStartupInput;
@@ -4782,6 +4847,7 @@ START_TEST(image)
test_colorkey();
test_dispose();
test_createeffect();
+ test_getadjustedpalette();
GdiplusShutdown(gdiplusToken);
}
diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h
index 2e22ff4..c6f16c4 100644
--- a/include/gdiplusflat.h
+++ b/include/gdiplusflat.h
@@ -436,6 +436,8 @@ GpStatus WINGDIPAPI GdipSetPropertyItem(GpImage*,GDIPCONST PropertyItem*);
/* ImageAttributes */
GpStatus WINGDIPAPI GdipCreateImageAttributes(GpImageAttributes**);
GpStatus WINGDIPAPI GdipDisposeImageAttributes(GpImageAttributes*);
+GpStatus WINGDIPAPI GdipGetImageAttributesAdjustedPalette(GpImageAttributes*,
+ ColorPalette*,ColorAdjustType);
GpStatus WINGDIPAPI GdipSetImageAttributesCachedBackground(GpImageAttributes*,
BOOL);
GpStatus WINGDIPAPI GdipSetImageAttributesColorKeys(GpImageAttributes*,
--
2.7.4
More information about the wine-patches
mailing list