DDraceNetwork Docs
CImageInfo Class Reference

#include <image.h>

Inheritance diagram for CImageInfo:
[legend]

Public Types

enum  EImageFormat {
  FORMAT_UNDEFINED = -1 , FORMAT_RGB = 0 , FORMAT_RGBA = 1 , FORMAT_R = 2 ,
  FORMAT_RA = 3
}
 

Public Member Functions

void Free ()
 
size_t PixelSize () const
 
const char * FormatName () const
 
size_t DataSize () const
 
bool DataEquals (const CImageInfo &Other) const
 
ColorRGBA PixelColor (size_t x, size_t y) const
 
void SetPixelColor (size_t x, size_t y, ColorRGBA Color) const
 
void CopyRectFrom (const CImageInfo &SrcImage, size_t SrcX, size_t SrcY, size_t Width, size_t Height, size_t DestX, size_t DestY) const
 

Static Public Member Functions

static size_t PixelSize (EImageFormat Format)
 
static const char * FormatName (EImageFormat Format)
 

Public Attributes

size_t m_Width = 0
 
size_t m_Height = 0
 
EImageFormat m_Format = FORMAT_UNDEFINED
 
uint8_t * m_pData = nullptr
 

Detailed Description

Represents an image that has been loaded into main memory.

Member Enumeration Documentation

◆ EImageFormat

Defines the format of image data.

Enumerator
FORMAT_UNDEFINED 
FORMAT_RGB 
FORMAT_RGBA 
FORMAT_R 
FORMAT_RA 

Member Function Documentation

◆ CopyRectFrom()

void CImageInfo::CopyRectFrom ( const CImageInfo SrcImage,
size_t  SrcX,
size_t  SrcY,
size_t  Width,
size_t  Height,
size_t  DestX,
size_t  DestY 
) const

Copies a rectangle of image data from the given image to this image.

Parameters
SrcImageThe image to copy data from.
SrcXThe x-offset in the source image.
SrcYThe y-offset in the source image.
WidthThe width of the rectangle to copy.
HeightThe height of the rectangle to copy.
DestXThe x-offset in the destination image (this).
DestYThe y-offset in the destination image (this).

◆ DataEquals()

bool CImageInfo::DataEquals ( const CImageInfo Other) const

Returns whether this image is equal to the given image in width, height, format and data.

Parameters
OtherThe image to compare with.
Returns
true if the images are identical, false otherwise.

◆ DataSize()

size_t CImageInfo::DataSize ( ) const

Returns the size of the data, as derived from the width, height and pixel size.

Returns
Expected size of the image data.

◆ FormatName() [1/2]

const char * CImageInfo::FormatName ( ) const

Returns a readable name for the format of this image.

Returns
Readable name for the format of this image.

◆ FormatName() [2/2]

const char * CImageInfo::FormatName ( EImageFormat  Format)
static

Returns a readable name for the given image format.

Parameters
FormatImage format.
Returns
Readable name for the given image format.

◆ Free()

void CImageInfo::Free ( )

Frees the image data and clears all info.

◆ PixelColor()

ColorRGBA CImageInfo::PixelColor ( size_t  x,
size_t  y 
) const

Returns the color of the pixel at the specified position.

Parameters
xThe x-coordinate to read from.
yThe y-coordinate to read from.
Returns
Pixel color converted to normalized RGBA.

◆ PixelSize() [1/2]

size_t CImageInfo::PixelSize ( ) const

Returns the pixel size in bytes for the format of this image.

Returns
Size of one pixel with the format of this image.
Remarks
The format must not be FORMAT_UNDEFINED.

◆ PixelSize() [2/2]

size_t CImageInfo::PixelSize ( EImageFormat  Format)
static

Returns the pixel size in bytes for the given image format.

Parameters
FormatImage format, must not be FORMAT_UNDEFINED.
Returns
Size of one pixel with the given image format.

◆ SetPixelColor()

void CImageInfo::SetPixelColor ( size_t  x,
size_t  y,
ColorRGBA  Color 
) const

Sets the color of the pixel at the specified position.

Parameters
xThe x-coordinate to write to.
yThe y-coordinate to write to.
ColorThe normalized RGBA color to write.

Member Data Documentation

◆ m_Format

EImageFormat CImageInfo::m_Format = FORMAT_UNDEFINED

Format of the image.

See also
EImageFormat

◆ m_Height

size_t CImageInfo::m_Height = 0

Height of the image.

◆ m_pData

uint8_t* CImageInfo::m_pData = nullptr

Pointer to the image data.

◆ m_Width

size_t CImageInfo::m_Width = 0

Width of the image.


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