Commit 7fbf0dee authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

gdiplus: Implement GdipGetImageAttributesAdjustedPalette.

parent e06bbf0d
......@@ -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)
......
......@@ -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];
};
......
......@@ -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;
......
......@@ -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)
{
......
......@@ -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);
}
......@@ -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*,
......
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