Reading Pixel Data from Image

I'm currently using stb_image for loading images in my little game. The problem I'm running into is that I need to read the pixels (in an array) but I can't find anything online that teaches me how to read pixels with stb_image.

I'm guessing that...

 
unsigned char *data = stbi_load((fileName).c_str(), &width, &height, &numComponents, 3);


...data is what I'm looking for, or maybe not. I'm little confused here. If anybody has experience with stb_image or has an alternate solution (not another lib) for reading pixel data of images, feel free to share it.
Last edited on

data[0] is the first pixel's R value.
data[1] is the first pixel's G value.
data[2] is the first pixel's B value.
data[3] is the second pixel's R value.
data[4] is the second pixel's G value.
data[5] is the second pixel's B value.
data[6] is the third pixel's R value.
data[7] is the third pixel's G value.
...
...
Thanks Moschops, I was going to post back an answer that helped me as well:


http://stackoverflow.com/questions/9296059/read-pixel-value-in-bmp-file
Topic archived. No new replies allowed.