1 #ifndef __DALI_INTERNAL_ENCODED_BUFFER_IMAGE_H__
2 #define __DALI_INTERNAL_ENCODED_BUFFER_IMAGE_H__
5 * Copyright (c) 2014 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.
22 #include <dali/public-api/object/ref-object.h>
23 #include <dali/internal/event/images/image-impl.h>
24 #include <dali/public-api/images/encoded-buffer-image.h>
32 class EncodedBufferImage;
33 typedef IntrusivePtr<EncodedBufferImage> EncodedBufferImagePtr;
40 * EncodedBufferImage represents an image resource that can be added to actors etc.
42 * A memory buffer of encoded image data is provided by the application and
43 * decoded asynchronously on a background thread to fill the image's
46 class EncodedBufferImage : public Image
50 * Construct using the supplied load policy.
52 EncodedBufferImage() : Image() {}
56 * Create an initialised image object from an encoded image buffer in memory.
57 * @param [in] encodedImage The encoded bytes of an image, in a supported
58 * image format such as PNG, JPEG, GIF, BMP, KTX, ICO, and WBMP, organised
59 * exactly as it would be as a file in the filesystem.
60 * The caller retains ownership of this buffer and is free to modify or
61 * discard it as soon as the function returns.
62 * @param [in] encodedImageByteCount The size in bytes of the buffer pointed to
64 * @param [in] attributes Requested parameters for loading (size, scaling etc.).
65 * @return A pointer to a newly allocated object, or null on error.
67 static EncodedBufferImagePtr New(const uint8_t * const encodedImage,
68 const std::size_t encodedImageByteCount,
69 ImageDimensions size = ImageDimensions(0, 0),
70 FittingMode::Type scalingMode = FittingMode::SHRINK_TO_FIT,
71 SamplingMode::Type samplingMode = SamplingMode::BOX,
72 bool orientationCorrection = true);
75 } // namespace Internal
78 * Helper methods for public API.
80 inline Internal::EncodedBufferImage& GetImplementation(Dali::EncodedBufferImage& image)
82 DALI_ASSERT_ALWAYS( image && "EncodedBufferImage handle is empty" );
84 BaseObject& handle = image.GetBaseObject();
86 return static_cast<Internal::EncodedBufferImage&>(handle);
89 inline const Internal::EncodedBufferImage& GetImplementation(const Dali::EncodedBufferImage& image)
91 DALI_ASSERT_ALWAYS( image && "EncodedBufferImage handle is empty" );
93 const BaseObject& handle = image.GetBaseObject();
95 return static_cast<const Internal::EncodedBufferImage&>(handle);
100 #endif // __DALI_INTERNAL_ENCODED_BUFFER_IMAGE_H__