You've already forked wine-staging
mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-09-12 18:50:20 -07:00
Rebase against 302153117e20b62c9170aed62aa33e83cacfaf59.
This commit is contained in:
@@ -1,115 +0,0 @@
|
||||
From ed7888a251aef87d82b931a02edc26c9899a236c Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
Date: Tue, 20 Sep 2016 14:28:49 +0800
|
||||
Subject: windowscodecs: Add support for palette image formats to PNG encoder.
|
||||
|
||||
---
|
||||
dlls/windowscodecs/pngformat.c | 45 ++++++++++++++++++++++++++++++++++++++++++
|
||||
dlls/windowscodecs/regsvr.c | 4 ++++
|
||||
2 files changed, 49 insertions(+)
|
||||
|
||||
diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c
|
||||
index 10c96038630..3df2c426a46 100644
|
||||
--- a/dlls/windowscodecs/pngformat.c
|
||||
+++ b/dlls/windowscodecs/pngformat.c
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2009 Vincent Povirk for CodeWeavers
|
||||
+ * Copyright 2016 Dmitry Timoshkov
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -325,8 +326,10 @@ MAKE_FUNCPTR(png_set_gray_to_rgb);
|
||||
MAKE_FUNCPTR(png_set_interlace_handling);
|
||||
MAKE_FUNCPTR(png_set_IHDR);
|
||||
MAKE_FUNCPTR(png_set_pHYs);
|
||||
+MAKE_FUNCPTR(png_set_PLTE);
|
||||
MAKE_FUNCPTR(png_set_read_fn);
|
||||
MAKE_FUNCPTR(png_set_strip_16);
|
||||
+MAKE_FUNCPTR(png_set_tRNS);
|
||||
MAKE_FUNCPTR(png_set_tRNS_to_alpha);
|
||||
MAKE_FUNCPTR(png_set_write_fn);
|
||||
MAKE_FUNCPTR(png_read_end);
|
||||
@@ -389,8 +392,10 @@ static void *load_libpng(void)
|
||||
LOAD_FUNCPTR(png_set_interlace_handling);
|
||||
LOAD_FUNCPTR(png_set_IHDR);
|
||||
LOAD_FUNCPTR(png_set_pHYs);
|
||||
+ LOAD_FUNCPTR(png_set_PLTE);
|
||||
LOAD_FUNCPTR(png_set_read_fn);
|
||||
LOAD_FUNCPTR(png_set_strip_16);
|
||||
+ LOAD_FUNCPTR(png_set_tRNS);
|
||||
LOAD_FUNCPTR(png_set_tRNS_to_alpha);
|
||||
LOAD_FUNCPTR(png_set_write_fn);
|
||||
LOAD_FUNCPTR(png_read_end);
|
||||
@@ -1315,6 +1320,10 @@ static const struct png_pixelformat formats[] = {
|
||||
{&GUID_WICPixelFormat32bppBGR, 32, 8, PNG_COLOR_TYPE_RGB, 1, 1},
|
||||
{&GUID_WICPixelFormat48bppRGB, 48, 16, PNG_COLOR_TYPE_RGB, 0, 0},
|
||||
{&GUID_WICPixelFormat64bppRGBA, 64, 16, PNG_COLOR_TYPE_RGB_ALPHA, 0, 0},
|
||||
+ {&GUID_WICPixelFormat1bppIndexed, 1, 1, PNG_COLOR_TYPE_PALETTE, 0, 0},
|
||||
+ {&GUID_WICPixelFormat2bppIndexed, 2, 2, PNG_COLOR_TYPE_PALETTE, 0, 0},
|
||||
+ {&GUID_WICPixelFormat4bppIndexed, 4, 4, PNG_COLOR_TYPE_PALETTE, 0, 0},
|
||||
+ {&GUID_WICPixelFormat8bppIndexed, 8, 8, PNG_COLOR_TYPE_PALETTE, 0, 0},
|
||||
{NULL},
|
||||
};
|
||||
|
||||
@@ -1617,6 +1626,42 @@ static HRESULT WINAPI PngFrameEncode_WritePixels(IWICBitmapFrameEncode *iface,
|
||||
(This->yres+0.0127) / 0.0254, PNG_RESOLUTION_METER);
|
||||
}
|
||||
|
||||
+ if (This->format->color_type == PNG_COLOR_TYPE_PALETTE && This->colors)
|
||||
+ {
|
||||
+ png_color png_palette[256];
|
||||
+ png_byte trans[256];
|
||||
+ UINT i, num_trans = 0, colors;
|
||||
+
|
||||
+ /* Newer libpng versions don't accept larger palettes than the declared
|
||||
+ * bit depth, so we need to generate the palette of the correct length.
|
||||
+ */
|
||||
+ colors = 1 << This->format->bit_depth;
|
||||
+
|
||||
+ for (i = 0; i < colors; i++)
|
||||
+ {
|
||||
+ if (i < This->colors)
|
||||
+ {
|
||||
+ png_palette[i].red = (This->palette[i] >> 16) & 0xff;
|
||||
+ png_palette[i].green = (This->palette[i] >> 8) & 0xff;
|
||||
+ png_palette[i].blue = This->palette[i] & 0xff;
|
||||
+ trans[i] = (This->palette[i] >> 24) & 0xff;
|
||||
+ if (trans[i] != 0xff)
|
||||
+ num_trans++;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ png_palette[i].red = 0;
|
||||
+ png_palette[i].green = 0;
|
||||
+ png_palette[i].blue = 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ ppng_set_PLTE(This->png_ptr, This->info_ptr, png_palette, colors);
|
||||
+
|
||||
+ if (num_trans)
|
||||
+ ppng_set_tRNS(This->png_ptr, This->info_ptr, trans, colors, NULL);
|
||||
+ }
|
||||
+
|
||||
ppng_write_info(This->png_ptr, This->info_ptr);
|
||||
|
||||
if (This->format->remove_filler)
|
||||
diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c
|
||||
index 10a6c03d9b6..b011d716451 100644
|
||||
--- a/dlls/windowscodecs/regsvr.c
|
||||
+++ b/dlls/windowscodecs/regsvr.c
|
||||
@@ -1359,6 +1359,10 @@ static GUID const * const png_encode_formats[] = {
|
||||
&GUID_WICPixelFormat32bppBGRA,
|
||||
&GUID_WICPixelFormat48bppRGB,
|
||||
&GUID_WICPixelFormat64bppRGBA,
|
||||
+ &GUID_WICPixelFormat1bppIndexed,
|
||||
+ &GUID_WICPixelFormat2bppIndexed,
|
||||
+ &GUID_WICPixelFormat4bppIndexed,
|
||||
+ &GUID_WICPixelFormat8bppIndexed,
|
||||
NULL
|
||||
};
|
||||
|
||||
--
|
||||
2.14.1
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user