A
A
alexanderpetrov2014-12-17 02:56:15
linux
alexanderpetrov, 2014-12-17 02:56:15

How to quickly and easily create a {gif,png,jpg} image in C++?

There is a program written in C++ that calculates the motion of particles using the molecular dynamics method. I will say right away that the operating system is Linux . The program can now only display the coordinates of individual particles. Particle motion is still two-dimensional. The task is to visualize the movement of particles (to present a video file). I want the program to create a set of images - individual frames in gif, png or jpg format . The image should be simply, roughly speaking, a rectangle in which circles fly - particles; all in bright children's colors. Next, I plan to use ffmpeg to collect all the images into a video file. Accordingly, is there any libraryso that you can manually create an image from the code, simply by operating on the coordinate data of the particles?
To date, I have already tried creating such images in gnuplot and then collecting everything in ffmpeg, but I feel that this is not the best solution.
Update: There are restrictions. Everything must compile with g++. The program will run on a cluster, so using OpenGL and capturing a screen is out of the question. And since the compiler must be g ++, then frameworks cannot be used either.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
SagePtr, 2014-12-17
@alexanderpetrov

ImageMagick , for example

M
ManWithBear, 2014-12-17
@ManWithBear

I may not understand something, but why not connect the banal openGL and just draw movements with it? And for video, you can record with some screen capture application.

D
Don Kaban, 2014-12-17
@donkaban

You need to create a video stream (even easier, a video file) from frames continuously created in memory, as I understand it. Hence the conclusion - intermediate saving in a graphical format - is redundant.
A simple solution, render each frame into memory (well, into a normal buffer in memory) and pack theora into a video file.
www.theora.org
svn.xiph.org/trunk/theora/examples
Choice of theory - well, for free, in source code, good documentation, open source software.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question