Plan 9 from Bell Labs’s /usr/web/sources/contrib/quanstro/src/tiff/tiff.h

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


typedef enum {
	BE,
	LE,
} End;

typedef enum {
	Izero,
	Ibyte,
	Iascii,
	Ishort,
	Ilong,
	Irat,
	Isbyte,
	Iundef,
	Isshort,
	Islong,
	Israt,
	Ifloat,
	Idbl,
	Iinfinite,
} IFDtype;

typedef struct {
	ulong n;
	ulong d;
} Rational;

// IFDS are ARRAYS
typedef struct {
	int 	tag;
	IFDtype	type;
	ulong 	n;
	uchar	roffset[4];
	ulong 	offset;
	union {
		char	*cp;
		short	*sp;
		long	*lp;
		Rational	*rp;
		double	*dp;
	};
} IFD;

typedef struct {
	End 	order;
	ulong 	ifd0;

	int 	n;
	int	alloc;
	IFD	*ifds;
	int	bpp;	// derived.
	uchar	*rawimge;
	uchar	*rawimg;
} Tiff;

typedef enum {
	Zzero 	= 1,
	Zccitt,
	Zgroup3,
	Zgroup4,
	Zlzw,
	Zjpeg,
	Zpack 	= 32773,
} Ztype;

typedef enum {
	Pwhitezero,
	Pblackzero,
	Prgb,
	Prgbcmap,
	Prgba,
	Pcmyk,
	PYCbCr,
	PCIELab,
} Ptype;

typedef enum {
	Tsubfiletype	= 0x0fe,		// long
	Twidth		= 0x100,
	Tlength		= 0x101,
	Tbitspersample	= 0x102,
	Tcompression	= 0x103,
	Tphotometric	= 0x106,
	Tthresholding	= 0x107,
	Tcellwidth	= 0x108,
	Tcelllength	= 0x109,
	Thwmodel	= 0x110,
	Tfillorder	= 0x10a,
	Timagedesc	= 0x10e,

	Tstripoffsets	= 0x111,
	Torientation	= 0x112,
	Tsamplespp	= 0x115,
	Trowsperstrip	= 0x116,
	Tstripbytecounts	= 0x117,		// AFTER compression

	Txresolution	= 0x11a,		// Rational
	Tyresolution	= 0x11b,
	Tplanarconf	= 0x11c,

	Tresolutionunit	= 0x128,
	Tpageno		= 0x129,
	Tsoftware	= 0x131,
	Tdatetime	= 0x132,
	Tartist		= 0x13b,
	Tcomputer	= 0x13c,
	Tpredictor	= 0x13d,
	Tcolormap	= 0x140,
	Textrasamples	= 0x152,		// 1 == premult α, 2 matte
//	Tcopyright	= 0x8298,

	Tend,
} Itype;

#define debug(...)	if(dflag) fprint(2, __VA_ARGS__)
extern int dflag;
extern int rflag;

long Btiffshorts(Biobuf *b, short *p, int n, End o);
long Btifflongs(Biobuf *b, long *p, int n, End o);

int tiffexpand(Tiff*);
long tiffimglen(Tiff*);
char* tiffzstr(ushort);
int tiffunz(Tiff *, ushort, Biobuf*, int);
int tiffhuff(Biobuf *, uchar *, int, int, ulong);
long lookifd(Tiff *, int);
IFD* lookifdptr(Tiff *, Itype);
long ifdidx(IFD*, int);
ulong tiffchan(Tiff *t);
char* tiffchantostr(Tiff *t, char *s);
void dirty(Tiff*);

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.