e31fb46535e52d1ad14f6104404fe3c2405464e1
[opencv] / src / highgui / grfmt_tiff.h
1 /*M///////////////////////////////////////////////////////////////////////////////////////\r
2 //\r
3 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
4 //\r
5 //  By downloading, copying, installing or using the software you agree to this license.\r
6 //  If you do not agree to this license, do not download, install,\r
7 //  copy or use the software.\r
8 //\r
9 //\r
10 //                           License Agreement\r
11 //                For Open Source Computer Vision Library\r
12 //\r
13 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.\r
14 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.\r
15 // Third party copyrights are property of their respective owners.\r
16 //\r
17 // Redistribution and use in source and binary forms, with or without modification,\r
18 // are permitted provided that the following conditions are met:\r
19 //\r
20 //   * Redistribution's of source code must retain the above copyright notice,\r
21 //     this list of conditions and the following disclaimer.\r
22 //\r
23 //   * Redistribution's in binary form must reproduce the above copyright notice,\r
24 //     this list of conditions and the following disclaimer in the documentation\r
25 //     and/or other materials provided with the distribution.\r
26 //\r
27 //   * The name of the copyright holders may not be used to endorse or promote products\r
28 //     derived from this software without specific prior written permission.\r
29 //\r
30 // This software is provided by the copyright holders and contributors "as is" and\r
31 // any express or implied warranties, including, but not limited to, the implied\r
32 // warranties of merchantability and fitness for a particular purpose are disclaimed.\r
33 // In no event shall the Intel Corporation or contributors be liable for any direct,\r
34 // indirect, incidental, special, exemplary, or consequential damages\r
35 // (including, but not limited to, procurement of substitute goods or services;\r
36 // loss of use, data, or profits; or business interruption) however caused\r
37 // and on any theory of liability, whether in contract, strict liability,\r
38 // or tort (including negligence or otherwise) arising in any way out of\r
39 // the use of this software, even if advised of the possibility of such damage.\r
40 //\r
41 //M*/\r
42 \r
43 #ifndef _GRFMT_TIFF_H_\r
44 #define _GRFMT_TIFF_H_\r
45 \r
46 #include "grfmt_base.h"\r
47 \r
48 namespace cv\r
49 {\r
50 \r
51 // native simple TIFF codec\r
52 enum TiffCompression\r
53 {\r
54     TIFF_UNCOMP = 1,\r
55     TIFF_HUFFMAN = 2,\r
56     TIFF_PACKBITS = 32773\r
57 };\r
58 \r
59 enum TiffByteOrder\r
60 {\r
61     TIFF_ORDER_II = 0x4949,\r
62     TIFF_ORDER_MM = 0x4d4d\r
63 };\r
64 \r
65 \r
66 enum  TiffTag\r
67 {\r
68     TIFF_TAG_WIDTH  = 256,\r
69     TIFF_TAG_HEIGHT = 257,\r
70     TIFF_TAG_BITS_PER_SAMPLE = 258,\r
71     TIFF_TAG_COMPRESSION = 259,\r
72     TIFF_TAG_PHOTOMETRIC = 262,\r
73     TIFF_TAG_STRIP_OFFSETS = 273,\r
74     TIFF_TAG_STRIP_COUNTS = 279,\r
75     TIFF_TAG_SAMPLES_PER_PIXEL = 277,\r
76     TIFF_TAG_ROWS_PER_STRIP = 278,\r
77     TIFF_TAG_PLANAR_CONFIG = 284,\r
78     TIFF_TAG_COLOR_MAP = 320\r
79 };\r
80 \r
81 \r
82 enum TiffFieldType\r
83 {\r
84     TIFF_TYPE_BYTE = 1,\r
85     TIFF_TYPE_SHORT = 3,\r
86     TIFF_TYPE_LONG = 4\r
87 };\r
88 \r
89 \r
90 #ifdef HAVE_TIFF\r
91 \r
92 // libtiff based TIFF codec\r
93 \r
94 class TiffDecoder : public BaseImageDecoder\r
95 {\r
96 public:\r
97     TiffDecoder();\r
98     virtual ~TiffDecoder();\r
99 \r
100     bool  readHeader();\r
101     bool  readData( Mat& img );\r
102     void  close();\r
103 \r
104     size_t signatureLength() const;\r
105     bool checkSignature( const string& signature ) const;\r
106     ImageDecoder newDecoder() const;\r
107 \r
108 protected:\r
109     void* m_tif;\r
110 };\r
111 \r
112 #endif\r
113 \r
114 // ... and writer\r
115 class TiffEncoder : public BaseImageEncoder\r
116 {\r
117 public:\r
118     TiffEncoder();\r
119     virtual ~TiffEncoder();\r
120 \r
121     bool  write( const Mat& img, const vector<int>& params );\r
122     ImageEncoder newEncoder() const;\r
123 \r
124 protected:\r
125     void  writeTag( WLByteStream& strm, TiffTag tag,\r
126                     TiffFieldType fieldType,\r
127                     int count, int value );\r
128 };\r
129 \r
130 }\r
131 \r
132 #endif/*_GRFMT_TIFF_H_*/\r