Dali 3D User Interface Engine
bitmap.h
Go to the documentation of this file.
1 #ifndef __DALI_INTEGRATION_BITMAP_H__
2 #define __DALI_INTEGRATION_BITMAP_H__
3 
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20 
21 // EXTERNAL INCLUDES
22 
23 // INTERNAL INCLUDES
29 
30 namespace Dali
31 {
32 
33 namespace Integration
34 {
35 
42 DALI_IMPORT_API void ConvertToGlFormat(Pixel::Format pixelformat, unsigned& pixelDataType, unsigned& internalFormat);
43 
44 class Bitmap;
46 typedef unsigned char PixelBuffer;
47 
53 {
54 protected:
55 
63 
70  void Initialize(Pixel::Format pixelFormat,
71  unsigned int width,
72  unsigned int height);
73 
74 
75 public:
78  enum Profile
79  {
86  BITMAP_COMPRESSED
87  };
88 
100  static Bitmap* New( Profile profile, ResourcePolicy::Discardable discardable );
101 
110  unsigned int GetImageWidth() const
111  {
112  return mImageWidth;
113  }
114 
119  unsigned int GetImageHeight() const
120  {
121  return mImageHeight;
122  }
123 
128  Pixel::Format GetPixelFormat() const
129  {
130  return mPixelFormat;
131  }
132 
139  virtual PixelBuffer* GetBuffer()
140  {
141  return mData;
142  }
143 
149  PixelBuffer* GetBufferOwnership();
150 
156  virtual size_t GetBufferSize() const = 0;
157 
162  bool HasAlphaChannel() const
163  {
164  return mHasAlphaChannel;
165  }
166 
171  bool IsFullyOpaque() const
172  {
173  // check pixel format for alpha channel
174  return !(HasAlphaChannel() && mAlphaChannelUsed);
175  }
176 
178 
179 
186  {
187  public:
188 
201  virtual PixelBuffer* ReserveBuffer(Pixel::Format pixelFormat,
202  unsigned int width,
203  unsigned int height,
204  unsigned int bufferWidth = 0,
205  unsigned int bufferHeight = 0) = 0;
206 
227  virtual void AssignBuffer(Pixel::Format pixelFormat,
228  PixelBuffer* buffer,
229  std::size_t bufferSize,
230  unsigned int width,
231  unsigned int height,
232  unsigned int bufferWidth = 0,
233  unsigned int bufferHeight = 0) = 0;
238  virtual unsigned int GetBufferWidth() const = 0;
239 
244  virtual unsigned int GetBufferHeight() const = 0;
245 
251  virtual unsigned int GetBufferStride() const = 0;
252 
257  virtual void TestForTransparency() = 0;
258  };
259 
263  virtual const PackedPixelsProfile* GetPackedPixelsProfile() const { return 0; }
268 
270 
271 
277  {
278  public:
291  virtual PixelBuffer* ReserveBufferOfSize( Pixel::Format pixelFormat,
292  const unsigned width,
293  const unsigned height,
294  const size_t numBytes ) = 0;
295  };
296 
297  virtual const CompressedProfile* GetCompressedProfile() const { return 0; }
298  virtual CompressedProfile* GetCompressedProfile() { return 0; }
306  void DiscardBuffer();
307 
312  bool IsDiscardable() const
313  {
314  return mDiscardable == ResourcePolicy::OWNED_DISCARD;
315  }
316 
320  void DeletePixelBuffer();
321 
325  virtual ~Bitmap();
326 
327 protected:
328 
329  unsigned int mImageWidth;
330  unsigned int mImageHeight;
335 
336 private:
337 
339 
340  Bitmap(const Bitmap& other);
341  Bitmap& operator = (const Bitmap& other);
342 
343  // Changes scope, should be at end of class
345 };
346 
347 } // namespace Integration
348 
349 } // namespace Dali
350 
351 #endif // __DALI_INTEGRATION_BITMAP_H__
Dali Docs Home
Read more about Dali