2 * Copyright (c) 2015 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/resource-image.h>
22 #include <dali/internal/common/image-attributes.h>
23 #include <dali/internal/event/images/resource-image-impl.h>
24 #include <dali/internal/event/common/thread-local-storage.h>
25 #include <dali/integration-api/platform-abstraction.h>
30 ImageDimensions ResourceImage::GetImageSize( const std::string& url )
32 const Internal::ImageAttributes& attribs = Internal::ImageAttributes::DEFAULT_ATTRIBUTES;
33 const ImageDimensions desiredSize = ImageDimensions( attribs.GetWidth(), attribs.GetHeight() );
34 const ImageDimensions size = Internal::ThreadLocalStorage::Get().GetPlatformAbstraction().GetClosestImageSize( url, desiredSize, attribs.GetScalingMode(), attribs.GetFilterMode(), attribs.GetOrientationCorrection() );
38 ResourceImage::ResourceImage()
42 ResourceImage::ResourceImage(Internal::ResourceImage* internal) : Image(internal)
46 ResourceImage::~ResourceImage()
50 ResourceImage::ResourceImage( const ResourceImage& handle )
55 ResourceImage& ResourceImage::operator=( const ResourceImage& rhs )
57 BaseHandle::operator=(rhs);
61 ResourceImage ResourceImage::New( const std::string& url, bool orientationCorrection )
63 Internal::ImageAttributes attributes = Internal::ImageAttributes::DEFAULT_ATTRIBUTES;
64 attributes.SetOrientationCorrection( orientationCorrection );
65 return ResourceImage( Internal::ResourceImage::New( url, attributes ).Get() );
68 ResourceImage ResourceImage::New( const std::string& url, LoadPolicy loadPol, ReleasePolicy releasePol, bool orientationCorrection )
70 Internal::ImageAttributes attributes = Internal::ImageAttributes::DEFAULT_ATTRIBUTES;
71 attributes.SetOrientationCorrection( orientationCorrection );
72 return ResourceImage( Internal::ResourceImage::New( url, attributes, loadPol, releasePol ).Get() );
75 ResourceImage ResourceImage::New( const std::string& url, ImageDimensions size, FittingMode::Type scalingMode, SamplingMode::Type samplingMode, bool orientationCorrection )
77 Internal::ImageAttributes attributes = Internal::ImageAttributes::DEFAULT_ATTRIBUTES;
78 attributes.SetSize( Size( size.GetWidth(), size.GetHeight() ) );
79 attributes.SetScalingMode( scalingMode );
80 attributes.SetFilterMode( samplingMode );
81 attributes.SetOrientationCorrection( orientationCorrection );
82 return ResourceImage( Internal::ResourceImage::New( url, attributes ).Get() );
85 ResourceImage ResourceImage::New( const std::string& url, LoadPolicy loadPol, ReleasePolicy releasePol, ImageDimensions size, FittingMode::Type scalingMode, SamplingMode::Type samplingMode, bool orientationCorrection )
87 Internal::ImageAttributes attributes = Internal::ImageAttributes::DEFAULT_ATTRIBUTES;
88 attributes.SetSize( Size( size.GetWidth(), size.GetHeight() ) );
89 attributes.SetScalingMode( scalingMode );
90 attributes.SetFilterMode( samplingMode );
91 attributes.SetOrientationCorrection( orientationCorrection );
92 return ResourceImage( Internal::ResourceImage::New( url, attributes, loadPol, releasePol ).Get() );
95 ResourceImage ResourceImage::DownCast( BaseHandle handle )
97 return ResourceImage( dynamic_cast<Dali::Internal::ResourceImage*>(handle.GetObjectPtr()) );
100 ResourceImage::LoadPolicy ResourceImage::GetLoadPolicy() const
102 return GetImplementation(*this).GetLoadPolicy();
105 LoadingState ResourceImage::GetLoadingState() const
107 return GetImplementation(*this).GetLoadingState();
110 std::string ResourceImage::GetUrl() const
112 return GetImplementation(*this).GetUrl();
115 void ResourceImage::Reload()
117 GetImplementation(*this).Reload();
120 ResourceImage::ResourceImageSignal& ResourceImage::LoadingFinishedSignal()
122 return GetImplementation(*this).LoadingFinishedSignal();