Update to 2.0.0 tree from current Fremantle build
[opencv] / src / highgui / grfmt_exr.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_EXR_H_\r
44 #define _GRFMT_EXR_H_\r
45 \r
46 #ifdef HAVE_ILMIMF\r
47 \r
48 #include <ImfChromaticities.h>\r
49 #include <ImfInputFile.h>\r
50 #include <ImfChannelList.h>\r
51 #include <ImathBox.h>\r
52 #include "grfmt_base.h"\r
53 \r
54 namespace cv\r
55 {\r
56 \r
57 using namespace Imf;\r
58 using namespace Imath;\r
59 \r
60 /* libpng version only */\r
61 \r
62 class ExrDecoder : public BaseImageDecoder\r
63 {\r
64 public:\r
65 \r
66     ExrDecoder();\r
67     ~ExrDecoder();\r
68 \r
69     bool  readData( Mat& img );\r
70     bool  readHeader();\r
71     void  close();\r
72 \r
73     ImageDecoder newDecoder() const;\r
74 \r
75 protected:\r
76     void  UpSample( uchar *data, int xstep, int ystep, int xsample, int ysample );\r
77     void  UpSampleX( float *data, int xstep, int xsample );\r
78     void  UpSampleY( uchar *data, int xstep, int ystep, int ysample );\r
79     void  ChromaToBGR( float *data, int numlines, int step );\r
80     void  RGBToGray( float *in, float *out );\r
81 \r
82     InputFile      *m_file;\r
83     PixelType       m_type;\r
84     Box2i           m_datawindow;\r
85     bool            m_ischroma;\r
86     const Channel  *m_red;\r
87     const Channel  *m_green;\r
88     const Channel  *m_blue;\r
89     Chromaticities  m_chroma;\r
90 };\r
91 \r
92 \r
93 class ExrEncoder : public BaseImageEncoder\r
94 {\r
95 public:\r
96     ExrEncoder();\r
97     ~ExrEncoder();\r
98 \r
99     bool  isFormatSupported( int depth ) const;\r
100     bool  write( const Mat& img, const Vector<int>& params );\r
101     ImageEncoder newEncoder() const;\r
102 };\r
103 \r
104 }\r
105 \r
106 #endif\r
107 \r
108 #endif/*_GRFMT_EXR_H_*/\r