FuncDoodle
Loading...
Searching...
No Matches
FuncDoodle::ImageArray Class Reference

2D array of RGB8 color pixels. More...

#include <Frame.h>

Public Member Functions

ImageArrayoperator= (const ImageArray &)=default
 Copies pixel data from another image array.
ImageArrayoperator= (ImageArray &&)=default
 Moves pixel data from another image array.
 ImageArray (const ImageArray &)=default
 Copies an existing image array.
 ImageArray (ImageArray &&)=default
 Moves an existing image array.
 ImageArray (int width, int height, Col bgCol)
 Construct array with dimensions.
 ~ImageArray ()
void RedoColorAdjustment (Col bgCol)
 Reapplies background-color dependent adjustments after a color change.
void Resize ()
 Resizes the backing pixel buffer to match current dimensions.
void Set (int x, int y, const Col &color)
 Sets a pixel color.
Col Get (int x, int y) const
 Returns a pixel color.
int Width () const
 Returns the image width in pixels.
void SetWidth (int width, bool clear=false)
 Sets the image width.
int Height () const
 Returns the image height in pixels.
void SetHeight (int height, bool clear=false)
 Sets the image height.
void SetData (const std::vector< Col > &data)
 Replaces the raw pixel buffer.
const std::vector< Col > & Data () const
 Returns the raw pixel buffer.
Col BgCol () const
 Returns the image background color.
void SetBG (const Col bgCol)
 Sets the background color.

Private Attributes

int m_Width = g_DefaultCanvasWidth
int m_Height = g_DefaultCanvasHeight
std::vector< Colm_Data
Col m_BG

Detailed Description

2D array of RGB8 color pixels.

Stores a width x height grid of Col (RGB8) values in a flat vector. Used by Frame to store pixel data. Supports bounds-checked get/set.

Invariant
Width() > 0 && Height() > 0
m_Data.size() == Width() * Height()
Note
Thread-unsafe: no locking.
Warning
Accessing out of bounds is undefined behavior.

Constructor & Destructor Documentation

◆ ImageArray() [1/3]

FuncDoodle::ImageArray::ImageArray ( const ImageArray & )
default

Copies an existing image array.

◆ ImageArray() [2/3]

FuncDoodle::ImageArray::ImageArray ( ImageArray && )
default

Moves an existing image array.

◆ ImageArray() [3/3]

FuncDoodle::ImageArray::ImageArray ( int width,
int height,
Col bgCol )

Construct array with dimensions.

Parameters
widthMust be > 0.
heightMust be > 0.
bgColBackground color for unfilled pixels.
Precondition
width > 0 && height > 0

◆ ~ImageArray()

FuncDoodle::ImageArray::~ImageArray ( )

Member Function Documentation

◆ BgCol()

Col FuncDoodle::ImageArray::BgCol ( ) const
inlinenodiscard

Returns the image background color.

Returns
Background color.

◆ Data()

const std::vector< Col > & FuncDoodle::ImageArray::Data ( ) const
inlinenodiscard

Returns the raw pixel buffer.

Returns
Const reference to pixel data.

◆ Get()

Col FuncDoodle::ImageArray::Get ( int x,
int y ) const
nodiscard

Returns a pixel color.

Parameters
xPixel X coordinate.
yPixel Y coordinate.
Returns
Pixel color at the requested coordinate.

◆ Height()

int FuncDoodle::ImageArray::Height ( ) const
inlinenodiscard

Returns the image height in pixels.

Returns
Image height.

◆ operator=() [1/2]

ImageArray & FuncDoodle::ImageArray::operator= ( const ImageArray & )
default

Copies pixel data from another image array.

◆ operator=() [2/2]

ImageArray & FuncDoodle::ImageArray::operator= ( ImageArray && )
default

Moves pixel data from another image array.

◆ RedoColorAdjustment()

void FuncDoodle::ImageArray::RedoColorAdjustment ( Col bgCol)

Reapplies background-color dependent adjustments after a color change.

Parameters
bgColNew background color.

◆ Resize()

void FuncDoodle::ImageArray::Resize ( )

Resizes the backing pixel buffer to match current dimensions.

◆ Set()

void FuncDoodle::ImageArray::Set ( int x,
int y,
const Col & color )

Sets a pixel color.

Parameters
xPixel X coordinate.
yPixel Y coordinate.
colorNew pixel color.

◆ SetBG()

void FuncDoodle::ImageArray::SetBG ( const Col bgCol)
inline

Sets the background color.

Parameters
bgColNew background color.

◆ SetData()

void FuncDoodle::ImageArray::SetData ( const std::vector< Col > & data)
inline

Replaces the raw pixel buffer.

Parameters
dataNew pixel buffer.

◆ SetHeight()

void FuncDoodle::ImageArray::SetHeight ( int height,
bool clear = false )
inline

Sets the image height.

Parameters
heightNew image height.
clearWhether pixel contents should be cleared.

◆ SetWidth()

void FuncDoodle::ImageArray::SetWidth ( int width,
bool clear = false )
inline

Sets the image width.

Parameters
widthNew image width.
clearWhether pixel contents should be cleared.

◆ Width()

int FuncDoodle::ImageArray::Width ( ) const
inlinenodiscard

Returns the image width in pixels.

Returns
Image width.

Member Data Documentation

◆ m_BG

Col FuncDoodle::ImageArray::m_BG
private

◆ m_Data

std::vector<Col> FuncDoodle::ImageArray::m_Data
private

◆ m_Height

int FuncDoodle::ImageArray::m_Height = g_DefaultCanvasHeight
private

◆ m_Width

int FuncDoodle::ImageArray::m_Width = g_DefaultCanvasWidth
private

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