ScummVM API documentation
Pixel buffers

Description

Class for managing pixel buffers.

Classes

class  Graphics::PixelBuffer
 

Functions

 Graphics::PixelBuffer::PixelBuffer ()
 
 Graphics::PixelBuffer::PixelBuffer (const Graphics::PixelFormat &format, int buffersize, DisposeAfterUse::Flag dispose)
 
 Graphics::PixelBuffer::PixelBuffer (const Graphics::PixelFormat &format, byte *buffer)
 
 Graphics::PixelBuffer::PixelBuffer (const PixelBuffer &buf)
 
 Graphics::PixelBuffer::~PixelBuffer ()
 
void Graphics::PixelBuffer::create (const Graphics::PixelFormat &format, int buffersize, DisposeAfterUse::Flag dispose)
 
void Graphics::PixelBuffer::create (int buffersize, DisposeAfterUse::Flag dispose)
 
void Graphics::PixelBuffer::set (const Graphics::PixelFormat &format, byte *buffer)
 
void Graphics::PixelBuffer::free ()
 
void Graphics::PixelBuffer::clear (uint length)
 
void Graphics::PixelBuffer::setPixelAt (int pixel, uint32 value)
 
void Graphics::PixelBuffer::setPixelAt (int pixel, const PixelBuffer &buf)
 
void Graphics::PixelBuffer::setPixelAt (int thisPix, const PixelBuffer &buf, int otherPix)
 
void Graphics::PixelBuffer::setPixelAt (int pixel, uint8 r, uint8 g, uint8 b)
 
void Graphics::PixelBuffer::setPixelAt (int pixel, uint8 a, uint8 r, uint8 g, uint8 b)
 
void Graphics::PixelBuffer::copyBuffer (int from, int length, const PixelBuffer &buf)
 
void Graphics::PixelBuffer::copyBuffer (int thisFrom, int otherFrom, int length, const PixelBuffer &buf)
 
void Graphics::PixelBuffer::shiftBy (int amount)
 
uint32 Graphics::PixelBuffer::getValueAt (int i) const
 
void Graphics::PixelBuffer::getRGBAt (int i, uint8 &r, uint8 &g, uint8 &b) const
 
void Graphics::PixelBuffer::getARGBAt (int i, uint8 &a, uint8 &r, uint8 &g, uint8 &b) const
 
byte * Graphics::PixelBuffer::getRawBuffer () const
 
byte * Graphics::PixelBuffer::getRawBuffer (int pixel) const
 
const PixelFormatGraphics::PixelBuffer::getFormat () const
 
PixelBufferGraphics::PixelBuffer::operator= (const PixelBuffer &buf)
 
PixelBufferGraphics::PixelBuffer::operator= (byte *buffer)
 
 Graphics::PixelBuffer::operator bool () const
 

Function Documentation

◆ PixelBuffer() [1/4]

Graphics::PixelBuffer::PixelBuffer ( )

Construct an empty PixelBuffer.

◆ PixelBuffer() [2/4]

Graphics::PixelBuffer::PixelBuffer ( const Graphics::PixelFormat format,
int  buffersize,
DisposeAfterUse::Flag  dispose 
)

Construct a PixelBuffer, allocating the internal buffer.

Parameters
formatThe format of the pixels in this buffer.
buffersizeThe number of pixels the buffer will store.
disposeIf YES the internal buffer will be deleted when this object is destroyed,

◆ PixelBuffer() [3/4]

Graphics::PixelBuffer::PixelBuffer ( const Graphics::PixelFormat format,
byte *  buffer 
)

Construct a PixelBuffer, using an already allocated buffer.

Parameters
formatThe format of the pixels in this buffer.
bufferThe raw buffer containing the pixels.

◆ PixelBuffer() [4/4]

Graphics::PixelBuffer::PixelBuffer ( const PixelBuffer buf)

Copy constructor. The internal buffer will NOT be duplicated, it will be shared between the instances.

◆ ~PixelBuffer()

Graphics::PixelBuffer::~PixelBuffer ( )

Destroy the object.

◆ create() [1/2]

void Graphics::PixelBuffer::create ( const Graphics::PixelFormat format,
int  buffersize,
DisposeAfterUse::Flag  dispose 
)

Initialize the buffer.

Parameters
formatThe format of the pixels.
buffersizeThe number of pixels the buffer will store.
disposeIf YES the internal buffer will be deleted when this object is destroyed,

◆ create() [2/2]

void Graphics::PixelBuffer::create ( int  buffersize,
DisposeAfterUse::Flag  dispose 
)

Initialize the buffer, using the already set pixel format.

