I'm trying to read a .bmb file with c++ and save the grey values (average over RGB values) normalized into a vector under Ubuntu 14.04. Somehow the values of the vector end up completely wrong. Can you imagine why?
I'm aware of the useless conversion and the memory leak and should have changed that, but I was just changing an existing code for my use. Anyway these are not the problems.
> Anyway these are not the problems.
But they add unnecessary complications to the analysis.
$ file example.bmp
example.bmp: PC bitmap, Windows 98/2000 and newer format, 3 x 3 x 32
each pixel has a depth of 32, corresponding to R, G, B, A.
You did not take into account the `A' field and so were reading the end of one pixel and the start of the neighbour.
Thank you, now it's working fine.
Just two last questions, how can I know if the bitmap is ARGB or only RGB?
And is the -53 instead of the -54 at the offset because of the ARGB or was the -54 simply wrong?
(1C) the number of bits per pixel, which is the color depth of the image. Typical values are 1, 4, 8, 16, 24 and 32.
Although the examples there show BGRA, doing an hexdump got ABGR in images created with gimp.
Also, there is no need to load the whole header if you are only interested on the first 0A (or 1C) bytes.
And using 54 is error-prone, you may `fgetpos()' instead.