1 /*
2  * File:	ximatif.h
3  * Purpose:	TIFF Image Class Loader and Writer
4  */
5 /* === C R E D I T S  &  D I S C L A I M E R S ==============
6  * CxImageTIF (c) 07/Aug/2001 Davide Pizzolato - www.xdp.it
7  * Permission is given by the author to freely redistribute and include
8  * this code in any program as long as this credit is given where due.
9  *
10  * CxImage version 5.99a 08/Feb/2004
11  * See the file history.htm for the complete bugfix and news report.
12  *
13  * Special thanks to Troels Knakkergaard for new features, enhancements and bugfixes
14  *
15  * Special thanks to Abe <God(dot)bless(at)marihuana(dot)com> for MultiPageTIFF code.
16  *
17  * Parts of the code come from FreeImage 2
18  * Design and implementation by
19  * - Floris van den Berg (flvdberg@wxs.nl)
20  * - Herv� Drolon (drolon@iut.univ-lehavre.fr)
21  * - Markus Loibl (markus.loibl@epost.de)
22  * - Luca Piergentili (l.pierge@terra.es)
23  *
24  * LibTIFF is:
25  * Copyright (c) 1988-1997 Sam Leffler
26  * Copyright (c) 1991-1997 Silicon Graphics, Inc.
27  *
28  * COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
29  * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
30  * THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
31  * OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
32  * CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
33  * THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
34  * SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
35  * PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
36  * THIS DISCLAIMER.
37  *
38  * Use at your own risk!
39  * ==========================================================
40  */
41 
42 
43 
44 #if !defined(__ximatif_h)
45 #define __ximatif_h
46 
47 #include "ximage.h"
48 
49 #if CXIMAGE_SUPPORT_TIF
50 
51 #include "../tiff/tiffio.h"
52 
53 class DLL_EXP CxImageTIF: public CxImage
54 {
55 public:
CxImageTIF()56 	CxImageTIF(): CxImage(CXIMAGE_FORMAT_TIF) {m_tif2=NULL; m_multipage=false; m_pages=0;}
57 	~CxImageTIF();
58 
59 	TIFF* TIFFOpenEx(CxFile * hFile);
60 	void  TIFFCloseEx(TIFF* tif);
61 
62 //	bool Load(const char * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_TIF);}
63 //	bool Save(const char * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_TIF);}
64 	bool Decode(CxFile * hFile);
Decode(FILE * hFile)65 	bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); }
66 
67 #if CXIMAGE_SUPPORT_ENCODE
68 	bool Encode(CxFile * hFile, bool bAppend=false);
69 	bool Encode(CxFile * hFile, CxImage ** pImages, int pagecount);
70 	bool Encode(FILE *hFile, bool bAppend=false) { CxIOFile file(hFile); return Encode(&file,bAppend); }
Encode(FILE * hFile,CxImage ** pImages,int pagecount)71 	bool Encode(FILE *hFile, CxImage ** pImages, int pagecount)
72 				{ CxIOFile file(hFile); return Encode(&file, pImages, pagecount); }
73 #endif // CXIMAGE_SUPPORT_ENCODE
74 
75 protected:
76 	void TileToStrip(uint8* out, uint8* in,	uint32 rows, uint32 cols, int outskew, int inskew);
77 	bool EncodeBody(TIFF *m_tif, bool multipage=false, int page=0, int pagecount=0);
78 	TIFF *m_tif2;
79 	bool m_multipage;
80 	int  m_pages;
81 };
82 
83 #endif
84 
85 #endif
86