test_image.h 1.37 KB
/*
 * image.h 
 *
 */

#ifndef IMAGE_INCLD
#define IMAGE_INCLD


/*
 * These image type constant have embedded byte size/shift counts in them
 *	type:		bit 0-7
 *	bytes:		bit 8-11
 *	components:	bit 12-15
 *	bit/comp:	bit 16-23
 */

#define	IM_STYPE(x)	(x&0xff)
#define	IM_SBYTE(x)	((x&0xf) << 8)
#define	IM_SCOMP(x)	((x&0xf) << 12)
#define	IM_SBPRC(x)	((x&0xff) << 16)

#define	IM_TYPE(x)	(x&0xff)
#define	IM_BYTE(x)	((x>>8) & 0xf)
#define	IM_COMP(x)	((x>>12) & 0xf)
#define	IM_BPRC(x)	((x>>16) & 0xff)

#define	IM_I8		IM_STYPE(0) | IM_SBYTE(1) | IM_SCOMP(1) | IM_SBPRC(8)
#define	IM_YUV		IM_STYPE(1) | IM_SBYTE(1) | IM_SCOMP(1) | IM_SBPRC(8)
#define	IM_Z8		IM_STYPE(2) | IM_SBYTE(1) | IM_SCOMP(1) | IM_SBPRC(8)
#define	IM_RGBA4444	IM_STYPE(3) | IM_SBYTE(2) | IM_SCOMP(4) | IM_SBPRC(4)
#define IM_RGBA5551	IM_STYPE(4) | IM_SBYTE(2) | IM_SCOMP(4) | IM_SBPRC(5)
#define IM_YUYV		IM_STYPE(5) | IM_SBYTE(2) | IM_SCOMP(2) | IM_SBPRC(8)
#define IM_Z16		IM_STYPE(6) | IM_SBYTE(2) | IM_SCOMP(1) | IM_SBPRC(16)
#define IM_RGBA8888	IM_STYPE(7) | IM_SBYTE(4) | IM_SCOMP(4) | IM_SBPRC(8)

typedef struct {
	int type;
	unsigned char *base;
	int xsize;
	int ysize;
	int lsize;		/* line size */
} Image;

/*
 *  Prototypes
 */

Image *load_image(char *file, Image *image);
void save_image(char *name, Image *image);
void save_cvg(char *name, Image *image);
void dump_image_header(char *name);


#endif /* IMAGE_INCLD */