Remove ImageAttributes from public API
[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) 2014 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 namespace Internal DALI_INTERNAL
33 {
34 class EncodedBufferImage;
35 }
36
37 typedef Uint16Pair ImageDimensions;
38
39
40 /**
41  * @brief EncodedBufferImage represents an image resource that can be added to
42  * ImageActors.
43  *
44  * A memory buffer of encoded image data is provided by the application and
45  * decoded asynchronously on a background thread to fill the image's
46  * pixel data.
47  *
48  * The buffer of data provided to an EncodedBufferImage factory function
49  * (New) should be filled with encoded image data in one of %Dali's
50  * supported image file formats, with the sequence of bytes in the buffer
51  * exactly matching the sequence of bytes that a file in the file system
52  * holding the encoded image data would have.
53  *
54  * The application may free the encoded image buffer passed to one of the
55  * New() static factory member functions as soon as they return.
56  *
57  * <h3> Signals </h3>
58  *
59  * Image::LoadingFinishedSignal is emitted when the decoding of the
60  * image data is completed, either successfully or not.
61  *
62  * Image::UploadedSignal is emitted when the decoded image data gets
63  * uploaded to the OpenGL ES implementation.
64  */
65 class DALI_IMPORT_API EncodedBufferImage : public Image
66 {
67 public:
68   /**
69    * @brief Constructor which creates an uninitialized EncodedBufferImage object.
70    *
71    * Use Image::New(...) to create an initialised object.
72    */
73   EncodedBufferImage();
74
75   /**
76    * @brief Create an initialised image object from an encoded image buffer in memory.
77    *
78    * The image will be created eagerly using LoadPolicy::Immediate.
79    * The function is non-blocking and returns immediately while the image
80    * decoding happens on a background thread.
81    * @param [in] encodedImage The encoded bytes of an image, in a supported
82    * image format such as PNG, JPEG, GIF, BMP, KTX, ICO, and WBMP, organised
83    * exactly as it would be as a file in the filesystem.
84    * The caller retains ownership of this buffer and is free to modify or
85    * discard it as soon as the function returns.
86    * @param [in] encodedImageByteCount The size in bytes of the buffer pointed to
87    * by encodedImage.
88    * @param [in] size The width and height to fit the loaded image to.
89    * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
90    * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size.
91    * @param [in] releasePol The ReleasePolicy to apply to Image. If the Unused
92    * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
93    * policy is set, a reload will not be possible, so the Image should never be
94    * used once all actors using it have gone off-stage.
95    * @return A handle to a newly allocated object.
96    */
97   static EncodedBufferImage New( const uint8_t * const encodedImage, std::size_t encodedImageByteCount, ImageDimensions size, FittingMode::Type fittingMode, SamplingMode::Type samplingMode, ReleasePolicy releasePol = Image::NEVER, bool orientationCorrection = true );
98
99   /**
100    * @brief Create an initialised image object from an encoded image buffer in memory.
101    *
102    * The image will be created eagerly using LoadPolicy::Immediate.
103    * The function is non-blocking and returns immediately while the image
104    * decoding happens on a background thread.
105    * @param [in] encodedImage The encoded bytes of an image, in a supported
106    * image format such as PNG, JPEG, GIF, BMP, KTX, ICO, and WBMP, organised
107    * exactly as it would be as a file in the filesystem.
108    * The caller retains ownership of this buffer and is free to modify or
109    * discard it as soon as the function returns.
110    * @param [in] encodedImageByteCount The size in bytes of the buffer pointed to
111    * by encodedImage.
112    * @return A handle to a newly allocated object.
113    */
114   static EncodedBufferImage New( const uint8_t * const encodedImage, std::size_t encodedImageByteCount );
115
116   /**
117    * @brief Downcast an Object handle to EncodedBufferImage.
118    *
119    * If handle points to a EncodedBufferImage the
120    * downcast produces valid handle. If not the returned handle is left uninitialized.
121    * @param[in] handle to An object
122    * @return handle to a EncodedBufferImage or an uninitialized handle
123    */
124   static EncodedBufferImage DownCast( BaseHandle handle );
125
126   /**
127    * @brief Destructor
128    *
129    * This is non-virtual since derived Handle types must not contain data or virtual methods.
130    */
131   ~EncodedBufferImage();
132
133   /**
134    * @brief This copy constructor is required for (smart) pointer semantics.
135    *
136    * @param [in] handle A reference to the copied handle
137    */
138   EncodedBufferImage(const EncodedBufferImage& handle);
139
140   /**
141    * @brief This assignment operator is required for (smart) pointer semantics.
142    *
143    * @param [in] rhs  A reference to the copied handle
144    * @return A reference to this
145    */
146   EncodedBufferImage& operator=(const EncodedBufferImage& rhs);
147
148 public: // Not intended for application developers
149
150   explicit DALI_INTERNAL EncodedBufferImage(Internal::EncodedBufferImage*);
151 };
152
153 } // namespace Dali
154
155 #endif // __DALI_ENCODED_BUFFER_IMAGE_H__