Chris' Cairo Blog

November 20, 2009

A PNG based image repository

Filed under: What I am working on — thorgch @ 3:14 pm

As I mentioned in my Getting serious with Cairo post, I decided that our new animation overview would use PNG images rendered with cairo in place of OpaqueImages (the reasons why are listed in that post). I also mentioned that I would talk a bit about the tools we use to put an overview together. In this post, I will talk about one of those tools in particular. In the current way of doing things, we always have a class that acts as an image repository. It isn’t uncommon for the class to contain a whole bunch of class side methods that answer an OpaqueImage.  Since the OpaqueImage instance creation method wants a figure and a shape as arguments, we also needed to create class side methods to answer those too. So, for each OpaqueImage we want to store in the repository, we also need one corresponding method to answer the figure and another to answer the mask. It ends up being a lot of class methods with even a small image repository.

Despite the number of methods, the “class as an image repository” approach has served us well. The various figure and mask methods are all annotated with a pragma so we can quickly see all the images with an image finder tool. We also have a nice tool at our disposal that makes easy work of loading a bitmap and then serializing it into the various parts we need to later reconstruct it as an OpaqueImage. Making the switch to PNG images meant we needed to make some changes to the current set of tools so that they can support PNG files. The following screen-shot and accompanying video link shows the PNG version of our repository tool.

FYI…I am still not happy with the quality of video after it is uploaded to VideoPress so that is why I am not embedding the video into this post. Just follow the link below the picture. It’s a .mov file, so you’ll need QuickTime. You can also click on the image just below to see the full size of the screen-shot.

PNG Image Tool Screen-shot

Here is a link to the video

I am especially pleased that I no longer need to deal with the methods to answer the figures and shapes. All that the PNG based repository contains are methods that answers an instance of a PNG image (more on that class in another post).

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Create a free website or blog at WordPress.com.