home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume19 / fbm / part01 / flpic.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-06-08  |  1.1 KB  |  56 lines

  1.  
  2. #include <stdio.h>
  3. #include "fbm.h"
  4. /*
  5.  * read_pic(image, rfile, mstr, mlen)
  6.  *
  7.  */
  8.  
  9. read_pic(image, rfile, mstr, mlen)
  10. FBM *image;
  11. FILE *rfile;
  12. char *mstr;
  13. int mlen;
  14. {
  15. unsigned int        Width, Height;
  16. int            i,j;
  17. unsigned char        *Red, *Grn, *Blu;
  18.  
  19. fscanf(rfile,"%d %d\n",&Height,&Width);
  20.  
  21. /* Create output image header */
  22.     image->hdr.rows = Height;
  23.     image->hdr.cols = Width;
  24.     /* If this is odd number of bytes, add one */
  25.     if ((image->hdr.cols & 1) != 0) image->hdr.cols++;
  26.     image->hdr.planes = 3;
  27.     image->hdr.bits = 8;
  28.     image->hdr.physbits = 8;
  29.     image->hdr.rowlen = image->hdr.cols;
  30.     image->hdr.plnlen = image->hdr.rows * image->hdr.cols;
  31.     image->hdr.clrlen = 0;
  32.     image->hdr.aspect = 1.0;
  33.     image->hdr.title[0] = '\0';
  34.     image->hdr.credits[0] = '\0';
  35.  
  36. /* Get the Image */
  37.     alloc_fbm(image);
  38.  
  39.     Red = image->bm;
  40.     Grn = Red + image->hdr.plnlen;
  41.     Blu = Grn + image->hdr.plnlen;
  42.     for (i=0; i< Height; i++)
  43.     {
  44.         for (j=0; j< Width; j++)
  45.         {
  46.             fread(Red++,1,1,rfile);
  47.             fread(Grn++,1,1,rfile);
  48.             fread(Blu++,1,1,rfile);
  49.         }
  50.         if (Width != image->hdr.cols)
  51.         {
  52.             Red++;Grn++;Blu++;
  53.         }
  54.     }
  55. }
  56.