Added transparency support in RGB565 bitmap outputs, for gif decoder.
[framework/osp/image-core.git] / src / FMedia_PngEncoder.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_PngEncoder.h
20  * @brief  This is header file for _PngEncoder.
21  */
22 #ifndef _FMEDIA_INTERNAL_PNG_ENCODER_H_
23 #define _FMEDIA_INTERNAL_PNG_ENCODER_H_
24
25 #include "FMedia_IImageEncoder.h"
26 #include <png.h>
27
28 namespace Tizen { namespace Media
29 {
30
31 class _PngEncoder
32         : public _IImageEncoder
33         , public Tizen::Base::Object
34 {
35 public:
36         static const int MIN_WIDTH = 8;
37         static const int MIN_HEIGHT = 8;
38         static const int MIN_BUF_SIZE = 67;
39         /**
40          * This is the default constructor for this class.
41          *
42          * @see   Construct()
43          */
44         _PngEncoder(void);
45
46         /**
47          * This is the destructor for this class.
48          *
49          * @see   Construct()
50          */
51         virtual ~_PngEncoder(void);
52
53         /**
54          *  Initialize this instance.
55          * @param[in]     dim                           Encode dimension
56          * @param[in]     pixelFormat           Encode pixel format
57          * @param[in]     quality                       Encoding quality
58          */
59         virtual result Construct(int width, int height,
60                                                          MediaPixelFormat srcPixelFormat,
61                                                          MediaPixelFormat& reqPixelFormat,
62                                                          int quality);
63
64         /**
65          * Encodes the image data
66          *
67          * @return               An error code
68          * @param[in]     srcBuf                  Source raw data
69          * @param[in]     srcLength       Source data length
70          * @param[out]   dstBuf                  Encoded destination buffer
71          * @param[out]   dstLength        Destination buffer length
72          *
73          * @exception     E_SUCCESS               The method is successful.
74          * @exception     E_OUT_OF_MEMORY       Memory is insufficient.
75          * @exception     E_INVALID_ARG   The input parameter is invalid.
76          */
77         virtual Tizen::Base::ByteBuffer* EncodeN(const byte* srcBuf, int srcLength);
78
79         /**
80          * Set specific key value to the encoder
81          * @return       An error code
82          * @param[in]  key                       The key to be set
83          * @param[in]  value               The value to be set.
84          */
85         virtual result SetValue(const Tizen::Base::String& key, Tizen::Base::Object &value);
86
87
88         static void PngWriteDataStatic(struct png_struct_def* pngPtr, png_bytep data, png_size_t length);
89
90         static void PngFlushDataStatic(struct png_struct_def* pngPtr);
91
92 private:
93         int __width;
94         int __height;
95         int __quality;
96         MediaPixelFormat __pixelFormat;
97
98 }; // class _PngEncoder
99
100
101 };
102 };
103
104 #endif