Hi,
A negative pitch value only indicates that it is a bottom-up DIB and its origin is the lower left corner. .Now since your each pixel is 24 bits long; each byte represents the relative intensities of blue, green and red respectively for each image.
The easiest and quickest way here could be:
1. Get the pointer to the pixel buffer using GetBits along with the other data (like width, height, BPP, pitch etc)
2. Calculate size of the image in bytes.
3. Then create three arrays blue, green, red of size (size of image in bytes/3)
4. Start reading byte wise from the buffer and store them in the respective arrays (for example byte 1 in the blue array, byte 2 in the green array and byte 3 in the red array, again byte 4 in the blue array, byte 5 in the green and so on)
5. It will be easy from here to get the data for pixel (x, y) and also to reconstruct.
I am a little unsure what you are trying to achieve especially in the latter part of the code:
value = *(byte_value+h*imagepitch-i*steps-j);
pixeldata[h*maxY+i] += value<<8*j;
Thanks
Sarita Bafna
Visual C++ Team
|