mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 04:39:45 +00:00
windowscodecs: Add support for 32bppGrayFloat format.
Signed-off-by: Vincent Povirk <vincent@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
82f82f6917
commit
8836ed61aa
@ -49,6 +49,7 @@ enum pixelformat {
|
||||
format_16bppBGRA5551,
|
||||
format_24bppBGR,
|
||||
format_24bppRGB,
|
||||
format_32bppGrayFloat,
|
||||
format_32bppBGR,
|
||||
format_32bppBGRA,
|
||||
format_32bppPBGRA,
|
||||
@ -996,6 +997,49 @@ static HRESULT copypixels_to_24bppRGB(struct FormatConverter *This, const WICRec
|
||||
}
|
||||
}
|
||||
|
||||
static HRESULT copypixels_to_32bppGrayFloat(struct FormatConverter *This, const WICRect *prc,
|
||||
UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
switch (source_format)
|
||||
{
|
||||
case format_32bppBGR:
|
||||
case format_32bppBGRA:
|
||||
case format_32bppPBGRA:
|
||||
case format_32bppGrayFloat:
|
||||
if (prc)
|
||||
{
|
||||
hr = IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
|
||||
break;
|
||||
}
|
||||
return S_OK;
|
||||
|
||||
default:
|
||||
hr = copypixels_to_32bppBGRA(This, prc, cbStride, cbBufferSize, pbBuffer, source_format);
|
||||
break;
|
||||
}
|
||||
|
||||
if (SUCCEEDED(hr) && prc && source_format != format_32bppGrayFloat)
|
||||
{
|
||||
INT x, y;
|
||||
BYTE *p = pbBuffer;
|
||||
|
||||
for (y = 0; y < prc->Height; y++)
|
||||
{
|
||||
BYTE *bgr = p;
|
||||
for (x = 0; x < prc->Width; x++)
|
||||
{
|
||||
float gray = (bgr[2] * 0.2126f + bgr[1] * 0.7152f + bgr[0] * 0.0722f) / 255.0f;
|
||||
*(float *)bgr = gray;
|
||||
bgr += 4;
|
||||
}
|
||||
p += cbStride;
|
||||
}
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
||||
static const struct pixelformatinfo supported_formats[] = {
|
||||
{format_1bppIndexed, &GUID_WICPixelFormat1bppIndexed, NULL},
|
||||
{format_2bppIndexed, &GUID_WICPixelFormat2bppIndexed, NULL},
|
||||
@ -1011,6 +1055,7 @@ static const struct pixelformatinfo supported_formats[] = {
|
||||
{format_16bppBGRA5551, &GUID_WICPixelFormat16bppBGRA5551, NULL},
|
||||
{format_24bppBGR, &GUID_WICPixelFormat24bppBGR, copypixels_to_24bppBGR},
|
||||
{format_24bppRGB, &GUID_WICPixelFormat24bppRGB, copypixels_to_24bppRGB},
|
||||
{format_32bppGrayFloat, &GUID_WICPixelFormat32bppGrayFloat, copypixels_to_32bppGrayFloat},
|
||||
{format_32bppBGR, &GUID_WICPixelFormat32bppBGR, copypixels_to_32bppBGR},
|
||||
{format_32bppBGRA, &GUID_WICPixelFormat32bppBGRA, copypixels_to_32bppBGRA},
|
||||
{format_32bppPBGRA, &GUID_WICPixelFormat32bppPBGRA, copypixels_to_32bppPBGRA},
|
||||
|
@ -1452,6 +1452,7 @@ static GUID const * const converter_formats[] = {
|
||||
&GUID_WICPixelFormat32bppBGR,
|
||||
&GUID_WICPixelFormat32bppBGRA,
|
||||
&GUID_WICPixelFormat32bppPBGRA,
|
||||
&GUID_WICPixelFormat32bppGrayFloat,
|
||||
&GUID_WICPixelFormat48bppRGB,
|
||||
&GUID_WICPixelFormat64bppRGBA,
|
||||
&GUID_WICPixelFormat32bppCMYK,
|
||||
|
@ -35,6 +35,7 @@ typedef struct bitmap_data {
|
||||
UINT height;
|
||||
double xres;
|
||||
double yres;
|
||||
const struct bitmap_data *alt_data;
|
||||
} bitmap_data;
|
||||
|
||||
typedef struct BitmapTestSrc {
|
||||
@ -43,6 +44,11 @@ typedef struct BitmapTestSrc {
|
||||
const bitmap_data *data;
|
||||
} BitmapTestSrc;
|
||||
|
||||
static BOOL near_equal(float a, float b)
|
||||
{
|
||||
return fabsf(a - b) < 0.001;
|
||||
}
|
||||
|
||||
static inline BitmapTestSrc *impl_from_IWICBitmapSource(IWICBitmapSource *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, BitmapTestSrc, IWICBitmapSource_iface);
|
||||
@ -213,9 +219,24 @@ static BOOL compare_bits(const struct bitmap_data *expect, UINT buffersize, cons
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (IsEqualGUID(expect->format, &GUID_WICPixelFormat32bppGrayFloat))
|
||||
{
|
||||
UINT i;
|
||||
const float *a=(const float*)expect->bits, *b=(const float*)converted_bits;
|
||||
equal=TRUE;
|
||||
for (i=0; i<(buffersize/4); i++)
|
||||
if (!near_equal(a[i], b[i]))
|
||||
{
|
||||
equal = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
equal = (memcmp(expect->bits, converted_bits, buffersize) == 0);
|
||||
|
||||
if (!equal && expect->alt_data)
|
||||
equal = compare_bits(expect->alt_data, buffersize, converted_bits);
|
||||
|
||||
return equal;
|
||||
}
|
||||
|
||||
@ -289,6 +310,19 @@ static const BYTE bits_32bppBGRA[] = {
|
||||
static const struct bitmap_data testdata_32bppBGRA = {
|
||||
&GUID_WICPixelFormat32bppBGRA, 32, bits_32bppBGRA, 4, 2, 96.0, 96.0};
|
||||
|
||||
/* XP and 2003 use linear color conversion, later versions use sRGB gamma */
|
||||
static const float bits_32bppGrayFloat_xp[] = {
|
||||
0.114000f,0.587000f,0.299000f,0.000000f,
|
||||
0.886000f,0.413000f,0.701000f,1.000000f};
|
||||
static const struct bitmap_data testdata_32bppGrayFloat_xp = {
|
||||
&GUID_WICPixelFormat32bppGrayFloat, 32, (const BYTE *)bits_32bppGrayFloat_xp, 4, 2, 96.0, 96.0};
|
||||
|
||||
static const float bits_32bppGrayFloat[] = {
|
||||
0.072200f,0.715200f,0.212600f,0.000000f,
|
||||
0.927800f,0.284800f,0.787400f,1.000000f};
|
||||
static const struct bitmap_data testdata_32bppGrayFloat = {
|
||||
&GUID_WICPixelFormat32bppGrayFloat, 32, (const BYTE *)bits_32bppGrayFloat, 4, 2, 96.0, 96.0, &testdata_32bppGrayFloat_xp};
|
||||
|
||||
static void test_conversion(const struct bitmap_data *src, const struct bitmap_data *dst, const char *name, BOOL todo)
|
||||
{
|
||||
BitmapTestSrc *src_obj;
|
||||
@ -729,6 +763,9 @@ START_TEST(converter)
|
||||
test_conversion(&testdata_24bppRGB, &testdata_32bppBGR, "24bppRGB -> 32bppBGR", FALSE);
|
||||
test_conversion(&testdata_32bppBGRA, &testdata_24bppRGB, "32bppBGRA -> 24bppRGB", FALSE);
|
||||
|
||||
test_conversion(&testdata_24bppRGB, &testdata_32bppGrayFloat, "24bppRGB -> 32bppGrayFloat", FALSE);
|
||||
test_conversion(&testdata_32bppBGR, &testdata_32bppGrayFloat, "32bppBGR -> 32bppGrayFloat", FALSE);
|
||||
|
||||
test_invalid_conversion();
|
||||
test_default_converter();
|
||||
|
||||
|
@ -196,6 +196,7 @@ cpp_quote("DEFINE_GUID(GUID_WICPixelFormat32bppPBGRA, 0x6fddc324,0x4e03,0x4bfe,0
|
||||
cpp_quote("DEFINE_GUID(GUID_WICPixelFormat32bppRGB, 0xd98c6b95,0x3efe,0x47d6,0xbb,0x25,0xeb,0x17,0x48,0xab,0x0c,0xf1);")
|
||||
cpp_quote("DEFINE_GUID(GUID_WICPixelFormat32bppRGBA, 0xf5c7ad2d,0x6a8d,0x43dd,0xa7,0xa8,0xa2,0x99,0x35,0x26,0x1a,0xe9);")
|
||||
cpp_quote("DEFINE_GUID(GUID_WICPixelFormat32bppPRGBA, 0x3cc4a650,0xa527,0x4d37,0xa9,0x16,0x31,0x42,0xc7,0xeb,0xed,0xba);")
|
||||
cpp_quote("DEFINE_GUID(GUID_WICPixelFormat32bppGrayFloat, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x11);")
|
||||
|
||||
cpp_quote("DEFINE_GUID(GUID_WICPixelFormat48bppRGB, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x15);")
|
||||
cpp_quote("DEFINE_GUID(GUID_WICPixelFormat64bppRGBA, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x16);")
|
||||
|
Loading…
Reference in New Issue
Block a user