2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FGrp_BitmapImpl.h
20 * @brief This is the header file for the _BitmapImpl class.
24 #ifndef _FGRP_INTERNAL_BITMAPIMPL_H_
25 #define _FGRP_INTERNAL_BITMAPIMPL_H_
32 #include <FBaseObject.h>
33 #include <FBaseString.h>
34 #include <FGrpBitmapCommon.h>
36 #include "FGrp_CanvasImpl.h"
39 namespace Tizen { namespace Base
44 namespace Tizen { namespace Graphics
55 class _OSP_EXPORT_ _BitmapImpl
56 : public Tizen::Base::Object
60 virtual ~_BitmapImpl(void);
62 result Construct(const Rectangle& rect);
63 result Construct(const Dimension& dim, BitmapPixelFormat format);
64 result Construct(const _CanvasImpl& canvas, const Tizen::Graphics::Rectangle& rect);
65 result Construct(const _BitmapImpl& bitmap, const Tizen::Graphics::Rectangle& rect);
66 result Construct(const Tizen::Base::ByteBuffer& buffer, const Dimension& dim, BitmapPixelFormat pixelFormat);
67 result Construct(const Tizen::Base::ByteBuffer& buffer, const Dimension& dim, BitmapPixelFormat pixelFormat, BufferScaling bufferScaling);
68 result Construct(const BufferInfo& bufferInfo);
69 result Construct(const Tizen::Base::String& fileName, BitmapPixelFormat pixelFormat);
71 bool IsConstructed(void) const;
72 const Tizen::Base::String& GetFileName(void) const;
74 result Scale(const Dimension& dim);
75 result Merge(const Point& destPoint, const _BitmapImpl& srcBitmap, const Rectangle& srcRect);
77 int GetHeight(void) const;
78 int GetWidth(void) const;
80 int GetBitsPerPixel(void) const;
81 BitmapPixelFormat GetPixelColorFormat(void) const;
83 result SetMaskingColor(const Color* pColor);
84 result GetMaskingColor(Color& color) const;
86 void SetAlphaConstant(int opacity);
87 int GetAlphaConstant(void) const;
89 result SetScalingQuality(BitmapScalingQuality quality);
90 BitmapScalingQuality GetScalingQuality(void) const;
92 bool IsNinePatchedBitmap(void) const;
94 void SetAsImmutable(void);
97 result Lock(BufferInfo& info, long timeout = INFINITE);
100 result LockFast(BufferInfo& info, long timeout = INFINITE);
101 result UnlockFast(void);
104 * This method is for internal use only. The Tizen C++ platform team is not
105 * responsible for any behavioral correctness, consistency, and
106 * security-related issues that might arise after using this method.
108 * Creates and returns a scaled bitmap from the specified nine-patched bitmap
111 * @return The scaled bitmap @n
112 * @c null, if an exception occurs
113 * @param[in] ninePatchedBitmap The nine-patched bitmap
114 * @param[in] width The width of the returned bitmap.
115 * @param[in] height The height of the returned bitmap.
116 * @exception E_SUCCESS The method was successful.
117 * @exception E_INVALID_ARG The specified input parameter is invalid.
118 * @exception E_OUT_OF_MEMORY Insufficient memory.
119 * @exception E_UNSUPPORTED_FORMAT The specified format is not supported.
120 * @exception E_SYSTEM An unknown operating system error has occurred.
122 * @remarks The specific error code can be accessed using the GetLastResult() method.
124 static Bitmap* GetExpandedBitmapN(const Bitmap& ninePatchedBitmap, int width, int height);
127 * This method is for internal use only. The Tizen C++ platform team is not
128 * responsible for any behavioral correctness, consistency, and
129 * security-related issues that might arise after using this method.
131 * Creates and returns a scaled bitmap from the specified nine-patched bitmap
134 * @return The converted bitmap @n
135 * @c null, if an exception occurs
136 * @param[in] bitmap The source bitmap
137 * @param[in] replacedColor The color replaced.
138 * @param[in] newColor The color replacing.
139 * @exception E_SUCCESS The method was successful.
140 * @exception E_INVALID_ARG The specified input parameter is invalid.
141 * @exception E_OUT_OF_MEMORY The memory is insufficient.
142 * @exception E_SYSTEM An unknown operating system error has occurred.
144 * @remarks The specific error code can be accessed using the GetLastResult() method.
146 static Bitmap* GetColorReplacedBitmapN(const Bitmap& bitmap, const Color& replacedColor, const Color& newColor);
149 * This method is for internal use only. The Tizen C++ platform team is not
150 * responsible for any behavioral correctness, consistency, and
151 * security-related issues that might arise after using this method.
153 * Clones a bitmap managed with a reference count
156 * @return The cloned bitmap @n
157 * @c null, if an exception occurs
158 * @param[in] bitmap The source bitmap
159 * @exception E_SUCCESS The method was successful.
160 * @exception E_INVALID_ARG The specified input parameter is invalid.
161 * @exception E_OUT_OF_MEMORY The memory is insufficient.
162 * @exception E_SYSTEM An unknown operating system error has occurred.
164 * @remarks The specific error code can be accessed using the GetLastResult() method.
166 static Bitmap* CloneN(const Bitmap& bitmap);
168 static _BitmapImpl* GetNonScaledBitmapImplN(const Tizen::Base::ByteBuffer& buffer, const Dimension& dim, BitmapPixelFormat pixelFormat);
171 * This method is for internal use only. The Tizen C++ platform team is not
172 * responsible for any behavioral correctness, consistency, and
173 * security-related issues that might arise after using this method.
175 * Creates and returns a non scaled bitmap.
178 * @return The non scaled bitmap @n
179 * @c null, if an exception occurs
180 * @param[in] buffer The buffer containing raw data
181 * @param[in] dim The dimensions of the bitmap @n
182 * The width and height must be greater than @c 0.
183 * @param[in] pixelFormat The pixel format of raw data
184 * @exception E_SUCCESS The method was successful.
185 * @exception E_INVALID_ARG The specified input parameter is invalid.
186 * @exception E_UNSUPPORTED_FORMAT The specified format is not supported.
187 * @exception E_OUT_OF_MEMORY Insufficient memory.
189 * @remarks The specific error code can be accessed using the GetLastResult() method.
191 static Bitmap* GetNonScaledBitmapN(const Tizen::Base::ByteBuffer& buffer, const Dimension& dim, BitmapPixelFormat pixelFormat);
193 static _BitmapImpl* GetInstance(Bitmap& bitmap);
194 static const _BitmapImpl* GetInstance(const Bitmap& bitmap);
197 bool _SetCallback(void (* DestroyCallback)(void*), void* pDestroyCallbackParam,
198 void (* LockCallback)(void*), void* pLockCallbackParam,
199 void (* UnlockCallback)(void*), void* pUnlockCallbackParam);
200 static _BitmapImpl*& _GetBitmapImpl(Bitmap* pBitmap);
203 _BitmapImpl(const _BitmapImpl& src);
204 _BitmapImpl& operator =(const _BitmapImpl& value);
206 result Construct(const Tizen::Base::ByteBuffer& buffer, const Dimension& dim, BitmapPixelFormat pixelFormat, bool autoScaling);
207 result Construct(const byte* pBuffer, int bufferSize, const Dimension& dim, BitmapPixelFormat pixelFormat, bool autoScaling);
209 bool __CheckValidity(bool canBufferExpand = true);
210 bool __RealizeBuffer(void);
215 std::auto_ptr<_Bitmap> nativeBitmap;
216 std::auto_ptr<struct _BitmapCoordHolder> coordHolder;
218 std::auto_ptr<_Bitmap> scaledNativeBitmap; // depend on lazyScaling flag
221 void (* pDestroyCallbackFunc)(void*);
222 void* pDestroyCallbackParam;
223 void (* pLockCallbackFunc)(void*);
224 void* pLockCallbackParam;
225 void (* pUnlockCallbackFunc)(void*);
226 void* pUnlockCallbackParam;
228 // removed a bit later
229 Tizen::Base::String associatedFileName;
233 Tizen::Base::String fileName;
234 BitmapPixelFormat pixelFormat;
237 void Move(_SharedItem& source);
240 std::tr1::shared_ptr<_SharedItem> _sharedItem;
243 friend class _CanvasImpl;
247 }} // Tizen::Graphics
249 #endif // _FGRP_INTERNAL_BITMAPIMPL_H_