"import icon..." -- doable?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark

Locked
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9837
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

"import icon..." -- doable?

Post by FourthWorld » Sat Jul 20, 2013 3:31 pm

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?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

SirWobbyTheFirst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 239
Joined: Tue Jun 30, 2009 11:15 pm

Re: "import icon..." -- doable?

Post by SirWobbyTheFirst » Mon Jul 22, 2013 4:09 pm

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:

Image

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1209
Joined: Thu Apr 11, 2013 11:27 am

Re: "import icon..." -- doable?

Post by LCMark » Tue Jul 23, 2013 9:59 am

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.

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: "import icon..." -- doable?

Post by monte » Tue Jul 23, 2013 11:57 am

OS X is easy... [NSWorkspace iconForFile:..
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9837
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: "import icon..." -- doable?

Post by FourthWorld » Tue Jul 23, 2013 3:45 pm

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.
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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

SirWobbyTheFirst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 239
Joined: Tue Jun 30, 2009 11:15 pm

Re: "import icon..." -- doable?

Post by SirWobbyTheFirst » Tue Jul 23, 2013 4:53 pm

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.
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.aspx

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.

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1209
Joined: Thu Apr 11, 2013 11:27 am

Re: "import icon..." -- doable?

Post by LCMark » Thu Jul 25, 2013 9:33 am

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).

SirWobbyTheFirst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 239
Joined: Tue Jun 30, 2009 11:15 pm

Re: "import icon..." -- doable?

Post by SirWobbyTheFirst » Thu Jul 25, 2013 4:29 pm

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).
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.

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

Locked

Return to “Engine Contributors”