/* ESE 558 Digital Image Processing rasio.h header file for sun rasterfile I/O routines sun raster io header file */ #ifndef _rasio_h #define _rasio_h #define HIBYTE(w) ((unsigned char) (((short int) (w) >> 8) & 0xFF)) #define LOBYTE(w) ((unsigned char) (short int) w) #define HIWORD(l) ((short int) (( (int) (l) >> 16) & 0xFFFF)) #define LOWORD(l) ((short int) (l)) #define RAS_MAGIC 0x59a66a95 /* Sun supported ras_type's */ #define RT_OLD 0 /* Raw pixrect image in 68000 byte order */ #define RT_STANDARD 1 /* Raw pixrect image in 68000 byte order */ #define RT_BYTE_ENCODED 2 /* Run-length compression of bytes */ #define RT_FORMAT_RGB 3 /* XRGB or RGB instead of XBGR or BGR */ #define RT_FORMAT_TIFF 4 /* tiff <-> standard rasterfile */ #define RT_FORMAT_IFF 5 /* iff (TAAC format) <-> standard rasterfile */ #define RT_EXPERIMENTAL 0xffff /* Reserved for testing */ /* Sun registered ras_maptype's */ #define RMT_RAW 2 /* Sun supported ras_maptype's */ #define RMT_NONE 0 /* ras_maplength is expected to be 0 */ #define RMT_EQUAL_RGB 1 /* red[ras_maplength/3],green[],blue[] */ /* * NOTES: * Each line of the image is rounded out to a multiple of 16 bits. * This corresponds to the rounding convention used by the memory pixrect * package (/usr/include/pixrect/memvar.h) of the SunWindows system. * The ras_encoding field (always set to 0 by Sun's supported software) * was renamed to length in release 2.0. As a result, rasterfiles * of type 0 generated by the old software claim to have 0 length; for * compatibility, code reading rasterfiles must be prepared to compute the * true length from the width, height, and depth fields. */ /* * Description of header for files containing raster images */ typedef struct { int magic; /* magic number */ int width; /* width (pixels) of image */ int height; /* height (pixels) of image */ int depth; /* depth (1, 8, or 24 bits) of pixel */ int length; /* length (bytes) of image */ int type; /* type of file; see RT_* below */ int maptype; /* type of colormap; see RMT_* below */ int maplength; /* length (bytes) of following map */ /* color map follows for maplength bytes, followed by image */ } Raster_header; /* defines the actual raster file */ typedef struct { Raster_header *header; unsigned char **image; } Raster_file; /* prototypes */ Raster_file *read_raster_file(char *infilename); void write_raster_file(char *outfilename,unsigned char **image, int height, int width); unsigned char **pic_alloc(int rows,int cols) ; void swap_int(int *input); void swap_header( Raster_header *header); void free_pic( unsigned char **pic, int rows); #endif