/* * * File: pict.h * Project: libpict 1.1 * Date: Fri, May 19, 1995 * (c) SPDsoft 1992-95 * */ #ifndef PICT_H #define PICT_H /* Definiciones generales */ #define BYTE 1 #define WORD 2 #define P_READ 0 #define P_WRITE 1 #define P_STDI 2 #define P_STDO 3 #define GRAYSCALE 0 #define OPTIMAL 1 #define M_ALPHA 2 #define R_CHAN 3 #define G_CHAN 4 #define B_CHAN 5 /* * Definicion de tipos */ #if defined(__osf__) # define LITEND typedef unsigned char p_byte; typedef unsigned short int p_word; typedef unsigned int p_long; typedef unsigned char U_char; typedef short int S_int; typedef int L_int; typedef unsigned short int US_int; #else typedef unsigned char p_byte; typedef unsigned short int p_word; typedef unsigned long int p_long; typedef unsigned char U_char; typedef short int S_int; typedef long int L_int; typedef unsigned short int US_int; #endif #if defined(__i386__) || defined (M_I86) || defined (_M_IX86) || defined (WIN32) # define LITEND #endif /*********************************************************************/ typedef U_char C_MAP[256][3]; typedef struct { FILE *fp; US_int clr_mode; US_int n_comp; US_int file_mode; US_int image_H, image_W; US_int row_bytes; US_int ctr_size; C_MAP map; U_char *pixels; } PictStruct; typedef PictStruct *Pict; typedef struct { US_int top, left, bottom, right; } PRect; /* size short = 2 bytes */ /* size L_int = 4 bytes */ typedef struct { S_int fpint, fpfrac; } fixedpoint; typedef struct { S_int HeaderOp; /*0C00*/ L_int unk1; /*FFFE0000*/ fixedpoint hres, /* ppp, normal: */ vres; /*00480000*/ PRect fBBox; L_int unk2; } tHeader; typedef struct { S_int clipRectOp; S_int clipSize; PRect clipFrame; } tclipRect; typedef struct { US_int ctIndex; /* 0 .. 255 */ unsigned char ctRed, /* Las componentes*/ ctRedP, /* de la tabla */ ctGreen, /* se repiten por*/ ctGreenP, /* cuestiones de*/ ctBlue, /* alineamiento */ ctBlueP; } colorTable; typedef struct { S_int pixMapOp; /*009A*/ L_int unused; /*000000FF*/ S_int rowBytes; /* ver doc */ PRect bounds; S_int pmVersion; /*0000*/ S_int packType; /*0004 packBytes 0003 packWords*/ L_int packSize; /*00000000*/ fixedpoint hres, vres; S_int pixelType, /*0010*/ pixelSize, cmpCount, cmpSize; L_int planeBytes, /*00000000*/ pmTable, /*00000000*/ pmReserved; /*00000000*/ PRect srcRect, dstRect; S_int mode; /*0040*/ } tpixMap9A; typedef struct { S_int pixMapOp; /*0098*/ S_int rowBytes; /* ver doc */ PRect bounds; S_int pmVersion; /*0000*/ S_int packType; /*0000 raw*/ L_int packSize; /*00000000*/ fixedpoint hres, vres; S_int pixelType, /*0000*/ pixelSize, cmpCount, cmpSize; L_int planeBytes, /*00000000*/ pmTable, /*00000000*/ pmReserved; /*00000000*/ L_int ctSeed; /*00000000*/ S_int ctFlags; /*0000*/ US_int ctSize; /*00ff*/ colorTable ctData[256]; PRect srcRect, dstRect; S_int mode; /*0000*/ } tpixMap98; typedef struct{ char fileHeader[512]; S_int picSize; /*0000*//*indiferente*/ PRect picFrame; S_int versOp, /*0011*/ vers2; /*02FF*/ tHeader pictHeader; tclipRect clipRect; tpixMap9A pixMap9A; } Header9A; /* RGBA32, RGB24, RGB16 */ typedef struct{ char fileHeader[512]; S_int picSize; /*0000*//*indiferente*/ PRect picFrame; S_int versOp, /*0011*/ vers2; /*02FF*/ tHeader pictHeader; tclipRect clipRect; tpixMap98 pixMap98; } Header98; /* Index8, Index4 */ /*********************************************************/ #define PICTF 0 #define PICTR 1 #define PICTG 2 #define PICTB 3 #define PICTA 0 /*********************************************************/ #define M_MONO 0 #define M_RGB8 1 #define M_RGB16 2 #define M_RGB24 3 #define M_RGBA32 4 /*********************************************************/ /* Funciones alto nivel */ #if defined(__STDC__) || defined(THINK_C) Pict pict_read_pict(char *); Pict pict_read_pict_c(char *); Pict pict_24_to_8(Pict, int, int, int); int pict_get_map(Pict, C_MAP); int pict_set_map(Pict, C_MAP); int pict_height(Pict); int pict_width(Pict); int pict_mode(Pict); int pict_n_comp(Pict); U_char *pict_pixels(Pict); void pict_pixel_rgba(Pict,int,int,U_char *,U_char *,U_char *,U_char *); Pict pict_open(char *,int,int,int,int,C_MAP); int pict_put_line(Pict,U_char *); int pict_get_line(Pict,U_char *); int pict_close(Pict); int pict_free(Pict); S_int pack_bytes(U_char *,S_int,FILE *); S_int unpack_bytes(U_char *,S_int,FILE *); int pict_write_header_9A(Pict,US_int,US_int,US_int); int pict_read_header_9A(Pict); int pict_write_header_98(Pict,US_int,US_int,US_int,C_MAP); int pict_read_header_98(Pict,C_MAP); int pict_ctable_98(Pict,C_MAP); #else /* __STDC__ || THINK_C */ Pict pict_read_pict(); Pict pict_read_pict_c(); Pict pict_24_to_8(); int pict_get_map(); int pict_set_map(); int pict_height(); int pict_width(); int pict_mode(); int pict_n_comp(); U_char *pict_pixels(); void pict_pixel_rgba(); Pict pict_open(); int pict_put_line(); int pict_get_line(); int pict_close(); int pict_free(); S_int pack_bytes(); S_int unpack_bytes(); int pict_write_header_9A(); int pict_read_header_9A(); int pict_write_header_98(); int pict_read_header_98(); int pict_ctable_98(); #endif /* __STDC__ || THINK_C */ /*********************************************************/ /* definiciones de bajo nivel */ #ifdef LITEND /* * assert sizeof(unsigned short int)==2 */ #define SWAP_W(a) ((unsigned short int) ( (a<<8) | (a>>8) ) ) #define PUTFRAME(x) { x.top=0;x.left=0; \ x.bottom=SWAP_W(im_H);x.right=SWAP_W(im_W) ;} #define UNUSED_9A 0XFF000000 #define CERO_W 0X0000 #define CERO_L 0x00000000 #define VERSOP 0x1100 #define VERS2 0xff02 #define HEADEROP 0x000c #define UNK1 0x0000feff #define _72PPP_INT 0x4800 #define _72PPP_FRAC 0x0000 #define CLIPRECTOPT 0x0100 #define CLIPSIZE 0x0a00 #define PIXMAP_98 0x9800 #define PIXMAP_9A 0x9a00 #define PIXMODE 0x4000 #define HB_MASK 0x0080 #else /* LITEND */ #define PUTFRAME(x) { x.top=0;x.left=0; \ x.bottom=im_H;x.right=im_W ;} #define UNUSED_9A 0X000000FF #define CERO_W 0X0000 #define CERO_L 0x00000000 #define VERSOP 0x0011 #define VERS2 0x02ff #define HEADEROP 0x0c00 #define UNK1 0xfffe0000 #define _72PPP_INT 0x0048 #define _72PPP_FRAC 0x0000 #define CLIPRECTOPT 0x0001 #define CLIPSIZE 0x000a #define PIXMAP_98 0x0098 #define PIXMAP_9A 0x009a #define PIXMODE 0x0040 #define HB_MASK 0x8000 #endif /* LITEND */ #endif /* PICT_H */