4bb12072e3bfeee86b9c15736e4e204515490e4d
[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 for JPEG encoding is 16x16 and for PNG encoding is 8x8.
43  *
44  * The %Image class is used for handling images, including image decoding, encoding, and conversion. @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 the image file into the decoded bitmap container. @n
193         * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP. @n
194         * The %DecodeN() method retains the aspect ratio of the original image.
195         *
196         * @if OSPCOMPAT
197         * @brief                <i> [Compatibility] </i>
198         * @endif
199         * @since                2.0
200         * @if OSPCOMPAT
201         * @compatibility        This method has compatibility issues with OSP compatible applications. @n
202         *                                       For more information, see @ref CompIoPathPage "here".
203         * @endif
204         *
205         * @return               The decoded bitmap that is not resized
206         * @param[in]    srcImagePath                    The local file path of the image file to open
207         * @param[in]    pixelFormat                             The output pixel format defined by Tizen::Graphics::BitmapPixelFormat
208         * @exception    E_SUCCESS                               The method is successful.
209         * @exception    E_INVALID_ARG                   The specified @c pixelFormat is not supported.
210         * @exception    E_INVALID_DATA                  The specified input instance has invalid data.
211         * @exception    E_OVERFLOW                              The specified input instance has overflowed.
212         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
213         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
214         * @exception    E_FILE_NOT_FOUND                The specified file cannot be found or accessed.
215         * @remarks
216         *                         - @c E_OUT_OF_MEMORY is returned if there is no available memory for decoding a large image.
217         *                         - The specific error code can be accessed using the GetLastResult() method.
218         *                         - This method returns an auto-scaled bitmap, @n
219         *                         so the dimension can be different from the dimension of the source image, if the returned bitmap is locked.
220         */
221         Tizen::Graphics::Bitmap* DecodeN(const Tizen::Base::String& srcImagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat) const;
222
223         /**
224         * Decodes the image file into the decoded bitmap container after resizing it as per the specified width and height. @n
225         * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP. @n
226         * The %DecodeN() method retains the aspect ratio of the original image. @n
227         * It supports only the downscaling of the image.
228         *
229         * @if OSPCOMPAT
230         * @brief                <i> [Compatibility] </i>
231         * @endif
232         * @since                2.0
233         * @if OSPCOMPAT
234         * @compatibility        This method has compatibility issues with OSP compatible applications. @n
235         *                                       For more information, see @ref CompIoPathPage "here".
236         * @endif
237         *
238         * @return               The decoded bitmap data with the specified destination width and height
239         * @param[in]    srcImagePath                    The local file path of the image file to open
240         * @param[in]    pixelFormat                             The output pixel format defined by Tizen::Graphics::BitmapPixelFormat
241         * @param[in]    destWidth                               The intended width of the image @n
242         *                                                                               An exception is returned if the value is less than @c 0.
243         * @param[in]    destHeight                              The intended height of the image @n
244         *                                                                               An exception is returned if the value is less than @c 0.
245         * @exception    E_SUCCESS                               The method is successful.
246         * @exception    E_INVALID_ARG                   The specified @c pixelFormat is not supported.
247         * @exception    E_INVALID_DATA                  The specified input instance has invalid data.
248         * @exception    E_OVERFLOW                              The specified input instance has overflowed.
249         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
250         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
251         * @exception    E_FILE_NOT_FOUND                The specified file cannot be found or accessed.
252         * @exception    E_OUT_OF_RANGE                  The specified size is out of the valid range.
253         * @remarks
254         *                         - The specific error code can be accessed using the GetLastResult() method.
255         *                         - This method returns an auto-scaled bitmap, @n
256         *                         so the dimension can be different from the requested dimension, if the returned bitmap is locked.
257         */
258         Tizen::Graphics::Bitmap* DecodeN(const Tizen::Base::String& srcImagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat, int destWidth, int destHeight) const;
259
260         /**
261         * Decodes the image data into the decoded bitmap container after resizing it as per the specified width and height. @n
262         * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP. @n
263         * The %DecodeN() method retains the aspect ratio of the original image.
264         *
265         * @since                2.1
266         *
267         * @return               The decoded bitmap data with the specified destination width and height
268         * @param[in]    srcImageBuf                             The data to decode
269         * @param[in]    pixelFormat                             The output pixel format defined by Tizen::Graphics::BitmapPixelFormat
270         * @param[in]    destWidth                               The intended width of the image
271         * @param[in]    destHeight                              The intended height of the image
272         * @exception    E_SUCCESS                               The method is successful.
273         * @exception    E_INVALID_DATA                  The specified input instance has invalid data.
274         * @exception    E_INVALID_ARG                   The specified @c pixelFormat is not supported.
275         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
276         * @exception    E_OBJ_NOT_FOUND                 The specified image buffer cannot be found.
277         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
278         * @remarks
279         *                         - The specific error code can be accessed using the GetLastResult() method.
280         *                         - There is a high probability for an occurrence of an out-of-memory exception. If possible, check whether the exception is 
281         *                       @c E_OUT_OF_MEMORY or not. For more information on how to handle the out-of-memory exception, 
282         *                       refer <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
283         *                         - This method returns an auto-scaled bitmap to support the logical coordinate system, so the actual dimension of the returned bitmap can 
284         *                         vary depending on the physical dimension of the target device.
285         */
286         Tizen::Graphics::Bitmap* DecodeN(const Tizen::Base::ByteBuffer& srcImageBuf, Tizen::Graphics::BitmapPixelFormat pixelFormat, float destWidth, float destHeight) const;
287
288         /**
289         * Decodes the image file into the decoded bitmap container after resizing it as per the specified width and height. @n
290         * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP. @n
291         * The %DecodeN() method retains the aspect ratio of the original image.
292         *
293         * @since                2.1
294         *
295         * @return               The decoded bitmap data with the specified destination width and height
296         * @param[in]    srcImagePath                    The local file path of the image file to open
297         * @param[in]    pixelFormat                             The output pixel format defined by Tizen::Graphics::BitmapPixelFormat
298         * @param[in]    destWidth                               The intended width of the image
299         * @param[in]    destHeight                              The intended height of the image
300         * @exception    E_SUCCESS                               The method is successful.
301         * @exception    E_INVALID_ARG                   The specified @c pixelFormat is not supported.
302         * @exception    E_INVALID_DATA                  The specified input instance has invalid data.
303         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
304         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
305         * @exception    E_FILE_NOT_FOUND                The specified file cannot be found or accessed.
306         * @remarks
307         *                         - The specific error code can be accessed using the GetLastResult() method.
308         *                         - There is a high probability for an occurrence of an out-of-memory exception. If possible, check whether the exception is @c E_OUT_OF_MEMORY 
309         *                       or not. For more information on how to handle the out-of-memory exception, 
310         *                       refer <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
311         *                         - This method returns an auto-scaled bitmap to support the logical coordinate system, so the actual dimension of the returned bitmap can 
312         *                         vary depending on the physical dimension of the target device.
313         */
314         Tizen::Graphics::Bitmap* DecodeN(const Tizen::Base::String& srcImagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat, float destWidth, float destHeight) const;
315
316         /**
317         * Decodes the image data into the decoded bitmap as per the specified width and height. @n
318         * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP. @n
319         * The %DecodeUrl() method retains the aspect ratio of the original image. @n
320         * It supports only the downscaling of the image.
321         *
322         * @since                2.0
323         *
324         * @return               An error code
325         * @param[in]    srcImageUrl                     The URL of the remote image to decode
326         * @param[in]    pixelFormat                     The output pixel format defined by Tizen::Graphics::BitmapPixelFormat
327         * @param[in]    destWidth                       The intended width of the image @n
328         *                                                                       An exception is returned if the value is less than @c 0.
329         * @param[in]    destHeight                      The intended height of the image @n
330         *                                                                       An exception is returned if the value is less than @c 0.
331         * @param[out]   reqId               The request ID
332         * @param[in]    listener                        An instance of IImageDecodeUrlEventListener
333         * @param[in]    timeout                         The timeout period in milliseconds @n
334         *                                                                       Set to @c TIMEOUT_INFINITE to make the @c timeout period infinite.
335         * @exception    E_SUCCESS                       The method is successful.
336         * @exception    E_INVALID_DATA          The specified input instance has invalid data.
337         * @exception    E_INVALID_ARG           The specified @c pixelFormat is not supported.
338         * @exception    E_OUT_OF_RANGE          The specified size is out of the valid range.
339         * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
340         * @exception    E_NETWORK_FAILED        The network is unavailable.
341         * @exception    E_MAX_EXCEEDED          The number of concurrent accesses to the URLs have reached the maximum limit.
342         * @remarks
343         *                         - The maximum limit for downloading is @c 3.
344         *                         - The supported protocol is HTTP.
345         */
346         result DecodeUrl(const Tizen::Base::Utility::Uri& srcImageUrl, Tizen::Graphics::BitmapPixelFormat pixelFormat, int destWidth, int destHeight, RequestId& reqId, const IImageDecodeUrlEventListener& listener, long timeout) const;
347
348         /**
349         * Decodes the image data into the decoded bitmap container without resizing. @n
350         * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP. @n
351         * The %DecodeN() method retains the aspect ratio of the original image.
352         *
353         * @since                2.0
354         *
355         * @return               The decoded bitmap data that has not been resized
356         * @param[in]    srcImageBuf                             The data to decode
357         * @param[in]    srcImageFormat                  The image format of the input file
358         * @param[in]    pixelFormat                             The output pixel format defined by Tizen::Graphics::BitmapPixelFormat
359         * @exception    E_SUCCESS                               The method is successful.
360         * @exception    E_INVALID_DATA                  The specified input instance has invalid data.
361         * @exception    E_INVALID_ARG                   The specified @c pixelFormat is not supported.
362         * @exception    E_OVERFLOW                              The specified input instance has overflowed.
363         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
364         * @exception    E_OBJ_NOT_FOUND                 The specified image buffer cannot be found.
365         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
366         * @remarks
367         *                         - @c E_OUT_OF_MEMORY is returned if there is no available memory for decoding a large image.
368         *                         - The specific error code can be accessed using the GetLastResult() method.
369         *                         - This method returns an auto-scaled bitmap, @n
370         *                         so the dimension can be different from the dimension of the source image if the returned bitmap is locked.
371         */
372         Tizen::Graphics::Bitmap* DecodeN(const Tizen::Base::ByteBuffer& srcImageBuf, ImageFormat srcImageFormat, Tizen::Graphics::BitmapPixelFormat pixelFormat) const;
373
374         /**
375         * Decodes the image data into the decoded bitmap container after resizing it as per the specified width and height. @n
376         * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP. @n
377         * The %DecodeN() method retains the aspect ratio of the original image. @n
378         * It supports only the downscaling of the image.
379         *
380         * @since                2.0
381         *
382         * @return               The decoded bitmap data with the specified destination width and height
383         * @param[in]    srcImageBuf                             The data to decode
384         * @param[in]    srcImageFormat                  The image format of the input file
385         * @param[in]    pixelFormat                             The output pixel format defined by Tizen::Graphics::BitmapPixelFormat
386         * @param[in]    destWidth                               The intended width of the image @n
387         *                                                                               An exception is returned if the value is less than @c 0.
388         * @param[in]    destHeight                              The intended height of the image @n
389         *                                                                               An exception is returned if the value is less than @c 0.
390         * @exception    E_SUCCESS                               The method is successful.
391         * @exception    E_INVALID_ARG                   The specified @c pixelFormat is not supported.
392         * @exception    E_INVALID_DATA                  The specified input instance has invalid data.
393         * @exception    E_OVERFLOW                              The specified input instance has overflowed.
394         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
395         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
396         * @exception    E_OBJ_NOT_FOUND                 The specified image buffer cannot be found.
397         * @exception    E_OUT_OF_RANGE                  The specified size is out of the valid range.
398         * @remarks
399         *                         - The specific error code can be accessed using the GetLastResult() method.
400         *                         - This method returns an auto-scaled bitmap, @n
401         *                         so the dimension can be different from the requested dimension if the returned bitmap is locked.
402         */
403         Tizen::Graphics::Bitmap* DecodeN(const Tizen::Base::ByteBuffer& srcImageBuf, ImageFormat srcImageFormat, Tizen::Graphics::BitmapPixelFormat pixelFormat, int destWidth, int destHeight) const;
404
405         /**
406         * Encodes the specified bitmap data into the byte buffer. @n
407         * The currently supported encoding formats are JPEG, BMP, and PNG.
408         *
409         * @since                2.0
410         *
411         * @return               The byte buffer that contains the encoded image data
412         * @param[in]    srcBitmap                               The bitmap data to encode
413         * @param[in]    destImageFormat                 The intended image format
414         * @exception    E_SUCCESS                               The method is successful.
415         * @exception    E_OVERFLOW                              The specified input instance has overflowed.
416         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
417         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
418         * @exception    E_OBJ_NOT_FOUND                 The specified bitmap data cannot be found.
419         * @remarks
420         *                         - The specific error code can be accessed using the GetLastResult() method.
421         *                         - This method uses the raw RGB data from the locked bitmap, @n
422         *                         so the dimension of the encoded data can be different from the dimension of the source bitmap if the bitmap is auto-scaled.
423         */
424         Tizen::Base::ByteBuffer* EncodeToBufferN(const Tizen::Graphics::Bitmap& srcBitmap, ImageFormat destImageFormat) const;
425
426         /**
427         * Encodes the specified bitmap data into a file. @n
428         * The currently supported encoding formats are JPEG, BMP, and PNG.
429         *
430         * @if OSPCOMPAT
431         * @brief                <i> [Compatibility] </i>
432         * @endif
433         * @since                2.0
434         * @if OSPCOMPAT
435         * @compatibility        This method has compatibility issues with OSP compatible applications. @n
436         *                                       For more information, see @ref CompIoPathPage "here".
437         * @endif
438         *
439         * @return               An error code
440         * @param[in]    srcBitmap                               The bitmap data to encode
441         * @param[in]    destImageFormat                 The intended image format
442         * @param[in]    destImagePath                   The intended name of the encoded image file @n
443         *                                                                               The available paths start with the prefixes retrieved from the functions such as: @n
444         *                                                                               Tizen::App::App::GetInstance()->GetAppRootPath() @n
445         *                                                                               Tizen::System::Environment::GetMediaPath() @n
446         *                                                                               Tizen::System::Environment::GetExternalStoragePath().
447         * @param[in]    overwrite                               Set to @c true to overwrite the file, @n
448         *                                                                               else @c false
449         * @exception    E_SUCCESS                               The method is successful.
450         * @exception    E_OVERFLOW                              The specified input instance has overflowed.
451         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
452         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
453         * @exception    E_FILE_NOT_FOUND                The specified file cannot be found or accessed.
454         * @exception    E_OBJ_NOT_FOUND                 The specified bitmap data cannot be found.
455         * @exception    E_FILE_ALREADY_EXIST    The specified file already exists.
456         * @exception    E_SYSTEM                                A system error has occurred.
457         * @exception    E_STORAGE_FULL          The storage is full.
458         * @remarks
459         *                         - The specific error code can be accessed using the GetLastResult() method.
460         *                         - The application should use the Tizen::Content::ContentManager::CreateContent() method to register the created file into the Contents database.
461         *                         - This method uses the raw RGB data from the locked bitmap, @n
462         *                         so the dimension of the encoded data can be different from the dimension of the source bitmap if the bitmap is auto-scaled.
463         */
464         result EncodeToFile(const Tizen::Graphics::Bitmap& srcBitmap, ImageFormat destImageFormat, const Tizen::Base::String& destImagePath, bool overwrite) const;
465
466         /**
467         * Converts the image file to the specified image format. @n
468         * This is a synchronous method. The currently supported converting formats are JPEG, BMP, and PNG.
469         *
470         * @if OSPCOMPAT
471         * @brief <i> [Compatibility] </i>
472         * @endif
473         * @since                2.0
474         * @if OSPCOMPAT
475         * @compatibility        This method has compatibility issues with OSP compatible applications. @n
476         *                                       For more information, see @ref CompIoPathPage "here".
477         * @endif
478         *
479         * @return               The byte buffer that contains the image data
480         * @param[in]    srcImagePath                    The local file path of the image file to open
481         * @param[in]    destImageFormat                 The intended image format
482         * @exception    E_SUCCESS                               The method is successful.
483         * @exception    E_INVALID_DATA                  The specified input instance has invalid data.
484         * @exception    E_OVERFLOW                              The specified input instance has overflowed.
485         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
486         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
487         * @exception    E_FILE_NOT_FOUND                The specified file cannot be found or accessed.
488         * @remarks      The specific error code can be accessed using the GetLastResult() method.
489         */
490         Tizen::Base::ByteBuffer* ConvertN(const Tizen::Base::String& srcImagePath, ImageFormat destImageFormat) const;
491
492         /**
493         * @cond OSPDEPREC
494         * Compresses the encoded image file to reduce its size as per the specified limit. @n
495         * The only supported compression format is JPEG.
496         *
497         * @if OSPCOMPAT
498         * @brief           <i> [Deprecated] [Compatibility] </i>
499         * @deprecated  This method is deprecated.
500         * @endif
501         * @since                2.0
502         * @if OSPCOMPAT
503         * @compatibility        This method has compatibility issues with OSP compatible applications. @n
504         *                                       For more information, see @ref CompIoPathPage "here".
505         * @endif
506         *
507         * @return               An error code
508         * @param[in]    srcImagePath                    The local file path of the image file to open
509         * @param[in]    destImagePath                   The destination file path @n
510         *                                                                               If the file already exists, it is overwritten @n
511         *                                                                               The available paths start with the prefixes retrieved from the functions such as: @n
512         *                                                                               Tizen::App::App::GetInstance()->GetAppRootPath() @n
513         *                                                                               Tizen::System::Environment::GetMediaPath() @n
514         *                                                                               Tizen::System::Environment::GetExternalStoragePath().
515         * @param[in]    limitSize                               The maximum compressed data size in bytes @n
516         *                                                                               If the data size is too small, the width and the height of the original image can be reduced @n 
517         *                                                                               The size must be less than the original size and greater than @c 1024 bytes.
518         * @exception    E_SUCCESS                               The method is successful.
519         * @exception    E_OVERFLOW                              The specified input instance has overflowed.
520         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
521         * @exception    E_FILE_NOT_FOUND                The specified file cannot be found or accessed.
522         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
523         * @exception    E_SYSTEM                                A system error has occurred.
524         * @exception    E_STORAGE_FULL          The file cannot be created as it has reached the maximum size limit.
525         * @exception    E_OUT_OF_RANGE                  The specified size is out of the valid range.
526         * @endcond
527         */
528         result CompressJpeg(const Tizen::Base::String& srcImagePath, const Tizen::Base::String& destImagePath, int limitSize) const;
529
530         /**
531         * @if OSPDEPREC
532         * Compresses the encoded image data into the byte buffer to reduce its data size as per the specified limit. @n
533         * The only supported compression format is JPEG.
534         *
535         * @brief           <i> [Deprecated] </i>
536         * @deprecated  This method is deprecated.
537         * @since                2.0
538         *
539         * @return               The byte buffer that contains the compressed image data as per the specified size
540         * @param[in]    srcImageBuf                             The encoded image source in the byte buffer
541         * @param[in]    limitSize                               The size limit within which to compress in bytes @n
542         *                                                                               The size must be less than the original size and greater than @c 1024 bytes.
543         * @exception    E_SUCCESS                               The method is successful.
544         * @exception    E_OVERFLOW                              The specified input instance has overflowed.
545         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
546         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
547         * @exception    E_OBJ_NOT_FOUND                 The specified image buffer cannot be found.
548         * @exception    E_SYSTEM                                A system error has occurred.
549         * @exception    E_OUT_OF_RANGE                  The specified size is out of the valid range.
550         * @remarks              The specific error code can be accessed using the GetLastResult() method.
551         * @endif
552         */
553         Tizen::Base::ByteBuffer* CompressJpegN(const Tizen::Base::ByteBuffer& srcImageBuf, int limitSize) const;
554
555         /**
556         * Decodes the image data into the decoded byte buffer container without resizing. @n
557         * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
558         *
559         * @since                2.0
560         *
561         * @return               The decoded byte data that is not resized, @n
562         *                               else @c null if an exception occurs
563         * @param[in]    srcImageBuf                             The data to decode
564         * @param[in]    srcImageFormat                  The image format of the input data
565         * @param[in]    pixelFormat                             The output pixel format defined by Tizen::Graphics::BitmapPixelFormat
566         * @param[out]   imageWidth                              The original width of the image @n
567         *                                                                               An exception is returned if the value is less than @c 0.
568         * @param[out]   imageHeight                             The original height of the image @n
569         *                                                                               An exception is returned if the value is less than @c 0.
570         * @exception    E_SUCCESS                               The method is successful.
571         * @exception    E_INVALID_ARG                   The specified color format is not supported.
572         * @exception    E_INVALID_DATA                  The specified input instance has invalid data.
573         * @exception    E_OVERFLOW                              The specified input instance has overflowed.
574         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
575         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
576         * @exception    E_OBJ_NOT_FOUND                 The specified media buffer cannot be found.
577         * @remarks              The specific error code can be accessed using the GetLastResult() method.
578         */
579         Tizen::Base::ByteBuffer* DecodeToBufferN(const Tizen::Base::ByteBuffer& srcImageBuf, ImageFormat srcImageFormat, Tizen::Graphics::BitmapPixelFormat pixelFormat, int& imageWidth, int& imageHeight) const;
580
581         /**
582         * Decodes the image file into the decoded byte buffer container without resizing. @n
583         * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
584         *
585         * @if OSPCOMPAT
586         * @brief                <i> [Compatibility] </i>
587         * @endif
588         * @since                2.0
589         * @if OSPCOMPAT
590         * @compatibility        This method has compatibility issues with OSP compatible applications. @n
591         *                                       For more information, see @ref CompIoPathPage "here".
592         * @endif
593         *
594         * @return               The decoded byte data that is not resized, @n
595         *                               else @c null if an exception occurs
596         * @param[in]    srcImagePath                    The local file path of the image file to decode
597         * @param[in]    pixelFormat                             The output pixel format defined by Tizen::Graphics::BitmapPixelFormat
598         * @param[out]   imageWidth                              The original width of the image @n
599         *                                                                               An exception is returned if the value is less than @c 0.
600         * @param[out]   imageHeight                             The original height of the image @n
601         *                                                                               An exception is returned if the value is less than @c 0.
602         * @exception    E_SUCCESS                               The method is successful.
603         * @exception    E_INVALID_ARG                   The specified color format is not supported.
604         * @exception    E_INVALID_DATA                  The specified input instance has invalid data.
605         * @exception    E_OVERFLOW                              The specified input instance has overflowed.
606         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
607         * @exception    E_FILE_NOT_FOUND                The specified file cannot be found or accessed.
608         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
609         * @remarks              The specific error code can be accessed using the GetLastResult() method.
610         */
611         Tizen::Base::ByteBuffer* DecodeToBufferN(const Tizen::Base::String& srcImagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat, int& imageWidth, int& imageHeight) const;
612
613         /**
614          * Sets the timeout interval to infinity.
615          *
616          * @since       2.0
617          */
618         static const int TIMEOUT_INFINITE = 0;
619
620
621         /**
622         * Gets the format of the image in the specified file.
623         *
624         * @if OSPCOMPAT
625         * @brief                <i> [Compatibility] </i>
626         * @endif
627         * @since                2.0
628         * @if OSPCOMPAT
629         * @compatibility        This method has compatibility issues with OSP compatible applications. @n
630         *                                       For more information, see @ref CompIoPathPage "here".
631         * @endif
632         *
633         * @return               The format of the image
634         * @param[in]    srcImagePath                    The local path of the image file
635         * @exception    E_SUCCESS                               The method is successful.
636         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
637         * @exception    E_SYSTEM                                A system error has occurred.
638         * @exception    E_FILE_NOT_FOUND                The specified file cannot be found or accessed.
639         * @remarks              The specific error code can be accessed using the GetLastResult() method.
640         */
641         Tizen::Media::ImageFormat GetImageFormat(const Tizen::Base::String& srcImagePath) const;
642
643         /**
644         * Gets the image format from the image buffer.
645         *
646         * @since                2.0
647         *
648         * @return               The format of the image
649         * @param[in]    srcImageBuf                             The Tizen::Base::ByteBuffer that contains the image data
650         * @exception    E_SUCCESS                               The method is successful.
651         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
652         * @exception    E_OBJ_NOT_FOUND                 The specified image buffer cannot be found.
653         * @exception    E_SYSTEM                                A system error has occurred.
654         * @remarks              The specific error code can be accessed using the GetLastResult() method.
655         */
656         Tizen::Media::ImageFormat GetImageFormat(const Tizen::Base::ByteBuffer& srcImageBuf) const;
657
658         /**
659         * Checks whether the specified image file has alpha channels. @n
660         * Currently only 32-bit PNG images are supported.
661         *
662         * @if OSPCOMPAT
663         * @brief                <i> [Compatibility] </i>
664         * @endif
665         * @since                2.0
666         * @if OSPCOMPAT
667         * @compatibility        This method has compatibility issues with OSP compatible applications. @n
668         *                                       For more information, see @ref CompIoPathPage "here".
669         * @endif
670         *
671         * @return               @c true if the image has alpha channels, @n
672         *                               else @c false
673         * @param[in]    srcImagePath                    The local file path of the image file
674         * @exception    E_SUCCESS                               The method is successful.
675         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
676         * @exception    E_FILE_NOT_FOUND                The specified image file cannot be found.
677         * @exception    E_SYSTEM                                A system error has occurred.
678         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
679         * @remarks              The specific error code can be accessed using the GetLastResult() method.
680         */
681         bool HasAlphaChannels(const Tizen::Base::String& srcImagePath) const;
682
683         /**
684         * Checks whether the specified image buffer has alpha channels. @n
685         * Currently only 32-bit PNG images are supported.
686         *
687         * @since                2.0
688         *
689         * @return               @c true if the image has alpha channels, @n
690         *                               else @c false
691         * @param[in]    srcImageBuf                             The Tizen::Base::ByteBuffer that contains the image data
692         * @exception    E_SUCCESS                               The method is successful.
693         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
694         * @exception    E_OBJ_NOT_FOUND                 The specified image buffer cannot be found.
695         * @exception    E_SYSTEM                                A system error has occurred.
696         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
697         * @remarks              The specific error code can be accessed using the GetLastResult() method.
698         */
699         bool HasAlphaChannels(const Tizen::Base::ByteBuffer& srcImageBuf) const;
700
701 private:
702
703         /**
704         * The implementation of this copy constructor is intentionally blank
705         * and declared as private to prohibit copying of objects.
706         */
707         Image(const Image& image);
708
709         /**
710         * The implementation of this copy assignment operator is intentionally blank
711         * and declared as private to prohibit copying of objects.
712         */
713         Image& operator =(const Image& image);
714
715 private:
716         class _ImageImpl* __pImageImpl;
717         friend class _ImageImpl;
718
719 }; // class Image
720
721 };
722 };  // Tizen::Media
723
724 #endif