home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume19 / fbm / part03 / fbm.h < prev    next >
C/C++ Source or Header  |  1989-06-08  |  4KB  |  112 lines

  1. /*****************************************************************
  2.  * fbm.h: FBM Library 0.9 (Beta Test)  07-Mar-89  Michael Mauldin
  3.  *
  4.  * Copyright (C) 1989 by Michael Mauldin.  Permission is granted to
  5.  * use this file in whole or in part provided that you do not sell it
  6.  * for profit and that this copyright notice is retained unchanged.
  7.  *
  8.  * fbm.h: Fuzzy Bitmap Definition
  9.  *
  10.  * USAGE
  11.  *    # include <fbm.h>
  12.  *
  13.  * EDITLOG
  14.  *    LastEditDate = Tue Mar  7 19:52:53 1989 - Michael Mauldin
  15.  *    LastFileName = /usr2/mlm/src/misc/fbm/fbm.h
  16.  *
  17.  * HISTORY
  18.  * 07-Mar-89  Michael Mauldin (mlm) at Carnegie Mellon University
  19.  *    Beta release (version 0.9) mlm@cs.cmu.edu.
  20.  *
  21.  * 20-Aug-88  Michael Mauldin (mlm) at Carnegie-Mellon University
  22.  *    Created.
  23.  *****************************************************************/
  24.  
  25. # define FBM_MAX_TITLE        80        /* For title and credits */
  26.  
  27. # define BLACK            0        /* For 8bit files */
  28. # define WHITE            255        /* For 8bit files */
  29. # define BYTE            256        /* For 8bit files */
  30.  
  31. # define BIG            1        /* msb first byte order */
  32. # define LITTLE            0        /* lsb first byte order */
  33.  
  34. # define BYTESPERLINE        32        /* For PostScript output */
  35.  
  36. # define BLANKS        "                                             "
  37. # define SKIPARG    while (*++(*argv)); --(*argv)
  38. # define CLRARG        strncpy (*argv, BLANKS, strlen (*argv)); \
  39.             while (*++(*argv)); --(*argv)
  40.  
  41. # define FMT_ATK    1    /*   Andrew toolkit raster format */
  42. # define FMT_FACE    2    /*   Bennet Yee's 1bit Face format */
  43. # define FMT_FBM    3    /* + Fuzzy bitmap format */
  44. # define FMT_GIF    4    /*   Compuserve Graphics Interchange */
  45. # define FMT_IFF    5    /*   Amiga Interchange Format File */
  46. # define FMT_LEAF    6    /*   InterLeaf image format */
  47. # define FMT_MCP    7    /*   Macpaint format */
  48. # define FMT_PBM    8    /*   Poskanzer 1bit format */
  49. # define FMT_PCX    9    /*   PCX format */
  50. # define FMT_SUN    10    /* + Sun rasterfile */
  51. # define FMT_TIFF    11    /*   Tagged IFF, Next, Macintosh */
  52. # define FMT_X11    12    /*   X11 format */
  53.  
  54. # define FMTCHAR ".ABFGILMPZSTX"
  55.  
  56. # define DEF_8BIT    FMT_FBM
  57. # define DEF_1BIT    FMT_SUN
  58.  
  59. /* An FBM bitmap header in memory */
  60. typedef struct fbm_hdr_struct {
  61.     int    cols;            /* Width in pixels */
  62.     int    rows;            /* Height in pixels */
  63.     int    planes;            /* Depth (1 for B+W, 3 for RGB) */
  64.     int    bits;            /* Bits per pixel */
  65.     int    physbits;        /* Bits to store each pixel */
  66.     int    rowlen;            /* Length of a row in bytes */
  67.     int    plnlen;            /* Length of a plane in bytes */
  68.     int    clrlen;            /* Length of color map */
  69.     double    aspect;            /* ratio of Y to X of one pixel */
  70.     char    title[FBM_MAX_TITLE];    /* Null terminated title */
  71.     char    credits[FBM_MAX_TITLE];    /* Null terminated credits */
  72. } FBMHDR;
  73.  
  74. # define FBM_MAGIC    "%bitmap"
  75. # define BM_MAGIC    ('!' << 8 | '!')
  76. # define PCX_MAGIC    0xa
  77. # define GIF_MAGIC    "GIF87a"
  78. # define IFF_MAGIC    "FORM"
  79. # define SUN_MAGIC    0x59a66a95
  80.  
  81. /* FBM bitmap headers in files (null terminated 12 character ascii strings) */
  82. typedef struct fbm_filehdr_struct {
  83.     char    magic[8];        /* 2 bytes FBM_MAGIC number */
  84.     char    cols[8];        /* Width in pixels */
  85.     char    rows[8];        /* Height in pixels */
  86.     char    planes[8];        /* Depth (1 for B+W, 3 for RGB) */
  87.     char    bits[8];        /* Bits per pixel */
  88.     char    physbits[8];        /* Bits to store each pixel */
  89.     char    rowlen[12];        /* Length of a row in bytes */
  90.     char    plnlen[12];        /* Length of a plane in bytes */
  91.     char    clrlen[12];        /* Length of colormap in bytes */
  92.     char    aspect[12];        /* ratio of Y to X of one pixel */
  93.     char    title[FBM_MAX_TITLE];    /* Null terminated title */
  94.     char    credits[FBM_MAX_TITLE];    /* Null terminated credits */
  95. } FBMFILEHDR;
  96.  
  97. /* An FBM bitmap in memory */
  98. typedef struct fbm_struct {
  99.     FBMHDR hdr;            /* Bitmap header */
  100.     unsigned char *cm;        /* Pointer to colormap */
  101.     unsigned char *bm;        /* Pointer to raw bits */
  102. } FBM;
  103.  
  104. /* Functions */
  105. double atof ();
  106. char *strcpy(), *strncpy(), *malloc();
  107. long time (), get_long ();
  108. int get_short ();
  109.  
  110. /* Macro for getting next magic char */
  111. # define NEXTMCH(F,S,L) (((L) > 0) ? ((L)--, *(S)++) : getc (F))
  112.