2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/public-api/images/image.h>
22 #include <dali/public-api/images/image-attributes.h>
23 #include <dali/public-api/math/vector2.h>
24 #include <dali/internal/event/images/image-impl.h>
25 #include <dali/internal/event/common/thread-local-storage.h>
26 #include <dali/integration-api/platform-abstraction.h>
31 const char* const Image::SIGNAL_IMAGE_LOADING_FINISHED = "image-loading-finished";
32 const char* const Image::SIGNAL_IMAGE_UPLOADED = "uploaded";
34 Vector2 Image::GetImageSize(const std::string fileName)
37 Internal::ThreadLocalStorage::Get().GetPlatformAbstraction().GetClosestImageSize(fileName, ImageAttributes::DEFAULT_ATTRIBUTES, size);
45 Image::Image(Internal::Image* internal) : BaseHandle(internal)
53 Image::Image(const Image& handle)
58 Image& Image::operator=(const Image& rhs)
60 BaseHandle::operator=(rhs);
64 Image Image::New(const std::string& filename)
66 Internal::ImagePtr internal = Internal::Image::New( filename,
67 Dali::ImageAttributes::DEFAULT_ATTRIBUTES );
68 return Image(internal.Get());
71 Image Image::New(const std::string& filename, LoadPolicy loadPol, ReleasePolicy releasePol)
73 Internal::ImagePtr internal = Internal::Image::New( filename,
74 Dali::ImageAttributes::DEFAULT_ATTRIBUTES,
75 loadPol, releasePol );
76 return Image(internal.Get());
79 Image Image::New(const std::string& filename, const ImageAttributes& attributes)
81 Internal::ImagePtr internal = Internal::Image::New(filename, attributes);
82 return Image(internal.Get());
85 Image Image::New(const std::string& filename, const ImageAttributes& attributes, LoadPolicy loadPol, ReleasePolicy releasePol)
87 Internal::ImagePtr internal = Internal::Image::New(filename, attributes, loadPol, releasePol);
88 return Image(internal.Get());
91 Image Image::NewDistanceField(const std::string& filename)
93 ImageAttributes attributes = ImageAttributes::NewDistanceField();
94 Internal::ImagePtr internal = Internal::Image::New(filename, attributes);
95 return Image(internal.Get());
98 Image Image::NewDistanceField(const std::string& filename, LoadPolicy loadPol, ReleasePolicy releasePol)
100 ImageAttributes attributes = ImageAttributes::NewDistanceField();
101 Internal::ImagePtr internal = Internal::Image::New(filename, attributes, loadPol, releasePol);
102 return Image(internal.Get());
105 Image Image::NewDistanceField(const std::string& filename, const ImageAttributes& attributes)
107 DALI_ASSERT_DEBUG(attributes.IsDistanceField());
109 Internal::ImagePtr internal = Internal::Image::New(filename, attributes);
110 return Image(internal.Get());
113 Image Image::NewDistanceField(const std::string& filename, const ImageAttributes& attributes, LoadPolicy loadPol, ReleasePolicy releasePol)
115 DALI_ASSERT_DEBUG(attributes.IsDistanceField());
117 Internal::ImagePtr internal = Internal::Image::New(filename, attributes, loadPol, releasePol);
118 return Image(internal.Get());
121 Image Image::New(NativeImage& nativeImg)
123 Internal::ImagePtr internal = Internal::Image::New(nativeImg);
124 return Image(internal.Get());
127 Image Image::DownCast( BaseHandle handle )
129 return Image( dynamic_cast<Dali::Internal::Image*>(handle.GetObjectPtr()) );
132 LoadingState Image::GetLoadingState() const
134 return GetImplementation(*this).GetLoadingState();
137 ImageAttributes Image::GetAttributes() const
139 return GetImplementation(*this).GetAttributes();
142 std::string Image::GetFilename() const
144 return GetImplementation(*this).GetFilename();
147 Image::LoadPolicy Image::GetLoadPolicy() const
149 return GetImplementation(*this).GetLoadPolicy();
152 Image::ReleasePolicy Image::GetReleasePolicy() const
154 return GetImplementation(*this).GetReleasePolicy();
157 unsigned int Image::GetWidth() const
159 return GetImplementation(*this).GetWidth();
162 unsigned int Image::GetHeight() const
164 return GetImplementation(*this).GetHeight();
169 GetImplementation(*this).Reload();
172 Image::ImageSignalType& Image::LoadingFinishedSignal()
174 return GetImplementation(*this).LoadingFinishedSignal();
177 Image::ImageSignalType& Image::UploadedSignal()
179 return GetImplementation(*this).UploadedSignal();