How to create grayscale pixel value array

Hello.
Thought I'd ask; having a hard time figuring this out on my own. I am using Borland C++ Builder 6 on a PC running Windows XP. I have a black and white image; I can put it in any format, bmp, jpg, tif, whatever. The image has pixel dimensions 500 x 500. Each pixel is a greyscale value from 0 (black)
to 2^16 (white). I want to write C++ code that will read the image and then create an array, call it DataArray[500][500] where DataArray[i][j] is the greyscale value for the pixel in the ith row, the jth column. How can I create such an array? This would allow me, for example, to create a graph of the greyscale values along any column (for all the rows) or along any row (for all the column values in that row). Any help would be greatly appreciated. Thanks.

-Rob
For each pixel:
1. Get the pixel with GetPixel()
2. Change the pixel colour to the average of the RGB values. That is set red, green and blue to the same value--this average value.
3. Set the new value with SetPixel().
Last edited on
gray = (red * 0.30) + (green * 0.59) + (blue * 0.11)
Topic archived. No new replies allowed.