ikrabbe / tclkit

Automatically exported from code.google.com/p/tclkit
1 stars 0 forks source link

Fix for tclkit custom icon replacement NOT FOUND error, final solution #6

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I know this has been an ongoing issue, I finally rolled up my sleeves
and dug into the sdx code. I figured out what the underlying problem
and solution is for replacing custom icons using tclkit / sdx to wrap
starkits. Pat Thoyts, please consider putting this fix in the sdx code
as soon as you can.

The problem:
when replacing the tcl icon with a custom icon in a starpack using the
latest tclkit (8.5.8), you will likely see the following messages:

  icon 48x48/256: NOT SAME SIZE
  icon 32x32/256: NOT SAME SIZE
  icon 16x16/256: NOT SAME SIZE
  icon 48x48/256: NOT SAME SIZE
  icon 32x32/256: NOT SAME SIZE
  icon 16x16/256: NOT SAME SIZE
  icon 48x48/256: replaced
  icon 32x32/256: replaced
  icon 16x16/256: replaced

This causes the icon in your starkit exe to only be partially replaced
(3 of the 9 images). I got to thinking, why does the 256 keep
repeating.

The explanation:

I unwraped the sdx kit and took a look. It turns out that in the sdx
code, the 256 represents the number of colors. However while opening
the ico file and inspecting the contents, if the sdx wrapping code
sees 0 it sets the number of colors to search for 256. However,
according to what I found on wikipedia 0 represents true color, which
of course Vista / 7 (and I presume at least XP / 2003) support. I
suppose this was a holdover from when the starpack solution was first
created.

The starpack code create an array of images found in both the original
icon and the new icon with the array element name of width X height X
numberofcolors. It then tries to match the array in the original with
the same one in the new icon file. If it finds one it checks the size.
Since the number of colors is incorrectly set to 256 for those above 8
bits, the sizes will not match.

The solution:

1. unwrap sdx.kit
2. navigate to the wrap.tcl file
3. in the procedure decICO, change the line
    lappend result ${w}x${h}/$cc $image
to
    lappend result ${w}x${h}/$bc $image

(bc is the bits per pixel ...
http://en.wikipedia.org/wiki/ICO_%28file_format%29
). We'll use the bits per pixel as part of the array index as opposed
to the number of colors.

4. rewrap sdx.kit
5. rewrap your application.

You will see the following output when you rewrap your app (assuming
you have the correct images in your ico file:

 customizing tclkit.ico in executable
  icon 64x64/32: replaced
  icon 48x48/32: replaced
  icon 32x32/32: replaced
  icon 24x24/32: replaced
  icon 16x16/32: replaced
  icon 48x48/24: replaced
  icon 32x32/24: replaced
  icon 24x24/24: replaced
  icon 16x16/24: replaced
  icon 48x48/8: replaced
  icon 32x32/8: replaced
  icon 24x24/8: replaced
  icon 16x16/8: replaced

I hope this ends this longstanding issue once and for all. Pat, please
let me know what you think.

Thanks,
Patrick 

Original issue reported on code.google.com by patrick....@activecompliance.com on 5 Mar 2010 at 6:21

GoogleCodeExporter commented 8 years ago
I checked this wrapping up the curent tclkit 8.5.8 with a custom icon for tkchat
which has 64x64/32 and others and it now works perfectly.
Patch applied - thank you very much.

Original comment by pattho...@gmail.com on 10 Mar 2010 at 12:48