Ocean
Ocean::Platform::Win::Bitmap Class Reference

This class implements a Windows device independent bitmap. More...

Public Member Functions

 Bitmap ()=default
 Creates an invalid bitmap. More...
 
 Bitmap (const Bitmap &bitmap)
 Copies a bitmap. More...
 
 Bitmap (Bitmap &&bitmap)
 Move constructor. More...
 
 Bitmap (const Frame &frame)
 Creates a new bitmap by a given frame holding the image data. More...
 
 Bitmap (const FrameType &frameType)
 Creates a new bitmap with given size and pixel format. More...
 
 Bitmap (const unsigned int width, const unsigned int height, const FrameType::PixelFormat preferredPixelFormat, const FrameType::PixelOrigin pixelOrigin)
 Creates a new bitmap with given size and pixel format. More...
 
 Bitmap (unsigned int width, unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const uint8_t *frame, const unsigned int framePaddingElements)
 Creates a new bitmap with given size and pixel data. More...
 
 ~Bitmap ()
 Destructs a bitmap. More...
 
unsigned int width () const
 Returns the width of the bitmap. More...
 
unsigned int height () const
 Returns the height of the bitmap. More...
 
FrameType::PixelFormat pixelFormat () const
 Returns the bitmap's pixel format. More...
 
FrameType::PixelOrigin pixelOrigin () const
 Returns the origin of the bitmap. More...
 
HDC dc () const
 Returns the device context of the bitmap. More...
 
const uint8_t * data () const
 Returns the pixel data of the bitmap. More...
 
uint8_t * data ()
 Returns the pixel data of the bitmap. More...
 
unsigned int size () const
 Returns the size of the bitmap's internal image buffer. More...
 
unsigned int paddingElements () const
 Returns the number of padding elements at the end of each bitmap row. More...
 
unsigned int strideElements () const
 Returns the number of elements per bitmap row including optional padding elements at the end of each row. More...
 
bool setData (const uint8_t *frame, const FrameType::PixelFormat pixelFormat, const unsigned int framePaddingElements)
 Sets the pixel data of the bitmap. More...
 
bool set (const unsigned int width, const unsigned int height, const FrameType::PixelFormat preferredPixelFormat, const FrameType::PixelOrigin pixelOrigin)
 Sets or changes the format of the bitmap. More...
 
bool set (const Frame &frame)
 Sets or changes the bitmap data. More...
 
void release ()
 Releases the bitmap data and resets all values to default values. More...
 
bool isValid () const
 Returns whether the bitmap holds valid data. More...
 
Bitmapoperator= (Bitmap &&bitmap)
 Move operator. More...
 
Bitmapoperator= (const Bitmap &bitmap)
 Assigns a bitmap. More...
 

Static Public Member Functions

static FrameType::PixelFormat internalPixelFormat (const FrameType::PixelFormat pixelFormat)
 Returns which (internal) pixel format the bitmap uses to store the image data for a given pixel format. More...
 

Protected Member Functions

bool createBitmap (const unsigned int width, const unsigned int height, const FrameType::PixelFormat supportedPixelFormat, const FrameType::PixelOrigin pixelOrigin)
 Creates a new bitmap object. More...
 

Static Protected Member Functions

static bool createBitmapInfo (const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, Memory &bitmapInfoMemory)
 Creates the bitmap info for a specified bitmap. More...
 

Protected Attributes

unsigned int bitmapWidth_ = 0u
 Width of the bitmap in pixel, with range [0, infinity) More...
 
unsigned int bitmapHeight_ = 0u
 Height of the bitmap in pixel, with range [0, infinity) More...
 
FrameType::PixelFormat bitmapPixelFormat_ = FrameType::FORMAT_UNDEFINED
 Pixel format of the bitmap. More...
 
FrameType::PixelOrigin bitmapPixelOrigin_ = FrameType::ORIGIN_INVALID
 Origin of the frame. More...
 
uint8_t * bitmapData_ = nullptr
 Pixel data of the bitmap. More...
 
unsigned int bitmapSize_ = 0u
 Size of the pixel buffer in bytes. More...
 
unsigned int bitmapPaddingElements_ = 0u
 The number of padding elements at the end of each bitmap row, with range [0, 3]. More...
 
unsigned int bitmapStrideElements_ = 0u
 Number of elements per bitmap row including optional padding elements at the end of each row, with range [width * channels, infinity) More...
 
HDC bitmapDC_ = nullptr
 Device context of the bitmap. More...
 
HBITMAP bitmapHandle_ = nullptr
 Handle of the bitmap. More...
 

Detailed Description

This class implements a Windows device independent bitmap.

Constructor & Destructor Documentation

◆ Bitmap() [1/7]

Ocean::Platform::Win::Bitmap::Bitmap ( )
default

Creates an invalid bitmap.

◆ Bitmap() [2/7]

Ocean::Platform::Win::Bitmap::Bitmap ( const Bitmap bitmap)

Copies a bitmap.

Parameters
bitmapThe bitmap to copy

◆ Bitmap() [3/7]

Ocean::Platform::Win::Bitmap::Bitmap ( Bitmap &&  bitmap)

