ookay people, here is the code c++; im trying to read BMP image file.

#include <iostream>
#include <fstream>
using namespace std;

void listing (void) {
unsigned char pixel;                 
int x, pix;
ofstream debug("debug.txt", ios::out);
ifstream inpaint( "source.bmp",ios::binary);
if(!inpaint) {
cout << "File not opened\n";
exit(1);
}
for(x=1; x<=54; x++) {
inpaint.get(pixel); //<----my problem is here.
pix = pixel;
debug << pix << endl; 
}

here i try to get source.bmp data using get() function // inpaint.get(pixel)// an put this info into pixel; which is unsigned char ofcourse. i get error. i think for binary incoming information; unsigned char is better . then i used simpe char // char pixel // and inpaint.get(pixel) worked; why can't i use unsigned char???

You need to understand .bmp format first. As always Wiki has a great article on its format. You need to read in specific things before you read the actual pixel first. If you really just want to learn then you can go read the article and work from there, if you just want to get a picture in the screen first, then learn later, then go use a external library that does the work for you already.

i have already figured it out and made it for my little engine. but thanks for help :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.