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;
36 class ResourceManager;
43 * EncodedBufferImage represents an image resource that can be added to actors etc.
45 * A memory buffer of encoded image data is provided by the application and
46 * decoded asynchronously on a background thread to fill the image's
49 class EncodedBufferImage : public Image
53 * Construct using the supplied load policy.
55 EncodedBufferImage( ReleasePolicy releasePol = IMAGE_RELEASE_POLICY_DEFAULT ) : Image( releasePol ) {}
59 * Create an initialised image object from an encoded image buffer in memory.
60 * @param [in] encodedImage The encoded bytes of an image, in a supported
61 * image format such as PNG, JPEG, GIF, BMP, KTX, ICO, and WBMP, organised
62 * exactly as it would be as a file in the filesystem.
63 * The caller retains ownership of this buffer and is free to modify or
64 * discard it as soon as the function returns.
65 * @param [in] encodedImageByteCount The size in bytes of the buffer pointed to
67 * @param [in] attributes Requested parameters for loading (size, scaling etc.).
68 * @param [in] releasePol The ReleasePolicy to apply to image. Since it cannot
69 * be recreated by dali, the default of Never will usually make sense.
70 * @return A pointer to a newly allocated object, or null on error.
72 static EncodedBufferImagePtr New(const uint8_t * const encodedImage,
73 const std::size_t encodedImageByteCount,
74 const ImageAttributes& attributes,
75 const ReleasePolicy releasePol=Dali::Image::NEVER);
78 } // namespace Internal
81 * Helper methods for public API.
83 inline Internal::EncodedBufferImage& GetImplementation(Dali::EncodedBufferImage& image)
85 DALI_ASSERT_ALWAYS( image && "EncodedBufferImage handle is empty" );
87 BaseObject& handle = image.GetBaseObject();
89 return static_cast<Internal::EncodedBufferImage&>(handle);
92 inline const Internal::EncodedBufferImage& GetImplementation(const Dali::EncodedBufferImage& image)
94 DALI_ASSERT_ALWAYS( image && "EncodedBufferImage handle is empty" );
96 const BaseObject& handle = image.GetBaseObject();
98 return static_cast<const Internal::EncodedBufferImage&>(handle);
103 #endif // __DALI_INTERNAL_ENCODED_BUFFER_IMAGE_H__