home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / genie-commodore-file-library / C128CPM / SGTOOL16.ARC / LIBC128.ARC / PCX.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-27  |  981 b   |  52 lines

  1. /*
  2. SG C Tools 1.6
  3.  
  4. (C) 1993 Steve Goldsmith
  5. All Rights Reserved
  6.  
  7. Compiled with HI-TECH C 3.09 (CP/M-80).
  8. */
  9.  
  10. #include <stdio.h>
  11. #include <hitech.h>
  12. #include <vdc.h>
  13. #include <pcx.h>
  14.  
  15. FILE    *pcxFile;
  16. pcxHead pcxHeader;
  17. ushort  pcxXSize, pcxYSize;
  18.  
  19. /* init decode 2 bit .pcx */
  20.  
  21. short initpcx(char *FileName)
  22. {
  23.   if ((pcxFile = fopen(FileName,"rb")) != NULL)
  24.   {
  25.     if (fread((uchar *) &pcxHeader,1,sizeof(pcxHeader),pcxFile) == sizeof(pcxHeader))
  26.     {
  27.       if (pcxHeader.Manufacturer == 0x0A)
  28.       {
  29.         if (pcxHeader.BitsPerPixel == 1)
  30.         {
  31.           pcxXSize = (pcxHeader.XMax - pcxHeader.XMin)+1;
  32.           pcxYSize = (pcxHeader.YMax - pcxHeader.YMin)+1;
  33.           return(pcxErrNone);
  34.         }
  35.         else
  36.           return(pcxErrNot2Bit);
  37.       }
  38.       else
  39.         return(pcxErrNotPCX);
  40.     }
  41.     else
  42.       return(pcxErrHeader);
  43.   }
  44.   else
  45.     return(pcxErrFile);
  46. }
  47.  
  48. void donepcx(void)
  49. {
  50.   fclose(pcxFile);
  51. }
  52.