Tk Library Source Code


[ Main Table Of Contents | Table Of Contents | Keyword Index | Categories | Modules | Applications ]


ico - Reading and writing windows icons

Table Of Contents


package require Tcl 8.4
package require ico ?1.0.5?

::ico::icons file ?option value...?
::ico::iconMembers file name ?option value...?
::ico::getIcon file name ?option value...?
::ico::getIconByName file name ?option value...?
::ico::getFileIcon file ?option value...?
::ico::writeIcon file name depth data ?option value...?
::ico::copyIcon file index file2 index2 ?option value...?
::ico::EXEtoICO file ?dir?
::ico::clearCache ?file?
::ico::transparentColor image color
::ico::Show file ?option value...?


This package provides functions for reading and writing Windows icons from ICO, EXE, DLL, ICL, and BMP files. As used in this module an icon is a visual representation of an object. An icon consists of one or more images usually with varying resolution and color depth. Each icon and image has a resource identifier which may be a text string or a positive integer value. Most commands use this identifier to specify which icon or image to operate on.



button .explore -image [::ico::getIcon explorer.exe 0 -name explore -res 16 -bpp 8]

set i [lsearch -inline [::ico::iconMembers tclkit.exe 0] {* 32 32 8}]
set colorlist [::ico::getIconByName tclkit.exe [lindex $i 0] -format colors]


Icons may not be added or removed from file types other than ICO. Icons in these files may only be replaced with icons of the same dimensions and color depth.

Icons of 8bpp or lower must include black in the pallete, this means if your icon does not have black in it, you will need to leave a color free so that it may be included by writeIcon.

There is currently no way to read alpha channel information from 32bpp icons.

Tk images do not have an alpha channel so the only way to write a true 32bpp icon is from a color list. writing a 32bpp icon from a Tkimage is identical to writing a 24bpp icon.

Bugs, Ideas, Feedback

This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category ico of the Tklib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.


dll, entry, exe, ico, icon