> 'for' loop to loop through the bytes of the image
OK, one way to check the colour if an individual pixel is to call GetPixel which will return the RGB() value it finds at that point on the screen. So GetPixel(x,y) where (x,y) is black will return RGB(0,0,0). Probably if the image is greyscale then R=G=B but if not you'll need to find some way of computing intensity from three RGB values.
However if you prefer to get the data directly from image then you'll need to know how image[n] is converted to one or more pixels on the screen, and you can use that to calculate the intensity of the pixel(s) represented by each entry in image.
Otherwise array1[image[i]]++; (as you already have done) seems a good way to me of increasing the count for each individual intensity value, and the representation for that in the histogram could just be a case of drawing a vertical line that is array1[n] pixels long at x=n, and from the code I can see you already know how to draw a straight line.