1

I have a piece of code that retrieves images from a camera and store them in a structure. The structure provides the pointer to the first pixel of the image as well as the image dimension, its width and height. My question is: how can I save the image stored in the structure in a say .jpg or .png file to be displayed and processed ?

Thanks in advance !

Gab
  • 11
  • 2
  • I would suggest using OpenCV - http://www.opencv.org/ but there are plenty of libs that does that... – Leonardo Alves Machado Jul 19 '17 at 14:10
  • @LeonardoAlvesMachado using an entire image processing framework to just save images to a file sounds pretty overkill to me ;) – Piglet Jul 19 '17 at 16:33
  • why don't you just google "save jpeg c++"? – Piglet Jul 19 '17 at 16:35
  • 1
    Possible duplicate of [save pixel array to jpeg image file c++](https://stackoverflow.com/questions/6044543/save-pixel-array-to-jpeg-image-file-c) and multiple other questions – Piglet Jul 19 '17 at 16:35
  • @Piglet: the JPEG library is as big as the framework itself ;-) –  Jul 19 '17 at 19:36
  • 1
    It may also be that the camera SDK has resources to save files. –  Jul 19 '17 at 19:43
  • Thanks a lot for your suggestions. I solved it using 'ofsstream' and writing the buffer into a file. – Gab Jul 21 '17 at 13:48

1 Answers1

0

You can integrate the libjpeg or libpng freewares, which are the most complete, but be ready for hard work.