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
8e45a6ec
Commit
8e45a6ec
authored
Jul 14, 2017
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: Add support for generating cursor files from SVG.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
9f22041b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
42 deletions
+43
-42
buildimage
tools/buildimage
+32
-38
makedep.c
tools/makedep.c
+11
-4
No files found.
tools/buildimage
View file @
8e45a6ec
...
...
@@ -34,23 +34,22 @@ die "Cannot open output file" unless defined($outFileName);
$outFileName
=~
m/(.*)\.(.*)/
;
my
$outName
=
$1
;
my
$ext
=
lc
(
$2
);
die
"Only BMP
and ICO outputs are supported"
unless
$ext
eq
"bmp"
or
$ext
eq
"ico
"
;
die
"Only BMP
, ICO and CUR outputs are supported"
unless
$ext
eq
"bmp"
or
$ext
eq
"ico"
or
$ext
eq
"cur
"
;
my
$renderedSVGFileName
=
"$svgFileName.png"
;
my
@pngFiles
;
my
@pngFilesRaw
;
# Get the programs from the environment variables
my
$convert
=
$ENV
{
"CONVERT"
}
||
"convert"
;
my
$rsvg
=
$ENV
{
"RSVG"
}
||
"rsvg"
;
my
$icotool
=
$ENV
{
"ICOTOOL"
}
||
"icotool"
;
my
@icotool_args
=
(
$ENV
{
"ICOTOOL"
}
||
"icotool"
,
"--create"
,
$ext
eq
"cur"
?
"--cursor"
:
"--icon"
,
"-o"
,
$outFileName
);
# Be ready to abort
sub
cleanup
()
{
unlink
$renderedSVGFileName
;
unlink
$_
foreach
(
@pngFiles
);
unlink
$_
foreach
(
@pngFilesRaw
);
}
$SIG
{
"INT"
}
=
"cleanup"
;
...
...
@@ -78,10 +77,20 @@ sub svg_element_start
my
$width
=
0
;
my
$height
=
0
;
if
(
$id
eq
"hotspot"
)
{
push
@icotool_args
,
"--hotspot-x=$attr{x}"
,
"--hotspot-y=$attr{y}"
;
return
;
}
if
(
$ext
eq
"ico"
)
{
return
unless
$id
=~
/icon:(\d*)-(\d*)/
;
$size
=
$1
;
$depth
=
$2
;
}
elsif
(
$ext
eq
"cur"
)
{
return
unless
$id
=~
/cursor:(\d*)-(\d*)/
;
$size
=
$1
;
$depth
=
$2
;
}
elsif
(
$ext
eq
"bmp"
)
{
return
unless
$id
=~
/bitmap:(\d*)-(\d*)/
;
$size
=
$1
;
...
...
@@ -90,14 +99,24 @@ sub svg_element_start
return
unless
defined
(
$size
)
and
defined
(
$depth
);
warn
"Unexpected
icon
depth"
unless
$depth
==
4
or
$depth
==
8
or
$depth
==
24
or
$depth
==
32
;
warn
"Unexpected depth"
unless
$depth
==
1
or
$depth
==
4
or
$depth
==
8
or
$depth
==
24
or
$depth
==
32
;
my
$pngFileName
=
"$outName-$size-$depth.png"
;
if
(
$element
eq
"svg"
)
{
if
(
$ext
eq
"bmp"
)
{
if
(
$depth
==
24
)
{
shell
$convert
,
$renderedSVGFileName
,
"+matte"
,
$outFileName
;
}
else
{
shell
$convert
,
$renderedSVGFileName
,
$outFileName
;
}
cleanup
();
exit
(
0
);
}
# The whole file is tagged
copy
(
$renderedSVGFileName
,
$pngFileName
)
or
die
"File could not be copied"
;
$pngFileName
=
$renderedSVGFileName
;
}
elsif
(
$element
eq
"rect"
)
{
...
...
@@ -109,10 +128,9 @@ sub svg_element_start
if
(
defined
(
$x
)
and
defined
(
$y
))
{
if
(
$x
=~
/\d*/
and
$y
=~
/\d*/
)
{
shell
$convert
,
$renderedSVGFileName
,
"-crop"
,
"${width}x${height}+$x+$y"
,
$pngFileName
;
shell
$convert
,
$renderedSVGFileName
,
"-crop"
,
"${width}x${height}+$x+$y"
,
"-depth"
,
$depth
,
$pngFileName
;
}
}
}
elsif
(
$element
eq
"image"
)
{
# Extract Base64 encoded PNG data to files
...
...
@@ -132,12 +150,13 @@ sub svg_element_start
if
(
$width
>=
128
&&
$height
>=
128
)
{
push
(
@pngFilesRaw
,
$pngFileName
)
;
push
@icotool_args
,
"--raw=$pngFileName"
;
}
else
{
push
(
@pngFiles
,
$pngFileName
)
;
push
@icotool_args
,
$pngFileName
;
}
push
@pngFiles
,
$pngFileName
;
}
# Render the SVG image
...
...
@@ -153,34 +172,9 @@ my $parser = new XML::Parser(
Handlers
=>
{
Start
=>
\&
svg_element_start
});
$parser
->
parsefile
(
"$svgFileName"
);
# If no render directives were found, take the full image as-is
unless
(
@pngFiles
||
@pngFilesRaw
)
{
my
$pngFileName
=
"bmp$renderedSVGFileName"
;
copy
(
$renderedSVGFileName
,
$pngFileName
)
or
die
"File could not be copied"
;
push
(
@pngFiles
,
$pngFileName
);
}
# Combine the renderings into the output file
if
(
$ext
eq
"ico"
)
{
# Place images into the ICO
shell
$icotool
,
"-c"
,
"-o"
,
$outFileName
,
@pngFiles
,
map
{
"--raw=$_"
;
}
@pngFilesRaw
;
}
elsif
(
$ext
eq
"bmp"
)
{
# Only the first image becomes the final BMP
my
$pngFile
=
$pngFiles
[
0
];
$pngFile
=~
/.*-\d*-(\d*)\.png/
;
my
$depth
=
$1
;
die
"no render directive found in $svgFileName"
unless
@pngFiles
;
# Convert it into a bmp
if
(
$depth
==
24
)
{
shell
$convert
,
"png:$pngFile"
,
"+matte"
,
$outFileName
;
}
else
{
shell
$convert
,
"png:$pngFile"
,
$outFileName
;
}
}
shell
@icotool_args
;
# Delete the intermediate images
cleanup
();
tools/makedep.c
View file @
8e45a6ec
...
...
@@ -2600,10 +2600,17 @@ static struct strarray output_sources( const struct makefile *make )
{
if
(
convert
&&
rsvg
&&
icotool
&&
!
make
->
src_dir
)
{
output
(
"%s.ico %s.bmp: %s
\n
"
,
src_dir_path
(
make
,
obj
),
src_dir_path
(
make
,
obj
),
source
->
filename
);
output
(
"
\t
CONVERT=
\"
%s
\"
ICOTOOL=
\"
%s
\"
RSVG=
\"
%s
\"
%s %s $@
\n
"
,
convert
,
icotool
,
rsvg
,
top_src_dir_path
(
make
,
"tools/buildimage"
),
source
->
filename
);
static
const
char
*
const
images
[]
=
{
"bmp"
,
"cur"
,
"ico"
,
NULL
};
for
(
i
=
0
;
images
[
i
];
i
++
)
if
(
find_include_file
(
make
,
strmake
(
"%s.%s"
,
obj
,
images
[
i
]
)))
break
;
if
(
images
[
i
])
{
output
(
"%s.%s: %s
\n
"
,
src_dir_path
(
make
,
obj
),
images
[
i
],
source
->
filename
);
output
(
"
\t
CONVERT=
\"
%s
\"
ICOTOOL=
\"
%s
\"
RSVG=
\"
%s
\"
%s %s $@
\n
"
,
convert
,
icotool
,
rsvg
,
top_src_dir_path
(
make
,
"tools/buildimage"
),
source
->
filename
);
}
}
}
else
if
(
!
strcmp
(
ext
,
"po"
))
/* po file */
...
...
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