gdiplus: Introduce dst palette parameter to convert_pixels().
Make it possible to define a destination colour palette when using convert_pixels(), so converting a bitmap from a non indexed format to an indexed format does not produce an empty image. Signed-off-by: Bernhard Kölbl <besentv@gmail.com> Signed-off-by: Esme Povirk <esme@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
8a43d0808a
commit
ec29292141
|
@ -207,8 +207,8 @@ extern void convert_32bppARGB_to_32bppPARGB(UINT width, UINT height,
|
||||||
BYTE *dst_bits, INT dst_stride, const BYTE *src_bits, INT src_stride) DECLSPEC_HIDDEN;
|
BYTE *dst_bits, INT dst_stride, const BYTE *src_bits, INT src_stride) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
extern GpStatus convert_pixels(INT width, INT height,
|
extern GpStatus convert_pixels(INT width, INT height,
|
||||||
INT dst_stride, BYTE *dst_bits, PixelFormat dst_format,
|
INT dst_stride, BYTE *dst_bits, PixelFormat dst_format, ColorPalette *dst_palette,
|
||||||
INT src_stride, const BYTE *src_bits, PixelFormat src_format, ColorPalette *palette) DECLSPEC_HIDDEN;
|
INT src_stride, const BYTE *src_bits, PixelFormat src_format, ColorPalette *src_palette) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
extern PixelFormat apply_image_attributes(const GpImageAttributes *attributes, LPBYTE data,
|
extern PixelFormat apply_image_attributes(const GpImageAttributes *attributes, LPBYTE data,
|
||||||
UINT width, UINT height, INT stride, ColorAdjustType type, PixelFormat fmt) DECLSPEC_HIDDEN;
|
UINT width, UINT height, INT stride, ColorAdjustType type, PixelFormat fmt) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -3350,7 +3350,7 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
|
||||||
dst_format = PixelFormat32bppRGB;
|
dst_format = PixelFormat32bppRGB;
|
||||||
|
|
||||||
convert_pixels(bitmap->width, bitmap->height,
|
convert_pixels(bitmap->width, bitmap->height,
|
||||||
bitmap->width*4, temp_bits, dst_format,
|
bitmap->width*4, temp_bits, dst_format, bitmap->image.palette,
|
||||||
bitmap->stride, bitmap->bits, bitmap->format,
|
bitmap->stride, bitmap->bits, bitmap->format,
|
||||||
bitmap->image.palette);
|
bitmap->image.palette);
|
||||||
}
|
}
|
||||||
|
|
|
@ -591,8 +591,9 @@ GpStatus WINGDIPAPI GdipBitmapSetPixel(GpBitmap* bitmap, INT x, INT y,
|
||||||
|
|
||||||
GpStatus convert_pixels(INT width, INT height,
|
GpStatus convert_pixels(INT width, INT height,
|
||||||
INT dst_stride, BYTE *dst_bits, PixelFormat dst_format,
|
INT dst_stride, BYTE *dst_bits, PixelFormat dst_format,
|
||||||
|
ColorPalette *dst_palette,
|
||||||
INT src_stride, const BYTE *src_bits, PixelFormat src_format,
|
INT src_stride, const BYTE *src_bits, PixelFormat src_format,
|
||||||
ColorPalette *palette)
|
ColorPalette *src_palette)
|
||||||
{
|
{
|
||||||
INT x, y;
|
INT x, y;
|
||||||
|
|
||||||
|
@ -612,7 +613,7 @@ GpStatus convert_pixels(INT width, INT height,
|
||||||
ARGB argb; \
|
ARGB argb; \
|
||||||
BYTE *color = (BYTE *)&argb; \
|
BYTE *color = (BYTE *)&argb; \
|
||||||
getpixel_function(&index, src_bits+src_stride*y, x); \
|
getpixel_function(&index, src_bits+src_stride*y, x); \
|
||||||
argb = (palette && index < palette->Count) ? palette->Entries[index] : 0; \
|
argb = (src_palette && index < src_palette->Count) ? src_palette->Entries[index] : 0; \
|
||||||
setpixel_function(color[2], color[1], color[0], color[3], dst_bits+dst_stride*y, x); \
|
setpixel_function(color[2], color[1], color[0], color[3], dst_bits+dst_stride*y, x); \
|
||||||
} \
|
} \
|
||||||
return Ok; \
|
return Ok; \
|
||||||
|
@ -633,7 +634,7 @@ GpStatus convert_pixels(INT width, INT height,
|
||||||
for (x=0; x<width; x++) { \
|
for (x=0; x<width; x++) { \
|
||||||
BYTE r, g, b, a; \
|
BYTE r, g, b, a; \
|
||||||
getpixel_function(&r, &g, &b, &a, src_bits+src_stride*y, x); \
|
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); \
|
setpixel_function(r, g, b, a, dst_bits+dst_stride*y, x, dst_palette); \
|
||||||
} \
|
} \
|
||||||
return Ok; \
|
return Ok; \
|
||||||
} while (0);
|
} while (0);
|
||||||
|
@ -1137,7 +1138,7 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect,
|
||||||
/* Make sure we can convert to the requested format. */
|
/* Make sure we can convert to the requested format. */
|
||||||
if (flags & ImageLockModeRead)
|
if (flags & ImageLockModeRead)
|
||||||
{
|
{
|
||||||
stat = convert_pixels(0, 0, 0, NULL, format, 0, NULL, bitmap->format, NULL);
|
stat = convert_pixels(0, 0, 0, NULL, format, NULL, 0, NULL, bitmap->format, NULL);
|
||||||
if (stat == NotImplemented)
|
if (stat == NotImplemented)
|
||||||
{
|
{
|
||||||
FIXME("cannot read bitmap from %x to %x\n", bitmap->format, format);
|
FIXME("cannot read bitmap from %x to %x\n", bitmap->format, format);
|
||||||
|
@ -1150,7 +1151,7 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect,
|
||||||
* the original format. */
|
* the original format. */
|
||||||
if (flags & ImageLockModeWrite)
|
if (flags & ImageLockModeWrite)
|
||||||
{
|
{
|
||||||
stat = convert_pixels(0, 0, 0, NULL, bitmap->format, 0, NULL, format, NULL);
|
stat = convert_pixels(0, 0, 0, NULL, bitmap->format, NULL, 0, NULL, format, NULL);
|
||||||
if (stat == NotImplemented)
|
if (stat == NotImplemented)
|
||||||
{
|
{
|
||||||
FIXME("cannot write bitmap from %x to %x\n", format, bitmap->format);
|
FIXME("cannot write bitmap from %x to %x\n", format, bitmap->format);
|
||||||
|
@ -1190,7 +1191,7 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect,
|
||||||
}
|
}
|
||||||
|
|
||||||
stat = convert_pixels(act_rect.Width, act_rect.Height,
|
stat = convert_pixels(act_rect.Width, act_rect.Height,
|
||||||
lockeddata->Stride, lockeddata->Scan0, format,
|
lockeddata->Stride, lockeddata->Scan0, format, bitmap->image.palette,
|
||||||
bitmap->stride,
|
bitmap->stride,
|
||||||
bitmap->bits + bitmap->stride * act_rect.Y + PIXELFORMATBPP(bitmap->format) * act_rect.X / 8,
|
bitmap->bits + bitmap->stride * act_rect.Y + PIXELFORMATBPP(bitmap->format) * act_rect.X / 8,
|
||||||
bitmap->format, bitmap->image.palette);
|
bitmap->format, bitmap->image.palette);
|
||||||
|
@ -1267,10 +1268,11 @@ GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap,
|
||||||
fixme = TRUE;
|
fixme = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* FIXME: Pass src_palette generated from lockeddata->PixelFormat. */
|
||||||
stat = convert_pixels(lockeddata->Width, lockeddata->Height,
|
stat = convert_pixels(lockeddata->Width, lockeddata->Height,
|
||||||
bitmap->stride,
|
bitmap->stride,
|
||||||
bitmap->bits + bitmap->stride * bitmap->locky + PIXELFORMATBPP(bitmap->format) * bitmap->lockx / 8,
|
bitmap->bits + bitmap->stride * bitmap->locky + PIXELFORMATBPP(bitmap->format) * bitmap->lockx / 8,
|
||||||
bitmap->format,
|
bitmap->format, bitmap->image.palette,
|
||||||
lockeddata->Stride, lockeddata->Scan0, lockeddata->PixelFormat, NULL);
|
lockeddata->Stride, lockeddata->Scan0, lockeddata->PixelFormat, NULL);
|
||||||
|
|
||||||
if (stat != Ok)
|
if (stat != Ok)
|
||||||
|
@ -1314,7 +1316,7 @@ GpStatus WINGDIPAPI GdipCloneBitmapArea(REAL x, REAL y, REAL width, REAL height,
|
||||||
if (stat == Ok)
|
if (stat == Ok)
|
||||||
{
|
{
|
||||||
stat = convert_pixels(area.Width, area.Height, (*dstBitmap)->stride, (*dstBitmap)->bits, (*dstBitmap)->format,
|
stat = convert_pixels(area.Width, area.Height, (*dstBitmap)->stride, (*dstBitmap)->bits, (*dstBitmap)->format,
|
||||||
srcBitmap->stride,
|
(*dstBitmap)->image.palette, srcBitmap->stride,
|
||||||
srcBitmap->bits + srcBitmap->stride * area.Y + PIXELFORMATBPP(srcBitmap->format) * area.X / 8,
|
srcBitmap->bits + srcBitmap->stride * area.Y + PIXELFORMATBPP(srcBitmap->format) * area.X / 8,
|
||||||
srcBitmap->format, srcBitmap->image.palette);
|
srcBitmap->format, srcBitmap->image.palette);
|
||||||
|
|
||||||
|
@ -1545,7 +1547,7 @@ GpStatus WINGDIPAPI GdipCreateHBITMAPFromBitmap(GpBitmap* bitmap,
|
||||||
}
|
}
|
||||||
|
|
||||||
stat = convert_pixels(width, height, -width*4,
|
stat = convert_pixels(width, height, -width*4,
|
||||||
bits + (width * 4 * (height - 1)), PixelFormat32bppPARGB,
|
bits + (width * 4 * (height - 1)), PixelFormat32bppPARGB, bitmap->image.palette,
|
||||||
bitmap->stride, bitmap->bits, bitmap->format, bitmap->image.palette);
|
bitmap->stride, bitmap->bits, bitmap->format, bitmap->image.palette);
|
||||||
if (stat != Ok)
|
if (stat != Ok)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue