From: Bernard D. <bde...@or...> - 2007-03-08 16:58:22
|
Kevin Walzer wrote: >I'm revisiting an earlier interest in getting Tk to display Mac-native >icons under Aqua. Tk had this capability under Classic, but it is >currently broken. My current method to display Mac-native icons is to >use an external command-line tool to retrieve the icon, then convert it >to a PNG via the sips tool. I would prefer to have a method to get icon >data in the same manner as other Carbon applications, via IconServices; >given a file path, Carbon would display the correct icon/image data in Tk. > > We are doing something similar in Alpha (this is still experimental, in the development builds). We define an [iconref] command which we use to register icons with the Icon Services. See http://alphatcl.sourceforge.net/wiki/pmwiki.php/Commands/IconrefCommand The bitmap approach is also feasible: it is not verry difficult to parse an icns resource or file and extract the bitmaps (some of them are compressed but there is an API to get them properly). It is easier though to get an iconref, call PlotIconRef and let it extract the appropriate bitmap itself. >Because I'm not an expert with C, my question is whether this could be >accomplished by patching tkMacOSXBitmap.c, or whether I would need to >delve much deeper into defining a new image format or doing some >conversion of icon data at the C level to display in Tk. Looking at >tkMacOSXBitmap.c, it appears to make at least some use of IconServices >(the function "GetIcon" is defined in IconServices). However, it focuses >mainly on old-style resource files (and uses QuickDraw calls--aren't >these deprecated?). The modern API for obtaining icon data is GetIconRef >and related functions. Is there any way to add this API to the >tkMacOSXBitmap.c file? > >The alternative approach I've envisioned involves creating a new image >format for Tk that could read data from GetIconRef, or alternatively, >doing some conversion of IconRef to a bitmap format that Tk can >recognize, via CoreGraphics or CoreImage. But creating a new image >format for Tk is out of my depth, and I have not found any method to >convert IconRef's into a standard image format, at least in Carbon. >(There are some methods that go the other way, i.e. convert a PNG to an >IconRef or something similar.) > >Any advice is appreciated. > > |