Posted On: Wednesday, February 6th, 2008 (Graphics)
Posted by: Paul Lefebvre

I have a lot of icons in PNG format with built in masks that I like to use in my toolbars. Although REALbasic loads the pictures fine with FolderItem.OpenAsPicture, it doesn’t load the mask, so I use the free PNG Utilities plug-in instead.

One annoyance I’ve had with this is that the PNG files need to be loaded at run-time. Dragging them into the project didn’t work; REALbasic would convert them and lose the mask. But it turns out there is a trick, posted to the REALbasic NUG mailing list by none other than Frank Condello, author of PNG Utilities. The trick is to rename your PNG files so that they don’t have a PNG extension (I used PNGDAT). Then you can drag them into your project; REALbasic will just import them as binary strings.

From there you can use the PNGu.GetPictureWithMask(name) method to convert the string into a picture object that you can then use with the toolbar. Perfect!

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

This entry was posted on Wednesday, February 6th, 2008 at 8:06 pm and is filed under Graphics. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

One Response to “PNG Utilities Tip”

  1. Paul Lefebvre on August 20th, 2008 at 2:54 pm

    You might also need to remove any OS X Creator Type Codes from the file.

Leave a Reply