2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FMedia_ImageImpl.h
20 * @brief This is the header file for the _ImageImpl.
22 #ifndef _FMEDIA_INTERNAL_IMAGE_IMPL_H_
23 #define _FMEDIA_INTERNAL_IMAGE_IMPL_H_
26 #include <FGraphics.h>
28 #include <FMediaImageTypes.h>
29 #include <FMediaTypes.h>
32 namespace Tizen { namespace Media
37 class IImageDecodeUrlEventListener;
39 class _OSP_EXPORT_ _ImageImpl
40 : public Tizen::Base::Object
45 virtual ~_ImageImpl(void);
48 result Construct(void);
51 * Decodes an image file into the decoded bitmap container. @n
52 * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
54 * @see Image::DecodeToBitmapN()
56 static Tizen::Graphics::Bitmap*
57 DecodeToBitmapN(const Tizen::Base::String& srcImagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat);
59 static Tizen::Graphics::Bitmap*
60 DecodeToBitmapN(const Tizen::Base::ByteBuffer& srcImageBuf, Tizen::Graphics::BitmapPixelFormat pixelFormat);
63 * Decodes an image data into the decoded bitmap container with resizing. @n
64 * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
65 * This method retains the aspect ratio of the original image.
67 * @see Image::DecodeToBitmapN()
69 /*static Tizen::Graphics::Bitmap*
70 DecodeToBitmapN(const Tizen::Base::ByteBuffer& srcImageBuf,
71 Tizen::Graphics::BitmapPixelFormat pixelFormat = Tizen::Graphics::BITMAP_PIXEL_FORMAT_ARGB8888,
72 const Tizen::Graphics::Dimension &dim = Tizen::Graphics::Dimension(0, 0),
73 Tizen::Graphics::BufferScaling bufferScaling = Tizen::Graphics::BUFFER_SCALING_AUTO,
74 ImageFormat imgFormat = IMG_FORMAT_NONE, bool keepAspectRatio = true);*/
76 static Tizen::Graphics::Bitmap*
77 DecodeToBitmapN(const Tizen::Base::String& srcImagePath,
78 Tizen::Graphics::BitmapPixelFormat pixelFormat,
79 const Tizen::Graphics::Dimension &destDim,
80 Tizen::Graphics::BufferScaling bufferScaling = Tizen::Graphics::BUFFER_SCALING_AUTO);
82 static Tizen::Graphics::Bitmap*
83 DecodeToBitmapN(const Tizen::Base::ByteBuffer& srcImageBuf,
84 Tizen::Graphics::BitmapPixelFormat pixelFormat,
85 const Tizen::Graphics::Dimension &destDim,
86 Tizen::Graphics::BufferScaling bufferScaling = Tizen::Graphics::BUFFER_SCALING_AUTO);
88 static Tizen::Graphics::Bitmap*
89 DecodeToBitmapN(const Tizen::Base::ByteBuffer& srcImageBuf,
90 Tizen::Graphics::BitmapPixelFormat pixelFormat,
91 const Tizen::Graphics::FloatDimension &destDim);
93 static Tizen::Graphics::Bitmap*
94 DecodeToBitmapN(const Tizen::Base::String& srcImagePath,
95 Tizen::Graphics::BitmapPixelFormat pixelFormat,
96 const Tizen::Graphics::FloatDimension &destDim);
100 * Decodes an image data into the decoded byte buffer container without resizing. @n
101 * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
103 * @see Image::DecodeToBufferN()
105 static Tizen::Base::ByteBuffer*
106 DecodeToBufferN(const Tizen::Base::ByteBuffer& srcImageBuf,
107 Tizen::Graphics::Dimension &restDim,
108 const Tizen::Graphics::Dimension &destDim = Tizen::Graphics::Dimension(0,0),
109 Tizen::Graphics::BitmapPixelFormat pixelFormat = Tizen::Graphics::BITMAP_PIXEL_FORMAT_ARGB8888,
110 ImageFormat imgFormat = IMG_FORMAT_NONE, bool keepAspectRatio = true);
113 * Decodes an image file into the decoded byte buffer container without resizing. @n
114 * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
116 * @see Image::DecodeToBufferN()
118 static Tizen::Base::ByteBuffer*
119 DecodeToBufferN(const Tizen::Base::String& srcImagePath,
120 Tizen::Graphics::Dimension &restDim,
121 const Tizen::Graphics::Dimension &destDim = Tizen::Graphics::Dimension(0,0),
122 Tizen::Graphics::BitmapPixelFormat pixelFormat = Tizen::Graphics::BITMAP_PIXEL_FORMAT_ARGB8888,
123 ImageFormat imgFormat = IMG_FORMAT_NONE, bool keepAspectRatio = true);
127 * Decodes an image file into the decoded byte buffer container without resizing. @n
128 * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
130 * @see Image::DecodeToBufferN()
132 static Tizen::Base::ByteBuffer*
133 DecodeToBufferN(const Tizen::Base::String& srcImagePath,
134 Tizen::Graphics::BitmapPixelFormat pixelFormat,
135 int& imageWidth, int& imageHeight, bool keepAspectRatio = true);
138 * Converts the image file to the specified image format. @n
139 * This is a synchronous method. The converting formats currently supported are JPEG, BMP, and PNG.
141 * @see Image::ConvertToBufferN()
143 static Tizen::Base::ByteBuffer*
144 ConvertToBufferN(const Tizen::Base::String& srcImagePath, ImageFormat destImageFormat);
147 * Encodes the specified bitmap data into a byte buffer. @n
148 * The currently supported encoding formats are JPEG, BMP, and PNG.
150 * @see Image::EncodeToBufferN()
152 static Tizen::Base::ByteBuffer*
153 EncodeToBufferN(const Tizen::Graphics::Bitmap& srcBitmap, ImageFormat destImageFormat);
157 * Encodes the specified bitmap data into a file. @n
158 * The currently supported encoding formats are JPEG, BMP, and PNG.
160 * @see Image::EncodeToFile()
162 static result EncodeToFile(const Tizen::Graphics::Bitmap& srcBitmap,
163 ImageFormat destImageFormat, const Tizen::Base::String& destImagePath,
167 * Recompresses an encoded image file to reduce its size as per the specified limit. @n
168 * The only supported compression format is JPEG.
170 * @see Image::CompressJpeg()
172 static result CompressJpeg(const Tizen::Base::String& srcImagePath,
173 const Tizen::Base::String& destImagePath, int limitSize);
176 * Recompresses an encoded image data to the byte buffer to reduce its data size as per the specified limit. @n
177 * The only supported compression format is JPEG.
179 * @see Image::CompressJpegN()
181 static Tizen::Base::ByteBuffer* CompressJpegN(const Tizen::Base::ByteBuffer& srcImageBuf,
185 * Get image informations
187 * @see Image::GetImageInfo()
189 static result GetImageInfo(const Tizen::Base::String& imagePath, ImageFormat &imgFormat,
190 Tizen::Graphics::Dimension &dim);
195 * @deprecated Use DecodeToBufferN
197 static Tizen::Base::ByteBuffer*
198 DecodeN(const Tizen::Base::String& srcImagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat,
199 int destWidth, int destHeight, bool keepAspectRatio=false);
202 result DecodeUrl(const Tizen::Base::Utility::Uri& srcImageUrl,
203 Tizen::Graphics::BitmapPixelFormat pixelFormat,
204 int destWidth, int destHeight, RequestId& reqId,
205 const IImageDecodeUrlEventListener& listener, long timeout);
209 // static Tizen::Base::ByteBuffer* DecodeN(const Tizen::Base::ByteBuffer& srcImageBuf,
210 // ImageFormat srcImageFormat,
211 // Tizen::Graphics::BitmapPixelFormat pixelFormat,
212 // Tizen::Graphics::Dimension& destDim);
214 // static Tizen::Base::ByteBuffer* DecodeN(const Tizen::Base::ByteBuffer& srcImageBuf,
215 // ImageFormat srcImageFormat,
216 // Tizen::Graphics::BitmapPixelFormat pixelFormat,
217 // int destWidth, int destHeight);
219 // static result DecodeN(const Tizen::Base::ByteBuffer& srcImageBuf,
220 // ImageFormat imgFormat, Tizen::Graphics::BitmapPixelFormat pixelFormat,
221 // byte*&outBuf, int &outLength, Tizen::Graphics::Dimension &dim);
224 static Tizen::Base::ByteBuffer*
225 EncodeToBufferLimitN(const Tizen::Base::ByteBuffer &srcBuf, const Tizen::Graphics::Dimension& dim,
226 MediaPixelFormat pixelFormat, ImageFormat imgFormat, int limit);
228 static Tizen::Base::ByteBuffer*
229 EncodeToBufferQualityN(const Tizen::Base::ByteBuffer &srcBuf,
230 const Tizen::Graphics::Dimension& dim,
231 MediaPixelFormat pixelFormat, ImageFormat imgFormat, int quality);
234 static _ImageImpl* GetInstance(Image* pImage);
235 static const _ImageImpl* GetInstance(const Image* pImage);
239 // static Tizen::Base::ByteBuffer* DecodeToBufferN(const Tizen::Base::String& srcImagePath,
240 // Tizen::Graphics::BitmapPixelFormat pixelFormat,
241 // Tizen::Graphics::Dimension& destDim);
244 // static int GetFilesizeWithLowestQuality(_ImageEncoder &enc, Tizen::Base::ByteBuffer& pOutBuf,
245 // Tizen::Graphics::Dimension& destDim);
248 _ImageImpl(const _ImageImpl& impl);
249 _ImageImpl& operator =(const _ImageImpl& impl);
251 }; // class _ImageImpl