--[AF] 08-08-03 this package provides functions for reading and writing [windows] [icon]s to ICO, EXE, DLL, and ICL files. the code has grown to become a little large for posting here. it is all available for download at http://www.fearme.com/misc/programs.cgi?type=tcltk&file=icons '''[[IconStats file type]]''' returns info on the icons within the ''file''. there is one list element per icon. each element consists of 3 numbers, the width, height, and color depth of the icon. ''type'' must be one of ICO, EXE '''[[getIconImage file type index]]''' returns the name of an [image] containing the icon named by ''file'' and ''index''. index starts at 0, see IconStats. '''[[getIconColors file type index]]''' returns a list where each element is a row of the image. each row is a list where each element is a pixel. each pixel is in the familiar form #RRGGBB. an empty pixel denotes transparency. the image rows are in a bottom to top order. '''[[writeIcon file type index bpp colors]]''' writes an icon to the named file. ''colors'' is either a list in the above format, or it is the name of an [image] from which to extract the data. ''bpp'' is the color depth to write the icon with. supported depths are 1, 4, 8, 24, and 32. if you select 1, 4, or 8 and your image has too many colors an error will be generated. ''index'' may be specified as one higher than the number of icons currently in the file. indexes outside this range will generate an error. when writing an exe you may only replace an icon with one of the same size and color depth. you cannot add new icons to exes. '''[[translateColors colors]]''' this function will change a list of colors in the #RRGGBB format to the "R G B" format. '''[[transparentColor image color]]''' sets every pixel that is color in Tk [image] ''image'' to be transparent. color may be either the #RRGGBB or the "R G B" format. '''[[EXEtoICO exe ico]]''' creates a new .ico file with the name ''ico'' containing every icon from the exe exe. this function is much faster than extracting and writing the icons using the other functions. '''Notes:''' Tk [image]s do not support alpha blending. writing a 32bpp icon from an [image] is equivalent to writing a 24bpp icon. you can use the full alpha channel by writing from a list of colors in the format "R G B A". you may write a 24bpp icon from 32bpp formatted data, the alpha channel will be silently dropped. DLLs and ICLs have the same format as EXEs so you can read them by using the EXE type. some keywords for searches: ico icl ---- [CF] - This is the missing link for turning a Starpack into a branded application with your Icon. Here's a short script that accepts a gif image as the command line argument, and creates a tclkit.ico file that can be used to create a Starpack with custom icons, as decribed at http://www.equi4.com/267 . This script runs on a Linux/Unix system with ImageMagick installed. The initial .gif image must be square. ---- source icons.tcl set orig [lindex $argv end] set icoFile tclkit.ico pack [label .l -textvariable state] image create photo temp48 -file $orig ::ico::writeIcon $icoFile ICO 0 8 temp48 set pos -1 foreach s {48 32 16} { set name [format "temp%s" $s] set geom [format %dx%d $s $s] set state "$geom @ 256"; update idle; exec convert -geometry $geom -colors 256 $orig $name.gif image create photo $name -file $name.gif ::ico::writeIcon $icoFile ICO [incr pos] 8 $name set state "$geom @ 16"; update idle; exec convert -geometry $geom -colors 16 $orig r$name.gif image create photo r$name -file r$name.gif ::ico::writeIcon $icoFile ICO [incr pos] 4 r$name file delete $name.gif r$name.gif } set state "DONE - Icon file is $icoFile" pack [button .b -text "EXIT" -command exit] ---- Anyone have an icon editor written in Tcl/Tk? [AF] Not that i know of, but now that i have provided the required functionality i think it would be cool if someone wrote one since there seems to be a lack of free icon editors. [TR] There ist bme, a bitmap editor by Ian Gay, listed on [Applications in Tcl and Tcl/Tk]. Find it here: http://www.sfu.ca/~gay/ It would be nice to have a version including this package here. ---- [Category GUI] | [Category Package]