home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / frasrc18.zip / TGAVIEW.C < prev    next >
Text File  |  1992-07-15  |  2KB  |  69 lines

  1.  
  2. /* Routine to decode Targa 16 bit RGB file
  3.    */
  4.  
  5. /* 16 bit .tga files were generated for continuous potential "potfile"s
  6.    from version 9.? thru version 14.  Replaced by double row gif type
  7.    file (.pot) in version 15.  Delete this code after a few more revs.
  8. */
  9.  
  10. #include <stdio.h>
  11. #include "fractint.h"
  12. #include "targa_lc.h"
  13. #include "prototyp.h"
  14.  
  15. extern char readname[];         /* file name          */
  16. extern unsigned int boxx[];        /* write-line routines use this */
  17. extern int colors;
  18. extern int rowcount;
  19.  
  20. static FILE *fptarga = NULL;        /* FILE pointer       */
  21. extern unsigned int height;        /* image height       */
  22. extern int (*outln)();
  23.  
  24. /* Main entry decoder */
  25. tgaview()
  26. {
  27.    int i;
  28.    int cs;
  29.    unsigned int width;
  30.    struct fractal_info info;
  31.    FILE *t16_open();
  32.  
  33.    if((fptarga = t16_open(readname, (int *)&width, (int *)&height, &cs, (U8 *)&info))==NULL)
  34.       return(-1);
  35.  
  36.    rowcount = 0;
  37.    for (i=0; i<height; ++i)
  38.    {
  39.        t16_getline(fptarga, width, (U16 *)boxx);
  40.        if ((*outln)(boxx,width))
  41.        {
  42.       fclose(fptarga);
  43.       fptarga = NULL;
  44.       return(-1);
  45.        }
  46.        if (keypressed())
  47.        {
  48.       fclose(fptarga);
  49.       fptarga = NULL;
  50.       return(-1);
  51.        }
  52.    }
  53.    fclose(fptarga);
  54.    fptarga = NULL;
  55.    return(0);
  56. }
  57. /* Outline function for 16 bit data with 8 bit fudge */
  58. outlin16(BYTE *buffer,int linelen)
  59. {
  60.     extern int rowcount;
  61.     U16 *buf;
  62.     int i;
  63.     buf = (U16 *)buffer;
  64.     for(i=0;i<linelen;i++)
  65.        putcolor(i,rowcount,buf[i]>>8); 
  66.     rowcount++;
  67.     return(0);
  68. }
  69.