since you are using VC++, it's easier if the scanned file is saved as bitmap (*.bmp) and then working on the bitmap file contents directly. You can look at Charles Petzold's "Programming Windows 5th Edition" in the image related chapter for the exact bitmap file format. As a preliminary info, IIRC windows bitmap store each RGB value in DWORD (32-bits) boundary for every scan line in the corresponding file, as per windows bitmap file version 3.0 that's in use in most of bitmap related software today.