Take the 2-minute tour ×

I'll first tell you the problem and then I'll tell you my solution.

Problem: I have a blank white PNG image approximately 900x900 pixels. I want to copy circles 30x30 pixels in size, which are essentially circles with a different colour. There are 8 different circles, and placed on the image depending on data values which I've created elsewhere.

Solution: I've used ImageMagicK, it's suppose to be good for general purpose image editing etc. I created a blank image


I upload all other small 30x30 pixel images with 'read' function.
I upload the data and extract vales.
I place the small 'circle' images on the blank one using the composite command.

    outimage.composite("some file.png",pixelx,pixely,InCompositeOp);

This all works fine and the images come up the way I want them too.

However its painfully SLOW. It takes 20 seconds to do one image, and I have 1000 of them. Surely there must be a better way to do this. I've seen other researchers simulate images way more complex and way faster. It's quite possible I took the wrong approach. Maybe I sould be 'drawing' circles instead of 'pasting' them or something. I'm quite baffled. Any input is appreciated.

share|improve this question
Try Cairo library. –  Dani Aug 18 '11 at 3:49
add comment

2 Answers

I suspect that you just need some library that is capable of drawing circles on bitmap and saving that bitmap as png.

For example my Graphin library: http://code.google.com/p/graphin/ Or some such. With Graphin you can also draw one PNG on surface of another as in your case.

share|improve this answer
add comment

You did not give any information about the platform you are using (only "C++"), so if you are looking for a platform independent solution, the CImg library might be worth a try.


By the way, did you try drawing the circles using the ImageMagick C++ API Magick++ instead of "composing" them? I cannot believe that it is that slow.

share|improve this answer
add comment

Your Answer