Move constructor.

Parameters
bitmapThe bitmap to move

◆ Bitmap() [4/7]

Ocean::Platform::Win::Bitmap::Bitmap ( const Frame frame)
explicit

Creates a new bitmap by a given frame holding the image data.

Parameters
frameThe frame to create a bitmap from

◆ Bitmap() [5/7]

Ocean::Platform::Win::Bitmap::Bitmap ( const FrameType frameType)
explicit

Creates a new bitmap with given size and pixel format.

Parameters
frameTypeThe type of the bitmap that will be created

◆ Bitmap() [6/7]

Ocean::Platform::Win::Bitmap::Bitmap ( const unsigned int  width,
const unsigned int  height,
const FrameType::PixelFormat  preferredPixelFormat,
const FrameType::PixelOrigin  pixelOrigin 
)

Creates a new bitmap with given size and pixel format.

Parameters
widthThe width of the bitmap in pixel, with range [1, infinity)
heightThe height of the bitmap in pixel, with range [1, infinity)
preferredPixelFormatPixel format of the bitmap
pixelOriginFrame origin

◆ Bitmap() [7/7]

Ocean::Platform::Win::Bitmap::Bitmap ( unsigned int  width,
unsigned int  height,
const FrameType::PixelFormat  pixelFormat,
const FrameType::PixelOrigin  pixelOrigin,
const uint8_t *  frame,
const unsigned int  framePaddingElements 
)

Creates a new bitmap with given size and pixel data.

Parameters
widthThe width of the bitmap in pixel, with range [1, infinity)
heightThe height of the bitmap in pixel, with range [1, infinity)
pixelFormatThe pixel format of the given data, must be supported
pixelOriginThe origin of the given frame data
frameThe frame data to be copied, must be valid
framePaddingElementsOptional number of padding elements at the end of each frame row, in elements, with range [0, infinity)
See also
internalPixelFormat().

◆ ~Bitmap()

Ocean::Platform::Win::Bitmap::~Bitmap ( )

Destructs a bitmap.

Member Function Documentation

◆ createBitmap()

bool Ocean::Platform::Win::Bitmap::createBitmap ( const unsigned int  width,
const unsigned int  height,
const FrameType::PixelFormat  supportedPixelFormat,
const FrameType::PixelOrigin  pixelOrigin 
)
protected

Creates a new bitmap object.

Parameters
widthThe width of the bitmap in pixel, with range [1, infinity)
heightThe height of the bitmap in pixel, with range [1, infinity)
supportedPixelFormatThe pixel format of the bitmap, must be supported by the bitmap, must be valid
pixelOriginThe origin of the bitmap
Returns
True, if succeeded

◆ createBitmapInfo()

static bool Ocean::Platform::Win::Bitmap::createBitmapInfo ( const unsigned int  width,
const unsigned int  height,
const FrameType::PixelFormat  pixelFormat,
const FrameType::PixelOrigin  pixelOrigin,
Memory bitmapInfoMemory 
)
staticprotected

Creates the bitmap info for a specified bitmap.

Parameters
widthThe width of the bitmap in pixel, with range [1, infinity)
heightThe height of the bitmap in pixel, with range [1, infinity)
pixelFormatThe pixel format of the bitmap, must be supported, must be valid
pixelOriginThe origin of the bitmap
bitmapInfoMemoryThe resulting bitmap info
Returns
True, if succeeded

◆ data() [1/2]

uint8_t * Ocean::Platform::Win::Bitmap::data ( )
inline

Returns the pixel data of the bitmap.

Returns
Pixel data

◆ data() [2/2]

const uint8_t * Ocean::Platform::Win::Bitmap::data ( ) const
inline

Returns the pixel data of the bitmap.

Returns
Pixel data

◆ dc()

HDC Ocean::Platform::Win::Bitmap::dc ( ) const
inline

Returns the device context of the bitmap.

Returns
Device context

◆ height()

unsigned int Ocean::Platform::Win::Bitmap::height ( ) const
inline

Returns the height of the bitmap.

Returns
The bitmap's height, in pixel with range [0, infinity)

◆ internalPixelFormat()

static FrameType::PixelFormat Ocean::Platform::Win::Bitmap::internalPixelFormat ( const FrameType::PixelFormat  pixelFormat)
static

Returns which (internal) pixel format the bitmap uses to store the image data for a given pixel format.

Parameters
pixelFormatThe pixel format for which the bitmap's internal pixel format will be returned, must be valid
Returns
The bitmap's internal pixel format for the specified pixel format, FORMAT_UNDEFINED if no internal pixel format exists

◆ isValid()

bool Ocean::Platform::Win::Bitmap::isValid ( ) const

Returns whether the bitmap holds valid data.

Returns
True, if so

◆ operator=() [1/2]

Bitmap& Ocean::Platform::Win::Bitmap::operator= ( Bitmap &&  bitmap)

Move operator.

Parameters
bitmapThe bitmap to move
Returns
Reference to this object

◆ operator=() [2/2]

Bitmap& Ocean::Platform::Win::Bitmap::operator= ( const Bitmap bitmap)

Assigns a bitmap.

