Dali 3D User Interface Engine
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
Dali::Integration::ImageData Class Reference

A simple container for image data. More...

#include <image-data.h>

Inheritance diagram for Dali::Integration::ImageData:
Inheritance graph
[legend]
Collaboration diagram for Dali::Integration::ImageData:
Collaboration graph
[legend]

Public Types

enum  AlphaUsage { ALPHA_USAGE_UNDETERMINED, ALPHA_USAGE_ALL_OPAQUE, ALPHA_USAGE_SOME_TRANSLUCENT }
 Three values for the information about the alpha values in the pixels. More...
 

Public Member Functions

const uint8_t * GetBuffer () const
 Access the buffer of image data. More...
 
uint8_t * GetBuffer ()
 Access the buffer of image data. More...
 
uint8_t * ReleaseImageBuffer ()
 Pass ownership of the buffer of pixel-level data that this instance currently owns to the caller, and forget about the buffer here as a side effect. More...
 
AlphaUsage GetAlphaUsage () const
 Get whether the alpha channel in the pixels is used. More...
 
void SetAlphaUsed (const bool alphaUsed)
 Set whether the alpha channel in the pixels is used. More...
 
- Public Member Functions inherited from Dali::RefObject
void Reference ()
 Increment the object's reference count. More...
 
void Unreference ()
 Decrement the object's reference count. More...
 
int ReferenceCount ()
 Retrieve the object's reference count. More...
 

Static Public Member Functions

static ImageDataPtr New (const BufferSize numBytes, unsigned imageWidth, unsigned imageHeight, Pixel::Format pixelFormat)
 Allocate and initialize a fresh ImageData object pointing at a new buffer, returning a smart pointer owning it. More...
 
static ImageDataPtr New (uint8_t *const imageBuffer, const BufferSize numBytes, unsigned imageWidth, unsigned imageHeight, Pixel::Format pixelFormat)
 Allocate and initialise a fresh ImageData object, taking ownership of the buffer passed in. More...
 

Public Attributes

const size_t dataSize
 Number of bytes in buffer pointed at by mData. More...
 
const uint16_t imageWidth
 Image logical width in pixels. More...
 
const uint16_t imageHeight
 Image logical height in pixels. More...
 
const Pixel::Format pixelFormat
 Pixel format. More...
 

Private Member Functions

 ImageData (const size_t numBytes, const unsigned imageWidth, const unsigned imageHeight, const Pixel::Format pixelFormat)
 Construct an instance and allocate a buffer owned by it. More...
 
 ImageData (uint8_t *const imageBuffer, const size_t numBytes, const unsigned imageWidth, const unsigned imageHeight, const Pixel::Format pixelFormat)
 Construct an instance and have it take ownership of the buffer passed in. More...
 
 ~ImageData ()
 
 ImageData (const ImageData &other)
 defined private to prevent use More...
 
ImageDataoperator= (const ImageData &other)
 defined private to prevent use More...
 

Private Attributes

uint8_t * mData
 Pointer to the buffer of image data. More...
 
AlphaUsage mAlphaChannelUsed
 
 DALI_LOG_OBJECT_STRING_DECLARATION
 

Additional Inherited Members

- Protected Member Functions inherited from Dali::RefObject
 RefObject ()
 Default constructor. More...
 
virtual ~RefObject ()
 RefObject is intended as a base class. More...
 
 RefObject (const RefObject &rhs)
 Copy constructor. More...
 
RefObjectoperator= (const RefObject &rhs)
 Assignment operator. More...
 

Detailed Description

A simple container for image data.

Just a pointer to a buffer and some minimal metadata. It always owns the buffer of image data that it points to until it is destroyed or the buffer is released with ReleaseImageBuffer().

The width and height stored are the logical image values. Compressed formats such as ETC group pixels into blocks (ETC = 4*4) and these logical width and height may indicate, for example for ETC, that 1 to 3 pixels in the rightmost column of blocks or bottom row are ignored for rendering. For simple uncompressed images, the buffer is exactly width * height * bytes-per-pixel in size with no spare bytes at right or bottom edge.

Definition at line 68 of file image-data.h.

Member Enumeration Documentation

Three values for the information about the alpha values in the pixels.

Alpha in pixels with the channel can be undetermined, it can be all-ones, or it can have at least one pixel that is translucent with an alpha < 1.0.

Enumerator
ALPHA_USAGE_UNDETERMINED 

Alpha not yet been tested.

ALPHA_USAGE_ALL_OPAQUE 

Alpha == 1.0 in every pixel.

ALPHA_USAGE_SOME_TRANSLUCENT 

Alpha < 1.0 in at least one pixel.

Definition at line 78 of file image-data.h.

Constructor & Destructor Documentation

Dali::Integration::ImageData::ImageData ( const size_t  numBytes,
const unsigned  imageWidth,
const unsigned  imageHeight,
const Pixel::Format  pixelFormat 
)
private

Construct an instance and allocate a buffer owned by it.

Parameters
[in]numBytesThe number of bytes to allocate to hold the image data.
[in]imageWidthThe width in pixels of the image.
[in]imageHeightThe height in pixels of the image.
[in]pixelFormatThe format of the image data in the buffer.

Definition at line 31 of file image-data.cpp.

