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
b084e52b
Commit
b084e52b
authored
Oct 12, 2011
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdi32: Add support for arbitrary DIB bitfields for 32-bpp conversions.
parent
b2ef9218
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
176 additions
and
29 deletions
+176
-29
primitives.c
dlls/gdi32/dibdrv/primitives.c
+175
-28
bitmap.c
dlls/gdi32/tests/bitmap.c
+1
-1
No files found.
dlls/gdi32/dibdrv/primitives.c
View file @
b084e52b
...
...
@@ -1030,11 +1030,31 @@ static DWORD colorref_to_pixel_888(const dib_info *dib, COLORREF color)
return
(
((
color
>>
16
)
&
0xff
)
|
(
color
&
0xff00
)
|
((
color
<<
16
)
&
0xff0000
)
);
}
static
const
DWORD
field_masks
[
33
]
=
{
0x00
,
/* should never happen */
0x80
,
0xc0
,
0xe0
,
0xf0
,
0xf8
,
0xfc
,
0xfe
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
};
static
inline
DWORD
get_field
(
DWORD
field
,
int
shift
,
int
len
)
{
shift
=
shift
-
(
8
-
len
);
if
(
shift
<
0
)
field
<<=
-
shift
;
else
field
>>=
shift
;
field
&=
field_masks
[
len
];
field
|=
field
>>
len
;
return
field
;
}
static
inline
DWORD
put_field
(
DWORD
field
,
int
shift
,
int
len
)
{
shift
=
shift
-
(
8
-
len
);
if
(
len
<=
8
)
field
&=
(((
1
<<
len
)
-
1
)
<<
(
8
-
len
));
field
&=
field_masks
[
len
];
if
(
shift
<
0
)
field
>>=
-
shift
;
else
...
...
@@ -1166,8 +1186,21 @@ static BOOL convert_to_8888(dib_info *dst, const dib_info *src, const RECT *src_
}
else
{
FIXME
(
"Unsupported conversion: 32 (%08x, %08x, %08x) -> 8888
\n
"
,
src
->
red_mask
,
src
->
green_mask
,
src
->
blue_mask
);
return
FALSE
;
for
(
y
=
src_rect
->
top
;
y
<
src_rect
->
bottom
;
y
++
)
{
dst_pixel
=
dst_start
;
src_pixel
=
src_start
;
for
(
x
=
src_rect
->
left
;
x
<
src_rect
->
right
;
x
++
)
{
src_val
=
*
src_pixel
++
;
*
dst_pixel
++
=
(
get_field
(
src_val
,
src
->
red_shift
,
src
->
red_len
)
<<
16
|
get_field
(
src_val
,
src
->
green_shift
,
src
->
green_len
)
<<
8
|
get_field
(
src_val
,
src
->
blue_shift
,
src
->
blue_len
));
}
if
(
pad_size
)
memset
(
dst_pixel
,
0
,
pad_size
);
dst_start
+=
dst
->
stride
/
4
;
src_start
+=
src
->
stride
/
4
;
}
}
break
;
}
...
...
@@ -1359,9 +1392,9 @@ static BOOL convert_to_32(dib_info *dst, const dib_info *src, const RECT *src_re
for
(
x
=
src_rect
->
left
;
x
<
src_rect
->
right
;
x
++
)
{
src_val
=
*
src_pixel
++
;
*
dst_pixel
++
=
put_field
(
(
src_val
>>
16
)
&
0xff
,
dst
->
red_shift
,
dst
->
red_len
)
|
put_field
(
(
src_val
>>
8
)
&
0xff
,
dst
->
green_shift
,
dst
->
green_len
)
|
put_field
(
src_val
&
0xff
,
dst
->
blue_shift
,
dst
->
blue_len
);
*
dst_pixel
++
=
put_field
(
src_val
>>
16
,
dst
->
red_shift
,
dst
->
red_len
)
|
put_field
(
src_val
>>
8
,
dst
->
green_shift
,
dst
->
green_len
)
|
put_field
(
src_val
,
dst
->
blue_shift
,
dst
->
blue_len
);
}
if
(
pad_size
)
memset
(
dst_pixel
,
0
,
pad_size
);
dst_start
+=
dst
->
stride
/
4
;
...
...
@@ -1404,9 +1437,21 @@ static BOOL convert_to_32(dib_info *dst, const dib_info *src, const RECT *src_re
}
else
{
FIXME
(
"Unsupported conversion: 32 (%08x, %08x, %08x) -> 32 (%08x, %08x, %08x)
\n
"
,
src
->
red_mask
,
src
->
green_mask
,
src
->
blue_mask
,
dst
->
red_mask
,
dst
->
green_mask
,
dst
->
blue_mask
);
return
FALSE
;
for
(
y
=
src_rect
->
top
;
y
<
src_rect
->
bottom
;
y
++
)
{
dst_pixel
=
dst_start
;
src_pixel
=
src_start
;
for
(
x
=
src_rect
->
left
;
x
<
src_rect
->
right
;
x
++
)
{
src_val
=
*
src_pixel
++
;
*
dst_pixel
++
=
put_field
(
get_field
(
src_val
,
src
->
red_shift
,
src
->
red_len
),
dst
->
red_shift
,
dst
->
red_len
)
|
put_field
(
get_field
(
src_val
,
src
->
green_shift
,
src
->
green_len
),
dst
->
green_shift
,
dst
->
green_len
)
|
put_field
(
get_field
(
src_val
,
src
->
blue_shift
,
src
->
blue_len
),
dst
->
blue_shift
,
dst
->
blue_len
);
}
if
(
pad_size
)
memset
(
dst_pixel
,
0
,
pad_size
);
dst_start
+=
dst
->
stride
/
4
;
src_start
+=
src
->
stride
/
4
;
}
}
break
;
}
...
...
@@ -1635,8 +1680,21 @@ static BOOL convert_to_24(dib_info *dst, const dib_info *src, const RECT *src_re
}
else
{
FIXME
(
"Unsupported conversion: 32 (%08x, %08x, %08x) -> 24
\n
"
,
src
->
red_mask
,
src
->
green_mask
,
src
->
blue_mask
);
return
FALSE
;
for
(
y
=
src_rect
->
top
;
y
<
src_rect
->
bottom
;
y
++
)
{
dst_pixel
=
dst_start
;
src_pixel
=
src_start
;
for
(
x
=
src_rect
->
left
;
x
<
src_rect
->
right
;
x
++
)
{
src_val
=
*
src_pixel
++
;
*
dst_pixel
++
=
get_field
(
src_val
,
src
->
blue_shift
,
src
->
blue_len
);
*
dst_pixel
++
=
get_field
(
src_val
,
src
->
green_shift
,
src
->
green_len
);
*
dst_pixel
++
=
get_field
(
src_val
,
src
->
red_shift
,
src
->
red_len
);
}
if
(
pad_size
)
memset
(
dst_pixel
,
0
,
pad_size
);
dst_start
+=
dst
->
stride
;
src_start
+=
src
->
stride
/
4
;
}
}
break
;
}
...
...
@@ -1859,8 +1917,21 @@ static BOOL convert_to_555(dib_info *dst, const dib_info *src, const RECT *src_r
}
else
{
FIXME
(
"Unsupported conversion: 32 (%08x, %08x, %08x) -> 555
\n
"
,
src
->
red_mask
,
src
->
green_mask
,
src
->
blue_mask
);
return
FALSE
;
for
(
y
=
src_rect
->
top
;
y
<
src_rect
->
bottom
;
y
++
)
{
dst_pixel
=
dst_start
;
src_pixel
=
src_start
;
for
(
x
=
src_rect
->
left
;
x
<
src_rect
->
right
;
x
++
)
{
src_val
=
*
src_pixel
++
;
*
dst_pixel
++
=
(((
get_field
(
src_val
,
src
->
red_shift
,
src
->
red_len
)
<<
7
)
&
0x7c00
)
|
((
get_field
(
src_val
,
src
->
green_shift
,
src
->
green_len
)
<<
2
)
&
0x03e0
)
|
(
get_field
(
src_val
,
src
->
blue_shift
,
src
->
blue_len
)
>>
3
));
}
if
(
pad_size
)
memset
(
dst_pixel
,
0
,
pad_size
);
dst_start
+=
dst
->
stride
/
2
;
src_start
+=
src
->
stride
/
4
;
}
}
break
;
}
...
...
@@ -2052,9 +2123,9 @@ static BOOL convert_to_16(dib_info *dst, const dib_info *src, const RECT *src_re
for
(
x
=
src_rect
->
left
;
x
<
src_rect
->
right
;
x
++
)
{
src_val
=
*
src_pixel
++
;
*
dst_pixel
++
=
put_field
(
(
src_val
>>
16
)
&
0xff
,
dst
->
red_shift
,
dst
->
red_len
)
|
put_field
(
(
src_val
>>
8
)
&
0xff
,
dst
->
green_shift
,
dst
->
green_len
)
|
put_field
(
src_val
&
0xff
,
dst
->
blue_shift
,
dst
->
blue_len
);
*
dst_pixel
++
=
put_field
(
src_val
>>
16
,
dst
->
red_shift
,
dst
->
red_len
)
|
put_field
(
src_val
>>
8
,
dst
->
green_shift
,
dst
->
green_len
)
|
put_field
(
src_val
,
dst
->
blue_shift
,
dst
->
blue_len
);
}
if
(
pad_size
)
memset
(
dst_pixel
,
0
,
pad_size
);
dst_start
+=
dst
->
stride
/
2
;
...
...
@@ -2070,9 +2141,9 @@ static BOOL convert_to_16(dib_info *dst, const dib_info *src, const RECT *src_re
for
(
x
=
src_rect
->
left
;
x
<
src_rect
->
right
;
x
++
)
{
src_val
=
*
src_pixel
++
;
*
dst_pixel
++
=
put_field
(
(
src_val
>>
src
->
red_shift
)
&
0xff
,
dst
->
red_shift
,
dst
->
red_len
)
|
put_field
(
(
src_val
>>
src
->
green_shift
)
&
0xff
,
dst
->
green_shift
,
dst
->
green_len
)
|
put_field
(
(
src_val
>>
src
->
blue_shift
)
&
0xff
,
dst
->
blue_shift
,
dst
->
blue_len
);
*
dst_pixel
++
=
put_field
(
src_val
>>
src
->
red_shift
,
dst
->
red_shift
,
dst
->
red_len
)
|
put_field
(
src_val
>>
src
->
green_shift
,
dst
->
green_shift
,
dst
->
green_len
)
|
put_field
(
src_val
>>
src
->
blue_shift
,
dst
->
blue_shift
,
dst
->
blue_len
);
}
if
(
pad_size
)
memset
(
dst_pixel
,
0
,
pad_size
);
dst_start
+=
dst
->
stride
/
2
;
...
...
@@ -2081,8 +2152,21 @@ static BOOL convert_to_16(dib_info *dst, const dib_info *src, const RECT *src_re
}
else
{
FIXME
(
"Unsupported conversion: 32 (%08x, %08x, %08x) -> 16
\n
"
,
src
->
red_mask
,
src
->
green_mask
,
src
->
blue_mask
);
return
FALSE
;
for
(
y
=
src_rect
->
top
;
y
<
src_rect
->
bottom
;
y
++
)
{
dst_pixel
=
dst_start
;
src_pixel
=
src_start
;
for
(
x
=
src_rect
->
left
;
x
<
src_rect
->
right
;
x
++
)
{
src_val
=
*
src_pixel
++
;
*
dst_pixel
++
=
put_field
(
get_field
(
src_val
,
src
->
red_shift
,
src
->
red_len
),
dst
->
red_shift
,
dst
->
red_len
)
|
put_field
(
get_field
(
src_val
,
src
->
green_shift
,
src
->
green_len
),
dst
->
green_shift
,
dst
->
green_len
)
|
put_field
(
get_field
(
src_val
,
src
->
blue_shift
,
src
->
blue_len
),
dst
->
blue_shift
,
dst
->
blue_len
);
}
if
(
pad_size
)
memset
(
dst_pixel
,
0
,
pad_size
);
dst_start
+=
dst
->
stride
/
2
;
src_start
+=
src
->
stride
/
4
;
}
}
break
;
}
...
...
@@ -2336,8 +2420,21 @@ static BOOL convert_to_8(dib_info *dst, const dib_info *src, const RECT *src_rec
}
else
{
FIXME
(
"Unsupported conversion: 32 (%08x, %08x, %08x) -> 8
\n
"
,
src
->
red_mask
,
src
->
green_mask
,
src
->
blue_mask
);
return
FALSE
;
for
(
y
=
src_rect
->
top
;
y
<
src_rect
->
bottom
;
y
++
)
{
dst_pixel
=
dst_start
;
src_pixel
=
src_start
;
for
(
x
=
src_rect
->
left
;
x
<
src_rect
->
right
;
x
++
)
{
src_val
=
*
src_pixel
++
;
*
dst_pixel
++
=
colorref_to_pixel_colortable
(
dst
,
(
get_field
(
src_val
,
src
->
red_shift
,
src
->
red_len
)
|
get_field
(
src_val
,
src
->
green_shift
,
src
->
green_len
)
<<
8
|
get_field
(
src_val
,
src
->
blue_shift
,
src
->
blue_len
)
<<
16
));
}
if
(
pad_size
)
memset
(
dst_pixel
,
0
,
pad_size
);
dst_start
+=
dst
->
stride
;
src_start
+=
src
->
stride
/
4
;
}
}
break
;
}
...
...
@@ -2602,8 +2699,32 @@ static BOOL convert_to_4(dib_info *dst, const dib_info *src, const RECT *src_rec
}
else
{
FIXME
(
"Unsupported conversion: 32 (%08x, %08x, %08x) -> 4
\n
"
,
src
->
red_mask
,
src
->
green_mask
,
src
->
blue_mask
);
return
FALSE
;
for
(
y
=
src_rect
->
top
;
y
<
src_rect
->
bottom
;
y
++
)
{
dst_pixel
=
dst_start
;
src_pixel
=
src_start
;
for
(
x
=
src_rect
->
left
;
x
<
src_rect
->
right
;
x
++
)
{
src_val
=
*
src_pixel
++
;
dst_val
=
colorref_to_pixel_colortable
(
dst
,
(
get_field
(
src_val
,
src
->
red_shift
,
src
->
red_len
)
|
get_field
(
src_val
,
src
->
green_shift
,
src
->
green_len
)
<<
8
|
get_field
(
src_val
,
src
->
blue_shift
,
src
->
blue_len
)
<<
16
));
if
((
x
-
src_rect
->
left
)
&
1
)
{
*
dst_pixel
=
(
dst_val
&
0x0f
)
|
(
*
dst_pixel
&
0xf0
);
dst_pixel
++
;
}
else
*
dst_pixel
=
(
dst_val
<<
4
)
&
0xf0
;
}
if
(
pad_size
)
{
if
((
x
-
src_rect
->
left
)
&
1
)
dst_pixel
++
;
memset
(
dst_pixel
,
0
,
pad_size
);
}
dst_start
+=
dst
->
stride
;
src_start
+=
src
->
stride
/
4
;
}
}
break
;
}
...
...
@@ -2955,8 +3076,34 @@ static BOOL convert_to_1(dib_info *dst, const dib_info *src, const RECT *src_rec
}
else
{
FIXME
(
"Unsupported conversion: 32 (%08x, %08x, %08x) -> 1
\n
"
,
src
->
red_mask
,
src
->
green_mask
,
src
->
blue_mask
);
return
FALSE
;
for
(
y
=
src_rect
->
top
;
y
<
src_rect
->
bottom
;
y
++
)
{
dst_pixel
=
dst_start
;
src_pixel
=
src_start
;
for
(
x
=
src_rect
->
left
,
bit_pos
=
0
;
x
<
src_rect
->
right
;
x
++
)
{
src_val
=
*
src_pixel
++
;
dst_val
=
colorref_to_pixel_colortable
(
dst
,
(
get_field
(
src_val
,
src
->
red_shift
,
src
->
red_len
)
|
get_field
(
src_val
,
src
->
green_shift
,
src
->
green_len
)
<<
8
|
get_field
(
src_val
,
src
->
blue_shift
,
src
->
blue_len
)
<<
16
))
?
0xff
:
0
;
if
(
bit_pos
==
0
)
*
dst_pixel
=
0
;
*
dst_pixel
=
(
*
dst_pixel
&
~
pixel_masks_1
[
bit_pos
])
|
(
dst_val
&
pixel_masks_1
[
bit_pos
]);
if
(
++
bit_pos
==
8
)
{
dst_pixel
++
;
bit_pos
=
0
;
}
}
if
(
pad_size
)
{
if
(
bit_pos
!=
0
)
dst_pixel
++
;
memset
(
dst_pixel
,
0
,
pad_size
);
}
dst_start
+=
dst
->
stride
;
src_start
+=
src
->
stride
/
4
;
}
}
break
;
}
...
...
dlls/gdi32/tests/bitmap.c
View file @
b084e52b
...
...
@@ -846,7 +846,7 @@ static void test_dib_formats(void)
case
32
:
expect_ok
=
(
compr
==
BI_RGB
||
compr
==
BI_BITFIELDS
);
break
;
default:
expect_ok
=
FALSE
;
break
;
}
todo
=
(
compr
==
BI_BITFIELDS
);
/* wine doesn't like strange bitfields */
todo
=
(
compr
==
BI_BITFIELDS
)
&&
bpp
==
16
;
/* wine doesn't like strange bitfields */
memset
(
bi
,
0
,
sizeof
(
bi
->
bmiHeader
)
);
bi
->
bmiHeader
.
biSize
=
sizeof
(
BITMAPINFOHEADER
);
...
...
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