PDA

View Full Version : How can I read pixel value of a bitmap file?



colagl
05-22-2016, 09:26 PM
Hi,

Suppose I've a bitmap file(a.bmp). I want to read it. I want to get the pixel values of this bitmap file. Then I want to store these pixel values in a text file.

Then I want to draw that image on opengl window.

Then I would change some pixel values and save it as b.bmp. The b.bmp will not be same as a.bmp.

How can I do this with opengl? Can someone post sample code?

Any answer will be highly appreciated.

Thanks in advance.

GClements
05-22-2016, 10:42 PM
OpenGL is unlikely to be useful here. It's a rendering API, not an image-processing library.

For C or C++, consider DevIL (http://openil.sourceforge.net/). Higher-level languages tend to either have image I/O as part of the standard library or have libraries tailored to that language (e.g. PIL/Pillow for Python).

PadMad
05-26-2016, 06:19 AM
- Check wikipedia for .bmp specification. Then you should know how a bitmap is built.
- Use low level IO functions in C to open and read a file.
- run through the stream with a byte pointer using the right offset.
- manipulate what ever you want.
- use low level IO functions to create a new file