home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga Shareware Floppies / ma01.dms / ma01.adf / wasp / src / raw.c < prev    next >
C/C++ Source or Header  |  1991-12-28  |  1KB  |  61 lines

  1. /* wasp - Copyright 1991 by Steven Reiz
  2.  * see COPYING and wasp.c for further info,
  3.  * raw.c, 4/12/90 - 3/1/91, 5/5/91 - 23/6/91, 8/7/91,
  4.  * 8/12/91, 27/12/91
  5.  */
  6.  
  7. static char *sourcefile=__FILE__;
  8.  
  9. #include "wasp.h"
  10.  
  11. #define RAW_ID id('S', 'R', 'G', 'R')
  12.  
  13. read_srgr(void)
  14. {
  15.     short y;
  16.     long t;
  17.  
  18.     cread(&t, 4);
  19.     if (t!=RAW_ID) {
  20.         cseek_in(0L, 0);
  21.         return 0;
  22.     }
  23.     cread(&xsz, (int)sizeof(xsz));
  24.     cread(&ysz, (int)sizeof(ysz));
  25.     printe("SRGR input; %ld x %ld\n", xsz, ysz);
  26.     if (!outfilename)
  27.     exit(0);
  28.     cread_type=CREAD_NONFATAL;
  29.     rgb=Malloc(ysz*sizeof(u_short *));
  30.     init_counter(0, (int)ysz, 20, "reading SRGR");
  31.     for (y=0; y<ysz; ++y)
  32.         rgb[y]=Calloc(xsz*sizeof(u_short));
  33.     for (y=0; y<ysz; ++y) {
  34.         counter();
  35.         cread(rgb[y], (int)(xsz*sizeof(u_short)));
  36.     if (cread_result!=xsz*sizeof(u_short))
  37.         break;
  38.     }
  39.     erase_counter(NULL);
  40.     cread_type=CREAD_STRICT;
  41.     return 1;
  42. }
  43.  
  44.  
  45. void
  46. write_srgr(void)
  47. {
  48.     short y;
  49.  
  50.     printe("SRGR output; %ld x %ld\n", xsz, ysz);
  51.     wrl((long)RAW_ID);
  52.     wrl(xsz);
  53.     wrl(ysz);
  54.     init_counter(0, (int)ysz, 20, "writing SRGR");
  55.     for (y=0; y<ysz; ++y) {
  56.         counter();
  57.         cwrite(rgb[y], xsz*sizeof(u_short));
  58.     }
  59.     erase_counter("SRGR file written, %ld bytes", cseek_out(0L, 1));
  60. }
  61.