cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/23/23:15:33

From: "Daniel Urquhart" <NoSpamdurquhart AT jlcrowe DOT org>
Newsgroups: comp.os.msdos.djgpp
Subject: ifstream error - Please help
Date: Tue, 23 Jun 1998 16:10:06 -0700
Organization: BCTEL Advanced Communications
Lines: 44
Message-ID: <6mpqen$a6h$1@news.bctel.net>
NNTP-Posting-Host: tral01m01-16.bctel.ca
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In the following code, when I attemp to load a 24bit, 320*200 file and place
on the screen it returns after puting only about 750 pixles.  Also I know
this because if I skip the eof() test it will make 90% of the screen white.
(could be lightest gray).  The file that I am loading is one saved by PSP 4
in the RAW format ( 24bit, ordered, not flipped RRGBRGBR...)

Any help would be greatly preciated :-)

#include <fstream.h>

void Raw::Load(char * Name, int dx = 320, int dy = 200, int tx=0, int ty=0)
{
        char r,g,b,rgb;

        ifstream temp(Name);

        if(!temp) exit(3);

        for(int ly = 0; ly < dy; ly++)
        {
          for(int lx = 0; lx < dx; lx++)
          {
                        if(temp.eof()) return;

                        r=temp.get();
                        g=temp.get();
                        b=temp.get();


                        r=(r>>5);
                        g=(g>>5);
                        b=(b>>6);


                        rgb= (r<<5)+(g<<2)+b;

          PutPixel(rgb,lx+tx,ly+ty);
}
 }

 temp.close();
}


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019