Added transparency support in RGB565 bitmap outputs, for gif decoder.
[framework/osp/image-core.git] / src / FMedia_JpegDecoder.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file   FMedia_JpegDecoder.h
20  * @brief  This is header file for _JpegDecoder.
21  */
22 #ifndef _FMEDIA_INTERNAL_JPEG_DECODER_H_
23 #define _FMEDIA_INTERNAL_JPEG_DECODER_H_
24
25 #include "FMedia_IImageDecoder.h"
26
27 namespace Tizen { namespace Media
28 {
29
30 class _JpegDecoder
31         : public _IImageDecoder
32         , public Tizen::Base::Object
33 {
34 public:
35         static const int MAX_WIDTH = 5000;
36         static const int MAX_HEIGHT = 5000;
37         static const int MAX_SIZE = 4096000;   // 4Mbyte
38
39         /**
40          * This is the default constructor for this class.
41          *
42          * @see   Construct()
43          */
44         _JpegDecoder(void);
45
46         /**
47          * This is the destructor for this class.
48          *
49          * @see   Construct()
50          */
51         virtual ~_JpegDecoder(void);
52
53         /**
54          * Constructs this instancce with given buffer and length.
55          *
56          * @return       An error code
57          * @param[in]  buffer            The buffer that contains compressed data.
58          * @param[in]  length            The length of buffer.
59          * @exception  E_SUCCESS          The method is successful.
60          * @exception  E_INVALID_ARG  The input parameter is invalid.
61          */
62         virtual result Construct(const byte* buffer, int length, MediaPixelFormat pixelFormat);
63
64         /**
65          * Decodes current frame and returns decoded data.
66          *
67          * @return        An error code
68          * @param[out]  outBuf                     The decoded frame buffer.
69          * @param[out]  length                     The length of outBuf.
70          * @exception   E_SUCCESS                       The method is successful.
71          * @exception   E_OUT_OF_MEMORY   Memory is insufficient.
72          * @exception   E_INVALID_DATA     The data is invalid.
73          */
74         virtual result DecodeN(byte*& outBuf, int& length);
75
76         /**
77          * Sets the decoding region. @n
78          *
79          * @return       An error code
80          * @param[in]  rect                                        The decoding region.
81          * @exception  E_SUCCESS                                  The method is successful.
82          * @exception  E_INVALID_ARG                      The input parameter is invalid.
83          * @exception  E_UNSUPPORTED_OPERATION  This method is unsupported.
84          */
85         virtual result SetDecodingRegion(int x, int y, int width, int height);
86
87         /**
88          * Gets current dimension of image.
89          *
90          * @return        An error code
91          * @param[out]  width              The width of image.
92          * @param[out]  height            The height of image.
93          * @param[out]  pitch              The pitch of image in bytes.
94          */
95         virtual result GetDimension(int& width, int& height);
96
97         /**
98          *  Gets the output pixel format.
99          *
100          *  @return                The output pixel format.
101          */
102         virtual MediaPixelFormat GetPixelFormat(void);
103
104         /**
105          *  Sets scale down degree.
106          *
107          *  @return      An error code
108          *  @param[in]  scaleDown                                 The level of scale down.
109          *  @exception  E_SUCCESS                                 The method is successful.
110          *  @exception  E_INVALID_ARG                     The input parameter is invalid.
111          *  @exception  E_UNSUPPORTED_OPERATION This method is unsupported.
112          */
113         virtual result SetScaleDown(int scaleDown);
114
115         /**
116          * Gets the value of given key.
117          *
118          * @return   An error code
119          * @param[in]  key                                        The key of the value.
120          * @param[out] value                                    The output value.
121          * @exception  E_SUCCESS                                The method is successful.
122          * @exception  E_INVALID_ARG                    The input parameter is invalid.
123          * @exception  E_UNSUPPORTED_OPERATION  This method is unsupported.
124          */
125         virtual result GetValue(const Tizen::Base::String& key, Tizen::Base::Object &value);
126
127 private:
128         _JpegDecoder(const _JpegDecoder&);
129         _JpegDecoder& operator =(const _JpegDecoder & __jpegDecoder);
130
131 private:
132         static void JpegErrorExitStatic(struct jpeg_common_struct * decInfo);
133         void JpegErrorExit(void);
134
135         byte* __pSrcBuf;
136         int __srcBufSize;
137         int __srcWidth;
138         int __srcHeight;
139         int __scale;
140         int __decodingRectX;
141         int __decodingRectY;
142         int __decodingRectWidth;
143         int __decodingRectHeight;
144         bool __isDecodeRegionEnabled;
145         struct jpeg_decompress_struct* __pDec;
146         struct jpeg_error_mgr* __pErr;
147         struct __jmp_buf_tag* __pJmp;
148 }; // class _JpegDecoder
149
150
151 };
152 };
153
154 #endif