Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
8836ed61
Commit
8836ed61
authored
Sep 15, 2016
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Sep 16, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
windowscodecs: Add support for 32bppGrayFloat format.
Signed-off-by:
Vincent Povirk
<
vincent@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
82f82f69
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
0 deletions
+84
-0
converter.c
dlls/windowscodecs/converter.c
+45
-0
regsvr.c
dlls/windowscodecs/regsvr.c
+1
-0
converter.c
dlls/windowscodecs/tests/converter.c
+37
-0
wincodec.idl
include/wincodec.idl
+1
-0
No files found.
dlls/windowscodecs/converter.c
View file @
8836ed61
...
...
@@ -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
.
2126
f
+
bgr
[
1
]
*
0
.
7152
f
+
bgr
[
0
]
*
0
.
0722
f
)
/
255
.
0
f
;
*
(
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
},
...
...
dlls/windowscodecs/regsvr.c
View file @
8836ed61
...
...
@@ -1452,6 +1452,7 @@ static GUID const * const converter_formats[] = {
&
GUID_WICPixelFormat32bppBGR
,
&
GUID_WICPixelFormat32bppBGRA
,
&
GUID_WICPixelFormat32bppPBGRA
,
&
GUID_WICPixelFormat32bppGrayFloat
,
&
GUID_WICPixelFormat48bppRGB
,
&
GUID_WICPixelFormat64bppRGBA
,
&
GUID_WICPixelFormat32bppCMYK
,
...
...
dlls/windowscodecs/tests/converter.c
View file @
8836ed61
...
...
@@ -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
.
114000
f
,
0
.
587000
f
,
0
.
299000
f
,
0
.
000000
f
,
0
.
886000
f
,
0
.
413000
f
,
0
.
701000
f
,
1
.
000000
f
};
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
.
072200
f
,
0
.
715200
f
,
0
.
212600
f
,
0
.
000000
f
,
0
.
927800
f
,
0
.
284800
f
,
0
.
787400
f
,
1
.
000000
f
};
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
();
...
...
include/wincodec.idl
View file @
8836ed61
...
...
@@ -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);"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment