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
19b7d1db
Commit
19b7d1db
authored
Aug 19, 2023
by
Jeff Smith
Committed by
Alexandre Julliard
Aug 24, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdiplus: Fix GdipCreateBitmapFromICON return status with mask-only icon.
parent
a548bef8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
59 deletions
+29
-59
image.c
dlls/gdiplus/image.c
+29
-55
image.c
dlls/gdiplus/tests/image.c
+0
-4
No files found.
dlls/gdiplus/image.c
View file @
19b7d1db
...
...
@@ -1635,11 +1635,11 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHICON(HICON hicon, GpBitmap** bitmap)
TRACE
(
"%p, %p
\n
"
,
hicon
,
bitmap
);
if
(
!
bitmap
||
!
GetIconInfo
(
hicon
,
&
iinfo
))
if
(
!
bitmap
||
!
GetIconInfo
(
hicon
,
&
iinfo
)
||
!
iinfo
.
hbmColor
||
!
iinfo
.
fIcon
)
return
InvalidParameter
;
/* get the size of the icon */
ret
=
GetObjectA
(
iinfo
.
hbmColor
?
iinfo
.
hbmColor
:
iinfo
.
hbmMask
,
sizeof
(
bm
),
&
bm
);
ret
=
GetObjectA
(
iinfo
.
hbmColor
,
sizeof
(
bm
),
&
bm
);
if
(
ret
==
0
)
{
DeleteObject
(
iinfo
.
hbmColor
);
DeleteObject
(
iinfo
.
hbmMask
);
...
...
@@ -1647,7 +1647,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHICON(HICON hicon, GpBitmap** bitmap)
}
width
=
bm
.
bmWidth
;
height
=
iinfo
.
hbmColor
?
abs
(
bm
.
bmHeight
)
:
abs
(
bm
.
bmHeight
)
/
2
;
height
=
abs
(
bm
.
bmHeight
)
;
stride
=
width
*
4
;
stat
=
GdipCreateBitmapFromScan0
(
width
,
height
,
stride
,
PixelFormat32bppARGB
,
NULL
,
bitmap
);
...
...
@@ -1672,7 +1672,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHICON(HICON hicon, GpBitmap** bitmap)
bih
.
biSize
=
sizeof
(
bih
);
bih
.
biWidth
=
width
;
bih
.
biHeight
=
iinfo
.
hbmColor
?
-
height
:
-
height
*
2
;
bih
.
biHeight
=
-
height
;
bih
.
biPlanes
=
1
;
bih
.
biBitCount
=
32
;
bih
.
biCompression
=
BI_RGB
;
...
...
@@ -1683,71 +1683,45 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHICON(HICON hicon, GpBitmap** bitmap)
bih
.
biClrImportant
=
0
;
screendc
=
CreateCompatibleDC
(
0
);
if
(
iinfo
.
hbmColor
)
{
GetDIBits
(
screendc
,
iinfo
.
hbmColor
,
0
,
height
,
lockeddata
.
Scan0
,
(
BITMAPINFO
*
)
&
bih
,
DIB_RGB_COLORS
);
GetDIBits
(
screendc
,
iinfo
.
hbmColor
,
0
,
height
,
lockeddata
.
Scan0
,
(
BITMAPINFO
*
)
&
bih
,
DIB_RGB_COLORS
);
if
(
bm
.
bmBitsPixel
==
32
)
{
has_alpha
=
FALSE
;
/* If any pixel has a non-zero alpha, ignore hbmMask */
src
=
(
DWORD
*
)
lockeddata
.
Scan0
;
for
(
y
=
0
;
y
<
height
&&
!
has_alpha
;
y
++
)
for
(
x
=
0
;
x
<
width
&&
!
has_alpha
;
x
++
)
if
((
*
src
++
&
0xff000000
)
!=
0
)
has_alpha
=
TRUE
;
}
else
has_alpha
=
FALSE
;
}
else
if
(
bm
.
bmBitsPixel
==
32
)
{
GetDIBits
(
screendc
,
iinfo
.
hbmMask
,
0
,
height
,
lockeddata
.
Scan0
,
(
BITMAPINFO
*
)
&
bih
,
DIB_RGB_COLORS
);
has_alpha
=
FALSE
;
/* If any pixel has a non-zero alpha, ignore hbmMask */
src
=
(
DWORD
*
)
lockeddata
.
Scan0
;
for
(
y
=
0
;
y
<
height
&&
!
has_alpha
;
y
++
)
for
(
x
=
0
;
x
<
width
&&
!
has_alpha
;
x
++
)
if
((
*
src
++
&
0xff000000
)
!=
0
)
has_alpha
=
TRUE
;
}
else
has_alpha
=
FALSE
;
if
(
!
has_alpha
)
{
if
(
iinfo
.
hbmMask
)
{
BYTE
*
bits
=
heap_alloc
(
height
*
stride
);
/* read alpha data from the mask */
if
(
iinfo
.
hbmColor
)
GetDIBits
(
screendc
,
iinfo
.
hbmMask
,
0
,
height
,
bits
,
(
BITMAPINFO
*
)
&
bih
,
DIB_RGB_COLORS
);
else
GetDIBits
(
screendc
,
iinfo
.
hbmMask
,
height
,
height
,
bits
,
(
BITMAPINFO
*
)
&
bih
,
DIB_RGB_COLORS
);
BYTE
*
bits
=
heap_alloc
(
height
*
stride
);
src
=
(
DWORD
*
)
bits
;
dst_row
=
lockeddata
.
Scan0
;
for
(
y
=
0
;
y
<
height
;
y
++
)
{
dst
=
(
DWORD
*
)
dst_row
;
for
(
x
=
0
;
x
<
width
;
x
++
)
{
DWORD
src_value
=
*
src
++
;
if
(
src_value
)
*
dst
++
=
0
;
else
*
dst
++
|=
0xff000000
;
}
dst_row
+=
lockeddata
.
Stride
;
}
/* read alpha data from the mask - the mask can safely be assumed to exist */
GetDIBits
(
screendc
,
iinfo
.
hbmMask
,
0
,
height
,
bits
,
(
BITMAPINFO
*
)
&
bih
,
DIB_RGB_COLORS
);
heap_free
(
bits
)
;
}
else
src
=
(
DWORD
*
)
bits
;
dst_row
=
lockeddata
.
Scan0
;
for
(
y
=
0
;
y
<
height
;
y
++
)
{
/* set constant alpha of 255 */
dst_row
=
lockeddata
.
Scan0
;
for
(
y
=
0
;
y
<
height
;
y
++
)
dst
=
(
DWORD
*
)
dst_row
;
for
(
x
=
0
;
x
<
width
;
x
++
)
{
dst
=
(
DWORD
*
)
dst_row
;
for
(
x
=
0
;
x
<
width
;
x
++
)
DWORD
src_value
=
*
src
++
;
if
(
src_value
)
*
dst
++
=
0
;
else
*
dst
++
|=
0xff000000
;
dst_row
+=
lockeddata
.
Stride
;
}
dst_row
+=
lockeddata
.
Stride
;
}
heap_free
(
bits
);
}
DeleteDC
(
screendc
);
...
...
dlls/gdiplus/tests/image.c
View file @
19b7d1db
...
...
@@ -1606,7 +1606,6 @@ static void test_fromhicon(void)
ok
(
hIcon
!=
0
,
"CreateIconIndirect failed
\n
"
);
stat
=
GdipCreateBitmapFromHICON
(
hIcon
,
&
bitmap
);
todo_wine
expect
(
InvalidParameter
,
stat
);
if
(
stat
==
Ok
)
GdipDisposeImage
((
GpImage
*
)
bitmap
);
...
...
@@ -1619,10 +1618,7 @@ static void test_fromhicon(void)
ok
(
hIcon
!=
0
,
"CreateIconIndirect failed
\n
"
);
stat
=
GdipCreateBitmapFromHICON
(
hIcon
,
&
bitmap
);
todo_wine
expect
(
InvalidParameter
,
stat
);
if
(
stat
==
Ok
)
GdipDisposeImage
((
GpImage
*
)
bitmap
);
DestroyIcon
(
hIcon
);
DeleteObject
(
hbmMask
);
...
...
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