aa23d372a1e2db35c97ce56602bdeff3c00ac7c8
[platform/framework/native/image.git] / inc / FMediaImage.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                 FMediaImage.h
20 * @brief                This is the header file for the %Image class.
21 *
22 * This header file contains the declarations of the %Image class.
23 */
24
25 #ifndef _FMEDIA_IMAGE_H_
26 #define _FMEDIA_IMAGE_H_
27
28 // include
29 #include <FBase.h>
30 #include <FGraphics.h>
31 #include <FMediaImageTypes.h>
32 #include <FMediaIImageEventListener.h>
33
34 namespace Tizen { namespace Media
35 {
36
37 /**
38  * @class       Image
39  * @brief       This class is used for handling images.
40  *
41  * @since       2.0
42  * @remarks The minimum dimension is 16x16 for JPEG encoding and 8x8 for PNG encoding.
43  *
44  * The %Image class is used for handling images, including image decoding, encoding, conversion, and JPEG compression. @n
45  *
46  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/media/viewing_processing_still_images.htm">Viewing and Processing Still Images</a>. @n
47  * The following example demonstrates how to use the %Image class for image decoding and encoding.
48  *
49  * @code
50 #include <FBase.h>
51 #include <FIo.h>
52 #include <FApp.h>
53 #include <FGraphics.h>
54 #include <FUi.h>
55 #include <FMedia.h>
56
57 using namespace Tizen::Base;
58 using namespace Tizen::Io;
59 using namespace Tizen::Graphics;
60 using namespace Tizen::Ui::Controls;
61 using namespace Tizen::Media;
62
63 class ImageSample
64         : public Tizen::Ui::Controls::Form
65 {
66 public:
67         result TestDecoding(void);
68         result TestEncoding(void);
69 };
70
71 result
72 ImageSample::TestDecoding(void)
73 {
74         result r = E_SUCCESS;
75         Image img;
76         Bitmap* pBitmap = null;
77         Canvas *pCanvas = null;
78         String filePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/test.jpg";
79
80         img.Construct();
81
82         // Decodes the image
83         pBitmap = img.DecodeN(filePath, BITMAP_PIXEL_FORMAT_RGB565);
84         if (pBitmap == null)
85         {
86                 goto CATCH;
87         }
88
89         // Gets a Canvas instance
90         pCanvas = GetCanvasN();
91         if (pCanvas == null)
92         {
93                 goto CATCH;
94         }
95
96         pCanvas->DrawBitmap(Point(0,0), *pBitmap);
97         pCanvas->Show();
98
99         return r;
100
101 CATCH:
102         if (pCanvas)
103         {
104                 delete pCanvas;
105         }
106         if (pBitmap)
107         {
108                 delete pBitmap;
109         }
110
111         return r;
112 }
113
114 result
115 ImageSample::TestEncoding(void)
116 {
117         result r = E_SUCCESS;
118         Image img;
119         Bitmap* pBitmap = null;
120         String filePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/test.jpg";
121         String dstPath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/test_out.jpg";
122
123         img.Construct();
124
125         pBitmap = img.DecodeN(filePath, BITMAP_PIXEL_FORMAT_RGB565);
126         if (pBitmap == null)
127         {
128                 goto CATCH;
129         }
130
131         r = img.EncodeToFile(*pBitmap, IMG_FORMAT_JPG, dstPath, true);
132         if (IsFailed(r))
133         {
134                 goto CATCH;
135         }
136
137         return r;
138
139 CATCH:
140         if (pBitmap)
141         {
142                 delete pBitmap;
143         }
144
145         return r;
146 }
147
148  * @endcode
149  */
150
151 class _OSP_EXPORT_ Image
152         : public Tizen::Base::Object
153 {
154 public:
155
156         /**
157         * This is the default constructor for this class. @n
158         * The object is not fully constructed after this constructor is called.
159         * For full construction, the Construct() method must be called right after
160         * calling this constructor.
161         *
162         * @since        2.0
163         *
164         * @see      Construct()
165         */
166         Image(void);
167
168         /**
169         * This is the destructor for this class. @n
170         * This destructor overrides Tizen::Base::Object::~Object().
171         *
172         * @since        2.0
173         *
174         * @see      Construct()
175         */
176         virtual ~Image(void);
177
178 public:
179         /**
180         * Initializes this instance of %Image.
181         *
182         * @since                2.0
183         *
184         * @return               An error code
185         * @exception    E_SUCCESS               The method is successful.
186         * @exception    E_OUT_OF_MEMORY The memory is insufficient.
187         * @exception    E_SYSTEM                A system error has occurred.
188         */
189         result Construct(void);
190
191         /**
192         * Decodes an image file into the decoded bitmap container. @n
193         * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
194         *
195         * @if OSPCOMPAT
196         * @brief <i> [Compatibility] </i>
197         * @endif
198         * @since                2.0
199         * @if OSPCOMPAT
200         * @compatibility        This method has compatibility issues with OSP compatible applications. @n
201         *                                       For more information, see @ref CompIoPathPage "here".
202         * @endif
203         *
204         * @return               A decoded bitmap that is not resized
205         * @param[in]    srcImagePath                    The local file path of the image file to open
206         * @param[in]    pixelFormat                             The output pixel format defined by Tizen::Graphics::BitmapPixelFormat
207         * @exception    E_SUCCESS                               The method is successful.
208         * @exception    E_INVALID_ARG                   The specified pixel format is not supported.
209         * @exception    E_INVALID_DATA                  The specified input instance has invalid data.
210         * @exception    E_OVERFLOW                              The specified input instance has overflowed.
211         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
212         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
213         * @exception    E_FILE_NOT_FOUND                The specified file cannot be found or accessed.
214         * @remarks              This method retains the aspect ratio of the original image. @n
215         *                               @c E_OUT_OF_MEMORY can be returned if there is no available memory when decoding a large image. @n
216         *                               The specific error code can be accessed using the GetLastResult() method. @n
217         *                               This method returns an auto-scaled bitmap, @n
218         *                               so the dimension can be different from the dimension of source image if the returned bitmap is locked.
219         */
220         Tizen::Graphics::Bitmap* DecodeN(const Tizen::Base::String& srcImagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat) const;
221
222         /**
223         * Decodes an image file into the decoded bitmap container after resizing it as per the specified width and height. @n
224         * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
225         *
226         * @if OSPCOMPAT
227         * @brief <i> [Compatibility] </i>
228         * @endif
229         * @since                2.0
230         * @if OSPCOMPAT
231         * @compatibility        This method has compatibility issues with OSP compatible applications. @n
232         *                                       For more information, see @ref CompIoPathPage "here".
233         * @endif
234         *
235         * @return               A decoded bitmap data with the specified destination width and height
236         * @param[in]    srcImagePath                    The local file path of the image file to open
237         * @param[in]    pixelFormat                             The output pixel format defined by Tizen::Graphics::BitmapPixelFormat
238         * @param[in]    destWidth                               The intended width of the image @n
239         *                                                                               An exception is returned if the value is less than @c 0.
240         * @param[in]    destHeight                              The intended height of the image @n
241         *                                                                               An exception is returned if the value is less than @c 0.
242         * @exception    E_SUCCESS                               The method is successful.
243         * @exception    E_INVALID_ARG                   The specified pixel format is not supported.
244         * @exception    E_INVALID_DATA                  The specified input instance has invalid data.
245         * @exception    E_OVERFLOW                              The specified input instance has overflowed.
246         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
247         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
248         * @exception    E_FILE_NOT_FOUND                The specified file cannot be found or accessed.
249         * @exception    E_OUT_OF_RANGE                  The specified size is out of range.
250         * @remarks              This method retains the aspect ratio of the original image. @n
251         *                               It supports only the downscaling of an image. @n
252         *                               The specific error code can be accessed using the GetLastResult() method. @n
253         *                               This method returns an auto-scaled bitmap, @n
254         *                               so the dimension can be different from the requested dimension if the returned bitmap is locked.
255         */
256         Tizen::Graphics::Bitmap* DecodeN(const Tizen::Base::String& srcImagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat, int destWidth, int destHeight) const;
257
258         /**
259         * Decodes an image data into the decoded bitmap container after resizing it as per the specified width and height. @n
260         * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP. @n
261         * The %DecodeN() method retains the aspect ratio of the original image.
262         *
263         * @since                2.1
264         *
265         * @return               A decoded bitmap data with the specified destination width and height.
266         * @param[in]    srcImageBuf                             The data to decode
267         * @param[in]    pixelFormat                             The output pixel format defined by Tizen::Graphics::BitmapPixelFormat
268         * @param[in]    destWidth                               The intended width of the image.
269         * @param[in]    destHeight                              The intended height of the image.
270         * @exception    E_SUCCESS                               The method is successful.
271         * @exception    E_INVALID_DATA                  The specified input instance has invalid data.
272         * @exception    E_INVALID_ARG                   The specified pixel format is not supported.
273         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
274         * @exception    E_OBJ_NOT_FOUND                 The specified image buffer cannot be found.
275         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
276         * @remarks
277         *                         - The specific error code can be accessed using the GetLastResult() method.
278         *                         - This method retains the aspect ratio of the original image.
279         *                         - It’s a high probability that the out-of-memory exception occurs. Check the exception as possible if it is E_OUT_OF_MEMORY.
280         *                           Refer to <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">Exception Check</a> and handle the out-of-memory.
281         *                         - This method returns auto scaled bitmap to support logical coordinate system, so the actual dimension of the returned bitmap can be vary depending on the physical dimension of target device.
282         */
283         Tizen::Graphics::Bitmap* DecodeN(const Tizen::Base::ByteBuffer& srcImageBuf, Tizen::Graphics::BitmapPixelFormat pixelFormat, float destWidth, float destHeight) const;
284
285         /**
286         * Decodes an image file into the decoded bitmap container after resizing it as per the specified width and height. @n
287         * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP. @n
288         * The %DecodeN() method retains the aspect ratio of the original image.
289         *
290         * @since                2.1
291         *
292         * @return               A decoded bitmap data with the specified destination width and height.
293         * @param[in]    srcImagePath                    The local file path of the image file to open
294         * @param[in]    pixelFormat                             The output pixel format defined by Tizen::Graphics::BitmapPixelFormat
295         * @param[in]    destWidth                               The intended width of the image.
296         * @param[in]    destHeight                              The intended height of the image.
297         * @exception    E_SUCCESS                               The method is successful.
298         * @exception    E_INVALID_ARG                   The specified pixel format is not supported.
299         * @exception    E_INVALID_DATA                  The specified input instance has invalid data.
300         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
301         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
302         * @exception    E_FILE_NOT_FOUND                The specified file cannot be found or accessed.
303         * @remarks
304         *                         - The specific error code can be accessed using the GetLastResult() method.
305         *                         - This method retains the aspect ratio of the original image.
306         *                         - It’s a high probability that the out-of-memory exception occurs. Check the exception as possible if it is E_OUT_OF_MEMORY.
307         *                           Refer to <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">Exception Check</a> and handle the out-of-memory.
308         *                         - This method returns auto scaled bitmap to support logical coordinate system, so the actual dimension of the returned bitmap can be vary depending on the physical dimension of target device.
309         */
310         Tizen::Graphics::Bitmap* DecodeN(const Tizen::Base::String& srcImagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat, float destWidth, float destHeight) const;
311
312         /**
313         * Decodes an image data into the decoded bitmap as per the specified width and height. @n
314         * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
315         *
316         * @since                2.0
317         *
318         * @return               An error code
319         * @param[in]    srcImageUrl                     The URL of the remote image to decode
320         * @param[in]    pixelFormat                     The output pixel format defined by Tizen::Graphics::BitmapPixelFormat
321         * @param[in]    destWidth                       The intended width of the image @n
322         *                                                                       An exception is returned if the value is less than @c 0.
323         * @param[in]    destHeight                      The intended height of the image @n
324         *                                                                       An exception is returned if the value is less than @c 0.
325         * @param[out]   reqId               The request ID
326         * @param[in]    listener                        An instance of IImageDecodeUrlEventListener
327         * @param[in]    timeout                         The timeout period in milliseconds @n
328         *                                                                       Set to @c TIMEOUT_INFINITE to make the @c timeout period infinite.
329         * @exception    E_SUCCESS                       The method is successful.
330         * @exception    E_INVALID_DATA          The specified input instance has invalid data.
331         * @exception    E_INVALID_ARG           The specified pixel format is not supported.
332         * @exception    E_OUT_OF_RANGE          The specified size is out of range.
333         * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
334         * @exception    E_NETWORK_FAILED        The network is unavailable.
335         * @exception    E_MAX_EXCEEDED          The number of concurrent accesses to the URLs has reached the maximum limit.
336         * @remarks              This method retains the aspect ratio of the original image. @n
337         *                               It supports only the downscaling of an image. @n
338         *                               The maximum limit for downloading is @c 3. @n
339         *                               The supported protocol is HTTP.
340         */
341         result DecodeUrl(const Tizen::Base::Utility::Uri& srcImageUrl, Tizen::Graphics::BitmapPixelFormat pixelFormat, int destWidth, int destHeight, RequestId& reqId, const IImageDecodeUrlEventListener& listener, long timeout) const;
342
343         /**
344         * Decodes an image data into the decoded bitmap container without resizing. @n
345         * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP. The %DecodeN() method retains the
346         * aspect ratio of the original image.
347         *
348         * @since                2.0
349         *
350         * @return               A decoded bitmap data that has not been resized
351         * @param[in]    srcImageBuf                             The data to decode
352         * @param[in]    srcImageFormat                  The image format of the input file
353         * @param[in]    pixelFormat                             The output pixel format defined by Tizen::Graphics::BitmapPixelFormat
354         * @exception    E_SUCCESS                               The method is successful.
355         * @exception    E_INVALID_DATA                  The specified input instance has invalid data.
356         * @exception    E_INVALID_ARG                   The specified pixel format is not supported.
357         * @exception    E_OVERFLOW                              The specified input instance has overflowed.
358         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
359         * @exception    E_OBJ_NOT_FOUND                 The specified image buffer cannot be found.
360         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
361         * @remarks              This method retains the aspect ratio of the original image. @n
362         *                               @c E_OUT_OF_MEMORY is returned if the memory is not available when decoding a large image. @n
363         *                               The specific error code can be accessed using the GetLastResult() method. @n
364         *                               This method returns an auto-scaled bitmap, @n
365         *                               so the dimension can be different from the dimension of source image if the returned bitmap is locked.
366         */
367         Tizen::Graphics::Bitmap* DecodeN(const Tizen::Base::ByteBuffer& srcImageBuf, ImageFormat srcImageFormat, Tizen::Graphics::BitmapPixelFormat pixelFormat) const;
368
369         /**
370         * Decodes an image data into the decoded bitmap container after resizing it as per the specified width and height. @n
371         * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
372         *
373         * @since                2.0
374         *
375         * @return               A decoded bitmap data with the specified destination width and height
376         * @param[in]    srcImageBuf                             The data to decode
377         * @param[in]    srcImageFormat                  The image format of the input file
378         * @param[in]    pixelFormat                             The output pixel format defined by Tizen::Graphics::BitmapPixelFormat
379         * @param[in]    destWidth                               The intended width of the image @n
380         *                                                                               An exception is returned if the value is less than @c 0.
381         * @param[in]    destHeight                              The intended height of the image @n
382         *                                                                               An exception is returned if the value is less than @c 0.
383         * @exception    E_SUCCESS                               The method is successful.
384         * @exception    E_INVALID_ARG                   The specified pixel format is not supported.
385         * @exception    E_INVALID_DATA                  The specified input instance has invalid data.
386         * @exception    E_OVERFLOW                              The specified input instance has overflowed.
387         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
388         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
389         * @exception    E_OBJ_NOT_FOUND                 The specified image buffer cannot be found.
390         * @exception    E_OUT_OF_RANGE                  The specified size is out of range.
391         * @remarks              This method retains the aspect ratio of the original image. @n
392         *                               It supports only the downscaling of an image. @n
393         *                               The specific error code can be accessed using the GetLastResult() method. @n
394         *                               This method returns an auto-scaled bitmap, @n
395         *                               so the dimension can be different from the requested dimension if the returned bitmap is locked.
396         */
397         Tizen::Graphics::Bitmap* DecodeN(const Tizen::Base::ByteBuffer& srcImageBuf, ImageFormat srcImageFormat, Tizen::Graphics::BitmapPixelFormat pixelFormat, int destWidth, int destHeight) const;
398
399         /**
400         * Encodes the specified bitmap data into a byte buffer. @n
401         * The currently supported encoding formats are JPEG, BMP, and PNG.
402         *
403         * @since                2.0
404         *
405         * @return               A byte buffer containing encoded image data
406         * @param[in]    srcBitmap                               The bitmap data to encode
407         * @param[in]    destImageFormat                 The intended image format
408         * @exception    E_SUCCESS                               The method is successful.
409         * @exception    E_OVERFLOW                              The specified input instance has overflowed.
410         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
411         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
412         * @exception    E_OBJ_NOT_FOUND                 The specified bitmap data cannot be found.
413         * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
414         *                               This method uses raw RGB data from locked bitmap, @n
415         *                               so the dimension of encoded data can be different from the dimension of source bitmap if the bitmap is auto-scaled.
416         */
417         Tizen::Base::ByteBuffer* EncodeToBufferN(const Tizen::Graphics::Bitmap& srcBitmap, ImageFormat destImageFormat) const;
418
419         /**
420         * Encodes the specified bitmap data into a file. @n
421         * The currently supported encoding formats are JPEG, BMP, and PNG.
422         *
423         * @if OSPCOMPAT
424         * @brief <i> [Compatibility] </i>
425         * @endif
426         * @since                2.0
427         * @if OSPCOMPAT
428         * @compatibility        This method has compatibility issues with OSP compatible applications. @n
429         *                                       For more information, see @ref CompIoPathPage "here".
430         * @endif
431         *
432         * @return               An error code
433         * @param[in]    srcBitmap                               The bitmap data to encode
434         * @param[in]    destImageFormat                 The intended image format
435         * @param[in]    destImagePath                   The intended name of encoded image file @n
436         *                                                                       The available paths start with prefixes retrieved from the functions such as: @n
437         *                                                                       Tizen::App::App::GetInstance()->GetAppRootPath() @n
438         *                                                                       Tizen::System::Environment::GetMediaPath() @n
439         *                                                                       Tizen::System::Environment::GetExternalStoragePath()
440         * @param[in]    overwrite                               Set to @c true to overwrite the file, @n
441         *                                                                               else @c false
442         * @exception    E_SUCCESS                               The method is successful.
443         * @exception    E_OVERFLOW                              The specified input instance has overflowed.
444         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
445         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
446         * @exception    E_FILE_NOT_FOUND                The specified file cannot be found or accessed.
447         * @exception    E_OBJ_NOT_FOUND                 The specified bitmap data cannot be found.
448         * @exception    E_FILE_ALREADY_EXIST    The specified file already exists.
449         * @exception    E_SYSTEM                                A system error has occurred.
450         * @exception    E_STORAGE_FULL          The storage is full.
451         * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
452         *                               The application should use Tizen::Content::ContentManager::CreateContent() to register the created file into the Contents database. @n
453         *                               This method uses raw RGB data from locked bitmap, @n
454         *                               so the dimension of encoded data can be different from the dimension of source bitmap if the bitmap is auto-scaled.
455         */
456         result EncodeToFile(const Tizen::Graphics::Bitmap& srcBitmap, ImageFormat destImageFormat, const Tizen::Base::String& destImagePath, bool overwrite) const;
457
458         /**
459         * Converts the image file to the specified image format. @n
460         * This is a synchronous method. The converting formats currently supported are JPEG, BMP, and PNG.
461         *
462         * @if OSPCOMPAT
463         * @brief <i> [Compatibility] </i>
464         * @endif
465         * @since                2.0
466         * @if OSPCOMPAT
467         * @compatibility        This method has compatibility issues with OSP compatible applications. @n
468         *                                       For more information, see @ref CompIoPathPage "here".
469         * @endif
470         *
471         * @return               The byte buffer containing image data
472         * @param[in]    srcImagePath                    The local file path of the image file to open
473         * @param[in]    destImageFormat                 The intended image format
474         * @exception    E_SUCCESS                               The method is successful.
475         * @exception    E_INVALID_DATA                  The specified input instance has invalid data.
476         * @exception    E_OVERFLOW                              The specified input instance has overflowed.
477         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
478         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
479         * @exception    E_FILE_NOT_FOUND                The specified file cannot be found or accessed.
480         * @remarks      The specific error code can be accessed using the GetLastResult() method.
481         */
482         Tizen::Base::ByteBuffer* ConvertN(const Tizen::Base::String& srcImagePath, ImageFormat destImageFormat) const;
483
484         /**
485         * @if OSPDEPREC
486         * @{
487         * Compresses an encoded image file to reduce its size as per the specified limit. @n
488         * The only supported compression format is JPEG.
489         *
490         * @if OSPCOMPAT
491         * @brief <i> [Deprecated] [Compatibility] </i>
492         * @deprecated  This method is deprecated.
493         * @endif
494         * @since                2.0
495         * @if OSPCOMPAT
496         * @compatibility        This method has compatibility issues with OSP compatible applications. @n
497         *                                       For more information, see @ref CompIoPathPage "here".
498         * @endif
499         *
500         * @return               An error code
501         * @param[in]    srcImagePath                    The local file path of the image file to open
502         * @param[in]    destImagePath                   The destination file path @n
503         *                                                                               If the file already exists, it is overwritten. @n
504         *                                                                               The available paths start with prefix such as: @n
505         *                                                                               Tizen::App::App::GetInstance()->GetAppRootPath() @n
506         *                                                                               Tizen::System::Environment::GetMediaPath() @n
507         *                                                                               Tizen::System::Environment::GetExternalStoragePath()
508         * @param[in]    limitSize                               The maximum compressed data size in bytes @n
509         *                                                                               If the data size is too small, the width and height of the original
510         *                                                                               image can be reduced. @n The size must be less than the original size
511         *                                                                               and greater than @c 1024 byte.
512         * @exception    E_SUCCESS                               The method is successful.
513         * @exception    E_OVERFLOW                              The specified input instance has overflowed.
514         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
515         * @exception    E_FILE_NOT_FOUND                The specified file cannot be found or accessed.
516         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
517         * @exception    E_SYSTEM                                A system error has occurred.
518         * @exception    E_STORAGE_FULL          The file cannot be created because the file has reached its size limit.
519         * @exception    E_OUT_OF_RANGE                  The specified size is out of range.
520         * @}
521         * @endif
522         */
523         result CompressJpeg(const Tizen::Base::String& srcImagePath, const Tizen::Base::String& destImagePath, int limitSize) const;
524
525         /**
526         * @if OSPDEPREC
527         * Compresses an encoded image data to the byte buffer to reduce its data size as per the specified limit. @n
528         * The only supported compression format is JPEG.
529         *
530         * @brief <i> [Deprecated] </i>
531         * @deprecated  This method is deprecated.
532         * @since                2.0
533         *
534         * @return               A byte buffer containing the compressed image data as per the specified size
535         * @param[in]    srcImageBuf                             The encoded image source in the byte buffer
536         * @param[in]    limitSize                               The limit size to compress in bytes @n
537         *                                                                               The size must be less than the original size and greater than @c 1024 bytes.
538         * @exception    E_SUCCESS                               The method is successful.
539         * @exception    E_OVERFLOW                              The specified input instance has overflowed.
540         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
541         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
542         * @exception    E_OBJ_NOT_FOUND                 The specified image buffer cannot be found.
543         * @exception    E_SYSTEM                                A system error has occurred.
544         * @exception    E_OUT_OF_RANGE                  The specified size is out of range.
545         * @remarks              The specific error code can be accessed using the GetLastResult() method.
546         * @endif
547         */
548         Tizen::Base::ByteBuffer* CompressJpegN(const Tizen::Base::ByteBuffer& srcImageBuf, int limitSize) const;
549
550         /**
551         * Decodes an image data into the decoded byte buffer container without resizing. @n
552         * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
553         *
554         * @since                2.0
555         *
556         * @return               A decoded byte data that is not resized, @n
557         *                               else @c null if an exception occurs
558         * @param[in]    srcImageBuf                             The data to decode
559         * @param[in]    srcImageFormat                  The image format of the input data
560         * @param[in]    pixelFormat                             The output pixel format defined by Tizen::Graphics::BitmapPixelFormat
561         * @param[out]   imageWidth                      The original width of the image @n
562         *                                                                               An exception is returned if the value is less than @c 0.
563         * @param[out]   imageHeight                     The original height of the image @n
564         *                                                                               An exception is returned if the value is less than @c 0.
565         * @exception    E_SUCCESS                               The method is successful.
566         * @exception    E_INVALID_ARG                   The specified color format is not supported.
567         * @exception    E_INVALID_DATA                  The specified input instance has invalid data.
568         * @exception    E_OVERFLOW                              The specified input instance has overflowed.
569         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
570         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
571         * @exception    E_OBJ_NOT_FOUND                 The specified media buffer cannot be found.
572         * @remarks              The specific error code can be accessed using the GetLastResult() method.
573         */
574         Tizen::Base::ByteBuffer* DecodeToBufferN(const Tizen::Base::ByteBuffer& srcImageBuf, ImageFormat srcImageFormat, Tizen::Graphics::BitmapPixelFormat pixelFormat, int& imageWidth, int& imageHeight) const;
575
576         /**
577         * Decodes an image file into the decoded byte buffer container without resizing. @n
578         * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
579         *
580         * @if OSPCOMPAT
581         * @brief <i> [Compatibility] </i>
582         * @endif
583         * @since                2.0
584         * @if OSPCOMPAT
585         * @compatibility        This method has compatibility issues with OSP compatible applications. @n
586         *                                       For more information, see @ref CompIoPathPage "here".
587         * @endif
588         *
589         * @return               A decoded byte data that is not resized, @n
590         *                               else @c null if an exception occurs
591         * @param[in]    srcImagePath                    The local file path of the image file to decode
592         * @param[in]    pixelFormat                             The output pixel format defined by Tizen::Graphics::BitmapPixelFormat
593         * @param[out]   imageWidth                      The original width of the image @n
594         *                                                                               An exception is returned if the value is less than @c 0.
595         * @param[out]   imageHeight                     The original height of the image @n
596         *                                                                               An exception is returned if the value is less than @c 0.
597         * @exception    E_SUCCESS                               The method is successful.
598         * @exception    E_INVALID_ARG                   The specified color format is not supported.
599         * @exception    E_INVALID_DATA                  The specified input instance has invalid data.
600         * @exception    E_OVERFLOW                              The specified input instance has overflowed.
601         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
602         * @exception    E_FILE_NOT_FOUND                The specified file cannot be found or accessed.
603         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
604         * @remarks              The specific error code can be accessed using the GetLastResult() method.
605         */
606         Tizen::Base::ByteBuffer* DecodeToBufferN(const Tizen::Base::String& srcImagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat, int& imageWidth, int& imageHeight) const;
607
608         /**
609          * Sets the timeout interval to infinity.
610          *
611          * @since       2.0
612          */
613         static const int TIMEOUT_INFINITE = 0;
614
615
616         /**
617         * Gets the format of the image in the specified file.
618         *
619         * @if OSPCOMPAT
620         * @brief <i> [Compatibility] </i>
621         * @endif
622         * @since                2.0
623         * @if OSPCOMPAT
624         * @compatibility        This method has compatibility issues with OSP compatible applications. @n
625         *                                       For more information, see @ref CompIoPathPage "here".
626         * @endif
627         *
628         * @return               The format of the image
629         * @param[in]    srcImagePath                    The local path of the image file
630         * @exception    E_SUCCESS                               The method is successful.
631         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
632         * @exception    E_SYSTEM                                A system error has occurred.
633         * @exception    E_FILE_NOT_FOUND                The specified file cannot be found or accessed.
634         * @remarks              The specific error code can be accessed using the GetLastResult() method.
635         */
636         Tizen::Media::ImageFormat GetImageFormat(const Tizen::Base::String& srcImagePath) const;
637
638         /**
639         * Gets the image format from an image buffer.
640         *
641         * @since                2.0
642         *
643         * @return               The format of the image
644         * @param[in]    srcImageBuf                             The Tizen::Base::ByteBuffer containing the image data
645         * @exception    E_SUCCESS                               The method is successful.
646         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
647         * @exception    E_OBJ_NOT_FOUND                 The specified image buffer cannot be found.
648         * @exception    E_SYSTEM                                A system error has occurred.
649         * @remarks              The specific error code can be accessed using the GetLastResult() method.
650         */
651         Tizen::Media::ImageFormat GetImageFormat(const Tizen::Base::ByteBuffer& srcImageBuf) const;
652
653         /**
654         * Checks whether the specified image file has alpha channels. @n
655         * Currently only 32-bit PNG images are supported.
656         *
657         * @if OSPCOMPAT
658         * @brief <i> [Compatibility] </i>
659         * @endif
660         * @since                2.0
661         * @if OSPCOMPAT
662         * @compatibility        This method has compatibility issues with OSP compatible applications. @n
663         *                                       For more information, see @ref CompIoPathPage "here".
664         * @endif
665         *
666         * @return               @c true if the image has alpha channels, @n
667         *                               else @c false
668         * @param[in]    srcImagePath                    The local file path of the image file
669         * @exception    E_SUCCESS                               The method is successful.
670         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
671         * @exception    E_FILE_NOT_FOUND                The specified image file cannot be found.
672         * @exception    E_SYSTEM                                A system error has occurred.
673         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
674         * @remarks              The specific error code can be accessed using the GetLastResult() method.
675         */
676         bool HasAlphaChannels(const Tizen::Base::String& srcImagePath) const;
677
678         /**
679         * Checks whether the specified image buffer has alpha channels. @n
680         * Currently only 32-bit PNG images are supported.
681         *
682         * @since                2.0
683         *
684         * @return               @c true if the image has alpha channels, @n
685         *                               else @c false
686         * @param[in]    srcImageBuf                             The Tizen::Base::ByteBuffer containing the image data
687         * @exception    E_SUCCESS                               The method is successful.
688         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
689         * @exception    E_OBJ_NOT_FOUND                 The specified image buffer cannot be found.
690         * @exception    E_SYSTEM                                A system error has occurred.
691         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
692         * @remarks              The specific error code can be accessed using the GetLastResult() method.
693         */
694         bool HasAlphaChannels(const Tizen::Base::ByteBuffer& srcImageBuf) const;
695
696 private:
697
698         /**
699         * The implementation of this copy constructor is intentionally blank
700         * and declared as private to prohibit copying of objects.
701         */
702         Image(const Image& image);
703
704         /**
705         * The implementation of this copy assignment operator is intentionally blank
706         * and declared as private to prohibit copying of objects.
707         */
708         Image& operator =(const Image& image);
709
710 private:
711         class _ImageImpl* __pImageImpl;
712         friend class _ImageImpl;
713
714 }; // class Image
715
716 };
717 };  // Tizen::Media
718
719 #endif