Note
If the pixel format was not set before the results are undefined.
Parameters
buffersizeThe number of pixels the buffer will store.
disposeIf YES the internal buffer will be deleted when this object is destroyed,

◆ set()

void Graphics::PixelBuffer::set ( const Graphics::PixelFormat format,
byte *  buffer 
)

Initialize the buffer.

Parameters
formatThe format of the pixels in this buffer.
bufferThe raw buffer containing the pixels.

◆ free()

void Graphics::PixelBuffer::free ( )

Delete the internal pixel buffer.

◆ clear()

void Graphics::PixelBuffer::clear ( uint  length)

Reset the value of the pixels.

Parameters
lengthThe length of the buffer, in pixels.

◆ setPixelAt() [1/5]

void Graphics::PixelBuffer::setPixelAt ( int  pixel,
uint32  value 
)
inline

Set the value of the pixel at index 'pixel' to 'value',

◆ setPixelAt() [2/5]

void Graphics::PixelBuffer::setPixelAt ( int  pixel,
const PixelBuffer buf 
)
inline

Set the value of a pixel. The pixel will be converted from a pixel in another PixelBuffer, at the same index.

Parameters
pixelThe index of the pixel to set.
bufThe buffer storing the source pixel.

◆ setPixelAt() [3/5]

void Graphics::PixelBuffer::setPixelAt ( int  thisPix,
const PixelBuffer buf,
int  otherPix 
)
inline

Set the value of a pixel. The pixel will be converted from a pixel in another PixelBuffer.

Parameters
thisPixThe index of the pixel to set.
bufThe buffer storing the source pixel.
otherPixThe index of the source pixel in 'buf'.

◆ setPixelAt() [4/5]

void Graphics::PixelBuffer::setPixelAt ( int  pixel,
uint8  r,
uint8  g,
uint8  b 
)
inline

Set a pixel, from RGB values.

◆ setPixelAt() [5/5]

void Graphics::PixelBuffer::setPixelAt ( int  pixel,
uint8  a,
uint8  r,
uint8  g,
uint8  b 
)
inline

Set a pixel, from ARGB values.

◆ copyBuffer() [1/2]

void Graphics::PixelBuffer::copyBuffer ( int  from,
int  length,
const PixelBuffer buf 
)
inline

Copy some pixels from a buffer. The pixels will be converted, storing the same ARGB value.

Parameters
fromThe starting index.
lengthThe number of pixels to copy.
bufThe source buffer.

◆ copyBuffer() [2/2]

void Graphics::PixelBuffer::copyBuffer ( int  thisFrom,
int  otherFrom,
int  length,
const PixelBuffer buf 
)

Copy some pixels from a buffer. The pixels will be converted, storing the same ARGB value.

Parameters
thisFromThe starting index.
otherFromThe starting index in the source buffer.
lengthThe number of pixels to copy.
bufThe source buffer.

◆ shiftBy()

void Graphics::PixelBuffer::shiftBy ( int  amount)
inline

Shift the internal buffer of some pixels, losing some pixels at the start of the buffer. The pixels lost will NOT be deleted.

◆ getValueAt()

uint32 Graphics::PixelBuffer::getValueAt ( int  i) const
inline

Return the encoded value of the pixel at the given index.

◆ getRGBAt()

void Graphics::PixelBuffer::getRGBAt ( int  i,
uint8 &  r,
uint8 &  g,
uint8 &  b 
) const
inline

Return the RGB value of the pixel at the given index.

◆ getARGBAt()

void Graphics::PixelBuffer::getARGBAt ( int  i,
uint8 &  a,
uint8 &  r,
uint8 &  g,
uint8 &  b 
) const
inline

Return the ARGB value of the pixel at the given index.

◆ getRawBuffer() [1/2]

byte* Graphics::PixelBuffer::getRawBuffer ( ) const
inline

Return the internal buffer.

◆ getRawBuffer() [2/2]

byte* Graphics::PixelBuffer::getRawBuffer ( int  pixel) const
inline

Return the internal buffer, pointing at the wanted pixel.

◆ getFormat()

const PixelFormat& Graphics::PixelBuffer::getFormat ( ) const
inline

Return the pixel format used.

◆ operator=() [1/2]

PixelBuffer& Graphics::PixelBuffer::operator= ( const PixelBuffer buf)

Copy a PixelBuffer object. The internal buffer will NOT be duplicated, it will be shared between the instances.

◆ operator=() [2/2]

PixelBuffer& Graphics::PixelBuffer::operator= ( byte *  buffer)

Set the internal buffer to an already allocated array.

Parameters
bufferThe pointer to the array.

◆ operator bool()

Graphics::PixelBuffer::operator bool ( ) const
inline

Check if the interal buffer is allocated.

Returns
true if allocated.