TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: JABO
from: KURT KUZBA
date: 1998-04-02 05:51:00
subject: loading a file

J>   now, how do i load a pcx file? in 320x200x256 ??
   I have some C code to read a 320x200x256 .pcx file.
   The info is available in PC Game Programmer's Encyclopedia.
   Look for PCGPE on your local BBS's. Someone should have it.
   In the meantime, this code will read ONLY 320x200x256.
   It does not take into account pictures of different sizes or
   screen size or pixel color depth. You should get the C_ECHO
   if possible. You might add the code for variable sizes and
   repost the viewer as a C++ class.
 /*_|_|   PCXVIEW.C
 _|_|_|   A simple program to view a 320x200x256 .PCX file.
 _|_|_|   No guarantee or warrantee is given or implied.
 _|_|_|   Released to   PUBLIC DOMAIN   by Kurt Kuzba.  (7/20/96)*/
#include 
#include 
#include 
#include 
void setmode(char m)
{
   _asm{
         mov ah, 00h
         mov al, m
         int 10h
   }
}
int main(int c, char *arg[])
{
   int index, data;
   long end, loc = 128, pixl = 0;
   char buf[768], *temp, far *mem = (char far*)0xa0000000l;
   FILE *fp = fopen(arg[1], "rb");
   if(c < 2)
   {
      puts("usage: pcxview filename.ext");
      return 1;
   }
   if(fp == NULL)
   {
        printf("Could not open %s\n", arg[1]);
     return 2;
   }
   fseek(fp, 0l, SEEK_END);
   end = ftell(fp) - 768;
   fseek(fp, end, SEEK_SET);
   fread(buf, 1, (size_t)768, fp);
   setmode(0x13);
   for(temp = &buf[0], index = 0; index < 256; index++)
   {
     outp(0x3c8, index);
     outp(0x3c9, *temp++ >> 2);
     outp(0x3c9, *temp++ >> 2);
     outp(0x3c9, *temp++ >> 2);
   }
   fseek(fp, loc, SEEK_SET);
   do {
     loc++;
     data = fgetc(fp);
     if((data & 0xc0) == 0xc0)
     {
       data &= 0x3f;
       memset(mem + (unsigned)pixl, fgetc(fp), data);
       pixl += data;
       loc++;
     }
     else  *(mem + (unsigned)pixl++) = (char)data;
   }  while(loc < end);
   fclose(fp);
   while(!kbhit())
     *mem = *mem + 1; /* cycles one pixel to show its not frozen */
   getch();
   setmode(0x03);
   return 0;
}
 /*_|_|   end   PCXVIEW.C   */
> ] I'd say something clever, but you have nothing low-fat......
---
---------------
* Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.