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:
64x64,36x36,32x32,32x32,18x18,16x16
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
http://documentation.xojo.com/index.php/Picture.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
[code]
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)
next
[/code][/quote]
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.
https://www.dropbox.com/s/e3p5n82lg6w2ce0/icns_test.zip?dl=0
Whoops … ummm code is from a future version
My bad
So … umm … no
Although the format is not hard to parse
https://en.wikipedia.org/wiki/Apple_Icon_Image_format
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
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.
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.