I knew it was too easy   Leave a comment

Converting Saturn and Titan from the Gtkmm tool kit to the Qt tool kit so that I could add an OS X version has been going very well with nothing causing any significant problems, until now. One of the most useful features of Saturn is that it embeds all the parameters required to reproduce the saved fractal image in the png file, as they can then used by Titan to produce much larger pictures I’ve been calling png files saved by Saturn, seed files. Loading these seed files into Saturn and Titan on Linux work every time, not so with OS X and Windows 7. The data embedded in the seed file varies in size, the biggest factor being the colour map definitions which can range up to 512 entries per map and there can be two maps per fractal image. Using Qt, the png files are loaded into a QImage object which allows the data to be accessed easily using text and setText methods, unfortunately Qt displays the following:

libpng warning

libpng warning

This means that not all the embedded data has been loaded, so when requesting a named piece of data it may not be found and on OS X, at least, an empty string is returned. The behaviour on Windows 7 is more severe, the program crashes. The result is the same for both OS X and Windows versions: Saturn and Titan can’t reproduce seed files that have their embedded data truncated.

Embedding data in the png file when it is saved, using the OS X version isn’t a problem.

OS X version of Saturn (development)

OS X version of Saturn (development)

The image shown above can be saved and can be successfully loaded into the Linux version of Saturn. When attempting to load the same file into the OS X version a message box is displayed saying that the file isn’t a Saturn seed file, if the picture had been saved using the Linux version it would have been accepted and the resulting picture would not match. The reason for the disparity is that the data is sorted into alphabetical order when added to the png file using the OS X version of the tool kit, the Linux version on the other hand does not sort the data. I don’t know what the Windows version does as I haven’t tried it yet, as long as all the data is added I’ll only have the loading issue to address.

So I need to extract the embedded data using some means other than using QImage, I’ve looked at various C++ wrappers for libpng and libpng itself to find a simple work around for the problem, the interface to the library is not that pleasant, so I’ve resorted to the finding the structure of png files and the simplest solution is to read the png file and extract the keys and their data from the tEXt chunks.

Writing software for multiple platforms should be easy when using cross platform tool kits but there are always kinks in the implementations here and there.


Posted 1 May 2013 by element90 in Fractal, Software

Tagged with , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: