1 #ifndef __DALI_ENCODED_BUFFER_IMAGE_H__
2 #define __DALI_ENCODED_BUFFER_IMAGE_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
32 * @addtogroup dali_core_images
36 namespace Internal DALI_INTERNAL
38 class EncodedBufferImage;
41 typedef Uint16Pair ImageDimensions;
45 * @brief EncodedBufferImage represents a Image as a buffer of encoded pixel data.
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
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.
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.
62 * Image::LoadingFinishedSignal is emitted when the decoding of the
63 * image data is completed, either successfully or not.
65 * Image::UploadedSignal is emitted when the decoded image data gets
66 * uploaded to the OpenGL ES implementation.
68 class DALI_IMPORT_API EncodedBufferImage : public Image
72 * @brief Constructor which creates an uninitialized EncodedBufferImage object.
74 * Use Image::New(...) to create an initialised object.
79 * @brief Create an initialised image object from an encoded image buffer in memory.
81 * @deprecated DALi 1.1.3 use New(const uint8_t* const, std::size_t,ImageDimensions,FittingMode::Type,SamplingMode::Type,bool) instead.
83 * @param [in] encodedImage The encoded bytes of an image, in a supported
84 * image format such as PNG, JPEG, GIF, BMP, KTX, ICO, and WBMP, organised
85 * exactly as it would be as a file in the filesystem.
86 * The caller retains ownership of this buffer and is free to modify or
87 * discard it as soon as the function returns.
88 * @param [in] encodedImageByteCount The size in bytes of the buffer pointed to
90 * @param [in] size The width and height to fit the loaded image to.
91 * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
92 * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size.
93 * @param [in] releasePol The ReleasePolicy to apply to Image.
94 * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
95 * policy is set, a reload will not be possible, so the Image should never be
96 * used once all actors using it have gone off-stage.
97 * @return A handle to a newly allocated object.
99 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 );
102 * @brief Create an initialised image object from an encoded image buffer in memory.
104 * @param [in] encodedImage The encoded bytes of an image, in a supported
105 * image format such as PNG, JPEG, GIF, BMP, KTX, ICO, and WBMP, organised
106 * exactly as it would be as a file in the filesystem.
107 * The caller retains ownership of this buffer and is free to modify or
108 * discard it as soon as the function returns.
109 * @param [in] encodedImageByteCount The size in bytes of the buffer pointed to
111 * @return A handle to a newly allocated object.
113 static EncodedBufferImage New( const uint8_t * const encodedImage, std::size_t encodedImageByteCount );
116 * @brief Create an initialised image object from an encoded image buffer in memory.
118 * @param [in] encodedImage The encoded bytes of an image, in a supported
119 * image format such as PNG, JPEG, GIF, BMP, KTX, ICO, and WBMP, organised
120 * exactly as it would be as a file in the filesystem.
121 * The caller retains ownership of this buffer and is free to modify or
122 * discard it as soon as the function returns.
123 * @param [in] encodedImageByteCount The size in bytes of the buffer pointed to
125 * @param [in] size The width and height to fit the loaded image to.
126 * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
127 * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size.
128 * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
129 * policy is set, a reload will not be possible, so the Image should never be
130 * used once all actors using it have gone off-stage.
131 * @return A handle to a newly allocated object.
135 static EncodedBufferImage New( const uint8_t * const encodedImage, std::size_t encodedImageByteCount, ImageDimensions size, FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection = true );
138 * @brief Downcast an Object handle to EncodedBufferImage.
140 * If handle points to a EncodedBufferImage the
141 * downcast produces valid handle. If not the returned handle is left uninitialized.
142 * @param[in] handle to An object
143 * @return handle to a EncodedBufferImage or an uninitialized handle
145 static EncodedBufferImage DownCast( BaseHandle handle );
150 * This is non-virtual since derived Handle types must not contain data or virtual methods.
152 ~EncodedBufferImage();
155 * @brief This copy constructor is required for (smart) pointer semantics.
157 * @param [in] handle A reference to the copied handle
159 EncodedBufferImage(const EncodedBufferImage& handle);
162 * @brief This assignment operator is required for (smart) pointer semantics.
164 * @param [in] rhs A reference to the copied handle
165 * @return A reference to this
167 EncodedBufferImage& operator=(const EncodedBufferImage& rhs);
169 public: // Not intended for application developers
171 explicit DALI_INTERNAL EncodedBufferImage(Internal::EncodedBufferImage*);
179 #endif // __DALI_ENCODED_BUFFER_IMAGE_H__