Animating PNG files

I have struggled with optimizing the process of animating PNG files. I have code that generates a PNG image based on an array of data, which, in my case is the intensity of an optical beam, but it can be anything. I have found various options ranging from quick-and-dirty to fairly robust. MEncoder plays a role in several of them, and it was no easy feat to find a combination of flags that properly encode the video for playback on linux and Mac platforms. Here, I present my two most promising options so far.

To clarify the usage, the commands quoted are what I used on a linux machine, which where I run C++ code to generate the images. I want to view movies on both linux and mac platforms (especially since I give presentations on my mac). The viewing is done with either mplayer (linux) or quicktime player (mac).

Continue reading


Writing PNGs from C++

hexagonsTo continue the series on using C++ to replace MATLAB, here are some details about using the pngwriter library. Included below is a function that I use in various places to write a 2D array to a png file. This can be left in a header somewhere and used in a similar way to MATLAB’s imagesc() function.

I’d be happy to post more details if anyone is interested, and I’ll try to keep up with posts about the process I followed to port from MATLAB to C++.

Continue reading