views:

246

answers:

4

I want a c++ Code to read every pixel from an image file. and i want to save the pixels like: r[] g[] b[]

does somebody know how to do this?

+2  A: 

The answer depends on the format of the image file. Is it a format which contains raw RGB data (such as uncompressed TGA)? Is it a YUV image? Is it a compressed image such as JPEG or PNG?

There are already plenty of C++ libraries out there which can read a wide variety of image file formats, and then provide the pixel-level access you require. Take a look at Adobe's GIL, or CImg for example.

Gareth Stockwell
-1: not an answer - should be a comment.
Paul R
@Paul R: Ask a silly question, get a silly answer. +1
Williham Totland
@Paul, added references to some libraries which can do what the OP requires - I think this now qualifies as an answer.
Gareth Stockwell
@gareth: OK, -1 removed.
Paul R
A: 

There are many freely available libraries for reading different image file formats. Since you're using C++ you might want to look at Adobe's Generic Image Library (GIL) or even OpenCV.

Paul R
A: 

Two libraries that I've used that jump to mind are:

These libraries can handle a wide variety of image formats, depending on what you need.

Greg Hewgill
+1  A: 

This will sort you out, very easy to use and 'low level' image library: http://easybmp.sourceforge.net/

zaf