home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / fbm / src / flpic.c < prev    next >
C/C++ Source or Header  |  1990-06-24  |  2KB  |  85 lines

  1. /*****************************************************************
  2.  * flpic.c: FBM Release 1.0 25-Feb-90 Michael Mauldin
  3.  *
  4.  * Copyright (C) 1989,1990 by Michael Mauldin.  Permission is granted
  5.  * to use this file in whole or in part for any purpose, educational,
  6.  * recreational or commercial, provided that this copyright notice
  7.  * is retained unchanged.  This software is available to all free of
  8.  * charge by anonymous FTP and in the UUNET archives.
  9.  *
  10.  * EDITLOG
  11.  *    LastEditDate = Mon Jun 25 00:31:34 1990 - Michael Mauldin
  12.  *    LastFileName = /usr2/mlm/src/misc/fbm/flpic.c
  13.  *
  14.  * HISTORY
  15.  * 25-Jun-90  Michael Mauldin (mlm@cs.cmu.edu) Carnegie Mellon
  16.  *    Package for Release 1.0
  17.  *
  18.  * 11-Jun-89  Michael Mauldin (mlm) at Carnegie Mellon University
  19.  *    Beta release (version 0.95) mlm@cs.cmu.edu
  20.  *    User contributed software.  I can't remember who wrote
  21.  *    it...if you know, send mail to mlm@cs.cmu.edu.
  22.  *****************************************************************/
  23.  
  24. #include <stdio.h>
  25. #include "fbm.h"
  26.  
  27. #ifndef lint
  28. static char *fbmid =
  29. "$FBM flpic.c <1.0> 25-Jun-90  (C) 1989,1990 by Michael Mauldin, source \
  30. code available free from MLM@CS.CMU.EDU and from UUNET archives$";
  31. #endif
  32.  
  33. /*
  34.  * read_pic(image, rfile, mstr, mlen)
  35.  *
  36.  */
  37.  
  38. read_pic(image, rfile, mstr, mlen)
  39. FBM *image;
  40. FILE *rfile;
  41. char *mstr;
  42. int mlen;
  43. {
  44. unsigned int        Width, Height;
  45. int            i,j;
  46. unsigned char        *Red, *Grn, *Blu;
  47.  
  48. fscanf(rfile,"%d %d\n",&Width,&Height);
  49.  
  50. /* Create output image header */
  51.     image->hdr.rows = Height;
  52.     image->hdr.cols = Width;
  53.     /* If this is odd number of bytes, add one */
  54.     if ((image->hdr.cols & 1) != 0) image->hdr.cols++;
  55.     image->hdr.planes = 3;
  56.     image->hdr.bits = 8;
  57.     image->hdr.physbits = 8;
  58.     image->hdr.rowlen = image->hdr.cols;
  59.     image->hdr.plnlen = image->hdr.rows * image->hdr.cols;
  60.     image->hdr.clrlen = 0;
  61.     image->hdr.aspect = 1.0;
  62.     image->hdr.title[0] = '\0';
  63.     image->hdr.credits[0] = '\0';
  64.  
  65. /* Get the Image */
  66.     alloc_fbm(image);
  67.  
  68.     Red = image->bm;
  69.     Grn = Red + image->hdr.plnlen;
  70.     Blu = Grn + image->hdr.plnlen;
  71.     for (i=0; i< Height; i++)
  72.     {
  73.         for (j=0; j< Width; j++)
  74.         {
  75.             fread(Red++,1,1,rfile);
  76.             fread(Grn++,1,1,rfile);
  77.             fread(Blu++,1,1,rfile);
  78.         }
  79.         if (Width != image->hdr.cols)
  80.         {
  81.             Red++;Grn++;Blu++;
  82.         }
  83.     }
  84. }
  85.