2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef _PNG_DECODER_H_
18 #define _PNG_DECODER_H_
21 #include "common/HereMaps_global.h"
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 */
43 TIZEN_MAPS_BEGIN_NAMESPACE
49 static const int MAX_WIDTH = 5000;
50 static const int MAX_HEIGHT = 5000;
51 static const int MAX_SIZE = 4096000; // 4Mbyte
54 virtual ~PngDecoder(void);
57 * Constructs this instancce with given buffer and length.
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.
65 virtual result Construct(const byte* buffer, int length, MediaPixelFormat pixelFormat);
68 * Decodes current frame and returns decoded data.
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.
76 virtual byte* DecodeN(int& outLength);
79 * Sets the decoding region. @n
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.
87 virtual result SetDecodingRegion(int x, int y, int width, int height);
90 * Gets current dimension of image.
92 * @return An error code
93 * @param[out] width The width of image.
94 * @param[out] height The height of image.
96 virtual result GetDimension(int& width, int& height);
99 * Gets the output pixel format.
101 * @return The output pixel format.
103 virtual MediaPixelFormat GetPixelFormat(void);
105 void PngReadData(void *pngPtr, byte* data, int size);
107 static void PngReadDataStatic(png_structp pngPtr, png_bytep data, png_size_t length);
113 unsigned int __curPos;
114 unsigned int __bufSize;
124 int __decodingRectWidth;
125 int __decodingRectHeight;
126 bool __isDecodeRegionEnabled;
127 MediaPixelFormat __format;
129 }; // class PngDecoder
131 TIZEN_MAPS_END_NAMESPACE