diff --git a/assets/make_ico.pl b/assets/make_ico.pl new file mode 100644 index 0000000..37744bd --- /dev/null +++ b/assets/make_ico.pl @@ -0,0 +1,88 @@ +#!/usr/bin/perl -w + +use strict; +use constant SIZEOF_HEADER => 6; +use constant SIZEOF_ENTRY => 16; + +use Getopt::Long; + +sub load_png { + + my ($file, $width, $height) = @_; + + print "Opening $file\n"; + open(my $io, "<", $file) or return ""; + binmode $io; + + local $/; + my $data = <$io>; + + my @header = unpack("C[8] NN NNC[5] N", $data); + close($io); + + # png header + return "" unless $header[0] == 0x89; + return "" unless $header[1] == 0x50; + return "" unless $header[2] == 0x4e; + return "" unless $header[3] == 0x47; + return "" unless $header[4] == 0x0d; + return "" unless $header[5] == 0x0a; + return "" unless $header[6] == 0x1a; + return "" unless $header[7] == 0x0a; + + # ihdr + return "" unless $header[8] == 0x0d; + return "" unless $header[9] == 0x49484452; + $$width = $header[10]; + $$height = $header[11]; + + # bit depth, color type, compression method, filter method, interface method + # crc + + return $data; +} + +GetOptions(); + + + + +my $count = scalar @ARGV; + +die "Usage: make_ico file.png ..." unless $count; + +open(my $ico, ">", "icon.ico") or die "unable to open icon.ico"; +binmode $ico; + +my $height = 0; +my $width = 0; +my $size = 0; + +my $offset = SIZEOF_HEADER + SIZEOF_ENTRY * $count; +my $header = pack("vvv", 0, 1, $count); + +my $entry = ""; + +seek $ico, $offset, 0; + +foreach my $file (@ARGV) { + my $data = load_png($file, \$height, \$width); + my $size = length($data); + + die "Icon too large ($file)" if ($height > 256 || $width > 256); + $height = 0 if ($height == 256); + $width = 0 if ($width == 256); + + $entry = $entry . pack("CCCCvvVV", $width, $height, 0, 0, 0, 0, $size, $offset); + $offset += $size; + + print $ico $data; +} + +seek $ico, 0, 0; +print $ico $header; +print $ico $entry; + +close($ico); +exit 0; + diff --git a/src/gsp_icon.ico b/src/gsp_icon.ico new file mode 100644 index 0000000..48ed64d Binary files /dev/null and b/src/gsp_icon.ico differ diff --git a/src/win32.rc b/src/win32.rc index c230e8f..271edf5 100644 --- a/src/win32.rc +++ b/src/win32.rc @@ -65,8 +65,8 @@ END // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. -IDC_GSPORT32 ICON DISCARDABLE "win32.ico" -GSPORT32_ICON ICON DISCARDABLE "win32.ico" +IDC_GSPORT32 ICON DISCARDABLE "gsp_icon.ico" +GSPORT32_ICON ICON DISCARDABLE "gsp_icon.ico" ///////////////////////////////////////////////////////////////////////////// //