References DALI_ASSERT_DEBUG.

Referenced by New().

Here is the caller graph for this function:

Dali::Integration::ImageData::ImageData ( uint8_t *const  imageBuffer,
const size_t  numBytes,
const unsigned  imageWidth,
const unsigned  imageHeight,
const Pixel::Format  pixelFormat 
)
private

Construct an instance and have it take ownership of the buffer passed in.

Parameters
[in]imageBufferA buffer of pixel data that should have been allocated using new uint8_t[].
[in]numBytesThe number of bytes in the buffer pointed to by imageBuffer.
[in]imageWidthThe width in pixels of the image.
[in]imageHeightThe height in pixels of the image.
[in]pixelFormatThe format of the image data in the buffer.

Definition at line 42 of file image-data.cpp.

References DALI_ASSERT_DEBUG.

Dali::Integration::ImageData::~ImageData ( )
private

Definition at line 53 of file image-data.cpp.

References mData.

Dali::Integration::ImageData::ImageData ( const ImageData other)
private

defined private to prevent use

Member Function Documentation

AlphaUsage Dali::Integration::ImageData::GetAlphaUsage ( ) const
inline

Get whether the alpha channel in the pixels is used.

Definition at line 156 of file image-data.h.

const uint8_t* Dali::Integration::ImageData::GetBuffer ( ) const
inline

Access the buffer of image data.

Definition at line 138 of file image-data.h.

uint8_t* Dali::Integration::ImageData::GetBuffer ( )
inline

Access the buffer of image data.

Definition at line 141 of file image-data.h.

ImageDataPtr Dali::Integration::ImageData::New ( const BufferSize  numBytes,
unsigned  imageWidth,
unsigned  imageHeight,
Pixel::Format  pixelFormat 
)
static

Allocate and initialize a fresh ImageData object pointing at a new buffer, returning a smart pointer owning it.

Note
Clients can alternatively use the helper function NewBitmapImageData() to calculate the buffer size from other parameters if the image data represents a bitmap (a 2d grid of addressable pixels).
Parameters
[in]numBytesThe number of bytes to allocate to hold the image data.
[in]imageWidthThe width in pixels of the image.
[in]imageHeightThe height in pixels of the image.
[in]pixelFormatThe format of the image data in the buffer.

Definition at line 58 of file image-data.cpp.

References Dali::Integration::BufferSize::bufferSize, DALI_ASSERT_DEBUG, and ImageData().

Referenced by Dali::Integration::NewBitmapImageData().

Here is the call graph for this function:

Here is the caller graph for this function:

ImageDataPtr Dali::Integration::ImageData::New ( uint8_t *const  imageBuffer,
const BufferSize  numBytes,
unsigned  imageWidth,
unsigned  imageHeight,
Pixel::Format  pixelFormat 
)
static

Allocate and initialise a fresh ImageData object, taking ownership of the buffer passed in.

Parameters
[in]imageBufferA block of memory allocated with new uint8_t[]. This is owned by the new ImageData instance on successful return and should be forgotten by the caller.
[in]numBytesThe number of bytes in the buffer pointed to by imageBuffer.
[in]imageWidthThe width in pixels of the image.
[in]imageHeightThe height in pixels of the image.
[in]pixelFormatThe format of the image data in the buffer.

Definition at line 65 of file image-data.cpp.

References Dali::Integration::BufferSize::bufferSize, DALI_ASSERT_DEBUG, and ImageData().

Here is the call graph for this function:

ImageData& Dali::Integration::ImageData::operator= ( const ImageData other)
private

defined private to prevent use

uint8_t* Dali::Integration::ImageData::ReleaseImageBuffer ( )
inline

Pass ownership of the buffer of pixel-level data that this instance currently owns to the caller, and forget about the buffer here as a side effect.

Returns
A pointer to the underlying buffer of pixel-level image data. The caller takes ownership of the buffer and is responsible for calling delete[] on it eventually.

Definition at line 151 of file image-data.h.

void Dali::Integration::ImageData::SetAlphaUsed ( const bool  alphaUsed)
inline

Set whether the alpha channel in the pixels is used.

Definition at line 161 of file image-data.h.

Member Data Documentation

Dali::Integration::ImageData::DALI_LOG_OBJECT_STRING_DECLARATION
private

Definition at line 181 of file image-data.h.

const size_t Dali::Integration::ImageData::dataSize

Number of bytes in buffer pointed at by mData.

Definition at line 172 of file image-data.h.

const uint16_t Dali::Integration::ImageData::imageHeight

Image logical height in pixels.

Definition at line 174 of file image-data.h.

const uint16_t Dali::Integration::ImageData::imageWidth

Image logical width in pixels.

Definition at line 173 of file image-data.h.

AlphaUsage Dali::Integration::ImageData::mAlphaChannelUsed
private

Definition at line 178 of file image-data.h.

uint8_t* Dali::Integration::ImageData::mData
private

Pointer to the buffer of image data.

Definition at line 169 of file image-data.h.

Referenced by ~ImageData().

const Pixel::Format Dali::Integration::ImageData::pixelFormat

Pixel format.

Definition at line 175 of file image-data.h.


The documentation for this class was generated from the following files:
Dali Docs Home
Read more about Dali