[dali_1.1.35] 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 that can be added to
46  * ImageViews.
47  *
48  * A memory buffer of encoded image data is provided by the application and
49  * decoded asynchronously on a background thread to fill the image's
50  * pixel data.
51  *
52  * The buffer of data provided to an EncodedBufferImage factory function
53  * (New) should be filled with encoded image data in one of %Dali's
54  * supported image file formats, with the sequence of bytes in the buffer
55  * exactly matching the sequence of bytes that a file in the file system
56  * holding the encoded image data would have.
57  *
58  * The application may free the encoded image buffer passed to one of the
59  * New() static factory member functions as soon as they return.
60  *
61  * <h3> Signals </h3>
62  *
63  * Image::LoadingFinishedSignal is emitted when the decoding of the
64  * image data is completed, either successfully or not.
65  *
66  * Image::UploadedSignal is emitted when the decoded image data gets
67  * uploaded to the OpenGL ES implementation.
68  * @SINCE_1_0.0
69  */
70 class DALI_IMPORT_API EncodedBufferImage : public Image
71 {
72 public:
73   /**
74    * @brief Constructor which creates an uninitialized EncodedBufferImage object.
75    *
76    * Use @ref EncodedBufferImage::New to create an initialised object.
77    * @SINCE_1_0.0
78    */
79   EncodedBufferImage();
80
81   /**
82    * @DEPRECATED_1_1.3. Use New(const uint8_t* const, std::size_t,ImageDimensions,FittingMode::Type,SamplingMode::Type,bool) instead.
83    *
84    * @brief Create an initialised image object from an encoded image buffer in memory.
85    *
86    * @SINCE_1_0.0
87    * @remarks Image::ReleasePolicy is an experimental feature and might not be supported in the next release.
88    * We do recommend not to use this method.
89    * Please refer the remarks of ReleasePolicy for more information.
90    * @param [in] encodedImage The encoded bytes of an image, in a supported
91    * image format such as PNG, JPEG, GIF, BMP, KTX, ICO, and WBMP, organised
92    * exactly as it would be as a file in the filesystem.
93    * The caller retains ownership of this buffer and is free to modify or
94    * discard it as soon as the function returns.
95    * @param [in] encodedImageByteCount The size in bytes of the buffer pointed to
96    * by encodedImage.
97    * @param [in] size The width and height to fit the loaded image to.
98    * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
99    * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size.
100    * @param [in] releasePol The releasePolicy to apply to Image. The default value is Image::NEVER.
101    * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
102    * policy is set, a reload will not be possible, so the Image should never be
103    * used once all actors using it have gone off-stage.
104    * @return A handle to a newly allocated object.
105    */
106   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 );
107
108   /**
109    * @brief Create an initialised image object from an encoded image buffer in memory.
110    *
111    * @SINCE_1_0.0
112    * @param [in] encodedImage The encoded bytes of an image, in a supported
113    * image format such as PNG, JPEG, GIF, BMP, KTX, ICO, and WBMP, organised
114    * exactly as it would be as a file in the filesystem.
115    * The caller retains ownership of this buffer and is free to modify or
116    * discard it as soon as the function returns.
117    * @param [in] encodedImageByteCount The size in bytes of the buffer pointed to
118    * by encodedImage.
119    * @return A handle to a newly allocated object.
120    */
121   static EncodedBufferImage New( const uint8_t * const encodedImage, std::size_t encodedImageByteCount );
122
123   /**
124    * @brief Create an initialised image object from an encoded image buffer in memory.
125    *
126    * @SINCE_1_1.4
127    * @param [in] encodedImage The encoded bytes of an image, in a supported
128    * image format such as PNG, JPEG, GIF, BMP, KTX, ICO, and WBMP, organised
129    * exactly as it would be as a file in the filesystem.
130    * The caller retains ownership of this buffer and is free to modify or
131    * discard it as soon as the function returns.
132    * @param [in] encodedImageByteCount The size in bytes of the buffer pointed to
133    * by encodedImage.
134    * @param [in] size The width and height to fit the loaded image to.
135    * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
136    * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size.
137    * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
138    * policy is set, a reload will not be possible, so the Image should never be
139    * used once all actors using it have gone off-stage.
140    * @return A handle to a newly allocated object.
141    */
142   static EncodedBufferImage New( const uint8_t * const encodedImage, std::size_t encodedImageByteCount, ImageDimensions size, FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection = true );
143
144   /**
145    * @brief Downcast a handle to EncodedBufferImage handle.
146    *
147    * If handle points to a EncodedBufferImage the
148    * downcast produces valid handle. If not the returned handle is left uninitialized.
149    * @SINCE_1_0.0
150    * @param[in] handle Handle to an object
151    * @return Handle to a EncodedBufferImage or an uninitialized handle
152    */
153   static EncodedBufferImage DownCast( BaseHandle handle );
154
155   /**
156    * @brief Destructor
157    *
158    * This is non-virtual since derived Handle types must not contain data or virtual methods.
159    * @SINCE_1_0.0
160    */
161   ~EncodedBufferImage();
162
163   /**
164    * @brief This copy constructor is required for (smart) pointer semantics.
165    *
166    * @SINCE_1_0.0
167    * @param [in] handle A reference to the copied handle
168    */
169   EncodedBufferImage(const EncodedBufferImage& handle);
170
171   /**
172    * @brief This assignment operator is required for (smart) pointer semantics.
173    *
174    * @SINCE_1_0.0
175    * @param [in] rhs  A reference to the copied handle
176    * @return A reference to this
177    */
178   EncodedBufferImage& operator=(const EncodedBufferImage& rhs);
179
180 public: // Not intended for application developers
181
182   explicit DALI_INTERNAL EncodedBufferImage(Internal::EncodedBufferImage*);
183 };
184
185 /**
186  * @}
187  */
188 } // namespace Dali
189
190 #endif // __DALI_ENCODED_BUFFER_IMAGE_H__