Dali 3D User Interface Engine
image-data.h
Go to the documentation of this file.
1 #ifndef __DALI_INTEGRATION_IMAGE_DATA_H__
2 #define __DALI_INTEGRATION_IMAGE_DATA_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 // INTERNAL INCLUDES
22 #include <dali/integration-api/debug.h> // For DALI_LOG_OBJECT_STRING_DECLARATION
26 
27 // EXTERNAL INCLUDES
28 #include <stdint.h>
29 
30 namespace Dali
31 {
32 
33 namespace Integration
34 {
35 
36 class ImageData;
38 
39 typedef uint8_t PixelBuffer;
40 
46 {
47 public:
48  explicit BufferSize(size_t size) : bufferSize( size )
49  { }
50  operator size_t() const { return bufferSize; }
51  const size_t bufferSize;
52 };
53 
69 {
70 public:
79  {
85  ALPHA_USAGE_SOME_TRANSLUCENT
86  };
87 
88 private:
89 
97  ImageData( const size_t numBytes, const unsigned imageWidth, const unsigned imageHeight, const Pixel::Format pixelFormat );
98 
107  ImageData( uint8_t * const imageBuffer, const size_t numBytes, const unsigned imageWidth, const unsigned imageHeight, const Pixel::Format pixelFormat );
108 
109  ~ImageData();
110 
111 public:
112 
123  static ImageDataPtr New( const BufferSize numBytes, unsigned imageWidth, unsigned imageHeight, Pixel::Format pixelFormat );
124 
135  static ImageDataPtr New( uint8_t * const imageBuffer, const BufferSize numBytes, unsigned imageWidth, unsigned imageHeight, Pixel::Format pixelFormat );
136 
138  const uint8_t * GetBuffer() const { return mData; }
139 
141  uint8_t * GetBuffer() { return mData; }
142 
151  uint8_t * ReleaseImageBuffer() { uint8_t * const data = mData; mData = 0; return data; }
152 
156  AlphaUsage GetAlphaUsage() const { return mAlphaChannelUsed; }
157 
161  void SetAlphaUsed( const bool alphaUsed ) { mAlphaChannelUsed = alphaUsed ? ALPHA_USAGE_SOME_TRANSLUCENT : ALPHA_USAGE_ALL_OPAQUE; }
162 
163 private:
164 
165  ImageData(const ImageData& other);
166  ImageData& operator = (const ImageData& other);
167 
169  uint8_t* mData;
170 
171 public:
172  const size_t dataSize;
173  const uint16_t imageWidth;
174  const uint16_t imageHeight;
176 
177 private:
179 
180  // Changes scope, should be at end of class
182 };
183 
191 DALI_IMPORT_API ImageDataPtr NewBitmapImageData( unsigned imageWidth, unsigned imageHeight, Pixel::Format pixelFormat );
192 
193 } // namespace Integration
194 
195 } // namespace Dali
196 
197 #endif // __DALI_INTEGRATION_IMAGE_DATA_H__
Dali Docs Home
Read more about Dali