0

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???

Edited by Nick Evan: Added CODE tags

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by ilnura
0

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.

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.