image.h 1.19 KB

/* image.h */

/*
 * 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)

struct Image {
	int type;
	ubyte *base;
	int xsize;
	int ysize;
	int lsize;		/* line size */
	int avg_color;	

	/* current tile info */

	int s;
	int t;
	int w;
	int h;
	int addr;
	} ;