Well, using a standard RGB system, setting the red, green, and blue components to the same value will produce a gray color. e.g. (R=0,G=0,B=0) means black, (R=255,G=255,B=255) means white, and all the values in between increase in brightness incrementally between 0 and 255.
Note that images could be RGBA, they could vary in bits per pixel, bits per color component, some have been compressed (with or without loss), etc. Not to mention every image format varies in the way they store the actual pixels and their supplementary data such as pallettes.
For example, examine the differences between BMP and JPEG (scroll down to syntax and structure and onward):
http://en.wikipedia.org/wiki/BMP_file_format
http://en.wikipedia.org/wiki/JPEG
If you want to work with images from scratch, I would suggest targeting an easier format such as GIF or BMP (Windows built-ins can be used as a good shortcut for working with BMPs). Otherwise, I would recommend using a library (such as CImg or DevIL). I haven't used any of those libraries so I can't comment on their efficacy.