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