2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 #include <dali/public-api/images/image.h>
21 #include <dali/public-api/images/image-attributes.h>
22 #include <dali/public-api/math/vector2.h>
23 #include <dali/internal/event/images/image-impl.h>
24 #include <dali/internal/event/common/thread-local-storage.h>
25 #include <dali/integration-api/platform-abstraction.h>
30 const char* const Image::SIGNAL_IMAGE_LOADING_FINISHED = "image-loading-finished";
31 const char* const Image::SIGNAL_IMAGE_UPLOADED = "uploaded";
33 Vector2 Image::GetImageSize(const std::string fileName)
36 Internal::ThreadLocalStorage::Get().GetPlatformAbstraction().LoadImageMetadata(fileName, size);
45 Image::Image(Internal::Image* internal) : BaseHandle(internal)
53 Image Image::New(const std::string& filename)
55 Internal::Image* internal = Internal::Image::New(filename);
56 return Image(internal);
59 Image Image::New(const std::string& filename, LoadPolicy loadPol, ReleasePolicy releasePol)
61 Internal::Image* internal = Internal::Image::New(filename, loadPol, releasePol);
62 return Image(internal);
65 Image Image::New(const std::string& filename, const ImageAttributes& attributes)
67 Internal::Image* internal = Internal::Image::New(filename, attributes);
68 return Image(internal);
71 Image Image::New(const std::string& filename, const ImageAttributes& attributes, LoadPolicy loadPol, ReleasePolicy releasePol)
73 Internal::Image* internal = Internal::Image::New(filename, attributes, loadPol, releasePol);
74 return Image(internal);
77 Image Image::NewDistanceField(const std::string& filename)
79 ImageAttributes attributes = ImageAttributes::NewDistanceField();
80 Internal::Image* internal = Internal::Image::New(filename, attributes);
81 return Image(internal);
84 Image Image::NewDistanceField(const std::string& filename, LoadPolicy loadPol, ReleasePolicy releasePol)
86 ImageAttributes attributes = ImageAttributes::NewDistanceField();
87 Internal::Image* internal = Internal::Image::New(filename, attributes, loadPol, releasePol);
88 return Image(internal);
91 Image Image::NewDistanceField(const std::string& filename, const ImageAttributes& attributes)
93 DALI_ASSERT_DEBUG(attributes.IsDistanceField());
95 Internal::Image* internal = Internal::Image::New(filename, attributes);
96 return Image(internal);
99 Image Image::NewDistanceField(const std::string& filename, const ImageAttributes& attributes, LoadPolicy loadPol, ReleasePolicy releasePol)
101 DALI_ASSERT_DEBUG(attributes.IsDistanceField());
103 Internal::Image* internal = Internal::Image::New(filename, attributes, loadPol, releasePol);
104 return Image(internal);
107 Image Image::New(NativeImage& nativeImg)
109 Internal::Image* internal = Internal::Image::New(nativeImg);
110 return Image(internal);
113 Image Image::New(NativeImage& nativeImg, LoadPolicy loadPol, ReleasePolicy releasePol)
115 Internal::Image* internal = Internal::Image::New(nativeImg, loadPol, releasePol);
116 return Image(internal);
119 Image Image::DownCast( BaseHandle handle )
121 return Image( dynamic_cast<Dali::Internal::Image*>(handle.GetObjectPtr()) );
124 LoadingState Image::GetLoadingState() const
126 return GetImplementation(*this).GetLoadingState();
129 ImageAttributes Image::GetAttributes() const
131 return GetImplementation(*this).GetAttributes();
134 std::string Image::GetFilename() const
136 return GetImplementation(*this).GetFilename();
139 Image::LoadPolicy Image::GetLoadPolicy() const
141 return GetImplementation(*this).GetLoadPolicy();
144 Image::ReleasePolicy Image::GetReleasePolicy() const
146 return GetImplementation(*this).GetReleasePolicy();
149 unsigned int Image::GetWidth() const
151 return GetImplementation(*this).GetWidth();
154 unsigned int Image::GetHeight() const
156 return GetImplementation(*this).GetHeight();
161 GetImplementation(*this).Reload();
164 Image::ImageSignalV2& Image::LoadingFinishedSignal()
166 return GetImplementation(*this).LoadingFinishedSignal();
169 Image::ImageSignalV2& Image::UploadedSignal()
171 return GetImplementation(*this).UploadedSignal();