changed attributes of header files
[platform/core/location/maps-plugin-here.git] / inc / engine / graphic / PngDecoder.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #ifndef _PNG_DECODER_H_
18 #define _PNG_DECODER_H_
19
20 #include <png.h>
21 #include "common/HereMaps_global.h"
22
23
24 enum MediaPixelFormat
25 {
26         MEDIA_PIXEL_FORMAT_NONE = 0x0000,     /**< The undefined pixel format */
27         MEDIA_PIXEL_FORMAT_RGB565LE = 0x0001, /**< The RGB565 little-endian format */
28         MEDIA_PIXEL_FORMAT_RGB565BE,          /**< The RGB565 big-endian format */
29         MEDIA_PIXEL_FORMAT_RGB888 = 0x0100,   /**< The RGB888 format */
30         MEDIA_PIXEL_FORMAT_BGR888,            /**< The BGR888 format */
31         MEDIA_PIXEL_FORMAT_RGBA8888,          /**< The RGBA8888 format */
32         MEDIA_PIXEL_FORMAT_BGRA8888,          /**< The BGRA8888 format */
33         MEDIA_PIXEL_FORMAT_YUV420P = 0x0200,  /**< The YUV420 Planar format */
34         MEDIA_PIXEL_FORMAT_NV12,              /**< The NV12 format */
35         MEDIA_PIXEL_FORMAT_NV12_TILE,         /**< The NV12 tiled format */
36         MEDIA_PIXEL_FORMAT_NV21,              /**< The NV21 format */
37         MEDIA_PIXEL_FORMAT_YUV444P,           /**< The YUV444 Planar format */
38         MEDIA_PIXEL_FORMAT_YUYV422,           /**< The YUYV422 format */
39         MEDIA_PIXEL_FORMAT_UYVY422,           /**< The UYVY422 format */
40         MEDIA_PIXEL_FORMAT_GRAY,              /**< The gray pixel format */
41 };
42
43 TIZEN_MAPS_BEGIN_NAMESPACE
44
45 class PngDecoder
46 {
47 public:
48
49         static const int MAX_WIDTH = 5000;
50         static const int MAX_HEIGHT = 5000;
51         static const int MAX_SIZE = 4096000;   // 4Mbyte
52
53         PngDecoder(void);
54         virtual ~PngDecoder(void);
55
56         /**
57          * Constructs this instancce with given buffer and length.
58          *
59          * @return       An error code
60          * @param[in]  buffer            The buffer that contains compressed data.
61          * @param[in]  length            The length of buffer.
62          * @exception  E_SUCCESS          The method is successful.
63          * @exception  E_INVALID_ARG  The input parameter is invalid.
64          */
65         virtual result Construct(const byte* buffer, int length, MediaPixelFormat pixelFormat);
66
67         /**
68          * Decodes current frame and returns decoded data.
69          *
70          * @return       A buffer pointer of decoded data
71          * @param[out] outLength                         The length of outBuf.
72          * @exception  E_SUCCESS                  The method is successful.
73          * @exception  E_OUT_OF_MEMORY  Memory is insufficient.
74          * @exception  E_INVALID_DATA    The data is invalid.
75          */
76         virtual byte* DecodeN(int& outLength);
77
78         /**
79          * Sets the decoding region. @n
80          *
81          * @return       An error code
82          * @param[in]  rect                                      The decoding region.
83          * @exception  E_SUCCESS                                The method is successful.
84          * @exception  E_INVALID_ARG                    The input parameter is invalid.
85          * @exception  E_UNSUPPORTED_OPERATION  This method is unsupported.
86          */
87         virtual result SetDecodingRegion(int x, int y, int width, int height);
88
89         /**
90          * Gets current dimension of image.
91          *
92          * @return        An error code
93          * @param[out]  width   The width of image.
94          * @param[out]  height  The height of image.
95          */
96         virtual result GetDimension(int& width, int& height);
97
98         /**
99          * Gets the output pixel format.
100          *
101          * @return                 The output pixel format.
102          */
103         virtual MediaPixelFormat GetPixelFormat(void);
104
105         void PngReadData(void *pngPtr, byte* data, int size);
106
107         static void PngReadDataStatic(png_structp pngPtr, png_bytep data, png_size_t length);
108 protected:
109
110
111 private:
112         byte* __pBuf;
113         unsigned int __curPos;
114         unsigned int __bufSize;
115
116         png_structp __pPng;
117         png_infop __pInfo;
118
119         int __srcWidth;
120         int __srcHeight;
121         int __scale;
122         int __decodingRectX;
123         int __decodingRectY;
124         int __decodingRectWidth;
125         int __decodingRectHeight;
126         bool __isDecodeRegionEnabled;
127         MediaPixelFormat __format;
128
129 }; // class PngDecoder
130
131 TIZEN_MAPS_END_NAMESPACE
132
133 #endif