How to read jpg image file in c++.

Hi,
I want to read jpg image file in c++. please help me how to read , edit and save it with C++.
Use one of the many freely available image libraries. There are lots. For example, CImg, ImageMagick++, DevIL, CxImage.

boost also has JPEG I/O support, it can be as simple as

1
2
3
4
5
6
7
8
9
10
#include <boost/gil/gil_all.hpp>
#include <boost/gil/extension/io/jpeg_dynamic_io.hpp>
int main()
{
    boost::gil::rgb8_image_t img;
    jpeg_read_image("in.jpg", img);
    boost::gil::rgb8_pixel_t black(0,0,0);
    fill_pixels(subimage_view(view(img), 10, 10, 100, 20), black); // censor bar
    jpeg_write_view("out.jpg", const_view(img));
}


Last edited on
I you don't need the complexity of a whole image library or boost GIL, you can just use libjpeg as well.
What operation do you want to perform on jpg image ?
Topic archived. No new replies allowed.