aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/jpg/imagefile.h
blob: 5f5a487367ef82589d84a5f1db5de8f8e00cb142 (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
typedef struct Rawimage Rawimage;

struct Rawimage
{
	Rectangle	r;
	uchar	*cmap;
	int		cmaplen;
	int		nchans;
	uchar	*chans[4];
	int		chandesc;
	int		chanlen;

	int		fields;    	/* defined by format */
	int		gifflags;	/* gif only; graphics control extension flag word */
	int		gifdelay;	/* gif only; graphics control extension delay in cs */
	int		giftrindex;	/* gif only; graphics control extension transparency index */
	int		gifloopcount;	/* number of times to loop in animation; 0 means forever */
};

enum
{
	/* Channel descriptors */
	CRGB	= 0,	/* three channels, no map */
	CYCbCr	= 1,	/* three channels, no map, level-shifted 601 color space */
	CY	= 2,	/* one channel, luminance */
	CRGB1	= 3,	/* one channel, map present */
	CRGBV	= 4,	/* one channel, map is RGBV, understood */
	CRGB24	= 5,	/* one channel in correct data order for loadimage(RGB24) */
	CRGBA32	= 6,	/* one channel in correct data order for loadimage(RGBA32) */
	CYA16	= 7,	/* one channel in correct data order for loadimage(Grey8+Alpha8) */
	CRGBVA16= 8,	/* one channel in correct data order for loadimage(CMAP8+Alpha8) */

	/* GIF flags */
	TRANSP	= 1,
	INPUT	= 2,
	DISPMASK = 7<<2
};


enum{	/* PNG flags */
	II_GAMMA =	1 << 0,
	II_COMMENT =	1 << 1
};

typedef struct ImageInfo {
	ulong	fields_set;
	double	gamma;
	char	*comment;
} ImageInfo;


Rawimage**	readjpg(int, int);
Rawimage**	Breadjpg(Biobuf *b, int);
Rawimage**	readpng(int, int);
Rawimage**	Breadpng(Biobuf *b, int);
Rawimage**	readgif(int, int);
Rawimage**	readpixmap(int, int);
Rawimage*	torgbv(Rawimage*, int);
Rawimage*	totruecolor(Rawimage*, int);
int		writerawimage(int, Rawimage*);
void*		_remaperror(char*, ...);

#ifndef _MEMDRAW_H_
typedef struct Memimage Memimage;	/* avoid necessity to include memdraw.h */
#endif

char*		startgif(Biobuf*, Image*, int);
char*		writegif(Biobuf*, Image*, char*, int, int);
void		endgif(Biobuf*);
char*		memstartgif(Biobuf*, Memimage*, int);
char*		memwritegif(Biobuf*, Memimage*, char*, int, int);
void		memendgif(Biobuf*);
Image*		onechan(Image*);
Memimage*	memonechan(Memimage*);

char*		writeppm(Biobuf*, Image*, char*);
char*		memwriteppm(Biobuf*, Memimage*, char*);
Image*		multichan(Image*);
Memimage*	memmultichan(Memimage*);

char*		memwritepng(Biobuf*, Memimage*, ImageInfo*);
extern int drawlog2[];