Parameters
bitmapRight bitmap
Returns
Reference to this bitmap

◆ paddingElements()

unsigned int Ocean::Platform::Win::Bitmap::paddingElements ( ) const
inline

Returns the number of padding elements at the end of each bitmap row.

Returns
The number of padding elements, in elements, with range [0, 3]

◆ pixelFormat()

FrameType::PixelFormat Ocean::Platform::Win::Bitmap::pixelFormat ( ) const
inline

Returns the bitmap's pixel format.

Returns
Pixel format
See also
internalPixelFormat().

◆ pixelOrigin()

FrameType::PixelOrigin Ocean::Platform::Win::Bitmap::pixelOrigin ( ) const
inline

Returns the origin of the bitmap.

Returns
Frame origin

◆ release()

void Ocean::Platform::Win::Bitmap::release ( )

Releases the bitmap data and resets all values to default values.

◆ set() [1/2]

bool Ocean::Platform::Win::Bitmap::set ( const Frame frame)

Sets or changes the bitmap data.

Parameters
frameThe frame to set
Returns
True, if succeeded

◆ set() [2/2]

bool Ocean::Platform::Win::Bitmap::set ( const unsigned int  width,
const unsigned int  height,
const FrameType::PixelFormat  preferredPixelFormat,
const FrameType::PixelOrigin  pixelOrigin 
)

Sets or changes the format of the bitmap.

Parameters
widthThe width of the bitmap in pixel, with range [1, infinity)
heightThe height of the bitmap in pixel, with range [1, infinity)
preferredPixelFormatPreferred pixel format of the bitmap, this may be changed internally
pixelOriginThe origin of the bitmap
Returns
True, if the format could be changed

◆ setData()

bool Ocean::Platform::Win::Bitmap::setData ( const uint8_t *  frame,
const FrameType::PixelFormat  pixelFormat,
const unsigned int  framePaddingElements 
)

Sets the pixel data of the bitmap.

The pixel format of the given frame must match with the bitmap's internal pixel format. Both pixel formats match if bitmap.internalPixelFormat(pixelFormat) == bitmap.pixelFormat().

Parameters
frameThe frame data to be set, must fit the resolution of this bitmap, must be valid
pixelFormatThe pixel format of the given data, must be a supported pixel format, must be valid
framePaddingElementsThe number of padding elements at the end of each frame row, in elements, with range [0, infinity)
Returns
True, if succeeded
See also
internalPixelFormat().

◆ size()

unsigned int Ocean::Platform::Win::Bitmap::size ( ) const
inline

Returns the size of the bitmap's internal image buffer.

Returns
The bitmap's internal image buffer, in bytes, with range [0, infinity)

◆ strideElements()

unsigned int Ocean::Platform::Win::Bitmap::strideElements ( ) const
inline

Returns the number of elements per bitmap row including optional padding elements at the end of each row.

Windows bitmap strides are 4-byte aligned.

Returns
The number of elements per bitmap row, in elements, with range [width * channels, infinity)

◆ width()

unsigned int Ocean::Platform::Win::Bitmap::width ( ) const
inline

Returns the width of the bitmap.

Returns
The bitmap's width, in pixel, with range [0, infinity)

Field Documentation

◆ bitmapData_

uint8_t* Ocean::Platform::Win::Bitmap::bitmapData_ = nullptr
protected

Pixel data of the bitmap.

◆ bitmapDC_

HDC Ocean::Platform::Win::Bitmap::bitmapDC_ = nullptr
protected

Device context of the bitmap.

◆ bitmapHandle_

HBITMAP Ocean::Platform::Win::Bitmap::bitmapHandle_ = nullptr
protected

Handle of the bitmap.

◆ bitmapHeight_

unsigned int Ocean::Platform::Win::Bitmap::bitmapHeight_ = 0u
protected

Height of the bitmap in pixel, with range [0, infinity)

◆ bitmapPaddingElements_

unsigned int Ocean::Platform::Win::Bitmap::bitmapPaddingElements_ = 0u
protected

The number of padding elements at the end of each bitmap row, with range [0, 3].

◆ bitmapPixelFormat_

FrameType::PixelFormat Ocean::Platform::Win::Bitmap::bitmapPixelFormat_ = FrameType::FORMAT_UNDEFINED
protected

Pixel format of the bitmap.

◆ bitmapPixelOrigin_

FrameType::PixelOrigin Ocean::Platform::Win::Bitmap::bitmapPixelOrigin_ = FrameType::ORIGIN_INVALID
protected

Origin of the frame.

◆ bitmapSize_

unsigned int Ocean::Platform::Win::Bitmap::bitmapSize_ = 0u
protected

Size of the pixel buffer in bytes.

◆ bitmapStrideElements_

unsigned int Ocean::Platform::Win::Bitmap::bitmapStrideElements_ = 0u
protected

Number of elements per bitmap row including optional padding elements at the end of each row, with range [width * channels, infinity)

◆ bitmapWidth_

unsigned int Ocean::Platform::Win::Bitmap::bitmapWidth_ = 0u
protected

Width of the bitmap in pixel, with range [0, infinity)


The documentation for this class was generated from the following file: