a tklib package to read and write icons from ICO ICL EXE and DLL files. see windows icons for more info. documentation is at ico
[perhaps someone could add a screenshot?]
MG just found this package again, and found it very useful. I was trying to add winico support to my app, and wanted to add an icon to the taskbar, but change the icon used periodically. Winico seems to only let you do this if all the icons you want to use are contained in one file (and mine weren't), but it was a simple case of
package require ico set newico "new.ico" set old [list foo.ico bar.ico baz.ico] set i 0 foreach x $old { ico::copyIcon $x 0 $newico $i incr i }
and I had a single file, new.ico, which contained all the icons from my other files.
AF says glad you found it useful, I just want to make this even easier:
package require ico set newico "new.ico" set old [list foo.ico bar.ico baz.ico] foreach x $old { ico::copyIcon $x 0 $newico -1 }
MG Cool, thanks. I didn't know you could use -1 like that.
jbr - There is a bug in the tklib 1.4 such that the padding on the and mask is incorrect. replace a line in ::ico::getAndMaskFromColors to look like:
append l [string repeat 0 [expr {(32 - ([string length $l] % 32))%32}]]
I have filed a bug on sourceforge.
TWu 2025-01-16 / 2025-01-21 - ico does not support completely icons with 256×256 in size or higher. Also including of png image inside of newer ICOns is not yet supported. Both problems we can detect on result "0×0" for the size and/or "21060" for the bpp (bits per pixel). This bpp is literally "DR" and comes from the PNG chunk name "IHDR" at bpp position, which ico seems read out without control/distinguishing BMP and PNG.
I propose to overwrite the useless "member-info" (like "0×0" or "21060bpp") by values from BMP DIB header (and may be later from embedded PNG and its header there). With this updated information we get better results on match on icon size/bpp.
Please see Open - Bug - tklib::ico - The ICO package does not handle 256x256 icons properly
I vote to correct both of the above points - including the reading of PNG width, height and bpp respectively, like the example but from different locations.
Testing with any "newer" ICOns of Windows Vista and above, ::ico::Show breaks at first PNG - regardless if correct images are after. Resolution in ico.tcl version 1.1.3, line 1428: replace "-$x" by "$name" (like it was done in line 1432 on transition from version 0.3.x to 1.y.z). Else it brings an internal error "no such variable" for 'x', which is known only in version 0.3.x iterating over "$icos". Would anybody file a bug for this on sourceforge, please? Thanks
@jbr and all others: John's 2012-01-06 reported bug is not yet solved - in both of the version variants. I found only the first half of the code sample in both source files, but all three are differently to each other.
Please see Open - Bug - tklib::ico - Padding on and mask rasters incorrect.
I vote to correct it.
How about the transparency / alpha channel? Tk has it, Img has it - native since 8.7 or latest release 9.0.1. See examples from PO for Fast image resizing, or others for Shrinking an image.
I'll provide solution for Open - Bug - tklib::ico - ico - Testsuite missing soon.