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
520d1bc5
Commit
520d1bc5
authored
May 13, 2008
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winemenubuilder: Copy the icon data before modifying it, resources are read-only.
parent
12de7d75
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
winemenubuilder.c
programs/winemenubuilder/winemenubuilder.c
+13
-6
No files found.
programs/winemenubuilder/winemenubuilder.c
View file @
520d1bc5
...
...
@@ -201,8 +201,8 @@ static BOOL SaveIconResAsPNG(const BITMAPINFO *pIcon, const char *png_filename,
png_infop
info_ptr
;
png_text
comment
;
int
nXORWidthBytes
,
nANDWidthBytes
,
color_type
=
0
,
i
,
j
;
BYTE
*
pXOR
,
*
row
;
const
BYTE
*
pAND
=
NULL
;
BYTE
*
row
,
*
copy
=
NULL
;
const
BYTE
*
p
XOR
,
*
p
AND
=
NULL
;
int
nWidth
=
pIcon
->
bmiHeader
.
biWidth
;
int
nHeight
=
pIcon
->
bmiHeader
.
biHeight
;
int
nBpp
=
pIcon
->
bmiHeader
.
biBitCount
;
...
...
@@ -233,21 +233,26 @@ static BOOL SaveIconResAsPNG(const BITMAPINFO *pIcon, const char *png_filename,
nXORWidthBytes
=
4
*
((
nWidth
*
nBpp
+
31
)
/
32
);
nANDWidthBytes
=
4
*
((
nWidth
+
31
)
/
32
);
pXOR
=
(
BYTE
*
)
pIcon
+
sizeof
(
BITMAPINFOHEADER
)
+
pIcon
->
bmiHeader
.
biClrUsed
*
sizeof
(
RGBQUAD
);
pXOR
=
(
const
BYTE
*
)
pIcon
+
sizeof
(
BITMAPINFOHEADER
)
+
pIcon
->
bmiHeader
.
biClrUsed
*
sizeof
(
RGBQUAD
);
if
(
nHeight
>
nWidth
)
{
nHeight
/=
2
;
pAND
=
pXOR
+
nHeight
*
nXORWidthBytes
;
}
/* image and mask are upside down reversed */
row
=
pXOR
+
(
nHeight
-
1
)
*
nXORWidthBytes
;
/* Apply mask if present */
if
(
pAND
)
{
RGBQUAD
bgColor
;
/* copy bytes before modifying them */
copy
=
HeapAlloc
(
GetProcessHeap
(),
0
,
nHeight
*
nXORWidthBytes
);
memcpy
(
copy
,
pXOR
,
nHeight
*
nXORWidthBytes
);
pXOR
=
copy
;
/* image and mask are upside down reversed */
row
=
copy
+
(
nHeight
-
1
)
*
nXORWidthBytes
;
/* top left corner */
bgColor
.
rgbRed
=
row
[
0
];
bgColor
.
rgbGreen
=
row
[
1
];
...
...
@@ -306,6 +311,7 @@ static BOOL SaveIconResAsPNG(const BITMAPINFO *pIcon, const char *png_filename,
ppng_destroy_write_struct
(
&
png_ptr
,
&
info_ptr
);
if
(
png_ptr
)
ppng_destroy_write_struct
(
&
png_ptr
,
NULL
);
fclose
(
fp
);
HeapFree
(
GetProcessHeap
(),
0
,
copy
);
HeapFree
(
GetProcessHeap
(),
0
,
comment
.
text
);
return
TRUE
;
...
...
@@ -313,6 +319,7 @@ static BOOL SaveIconResAsPNG(const BITMAPINFO *pIcon, const char *png_filename,
if
(
png_ptr
)
ppng_destroy_write_struct
(
&
png_ptr
,
NULL
);
fclose
(
fp
);
unlink
(
png_filename
);
HeapFree
(
GetProcessHeap
(),
0
,
copy
);
HeapFree
(
GetProcessHeap
(),
0
,
comment
.
text
);
return
FALSE
;
}
...
...
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