loading .icns file ?

Is there a way to load an .icns file in pure Xojo ?

What have you tried ?
And what’s the end goal ? Just to open it ? Get the respective images from it ? or something else ?

I can load the icns file from file using Picture.Open but this only gets the larges size (64x64) but I’d like to get other repesentations too. For instance I have an icon file which contains:

and let’s say I’d like to get the 18x18 one.

[quote=273670:@Norman Palardy]Hmm here I get all images
Note that Picture.ImageCount should be > 0 and you can get each indexed image with IndexedImage

Something like this shows all the images in the picture
I put this code in the open event of a listbox in a new desktop app
Then when the prompt asked me to open a file I selected an icns file

dim f as folderItem = GetOpenFolderItem("")

dim p as picture = picture.open( f )

for i as integer = 0 to p.ImageCount-1
dim tmp as picture = p.IndexedImage(i)

me.AddRow "img : " + str(i) + " - " + str(tmp.Height) + " x " + str(tmp.Width) + " @ " + str(tmp.HorizontalResolution) +"ppi x " + str(tmp.VerticalResolution)


That’s weird because imagcount was always 0. I am trying it again.

What version are you using ?
Thats relevant here

I’m also getting a single image (mutable bitmap) in Xojo 2016r1.1 OSX10.11.5

Another approach would be to use the iconutil command

iconutil -c iconset myicns.icns

converts the icns to a folder of png files…
do 'man iconutil ’ in Terminal to get more info.

2016_1_1 No it doesn’t work. Maybe I do something wrong. Let me attach the example.

Whoops … ummm code is from a future version
My bad

So … umm … no
Although the format is not hard to parse
The hardest is old icns files with some of the old bitmap formats in them

The ide does this to load ICNS files since there isn’t a way to open them as a multirepresentation format

Thanks. Then I will wait for the future code :slight_smile:

You can do this with my Retina Kit, I use it to load ICNS images in some cases. If you’re interested I can dig out some example code.

Example has been deleted from above. :wink:
Hopefully that’s not too far in the future. hungry like a dog

Anyone using MBS Plugin can use the IconMBS class there…

Hey Sam,

If you could the code snipped, I would take it up for sure and I guess some other ppls too. :slight_smile: