[82720] users/ryandesign/scripts/digger-icon.php
ryandesign at macports.org
ryandesign at macports.org
Thu Aug 18 19:37:58 PDT 2011
Revision: 82720
http://trac.macports.org/changeset/82720
Author: ryandesign at macports.org
Date: 2011-08-18 19:37:58 -0700 (Thu, 18 Aug 2011)
Log Message:
-----------
Add script used to generate app bundle icon for digger port
Added Paths:
-----------
users/ryandesign/scripts/digger-icon.php
Added: users/ryandesign/scripts/digger-icon.php
===================================================================
--- users/ryandesign/scripts/digger-icon.php (rev 0)
+++ users/ryandesign/scripts/digger-icon.php 2011-08-19 02:37:58 UTC (rev 82720)
@@ -0,0 +1,39 @@
+#!/usr/bin/env php
+<?php
+
+$file = file_get_contents('icon.c');
+
+preg_match('/Uint8 Icon\[\]\s*=\s*{(.*)};/', $file, $matches);
+$pixels = explode(',', $matches[1]);
+
+$w = $h = sqrt(count($pixels));
+
+$im = imagecreate($w, $h);
+
+preg_match('/SDL_Color IconPalette\[\d+\]\s*=\s*{{(.*)}};/', $file, $matches);
+$colorvalues = explode('},{', $matches[1]);
+$colors = array();
+foreach ($colorvalues as $i => $colorvalue) {
+ $colorvalue = explode(',', $colorvalue);
+ $colors[$i] = imagecolorallocatealpha($im, $colorvalue[0], $colorvalue[1], $colorvalue[2], $colorvalue[3]);
+ if ($colors[$i] === false) echo "failed to allocate color $i\n";
+}
+
+$x = $y = 0;
+foreach ($pixels as $i => $pixel) {
+ $result = imagesetpixel($im, $x, $y, $colors[$pixel]);
+ if ($result === false) echo "failed to set pixel at $x,$y\n";
+ $x++;
+ if ($x >= $w) {
+ $x = 0;
+ $y++;
+ }
+}
+
+imagecolortransparent($im, $colors[$pixels[0]]);
+
+imagepng($im, 'icon.png');
+
+imagedestroy($im);
+
+?>
Property changes on: users/ryandesign/scripts/digger-icon.php
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:eol-style
+ native
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20110818/24b45708/attachment.html>
More information about the macports-changes
mailing list