"import icon..." -- doable?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark
-
- VIP Livecode Opensource Backer
- Posts: 9867
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
"import icon..." -- doable?
Certain types of media and other file management apps could benefit from being able to render the icon associated with the file, whether it be an app or a document. I would imagine one way to do this syntactically might be:
import icon from file <filePath> [at <size>]
...where "size" is the width/height of the resulting image in pixels.
How feasible would it be to do this for Mac, Win, and Linux?
And am I the only one who would find this useful?
import icon from file <filePath> [at <size>]
...where "size" is the width/height of the resulting image in pixels.
How feasible would it be to do this for Mac, Win, and Linux?
And am I the only one who would find this useful?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 239
- Joined: Tue Jun 30, 2009 11:15 pm
Re: "import icon..." -- doable?
Do you mean something along the lines of displaying a .EXE's icon in an image similar to the properties window on Windows? Like below:
Re: "import icon..." -- doable?
Well, on Windows, you can certainly lookup the icon of an executable as its embedded within it. For documents, you resolve the filetype of the document then lookup in the registry for its icon (which will be also be embedded in some executable). Mac, it would be a similar story - the icon is stored in the app bundle, and referenced in the plist, same for document icons. Linux, I'm not 100% sure - I think gnome has a registry of some sort for such things, so it will depend on what APIs are provided there.
Re: "import icon..." -- doable?
OS X is easy... [NSWorkspace iconForFile:..
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
-
- VIP Livecode Opensource Backer
- Posts: 9867
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: "import icon..." -- doable?
If you'd be interested in the hard part of parsing out the ICO and icns resources and converting those to PNG for import, I'd be happy to look up the GTK APIs for Linux.runrevmark wrote:Well, on Windows, you can certainly lookup the icon of an executable as its embedded within it. For documents, you resolve the filetype of the document then lookup in the registry for its icon (which will be also be embedded in some executable). Mac, it would be a similar story - the icon is stored in the app bundle, and referenced in the plist, same for document icons. Linux, I'm not 100% sure - I think gnome has a registry of some sort for such things, so it will depend on what APIs are provided there.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 239
- Joined: Tue Jun 30, 2009 11:15 pm
Re: "import icon..." -- doable?
In order to load the icon for a .EXE, you need to parse the PE format, go to the resources section and then pick out the first icon. Microsoft has got a description of the PE format on the MSDN site which could help. http://msdn.microsoft.com/en-us/library ... 63119.aspxrunrevmark wrote:Well, on Windows, you can certainly lookup the icon of an executable as its embedded within it. For documents, you resolve the filetype of the document then lookup in the registry for its icon (which will be also be embedded in some executable). Mac, it would be a similar story - the icon is stored in the app bundle, and referenced in the plist, same for document icons. Linux, I'm not 100% sure - I think gnome has a registry of some sort for such things, so it will depend on what APIs are provided there.
At that point, you will need to parse an ICO format and convert it to PNG or another image type before you could display it in LiveCode.
Re: "import icon..." -- doable?
Well, whether that is necessary depends on how 'cross-platform' we want the feature - i.e. in the first instance if it is sufficient to only fetch icons from Windows exes on Windows and Mac bundles on Mac (Linux doesn't have any sort of embedded icons, they are - I believe - registered with the desktop environment so that won't be available anywhere but Linux) then there are system API calls that do the work (meaning parsing of exe files and such isn't necessary).
-
- VIP Livecode Opensource Backer
- Posts: 239
- Joined: Tue Jun 30, 2009 11:15 pm
Re: "import icon..." -- doable?
That does make sense, I had a look on MSDN and found a number of API calls for extracting icons and have listed them below, all seem to be located within Shell32.dll, so they should work across pretty much every version of Windows since Windows 95 (Although the articles state support since Windows 2000), even in the live environments like Windows PE, so if you develop an app for corporate use, it would work in those environments too.runrevmark wrote:Well, whether that is necessary depends on how 'cross-platform' we want the feature - i.e. in the first instance if it is sufficient to only fetch icons from Windows exes on Windows and Mac bundles on Mac (Linux doesn't have any sort of embedded icons, they are - I believe - registered with the desktop environment so that won't be available anywhere but Linux) then there are system API calls that do the work (meaning parsing of exe files and such isn't necessary).
Hell revEnterprise 4.0 was able to fire up with no problems in those environments, well provided that you used the 32-bit Windows PE as the 64-bit version doesn't include support for 32-bit apps.
http://msdn.microsoft.com/en-us/library ... s.85).aspx