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
465e6539
Commit
465e6539
authored
May 16, 2010
by
Joel Holdsworth
Committed by
Alexandre Julliard
May 17, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: Modified the ICO render script to also render BMPs.
parent
0c0e352f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
24 deletions
+65
-24
Make.rules.in
Make.rules.in
+3
-5
buildimage
tools/buildimage
+62
-19
No files found.
Make.rules.in
View file @
465e6539
...
...
@@ -63,7 +63,7 @@ IDLFLAGS = $(INCLUDES) $(DEFS) $(EXTRAIDLFLAGS)
TARGETFLAGS = @TARGETFLAGS@
MKINSTALLDIRS= $(TOPSRCDIR)/tools/mkinstalldirs -m 755
WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi/winapi_check
BUILDI
CON = $(TOPSRCDIR)/tools/buildicon
BUILDI
MAGE = $(TOPSRCDIR)/tools/buildimage
C2MAN = $(TOPSRCDIR)/tools/c2man.pl
RUNTEST = $(TOPSRCDIR)/tools/runtest
WINEBUILD = $(TOOLSDIR)/tools/winebuild/winebuild$(TOOLSEXT)
...
...
@@ -190,12 +190,10 @@ filter: dummy
LC_ALL=C sed -e 's,@bindir\@,$(bindir),g' -e 's,@dlldir\@,$(dlldir),g' -e 's,@PACKAGE_STRING\@,@PACKAGE_STRING@,g' $< >$@ || ($(RM) $@ && false)
.svg.ico:
CONVERT="$(CONVERT)" ICOTOOL="$(ICOTOOL)" RSVG="$(RSVG)" $(BUILDI
CON
) $< $@
CONVERT="$(CONVERT)" ICOTOOL="$(ICOTOOL)" RSVG="$(RSVG)" $(BUILDI
MAGE
) $< $@
.svg.bmp:
$(RSVG) $< $<.png
$(CONVERT) $<.png -alpha off $@
$(RM) $<.png
CONVERT="$(CONVERT)" ICOTOOL="$(ICOTOOL)" RSVG="$(RSVG)" $(BUILDIMAGE) $< $@
# Rules for IDL files
...
...
tools/buildi
con
→
tools/buildi
mage
View file @
465e6539
#! /usr/bin/perl -w
#
# Render SVG files containing
multiple images
# Render SVG files containing
one or more images into an ICO or BMP.
#
# Copyright (C) 2010 Joel Holdsworth
#
...
...
@@ -22,17 +22,21 @@ use strict;
use
warnings
;
use
XML::
Parser
;
use
MIME::
Base64
;
use
File::
Copy
;
# Parse the parameters
my
$svgFileName
=
$ARGV
[
0
];
my
$icoFileName
=
$ARGV
[
1
];
my
$outFileName
=
$ARGV
[
1
];
die
"Cannot open SVG file"
unless
defined
(
$svgFileName
);
die
"Cannot open
ICO file"
unless
defined
(
$ico
FileName
);
die
"Cannot open
output file"
unless
defined
(
$out
FileName
);
my
$renderedSVGFileName
=
"$svgFileName.ico"
;
$icoFileName
=~
m/(.*)\.ico/
;
my
$icoName
=
$1
;
$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"
;
my
$renderedSVGFileName
=
"$svgFileName.png"
;
my
@pngFiles
;
# Get the programs from the environment variables
...
...
@@ -40,6 +44,7 @@ my $convert = $ENV{"CONVERT"} || "convert";
my
$rsvg
=
$ENV
{
"RSVG"
}
||
"rsvg"
;
my
$icotool
=
$ENV
{
"ICOTOOL"
}
||
"icotool"
;
# Be ready to abort
sub
cleanup
()
{
unlink
$renderedSVGFileName
;
...
...
@@ -62,19 +67,35 @@ sub svg_element_start
{
my
(
$expat
,
$element
,
%
attr
)
=
@_
;
# Parse the id for icon
format
# Parse the id for icon
/bitmap render directives
my
$id
=
$attr
{
'id'
};
return
unless
defined
(
$id
);
return
unless
$id
=~
/icon:(\d*)-(\d*)/
;
my
$size
=
$1
;
my
$depth
=
$2
;
my
$size
=
0
;
my
$depth
=
0
;
if
(
$ext
eq
"ico"
)
{
return
unless
$id
=~
/icon:(\d*)-(\d*)/
;
$size
=
$1
;
$depth
=
$2
;
}
elsif
(
$ext
eq
"bmp"
)
{
return
unless
$id
=~
/bitmap:(\d*)-(\d*)/
;
$size
=
$1
;
$depth
=
$2
;
}
return
unless
defined
(
$size
)
and
defined
(
$depth
);
warn
"Unexpected icon depth"
unless
$depth
==
4
or
$depth
==
8
or
$depth
==
32
;
my
$pngFileName
=
"$
ico
Name-$size-$depth.png"
;
$depth
==
4
or
$depth
==
8
or
$depth
==
24
or
$depth
==
32
;
my
$pngFileName
=
"$
out
Name-$size-$depth.png"
;
if
(
$element
eq
"rect"
)
{
if
(
$element
eq
"svg"
)
{
# The whole file is tagged
copy
(
$renderedSVGFileName
,
$pngFileName
)
or
die
"File could not be copied"
;
}
elsif
(
$element
eq
"rect"
)
{
# Extract SVG vector images
my
$x
=
$attr
{
'x'
};
...
...
@@ -116,12 +137,34 @@ my $parser = new XML::Parser(
Handlers
=>
{
Start
=>
\&
svg_element_start
});
$parser
->
parsefile
(
"$svgFileName"
);
# Die if no render directives were found
die
"No render directives found in icon"
unless
(
@pngFiles
);
# If no render directives were found, take the full image as-is
unless
(
@pngFiles
)
{
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
;
}
elsif
(
$ext
eq
"bmp"
)
{
# Only the first image becomes the final BMP
my
$pngFile
=
$pngFiles
[
0
];
$pngFile
=~
/.*-\d*-(\d*)\.png/
;
my
$depth
=
$1
;
# Combine them into an ICO file
shell
$icotool
,
"-c"
,
"-o"
,
$icoFileName
,
@pngFiles
;
# Convert it into a bmp
if
(
$depth
==
24
)
{
shell
$convert
,
"png:$pngFile"
,
"+matte"
,
$outFileName
;
}
else
{
shell
$convert
,
"png:$pngFile"
,
$outFileName
;
}
}
# Delete the intermediate images
unlink
$renderedSVGFileName
;
unlink
$_
foreach
(
@pngFiles
);
cleanup
();
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