Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
e02de775
Commit
e02de775
authored
Apr 05, 2010
by
Joel Holdsworth
Committed by
Alexandre Julliard
Apr 06, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: Installed new icon build script.
parent
476a2bee
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
131 additions
and
5 deletions
+131
-5
Make.rules.in
Make.rules.in
+2
-5
buildicon
tools/buildicon
+129
-0
No files found.
Make.rules.in
View file @
e02de775
...
...
@@ -64,6 +64,7 @@ TARGETFLAGS = @TARGETFLAGS@
WINEBUILDFLAGS = $(TARGETFLAGS) $(DLLFLAGS)
MKINSTALLDIRS= $(TOPSRCDIR)/tools/mkinstalldirs -m 755
WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi/winapi_check
BUILDICON = $(TOPSRCDIR)/tools/buildicon
C2MAN = $(TOPSRCDIR)/tools/c2man.pl
RUNTEST = $(TOPSRCDIR)/tools/runtest
WINEBUILD = $(TOOLSDIR)/tools/winebuild/winebuild$(TOOLSEXT)
...
...
@@ -190,11 +191,7 @@ 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:
$(RSVG) -w 16 -h 16 -f png $< $*-16.png
$(RSVG) -w 32 -h 32 -f png $< $*-32.png
$(RSVG) -w 48 -h 48 -f png $< $*-48.png
$(ICOTOOL) -c -o $@ $*-16.png $*-32.png $*-48.png
$(RM) $*-16.png $*-32.png $*-48.png
CONVERT="$(CONVERT)" ICOTOOL="$(ICOTOOL)" RSVG="$(RSVG)" $(BUILDICON) $< $@
# Rules for IDL files
...
...
tools/buildicon
0 → 100755
View file @
e02de775
#! /usr/bin/perl -w
#
# Render SVG files containing multiple images
#
# Copyright (C) 2010 Joel Holdsworth
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
use
strict
;
use
warnings
;
use
XML::
Parser
;
use
MIME::
Base64
;
# Parse the parameters
my
$svgFileName
=
$ARGV
[
0
];
my
$icoFileName
=
$ARGV
[
1
];
die
"Cannot open SVG file"
unless
defined
(
$svgFileName
);
die
"Cannot open ICO file"
unless
defined
(
$icoFileName
);
my
$renderedSVGFileName
=
"$svgFileName.ico"
;
$icoFileName
=~
m/(.*)\.ico/
;
my
$icoName
=
$1
;
my
@pngFiles
;
# Get the programs from the environment variables
my
$convert
=
$ENV
{
"CONVERT"
};
$convert
=
"convert"
if
$convert
eq
""
;
my
$rsvg
=
$ENV
{
"RSVG"
};
$rsvg
=
"rsvg"
if
$rsvg
eq
""
;
my
$icotool
=
$ENV
{
"ICOTOOL"
};
$icotool
=
"icotool"
if
$icotool
eq
""
;
sub
svg_element_start
{
my
(
$expat
,
$element
,
%
attr
)
=
@_
;
# Parse the id for icon format
my
$id
=
$attr
{
'id'
};
return
unless
defined
(
$id
);
return
unless
$id
=~
/icon:(\d*)-(\d*)/
;
my
$size
=
$1
;
my
$depth
=
$2
;
return
unless
defined
(
$size
)
and
defined
(
$depth
);
warn
"Unexpected icon depth"
unless
$depth
==
4
or
$depth
==
8
or
$depth
==
32
;
my
$pngFileName
=
"$icoName-$size-$depth.png"
;
if
(
$element
eq
"rect"
)
{
# Extract SVG vector images
my
$x
=
$attr
{
'x'
};
my
$y
=
$attr
{
'y'
};
if
(
defined
(
$x
)
and
defined
(
$x
))
{
if
(
$x
=~
/\d*/
and
$y
=~
/\d*/
)
{
system
"$convert $renderedSVGFileName -crop '$size x$size+$x+$y' $pngFileName"
;
}
}
}
elsif
(
$element
eq
"image"
)
{
# Extract Base64 encoded PNG data to files
my
$xlinkHref
=
$attr
{
'xlink:href'
};
if
(
defined
(
$xlinkHref
))
{
$xlinkHref
=~
/data:image\/png;base64(.*)/
;
my
$imageEncodedData
=
$1
;
if
(
defined
$imageEncodedData
)
{
open
(
FILE
,
'>'
.
$pngFileName
)
or
die
"$!"
;
print
FILE
decode_base64
(
$imageEncodedData
);
close
FILE
;
}
}
}
else
{
return
;
}
push
(
@pngFiles
,
$pngFileName
);
}
sub
resize_image
{
# Use ImageMagick to stretch the image
my
(
$size
)
=
@_
;
my
$pngFileName
=
"$icoName-$size.png"
;
system
"$convert $renderedSVGFileName -resize '$size x$size' $pngFileName"
;
push
(
@pngFiles
,
$pngFileName
);
}
sub
fallback_render
{
resize_image
(
16
);
resize_image
(
32
);
resize_image
(
48
);
}
# Render the SVG image
system
'rsvg'
,
$svgFileName
,
$renderedSVGFileName
;
# Render the images in the SVG
my
$parser
=
new
XML::
Parser
(
Handlers
=>
{
Start
=>
\&
svg_element_start
});
$parser
->
parsefile
(
"$svgFileName"
);
# If no render directives were found, this is an old-style icon
# which should be rendered with the old build rule
fallback_render
unless
(
@pngFiles
);
# Combine them into an ICO file
my
$icotoolCommand
=
"$icotool -c -o $icoFileName"
;
$icotoolCommand
.=
" $_"
foreach
(
@pngFiles
);
system
$icotoolCommand
;
# Delete the intermediate images
unlink
$renderedSVGFileName
;
unlink
$_
foreach
(
@pngFiles
);
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