Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I extract an image of a specific size from an icon?

How can I extract an image of a specific size or all images from an icon with multiple images?

like image 787
Branko Avatar asked Sep 28 '10 14:09

Branko


People also ask

How do I extract an MSI icon?

You can open the MSI with Orca tool, go to this table, and double click the "Data" column, you will then be prompted with option to export the resource or even overwrite it. Show activity on this post. Try decompressing it with 7-zip or The Unarchiver (on OS X). Decompressing the .

How do I change the size of an ICO file?

To resize desktop icons, right-click (or press and hold) the desktop, point to View, then select Large icons, Medium icons, or Small icons.


1 Answers

You don't say what the purpose of this is, and there are a number of ways of getting icons and one method may be better than another depending on the purpose.

However, to extract any number of "large" (32x32) and/or "small" (16x16) icons* from an arbitrary file, use the ExtractIconEx function. This lets you extract one or more icons of either of these two standard sizes from an icon file (.ico), EXE, or DLL. An icon file can contain multiple images and this function will let you get all of them.

The function will write to an array of handles, each of which you can assign to the Handle property of a TIcon instance. Then you can use the TIcon methods as you normally would if you'd loaded the TIcon any other way. Note that new to Delphi XE is the ability to copy it easily to a bitmap via the Assign method. That article also shows how to access all of the stock (inbuilt / standard) Windows icons, if that happens to be what you're after.

(Side note: I think the TIcon class lets you load from a file via its LoadFromFile method - this seems to be missing from the documentation, but I'm pretty certain it exists. From memory, that only loads a single icon.)

(*) Actually, "large" and "small" can be different to 32x32 and 16x16: use the GetSystemMetrics function with the SM_CXICON, SM_CYICON, SM_CXSMICON, and SM_CYSMICON flags to find out the dimensions of each type.

like image 147
David Avatar answered Oct 14 '22 20:10

David