Reading from a file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JoeC

    #1

    Reading from a file

    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::graphi c(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 = CreateBitmapInd irect(&bitmap);

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

  • Phlip

    #2
    Re: Reading from a file

    JoeC wrote:
    [color=blue]
    > 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?[/color]

    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...
    [color=blue]
    > std::ifstream fin(n.c_str());[/color]

    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.

    --
    Phlip
    http://www.greencheese.org/ZeekLand <-- NOT a blog!!!

    Comment

    • JoeC

      #3
      Re: Reading from a file

      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.

      Comment

      Working...