[Mono-osx] NSImage.ImageNamed - in folder?
Aaron Oneal
aaron.oneal at spicypixel.com
Thu Dec 6 20:13:09 UTC 2012
I'm pretty sure that method uses either a named image that was
previously set or looks only in the bundle root. For subfolders, you
probably need to use the NSImage constructor that takes a filename. If
the constructor doesn't assume the bundle root, you can probably
construct the absolute path usingNSBundle.MainBundle.PathForResource.
> thenextman <mailto:rmarkiewicz at devolutions.net>
> December 6, 2012 11:53 AM
> Possible stupid question - how can I load an image from a folder?
>
> Project structure:
>
> Clarus.gif
> Images (dir)
> ClarusInFolder.gif
>
> Code:
>
> NSImage image1 = NSImage.ImageNamed("Clarus.gif");
> Console.WriteLine(image1 == null); // Prints false
>
> NSImage image2 = NSImage.ImageNamed("ClarusInFolder.gif");
> Console.WriteLine(image2 == null); // Prints true
>
> How can I make the second image work? I've tried to specify the folder in
> the path, everything... Both images have build action set to
> 'Content', and
> if I peek inside the bundle I can see the folder structure recreated in
> there.
>
> Thanks in advance!
>
>
>
> --
> View this message in context:
> http://mono.1490590.n4.nabble.com/NSImage-ImageNamed-in-folder-tp4657676.html
> Sent from the Mono - OSX mailing list archive at Nabble.com.
> _______________________________________________
> Mono-osx mailing list
> Mono-osx at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-osx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-osx/attachments/20121206/648ce577/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compose-unknown-contact.jpg
Type: image/jpeg
Size: 770 bytes
Desc: not available
URL: <http://lists.ximian.com/pipermail/mono-osx/attachments/20121206/648ce577/attachment.jpg>
More information about the Mono-osx
mailing list