gdiplus: Implement GdipInitializePalette.
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru> Signed-off-by: Vincent Povirk <vincent@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
d102d6e9f7
commit
cbc486aca1
|
@ -615,7 +615,7 @@
|
||||||
615 stub GdipGetEffectParameterSize
|
615 stub GdipGetEffectParameterSize
|
||||||
616 stub GdipGetEffectParameters
|
616 stub GdipGetEffectParameters
|
||||||
617 stdcall GdipSetEffectParameters(ptr ptr long)
|
617 stdcall GdipSetEffectParameters(ptr ptr long)
|
||||||
618 stub GdipInitializePalette
|
618 stdcall GdipInitializePalette(ptr long long long ptr)
|
||||||
619 stdcall GdipBitmapCreateApplyEffect(ptr long ptr ptr ptr ptr long ptr ptr)
|
619 stdcall GdipBitmapCreateApplyEffect(ptr long ptr ptr ptr ptr long ptr ptr)
|
||||||
620 stdcall GdipBitmapApplyEffect(ptr ptr ptr long ptr ptr)
|
620 stdcall GdipBitmapApplyEffect(ptr ptr ptr long ptr ptr)
|
||||||
621 stdcall GdipBitmapGetHistogram(ptr long long ptr ptr ptr ptr)
|
621 stdcall GdipBitmapGetHistogram(ptr long long ptr ptr ptr ptr)
|
||||||
|
|
|
@ -5640,3 +5640,111 @@ GpStatus WINGDIPAPI GdipBitmapGetHistogramSize(HistogramFormat format, UINT *num
|
||||||
*num_of_entries = 256;
|
*num_of_entries = 256;
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GpStatus create_optimal_palette(ColorPalette *palette, INT desired,
|
||||||
|
BOOL transparent, GpBitmap *bitmap)
|
||||||
|
{
|
||||||
|
GpStatus status;
|
||||||
|
BitmapData data;
|
||||||
|
HRESULT hr;
|
||||||
|
IWICImagingFactory *factory;
|
||||||
|
IWICPalette *wic_palette;
|
||||||
|
|
||||||
|
if (!bitmap) return InvalidParameter;
|
||||||
|
if (palette->Count < desired) return GenericError;
|
||||||
|
|
||||||
|
status = GdipBitmapLockBits(bitmap, NULL, ImageLockModeRead, PixelFormat24bppRGB, &data);
|
||||||
|
if (status != Ok) return status;
|
||||||
|
|
||||||
|
hr = WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory);
|
||||||
|
if (hr != S_OK)
|
||||||
|
{
|
||||||
|
GdipBitmapUnlockBits(bitmap, &data);
|
||||||
|
return hresult_to_status(hr);
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = IWICImagingFactory_CreatePalette(factory, &wic_palette);
|
||||||
|
if (hr == S_OK)
|
||||||
|
{
|
||||||
|
IWICBitmap *bitmap;
|
||||||
|
|
||||||
|
/* PixelFormat24bppRGB actually stores the bitmap bits as BGR. */
|
||||||
|
hr = IWICImagingFactory_CreateBitmapFromMemory(factory, data.Width, data.Height,
|
||||||
|
&GUID_WICPixelFormat24bppBGR, data.Stride, data.Stride * data.Width, data.Scan0, &bitmap);
|
||||||
|
if (hr == S_OK)
|
||||||
|
{
|
||||||
|
hr = IWICPalette_InitializeFromBitmap(wic_palette, (IWICBitmapSource *)bitmap, desired, transparent);
|
||||||
|
if (hr == S_OK)
|
||||||
|
{
|
||||||
|
palette->Flags = 0;
|
||||||
|
IWICPalette_GetColorCount(wic_palette, &palette->Count);
|
||||||
|
IWICPalette_GetColors(wic_palette, palette->Count, palette->Entries, &palette->Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
IWICBitmap_Release(bitmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
IWICPalette_Release(wic_palette);
|
||||||
|
}
|
||||||
|
|
||||||
|
IWICImagingFactory_Release(factory);
|
||||||
|
GdipBitmapUnlockBits(bitmap, &data);
|
||||||
|
|
||||||
|
return hresult_to_status(hr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
* GdipInitializePalette [GDIPLUS.@]
|
||||||
|
*/
|
||||||
|
GpStatus WINGDIPAPI GdipInitializePalette(ColorPalette *palette,
|
||||||
|
PaletteType type, INT desired, BOOL transparent, GpBitmap *bitmap)
|
||||||
|
{
|
||||||
|
TRACE("(%p,%d,%d,%d,%p)\n", palette, type, desired, transparent, bitmap);
|
||||||
|
|
||||||
|
if (!palette) return InvalidParameter;
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case PaletteTypeCustom:
|
||||||
|
return Ok;
|
||||||
|
|
||||||
|
case PaletteTypeOptimal:
|
||||||
|
return create_optimal_palette(palette, desired, transparent, bitmap);
|
||||||
|
|
||||||
|
/* WIC palette type enumeration matches these gdiplus enums */
|
||||||
|
case PaletteTypeFixedBW:
|
||||||
|
case PaletteTypeFixedHalftone8:
|
||||||
|
case PaletteTypeFixedHalftone27:
|
||||||
|
case PaletteTypeFixedHalftone64:
|
||||||
|
case PaletteTypeFixedHalftone125:
|
||||||
|
case PaletteTypeFixedHalftone216:
|
||||||
|
case PaletteTypeFixedHalftone252:
|
||||||
|
case PaletteTypeFixedHalftone256:
|
||||||
|
{
|
||||||
|
ColorPalette *wic_palette;
|
||||||
|
GpStatus status = Ok;
|
||||||
|
|
||||||
|
wic_palette = get_palette(NULL, type);
|
||||||
|
if (!wic_palette) return OutOfMemory;
|
||||||
|
|
||||||
|
if (palette->Count >= wic_palette->Count)
|
||||||
|
{
|
||||||
|
palette->Flags = wic_palette->Flags;
|
||||||
|
palette->Count = wic_palette->Count;
|
||||||
|
memcpy(palette->Entries, wic_palette->Entries, wic_palette->Count * sizeof(wic_palette->Entries[0]));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
status = GenericError;
|
||||||
|
|
||||||
|
heap_free(wic_palette);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
FIXME("unknown palette type %d\n", type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return InvalidParameter;
|
||||||
|
}
|
||||||
|
|
|
@ -266,6 +266,7 @@ GpStatus WINGDIPAPI GdipGraphicsClear(GpGraphics*,ARGB);
|
||||||
GpStatus WINGDIPAPI GdipGraphicsSetAbort(GpGraphics*,GdiplusAbort*);
|
GpStatus WINGDIPAPI GdipGraphicsSetAbort(GpGraphics*,GdiplusAbort*);
|
||||||
GpStatus WINGDIPAPI GdipGetVisibleClipBounds(GpGraphics*,GpRectF*);
|
GpStatus WINGDIPAPI GdipGetVisibleClipBounds(GpGraphics*,GpRectF*);
|
||||||
GpStatus WINGDIPAPI GdipGetVisibleClipBoundsI(GpGraphics*,GpRect*);
|
GpStatus WINGDIPAPI GdipGetVisibleClipBoundsI(GpGraphics*,GpRect*);
|
||||||
|
GpStatus WINGDIPAPI GdipInitializePalette(ColorPalette*,PaletteType,INT,BOOL,GpBitmap*);
|
||||||
GpStatus WINGDIPAPI GdipIsClipEmpty(GpGraphics*, BOOL*);
|
GpStatus WINGDIPAPI GdipIsClipEmpty(GpGraphics*, BOOL*);
|
||||||
GpStatus WINGDIPAPI GdipIsVisiblePoint(GpGraphics*,REAL,REAL,BOOL*);
|
GpStatus WINGDIPAPI GdipIsVisiblePoint(GpGraphics*,REAL,REAL,BOOL*);
|
||||||
GpStatus WINGDIPAPI GdipIsVisiblePointI(GpGraphics*,INT,INT,BOOL*);
|
GpStatus WINGDIPAPI GdipIsVisiblePointI(GpGraphics*,INT,INT,BOOL*);
|
||||||
|
|
Loading…
Reference in New Issue