test_image.h
1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* 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 */