blob: 00328d7c7ba51465557259ecc25a299f609e257f [file] [log] [blame]
Dominik Riebeling9d1c2862011-05-31 21:08:29 +00001#!/usr/bin/perl -w
2# __________ __ ___.
3# Open \______ \ ____ ____ | | _\_ |__ _______ ___
4# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7# \/ \/ \/ \/ \/
8# $Id$
9#
10# Copyright (C) 2011 Dominik Riebeling
11#
12# All files in this archive are subject to the GNU General Public License.
13# See the file COPYING in the source tree root for full license agreement.
14#
15# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16# KIND, either express or implied.
17
18
19# This script is to generate an iconset (iconstrip bmp file) from Tango icons.
20# It should be usable for other iconsets that are provided as svg images. For
21# those adjusting the paths to the icons might need adjustment.
22# To be run from the icons/ folder in a Rockbox checkout.
23
24use File::Temp;
25
26# list of icons for strip
27my @iconlist = (
28 "mimetypes/audio-x-generic", # Icon_Audio
29 "places/folder", # Icon_Folder
30 "actions/format-indent-more", # Icon_Playlist
31 "actions/media-playback-start", # Icon_Cursor ###
32 "apps/preferences-desktop-wallpaper", # Icon_Wps
33 "devices/computer", # Icon_Firmware ###
34 "apps/preferences-desktop-font", # Icon_Font
35 "apps/preferences-desktop-locale", # Icon_Language
36 "categories/preferences-system", # Icon_Config
37 "status/software-update-available", # Icon_Plugin
38 "actions/bookmark-new", # Icon_Bookmark
39 "places/start-here", # Icon_Preset
40 "actions/go-jump", # Icon_Queued
41 "actions/go-next", # Icon_Moving
42 "devices/input-keyboard", # Icon_Keyboard
43 "actions/mail-send-receive", # Icon_Reverse_Cursor
44 "apps/help-browser", # Icon_Questionmark
45 "actions/document-properties", # Icon_Menu_setting
46 "categories/applications-other", # Icon_Menu_functioncall
47 "actions/list-add", # Icon_Submenu
48 "categories/preferences-system", # Icon_Submenu_Entered
49 "actions/media-record", # Icon_Recording
50 "devices/audio-input-microphone", # Icon_Voice ###
51 "categories/preferences-desktop", # Icon_General_settings_menu
52 "categories/applications-other", # Icon_System_menu
53 "actions/media-playback-start", # Icon_Playback_menu
54 "devices/video-display", # Icon_Display_menu
55 "devices/video-display", # Icon_Remote_Display_menu
56 "devices/network-wireless", # Icon_Radio_screen ###
57 "mimetypes/package-x-generic", # Icon_file_view_menu
58 "apps/utilities-system-monitor", # Icon_EQ
59 "../rbutil/rbutilqt/icons/rockbox-clef.svg" # Icon_Rockbox
60);
61
62
63if($#ARGV < 1) {
64 print "Usage: $0 <path to iconset> <size>\n";
65 exit();
66}
67my $tangopath = $ARGV[0];
68my $size = $ARGV[1];
69
70# temporary files
71my $alphatemp = File::Temp->new(SUFFIX => ".png");
72my $alphatempfname = $alphatemp->filename();
73my $exporttemp = File::Temp->new(SUFFIX => ".png");
74my $exporttempfname = $exporttemp->filename();
75my $tempstrip = File::Temp->new(SUFFIX => ".png");
76my $tempstripfname = $tempstrip->filename();
77
78my $newoutput = "tango_icons.$size.bmp";
79
80if(-e $newoutput) {
81 die("output file $newoutput does already exist!");
82}
83
84print "Creating icon strip as $newoutput\n\n";
85
86my $count;
87$count = 0;
88foreach(@iconlist) {
89 print "processing $_ ...\n";
90 my $file;
91 if(m/^$/) {
92 # if nothing is defined make it empty / transparent
93 my $s = $size . "x" . $size;
94 `convert -size $s xc:"#f0f" $exporttempfname`
95 }
96 elsif(m/\.\./) {
97 # icon is inside the Rockbox tree
98 $file = $_;
99 `inkscape --export-png=$exporttempfname --export-width=$size --export-height=$size $file`
100 }
101 else {
102 # icon is inside the tango tree
103 $file = "$tangopath/scalable/" . $_ . ".svg";
104 `inkscape --export-png=$exporttempfname --export-width=$size --export-height=$size $file`
105 }
106 if($count != 0) {
107 `convert -append $tempstripfname $exporttempfname $tempstripfname`;
108 }
109 else {
110 `convert $exporttempfname $tempstripfname`;
111 }
112 $count++;
113}
114print "masking and converting result ...\n";
115# create mask
116`convert $tempstripfname -alpha extract -monochrome -negate -alpha copy -colorize 0,100,0 $alphatempfname`;
117# combine mask with image and drop transparency and scale down
118`convert -composite $tempstripfname $alphatempfname -flatten -background '#f0f' -alpha off $newoutput`;
119print "done!\n";
120