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/internal/update/resources/bitmap-metadata.h>
25 #include <dali/integration-api/debug.h>
34 BitmapMetadata BitmapMetadata::New(NativeImageInterfacePtr nativeImage)
36 return BitmapMetadata(nativeImage->GetWidth(), nativeImage->GetHeight(), nativeImage->RequiresBlending(), ! nativeImage->RequiresBlending());
39 BitmapMetadata BitmapMetadata::New(Integration::Bitmap* const bitmap)
41 return BitmapMetadata(bitmap->GetImageWidth(), bitmap->GetImageHeight(), Pixel::HasAlpha(bitmap->GetPixelFormat()), bitmap->IsFullyOpaque());
45 BitmapMetadata BitmapMetadata::New(unsigned int width,
49 return BitmapMetadata(width, height, hasAlphaChannel, !hasAlphaChannel );
53 BitmapMetadata::BitmapMetadata( unsigned int width,
59 mHasAlphaChannel(hasAlphaChanne),
60 mOpaqueness(opaqueness),
61 mIsNativeImage(false),
66 BitmapMetadata::BitmapMetadata( )
69 mHasAlphaChannel(true),
71 mIsNativeImage(false),
76 BitmapMetadata::BitmapMetadata( const BitmapMetadata& rhs )
77 : mImageWidth(rhs.mImageWidth),
78 mImageHeight(rhs.mImageHeight),
79 mHasAlphaChannel(rhs.mHasAlphaChannel),
80 mOpaqueness(rhs.mOpaqueness),
81 mIsNativeImage(rhs.mIsNativeImage),
82 mIsFramebuffer(rhs.mIsFramebuffer)
86 BitmapMetadata& BitmapMetadata::operator=( const BitmapMetadata& rhs )
88 mImageWidth = rhs.mImageWidth;
89 mImageHeight =rhs.mImageHeight;
90 mHasAlphaChannel = rhs.mHasAlphaChannel;
91 mOpaqueness = rhs.mOpaqueness;
92 mIsNativeImage = rhs.mIsNativeImage;
93 mIsFramebuffer = rhs.mIsFramebuffer;
97 void BitmapMetadata::Update(NativeImageInterfacePtr nativeImage)
99 mImageWidth = nativeImage->GetWidth();
100 mImageHeight = nativeImage->GetHeight();
101 mHasAlphaChannel = nativeImage->RequiresBlending();
102 mOpaqueness = ! mHasAlphaChannel;
103 mIsNativeImage = true;
106 void BitmapMetadata::Update(Integration::Bitmap* const bitmap)
108 mImageWidth = bitmap->GetImageWidth();
109 mImageHeight = bitmap->GetImageHeight();
110 mHasAlphaChannel = Pixel::HasAlpha(bitmap->GetPixelFormat());
111 mOpaqueness = bitmap->IsFullyOpaque();
112 mIsNativeImage = false;
115 unsigned int BitmapMetadata::GetWidth() const
120 unsigned int BitmapMetadata::GetHeight() const
125 bool BitmapMetadata::HasAlphaChannel() const
127 return mHasAlphaChannel;
130 bool BitmapMetadata::IsFullyOpaque() const
135 void BitmapMetadata::SetWidth(unsigned int width)
140 void BitmapMetadata::SetHeight(unsigned int height)
142 mImageHeight = height;
145 void BitmapMetadata::SetHasAlphaChannel( bool hasAlphaChannel )
147 mHasAlphaChannel = hasAlphaChannel;
150 void BitmapMetadata::SetOpaqueness(bool opaqueness)
152 mOpaqueness = opaqueness;
155 void BitmapMetadata::SetIsNativeImage( bool isNativeImage )
157 mIsNativeImage = isNativeImage;
160 bool BitmapMetadata::GetIsNativeImage()
162 return mIsNativeImage;
165 void BitmapMetadata::SetIsFramebuffer( bool isFramebuffer )
167 mIsFramebuffer = isFramebuffer;
170 bool BitmapMetadata::GetIsFramebuffer()
172 return mIsFramebuffer;
177 } // namespace Internal