I am quite new to that stuff, and I need a little help from you.
I need to read in an always same sized .BMP file and dump all pixels (- will be only black and white) into an array, to store the data later raw in an hex file.
I already found many other discussions about reading an bmp - but I didnt understand them - or the compiler doesnt like the code - or it is filled up with for my needs too useless stuff...... ... so is there a dead simple library where I can simply tell with a function, that i want get the pixel value from position x,y?
- I woudnt need any more
btw.: I am using an old DMC-compiler - but I want to swap to visual studio.
hopw you guys can help me.
It's kind of hard to recommend anything, because I don't really know what knowledge of the language you have and don't have.
If I would have to do this task, I think I would figure out the way the bmp file format works and just create a very basic reader for it myself - it would be a great learning experience.
Here's some links that explain the format:
http://expertsetup.com/~brian/bmp/index.html
http://en.wikipedia.org/wiki/BMP_file_format
http://atlc.sourceforge.net/bmp.html
As you can see every bit of information about the image is stored at specific locations.
This means that you can read the file in like you would any other text file, then use standard functions to find the positions specified and extract the information that way.
Once you find a way for that, you need to convert the pixel data into a 2D array. I think you could even use a bool array if you're only going to use black and white.
If you don't want to do that yourself, here's some more threads to take a look at:
// do this once to load the image
HDC mdc = CreateCompatibleDC(NULL);
HBITMAP bmp = LoadImage( NULL, TEXT("imagefilename.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE );
HBITMAP bmpold = (HBITMAP)SelectObject(mdc, bmp);
// do this for each pixel you want to get (X,Y)
COLORREF clr = GetPixel( mdc, X, Y );
// COLORREF is in format 0x00bbggrr
// so black=0x00000000
// and white = 0x00FFFFFF
// do this once to cleanup, after you are done with the image
SelectObject(mdc,bmpold);
DeleteObject(bmp);
DeleteDC(mdc);