[dali_1.1.38] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / public-api / images / encoded-buffer-image.h
1 #ifndef __DALI_ENCODED_BUFFER_IMAGE_H__
2 #define __DALI_ENCODED_BUFFER_IMAGE_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <stdint.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/images/image.h>
26 #include <dali/public-api/images/image-operations.h>
27 #include <dali/public-api/math/uint-16-pair.h>
28
29 namespace Dali
30 {
31 /**
32  * @addtogroup dali_core_images
33  * @{
34  */
35
36 namespace Internal DALI_INTERNAL
37 {
38 class EncodedBufferImage;
39 }
40
41 typedef Uint16Pair ImageDimensions;
42
43
44 /**
45  * @brief EncodedBufferImage represents an image resource as a buffer of encoded pixel data.
46  *
47  * A memory buffer of encoded image data is provided by the application and
48  * decoded asynchronously on a background thread to fill the image's
49  * pixel data.
50  *
51  * The buffer of data provided to an EncodedBufferImage factory function
52  * (New) should be filled with encoded image data in one of %Dali's
53  * supported image file formats, with the sequence of bytes in the buffer
54  * exactly matching the sequence of bytes that a file in the file system
55  * holding the encoded image data would have.
56  *
57  * The application may free the encoded image buffer passed to one of the
58  * New() static factory member functions as soon as they return.
59  *
60  * <h3> Signals </h3>
61  *
62  * Image::LoadingFinishedSignal is emitted when the decoding of the
63  * image data is completed, either successfully or not.
64  *
65  * Image::UploadedSignal is emitted when the decoded image data gets
66  * uploaded to the OpenGL ES implementation.
67  * @SINCE_1_0.0
68  */
69 class DALI_IMPORT_API EncodedBufferImage : public Image
70 {
71 public:
72   /**
73    * @brief Constructor which creates an uninitialized EncodedBufferImage object.
74    *
75    * Use @ref EncodedBufferImage::New to create an initialised object.
76    * @SINCE_1_0.0
77    */
78   EncodedBufferImage();
79
80   /**
81    * @DEPRECATED_1_1.3. Use New(const uint8_t* const, std::size_t,ImageDimensions,FittingMode::Type,SamplingMode::Type,bool) instead.
82    *
83    * @brief Create an initialised image object from an encoded image buffer in memory.
84    *
85    * @SINCE_1_0.0
86    * @remarks Image::ReleasePolicy is an experimental feature and might not be supported in the next release.
87    * We do recommend not to use this method.
88    * Please refer the remarks of ReleasePolicy for more information.
89    * @param [in] encodedImage The encoded bytes of an image, in a supported
90    * image format such as PNG, JPEG, GIF, BMP, KTX, ICO, and WBMP, organised
91    * exactly as it would be as a file in the filesystem.
92    * The caller retains ownership of this buffer and is free to modify or
93    * discard it as soon as the function returns.
94    * @param [in] encodedImageByteCount The size in bytes of the buffer pointed to
95    * by encodedImage.
96    * @param [in] size The width and height to fit the loaded image to.
97    * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
98    * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size.
99    * @param [in] releasePol The releasePolicy to apply to Image. The default value is Image::NEVER.
100    * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
101    * policy is set, a reload will not be possible, so the Image should never be
102    * used once all actors using it have gone off-stage.
103    * @return A handle to a newly allocated object.
104    */
105   static EncodedBufferImage New( const uint8_t * const encodedImage, std::size_t encodedImageByteCount, ImageDimensions size, FittingMode::Type fittingMode, SamplingMode::Type samplingMode, ReleasePolicy releasePol, bool orientationCorrection = true );
106
107   /**
108    * @brief Create an initialised image object from an encoded image buffer in memory.
109    *
110    * @SINCE_1_0.0
111    * @param [in] encodedImage The encoded bytes of an image, in a supported
112    * image format such as PNG, JPEG, GIF, BMP, KTX, ICO, and WBMP, organised
113    * exactly as it would be as a file in the filesystem.
114    * The caller retains ownership of this buffer and is free to modify or
115    * discard it as soon as the function returns.
116    * @param [in] encodedImageByteCount The size in bytes of the buffer pointed to
117    * by encodedImage.
118    * @return A handle to a newly allocated object.
119    */
120   static EncodedBufferImage New( const uint8_t * const encodedImage, std::size_t encodedImageByteCount );
121
122   /**
123    * @brief Create an initialised image object from an encoded image buffer in memory.
124    *
125    * @SINCE_1_1.4
126    * @param [in] encodedImage The encoded bytes of an image, in a supported
127    * image format such as PNG, JPEG, GIF, BMP, KTX, ICO, and WBMP, organised
128    * exactly as it would be as a file in the filesystem.
129    * The caller retains ownership of this buffer and is free to modify or
130    * discard it as soon as the function returns.
131    * @param [in] encodedImageByteCount The size in bytes of the buffer pointed to
132    * by encodedImage.
133    * @param [in] size The width and height to fit the loaded image to.
134    * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
135    * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size.
136    * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
137    * policy is set, a reload will not be possible, so the Image should never be
138    * used once all actors using it have gone off-stage.
139    * @return A handle to a newly allocated object.
140    */
141   static EncodedBufferImage New( const uint8_t * const encodedImage, std::size_t encodedImageByteCount, ImageDimensions size, FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection = true );
142
143   /**
144    * @brief Downcast a handle to EncodedBufferImage handle.
145    *
146    * If handle points to a EncodedBufferImage the
147    * downcast produces valid handle. If not the returned handle is left uninitialized.
148    * @SINCE_1_0.0
149    * @param[in] handle Handle to an object
150    * @return Handle to a EncodedBufferImage or an uninitialized handle
151    */
152   static EncodedBufferImage DownCast( BaseHandle handle );
153
154   /**
155    * @brief Destructor
156    *
157    * This is non-virtual since derived Handle types must not contain data or virtual methods.
158    * @SINCE_1_0.0
159    */
160   ~EncodedBufferImage();
161
162   /**
163    * @brief This copy constructor is required for (smart) pointer semantics.
164    *
165    * @SINCE_1_0.0
166    * @param [in] handle A reference to the copied handle
167    */
168   EncodedBufferImage(const EncodedBufferImage& handle);
169
170   /**
171    * @brief This assignment operator is required for (smart) pointer semantics.
172    *
173    * @SINCE_1_0.0
174    * @param [in] rhs  A reference to the copied handle
175    * @return A reference to this
176    */
177   EncodedBufferImage& operator=(const EncodedBufferImage& rhs);
178
179 public: // Not intended for application developers
180
181   explicit DALI_INTERNAL EncodedBufferImage(Internal::EncodedBufferImage*);
182 };
183
184 /**
185  * @}
186  */
187 } // namespace Dali
188
189 #endif // __DALI_ENCODED_BUFFER_IMAGE_H__