0

I'm creating a simple graphic editor by C/glut. So I just wonder how can I save my draws as PNG, BMP etc. I tried png.h but didn't work for me. I didn't get any errors but it did not save anything.

Any advice?

  • Could you provide the code of what you've already tried ? – frostblue Oct 25 '16 at 12:19
  • Did you take a look to this related post [GLUT screen capture in C](http://stackoverflow.com/questions/9090892/glut-screen-capture-in-c) ? – J. Piquard Oct 25 '16 at 12:43
  • @LudaOtaku I tried this code and I got undefined reference to error. Here's link : [link](http://zarb.org/~gc/html/libpng.html) I couldn't find other code which didn't work. J.Piquard; Yes, but I don't know what can I do with this. – unskilled programmer Oct 25 '16 at 18:40

1 Answers1

0

You can easily save bmp images from your app using libsoil.

http://lonesock.net/soil.html

For example, I used:

    int save_result = SOIL_save_screenshot(
        filename,
        SOIL_SAVE_TYPE_BMP,
        0,0,
        width, height
    );

If you are a debian user, there is a package named libsoil-dev. It should be available in Ubuntu too.

antoineMoPa
  • 854
  • 10
  • 20