]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/jpg/imagefile.h
merge
[plan9front.git] / sys / src / cmd / jpg / imagefile.h
1 typedef struct Rawimage Rawimage;
2
3 struct Rawimage
4 {
5         Rectangle       r;
6         uchar   *cmap;
7         int             cmaplen;
8         int             nchans;
9         uchar   *chans[4];
10         int             chandesc;
11         int             chanlen;
12
13         int             fields;         /* defined by format */
14         int             gifflags;       /* gif only; graphics control extension flag word */
15         int             gifdelay;       /* gif only; graphics control extension delay in cs */
16         int             giftrindex;     /* gif only; graphics control extension transparency index */
17         int             gifloopcount;   /* number of times to loop in animation; 0 means forever */
18 };
19
20 enum
21 {
22         /* Channel descriptors */
23         CRGB    = 0,    /* three channels, no map */
24         CYCbCr  = 1,    /* three channels, no map, level-shifted 601 color space */
25         CY      = 2,    /* one channel, luminance */
26         CRGB1   = 3,    /* one channel, map present */
27         CRGBV   = 4,    /* one channel, map is RGBV, understood */
28         CRGB24  = 5,    /* one channel in correct data order for loadimage(RGB24) */
29         CRGBA32 = 6,    /* one channel in correct data order for loadimage(RGBA32) */
30         CYA16   = 7,    /* one channel in correct data order for loadimage(Grey8+Alpha8) */
31         CRGBVA16= 8,    /* one channel in correct data order for loadimage(CMAP8+Alpha8) */
32
33         /* GIF flags */
34         TRANSP  = 1,
35         INPUT   = 2,
36         DISPMASK = 7<<2
37 };
38
39
40 enum{   /* PNG flags */
41         II_GAMMA =      1 << 0,
42         II_COMMENT =    1 << 1,
43 };
44
45 typedef struct ImageInfo {
46         ulong   fields_set;
47         double  gamma;
48         char    *comment;
49 } ImageInfo;
50
51
52 Rawimage**      readjpg(int, int);
53 Rawimage**      Breadjpg(Biobuf *b, int);
54 Rawimage**      readpng(int, int);
55 Rawimage**      Breadpng(Biobuf *b, int);
56 Rawimage**      readgif(int, int);
57 Rawimage**      readpixmap(int, int);
58 Rawimage*       torgbv(Rawimage*, int);
59 Rawimage*       totruecolor(Rawimage*, int);
60 int             writerawimage(int, Rawimage*);
61 void*           _remaperror(char*, ...);
62
63 typedef struct Memimage Memimage;       /* avoid necessity to include memdraw.h */
64
65 char*           startgif(Biobuf*, Image*, int);
66 char*           writegif(Biobuf*, Image*, char*, int, int);
67 void            endgif(Biobuf*);
68 char*           memstartgif(Biobuf*, Memimage*, int);
69 char*           memwritegif(Biobuf*, Memimage*, char*, int, int);
70 void            memendgif(Biobuf*);
71 Image*          onechan(Image*);
72 Memimage*       memonechan(Memimage*);
73
74 char*           writeppm(Biobuf*, Image*, char*);
75 char*           memwriteppm(Biobuf*, Memimage*, char*);
76 Image*          multichan(Image*);
77 Memimage*       memmultichan(Memimage*);
78
79 char*           memwritepng(Biobuf*, Memimage*, ImageInfo*);