Reading from a file

J

JoeC

I am trying to create a graphic library that read bitmap info from a
fil this dosn't seem to worlk, it read in the first two values but
dosn't seem to read the graphic data am I doing this wrong?

graphic::graphic(std::string n){
std::ifstream fin(n.c_str());
BYTE num = 0;
BYTE gr[64];
BYTE * pgr;
pgr = &gr[0];
if (fin){
fin>>ud>>lr;
while(fin){
fin>>pgr;
pgr++;
}
} else {
MessageBox(NULL, "Could Not Open File!" , "Error!", MB_OK);
}
BITMAP bitmap = {0,ud,lr,8,1,1};
bitmap.bmBits = gr;
hbitmap = CreateBitmapIndirect(&bitmap);

///////////////////////////////////////////////////////////////////////////////////////
file info:
8 8 0 0x7e 0 0x7e 0 0x7e 0 0x7e 0 0 0
 
P

Phlip

JoeC said:
I am trying to create a graphic library that read bitmap info from a
fil this dosn't seem to worlk, it read in the first two values but
dosn't seem to read the graphic data am I doing this wrong?

A little Googling will hit some copy of Microsoft's sample code for reading
a BMP file. It's sick code, but all you will need to do is copy it out and
use it.

This newsgroup is not qualified to help directly because your question isn't
about C++. Except...
std::ifstream fin(n.c_str());

You may want to open the file in binary mode. Streams default to text mode,
which adds those peesashit extra \r codes to the ends of lines for no
apparent reason.
 
J

JoeC

This newsgroup is not qualified to help directly because your question
isn't
about C++. Except...

I thougty not so I posted in several different places.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top