mResourceClient = &tls.GetResourceClient();
mWidth = width;
mHeight = height;
+ mNaturalSizeSet = true;
const ImageTicketPtr& t = mResourceClient->AllocateBitmapImage(width, height, width, height, pixelformat);
mTicket = t.Get();
mResourceClient = &tls.GetResourceClient();
mWidth = width;
mHeight = height;
+ mNaturalSizeSet = true;
Integration::Bitmap* bitmap = new BitmapExternal(pixBuf, width, height, pixelformat, stride);
const ImageTicketPtr& t = mResourceClient->AddBitmapImage(bitmap);
mTicket = t.Get();
Image::Image( LoadPolicy loadPol, ReleasePolicy releasePol )
: mWidth(0),
mHeight(0),
+ mNaturalSizeSet(false),
mLoadPolicy(loadPol),
mReleasePolicy(releasePol),
mConnectionCount(0),
ImagePtr image = new Image( loadPol, releasePol );
image->Initialize();
- if( ! filename.empty() )
- {
- Vector2 closestSize;
-
- Internal::ThreadLocalStorage::Get().GetPlatformAbstraction().GetClosestImageSize( filename, attributes, closestSize );
- image->mWidth = closestSize.width;
- image->mHeight = closestSize.height;
- }
-
image->mRequest = image->mImageFactory.RegisterRequest( filename, &attributes );
if( Dali::Image::Immediate == loadPol )
image->mWidth = nativeImg.GetWidth();
image->mHeight = nativeImg.GetHeight();
+ image->mNaturalSizeSet = true;
const ResourceTicketPtr& ticket = resourceClient.AddNativeImage( nativeImg );
DALI_ASSERT_DEBUG( dynamic_cast<ImageTicket*>( ticket.Get() ) && "Resource ticket not ImageTicket subclass for image resource.\n" );
const ImageTicket* imageTicket = static_cast<const ImageTicket*>(&ticket);
mWidth = imageTicket->GetWidth();
mHeight = imageTicket->GetHeight();
+ mNaturalSizeSet = true;
mLoadingFinishedV2.Emit( Dali::Image( this ) );
}
unsigned int Image::GetWidth() const
{
- // Width has already been calculated - just return that
- return mWidth;
+ unsigned int width = 0;
+ if( mNaturalSizeSet )
+ {
+ // Width has already been calculated - just return that
+ width = mWidth;
+ }
+ else if( mTicket )
+ {
+ const ImageAttributes& attr = mImageFactory.GetActualAttributes( mTicket->GetId() );
+ width = attr.GetWidth();
+ }
+ else if( mRequest )
+ {
+ const ImageAttributes& attr = mImageFactory.GetRequestAttributes( mRequest.Get() );
+ width = attr.GetWidth();
+ }
+
+ return width;
}
unsigned int Image::GetHeight() const
{
- // Height has already been calculated - just return that
- return mHeight;
+ unsigned int height = 0;
+ if( mNaturalSizeSet )
+ {
+ // Height has already been calculated - just return that
+ height = mHeight;
+ }
+ else if( mTicket )
+ {
+ const ImageAttributes& attr = mImageFactory.GetActualAttributes( mTicket->GetId() );
+ height = attr.GetHeight();
+ }
+ else if( mRequest )
+ {
+ const ImageAttributes& attr = mImageFactory.GetRequestAttributes( mRequest.Get() );
+ height = attr.GetHeight();
+ }
+
+ return height;
}
Vector2 Image::GetNaturalSize() const
{
- return Vector2( mWidth, mHeight );
+ Vector2 naturalSize(mWidth, mHeight);
+ if( ! mNaturalSizeSet )
+ {
+ if( mTicket )
+ {
+ const ImageAttributes& attr = mImageFactory.GetActualAttributes( mTicket->GetId() );
+ naturalSize.width = attr.GetWidth();
+ naturalSize.height = attr.GetHeight();
+ }
+ else if( mRequest )
+ {
+ const ImageAttributes& attr = mImageFactory.GetRequestAttributes( mRequest.Get() );
+ naturalSize.width = attr.GetWidth();
+ naturalSize.height = attr.GetHeight();
+ }
+ }
+ return naturalSize;
}
void Image::Connect()