orle.h

Go to the documentation of this file.
00001 /** @addtogroup utahrle */
00002 /*@{*/
00003 /*
00004 
00005         Modified by :           Gary S. Moss
00006                                 U. S. Army Ballistic Research Laboratory
00007                                 Aberdeen Proving Ground
00008                                 Maryland 21005-5066
00009                                 (301)278-6647 or AV-283-6647
00010  *
00011  *  Note:  Users of this file will need to include "fb.h" first.
00012  */
00013 /*
00014  * Runsv.h - Definitions for Run Length Encoding.
00015  *
00016  * Author:      Spencer W. Thomas
00017  *              Computer Science Dept.
00018  *              University of Utah
00019  * Date:        Mon Aug  9 1982
00020  * Copyright (c) 1982 Spencer W. Thomas
00021  */
00022 
00023 #include "machine.h"            /* for BIG_ENDIAN definition */
00024 
00025 #ifdef BIG_ENDIAN
00026 #define SWAB(shrt)  (shrt = ((shrt >> 8) & 0xff) | ((shrt << 8) & 0xff00))
00027 #else
00028 #define SWAB(shrt)
00029 #endif
00030 
00031 /* Opcode definitions.                                                  */
00032 #define RSkipLinesOp    1
00033 #define RSetColorOp     2
00034 #define RSkipPixelsOp   3
00035 #define RByteDataOp     5
00036 #define RRunDataOp      6
00037 
00038 /* If this bit is set in inst.opcode, we have a long instruction.       */
00039 #define LONG            0x40
00040 
00041 /* Flags returned by 'rle_rhdr()'.                                      */
00042 #define NO_BOX_SAVE     (1<<0)  /* Saved with backgr.== H_CLEARFIRST    */
00043 #define NO_COLORMAP     (1<<1)  /* Color map not saved.                 */
00044 #define NO_IMAGE        (1<<2)  /* Only color map saved.                */
00045 
00046 typedef struct  /* Extended format RLE header.                          */
00047         {
00048         short   h_xpos, h_ypos; /* Lower-left corner of image.          */
00049         short   h_xlen, h_ylen; /* Size of saved box.                   */
00050         char    h_flags;        /* Some flags.                          */
00051 #define H_CLEARFIRST    0x1     /* Clear the fb to background first.    */
00052 #define H_BOXSAVE       0x0     /* Straight box save.                   */
00053         char    h_ncolors;      /* Number of color channels.            */
00054 #define H_LD_CMAP_ONLY  0       /* Load only the color map (if present).*/
00055 #define H_B_W           1       /* We have a black and white image.     */
00056 #define H_RGB           3       /* We have a normal color image.        */
00057         char    h_pixelbits;    /* Bits per pixel per channel.          */
00058         char    h_ncmap;        /* Channels in color map (map present). */
00059         char    h_cmaplen;      /* Log base 2 of entries in color map.  */
00060         unsigned char  h_background[3]; /* Background color.            */
00061 } Xtnd_Rle_Header;
00062 
00063 typedef struct  /* Old format RLE header minus magic number field.      */
00064         {
00065 /***    short   magic;  Read seperately ***/
00066         short   xpos, ypos;     /* Lower-left corner of image.          */
00067         short   xsize, ysize;   /* Size of saved box.                   */
00068         unsigned char   bg_r;   /* Background colors.                   */
00069         unsigned char   bg_g;
00070         unsigned char   bg_b;
00071         char    map;            /* Flag for map presence.               */
00072         } Old_Rle_Header;
00073 
00074 typedef struct /* Old RLE format instruction.                           */
00075         {
00076 #if __STDC__ || defined(__convexc__)
00077         /* XXX This won't match the file format, but will at least compile */
00078         /* ANSI insists that bit-field must be of type signed int, unsigned int or int */
00079         unsigned int datum:12, opcode:4;
00080 #else
00081         unsigned short datum:12, opcode:4;
00082 #endif
00083         } Old_Inst;
00084 
00085 typedef struct /* Old RLE format instruction.                           */
00086         {
00087 #if __STDC__ || defined(__convexc__)
00088         /* XXX This won't match the file format, but will at least compile */
00089         /* ANSI insists that bit-field must be of type signed int, unsigned int or int */
00090         int     opcode:8, datum:8;
00091 #else
00092         short   opcode:8, datum:8;
00093 #endif
00094         } Xtnd_Inst;
00095 
00096 #define OPCODE(inst) (inst.opcode & ~LONG)
00097 #define LONGP(inst) (inst.opcode & LONG)
00098 #define DATUM(inst) (0x00ff & inst.datum)
00099 
00100 /* Old RLE format magic numbers.                                        */
00101 #define     RMAGIC      ('R' << 8)      /* Top half of magic number.    */
00102 #define     WMAGIC      ('W' << 8)      /* Black&white rle image.       */
00103 
00104 #define     XtndRMAGIC  ((short)0xcc52) /* Extended RLE magic number.   */
00105 
00106 #define STRIDE (sizeof(RGBpixel))       /* Distance (bytes) to next pixel.      */
00107 
00108 /* Global data intended mainly for internal (library) use.              */
00109 extern int      _bg_flag;
00110 extern int      _bw_flag;
00111 extern int      _cm_flag;
00112 extern RGBpixel _bg_pixel;
00113 
00114 /* Global flags for general use.                                        */
00115 extern int      rle_debug;
00116 extern int      rle_verbose;
00117 
00118 /* Entry points.                                                        */
00119 void    rle_rlen(), rle_wlen(), rle_rpos(), rle_wpos();
00120 int     rle_rhdr(), rle_whdr(), rle_rmap(), rle_wmap();
00121 int     rle_decode_ln(), rle_encode_ln();
00122 
00123 /*@}*/
00124 /*
00125  * Local Variables:
00126  * mode: C
00127  * tab-width: 8
00128  * c-basic-offset: 4
00129  * indent-tabs-mode: t
00130  * End:
00131  * ex: shiftwidth=4 tabstop=8
00132  */

Generated on Mon Sep 18 01:24:41 2006 for BRL-CAD by  doxygen 1.4.6