home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / graf / fract5.zip / TGAVIEW.C < prev    next >
Text File  |  1989-07-25  |  2KB  |  63 lines

  1.  
  2. /* Routine to decode Targa 16 bit RGB file */
  3.  
  4. #include <stdio.h>
  5. #include "fractint.h"
  6. #include "targa_lc.h"
  7. #include "port.h"
  8.  
  9. extern char readname[];                    /* file name              */
  10. extern unsigned int decoderline[];    /* write-line routines use this */
  11. extern int colors;
  12. extern int rowcount;
  13.  
  14. static FILE *fptarga = NULL;                /* FILE pointer           */
  15. extern unsigned int height;                 /* image height           */
  16. extern int (*outln)();
  17.  
  18. /* Main entry decoder */
  19. tgaview()
  20. {
  21.    int i;
  22.    int cs;
  23.    unsigned numcolors;
  24.    unsigned int width;
  25.    struct fractal_info info;
  26.    FILE *t16_open();
  27.    
  28.    if((fptarga = t16_open(readname, &width, &height, &cs, (int *)&info))==NULL)
  29.       return(-1);
  30.  
  31.    rowcount = 0;
  32.    for (i=0; i<height; ++i) 
  33.    {
  34.        t16_getline(fptarga, width, (U16 *)decoderline);
  35.        if ((*outln)(decoderline,width))
  36.        {
  37.           fclose(fptarga);
  38.           fptarga = NULL;
  39.           return(-1);
  40.        }   
  41.        if (keypressed()) 
  42.        {
  43.           buzzer(1);
  44.           fclose(fptarga);
  45.           fptarga = NULL;
  46.           return(-1);
  47.        }
  48.    }
  49.    fclose(fptarga);
  50.    fptarga = NULL;
  51.    return(0);
  52. }
  53. /* Outline function for 16 bit data with 8 bit fudge */
  54. outlin16(unsigned int *buffer,int linelen)
  55. {
  56.     extern int rowcount;
  57.     int i,color;
  58.     for(i=0;i<linelen;i++)
  59.        putcolor(i,rowcount,buffer[i]>>8);
  60.     rowcount++;
  61.     return(0);
  62. }
  63.