Commit 0aa3ae18 authored by Alexandre Julliard's avatar Alexandre Julliard

buildimage: Store large images as raw PNG files in icons.

parent c9d806a0
...@@ -38,6 +38,7 @@ die "Only BMP and ICO outputs are supported" unless $ext eq "bmp" or $ext eq "ic ...@@ -38,6 +38,7 @@ die "Only BMP and ICO outputs are supported" unless $ext eq "bmp" or $ext eq "ic
my $renderedSVGFileName = "$svgFileName.png"; my $renderedSVGFileName = "$svgFileName.png";
my @pngFiles; my @pngFiles;
my @pngFilesRaw;
# Get the programs from the environment variables # Get the programs from the environment variables
my $convert = $ENV{"CONVERT"} || "convert"; my $convert = $ENV{"CONVERT"} || "convert";
...@@ -49,6 +50,7 @@ sub cleanup() ...@@ -49,6 +50,7 @@ sub cleanup()
{ {
unlink $renderedSVGFileName; unlink $renderedSVGFileName;
unlink $_ foreach(@pngFiles); unlink $_ foreach(@pngFiles);
unlink $_ foreach(@pngFilesRaw);
} }
$SIG{"INT"} = "cleanup"; $SIG{"INT"} = "cleanup";
...@@ -73,6 +75,8 @@ sub svg_element_start ...@@ -73,6 +75,8 @@ sub svg_element_start
my $size = 0; my $size = 0;
my $depth = 0; my $depth = 0;
my $width = 0;
my $height = 0;
if($ext eq "ico") { if($ext eq "ico") {
return unless $id =~ /icon:(\d*)-(\d*)/; return unless $id =~ /icon:(\d*)-(\d*)/;
...@@ -100,8 +104,8 @@ sub svg_element_start ...@@ -100,8 +104,8 @@ sub svg_element_start
# Extract SVG vector images # Extract SVG vector images
my $x = $attr{'x'}; my $x = $attr{'x'};
my $y = $attr{'y'}; my $y = $attr{'y'};
my $width = $attr{'width'}; $width = $attr{'width'};
my $height = $attr{'height'}; $height = $attr{'height'};
if(defined($x) and defined($x)) { if(defined($x) and defined($x)) {
if($x =~ /\d*/ and $y =~ /\d*/) { if($x =~ /\d*/ and $y =~ /\d*/) {
...@@ -126,7 +130,14 @@ sub svg_element_start ...@@ -126,7 +130,14 @@ sub svg_element_start
return; return;
} }
push(@pngFiles, $pngFileName); if ($width >= 128 && $height >= 128)
{
push(@pngFilesRaw, $pngFileName);
}
else
{
push(@pngFiles, $pngFileName);
}
} }
# Render the SVG image # Render the SVG image
...@@ -138,7 +149,7 @@ my $parser = new XML::Parser( ...@@ -138,7 +149,7 @@ my $parser = new XML::Parser(
$parser->parsefile("$svgFileName"); $parser->parsefile("$svgFileName");
# If no render directives were found, take the full image as-is # If no render directives were found, take the full image as-is
unless(@pngFiles) { unless (@pngFiles || @pngFilesRaw) {
my $pngFileName = "bmp$renderedSVGFileName"; my $pngFileName = "bmp$renderedSVGFileName";
copy($renderedSVGFileName, $pngFileName) or die "File could not be copied"; copy($renderedSVGFileName, $pngFileName) or die "File could not be copied";
push(@pngFiles, $pngFileName); push(@pngFiles, $pngFileName);
...@@ -148,7 +159,7 @@ unless(@pngFiles) { ...@@ -148,7 +159,7 @@ unless(@pngFiles) {
if($ext eq "ico") { if($ext eq "ico") {
# Place images into the ICO # Place images into the ICO
shell $icotool, "-c", "-o", $outFileName, @pngFiles; shell $icotool, "-c", "-o", $outFileName, @pngFiles, map { "--raw=$_"; } @pngFilesRaw;
} elsif($ext eq "bmp") { } elsif($ext eq "bmp") {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment