Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cSurfaceBase Class Reference

#include <cSurfaceBase.h>

Inheritance diagram for GrayLib::cSurfaceBase:
Gray::cMemBlock GrayLib::cImageBase GrayLib::cSurface GrayCodec::cImageJP2 GrayCodec::cImageJPG GrayCodec::cImagePNG GrayLib::cImageBMP GrayLib::cImageDDS GrayLib::cImageTGA GrayLib::cImageGIF

Public Member Functions

 cSurfaceBase () noexcept
 
 cSurfaceBase (void *pPixelData, const cSurfaceInfo &rInfo)
 
 cSurfaceBase (void *pPixelData, PIXELS_t cx, PIXELS_t cy, size_t uPitchBytes, SURF_FORM_TYPE ePixelFormat)
 
virtual ~cSurfaceBase ()
 
HRESULT SaveRaw (cStreamOutput &file)
 
HRESULT SaveRaw (const FILECHAR_t *pszFilename)
 
virtual void SetEmpty ()
 
bool isValidCheck () const noexcept
 
const cSurfaceInfoget_Info () const noexcept
 
void put_Info (const cSurfaceInfo &rInfo)
 
size_t get_PitchBytes () const noexcept
 
PIXELS_t get_Width () const noexcept
 
PIXELS_t get_Height () const noexcept
 
bool isTopDown () const noexcept
 
SURF_FORM_TYPE get_PixelFormat () const noexcept
 
bool isValidPixelData () const noexcept
 basic attributes. More...
 
void * get_PixelData () const noexcept
 
BYTE * get_PixelBytes () const noexcept
 
void put_PixelData (void *pPixelData) noexcept
 
void * GetLinePtrRaw (PIXELS_t y) const noexcept
 
BYTE * GetLinePtrByte (PIXELS_t y) const noexcept
 
void * GetLinePtr (PIXELS_t y) const noexcept
 
void * GetNextLine (const void *pLinePtr) const noexcept
 
bool IsValidPixPtr (const void *p) const noexcept
 
BYTE * GetPixPtr (const void *pvLine, PIXELS_t x, size_t sizePixel) const noexcept
 
BYTE * GetPixPtr (PIXELS_t x, PIXELS_t y, size_t sizePixel) const noexcept
 
COLOR16_tGetPixPtr16 (PIXELS_t x, PIXELS_t y) const noexcept
 
BYTE * GetPixPtr (PIXELS_t x, PIXELS_t y) const noexcept
 
bool Lock ()
 
void Unlock ()
 
bool GetPixColor1 (const void *pvLine, PIXELS_t x) const
 
void SetPixColor1 (void *pvLine, PIXELS_t x, bool b)
 
BYTE GetPixColor8 (const void *pvLine, PIXELS_t x) const noexcept
 
void SetPixColor8 (void *pvLine, PIXELS_t x, BYTE bColor) noexcept
 
COLOR16_t GetPixColor16 (const void *pvLine, PIXELS_t x) const noexcept
 
void SetPixColor16 (void *pvLine, PIXELS_t x, COLOR16_t wColor) noexcept
 
COLOR16_t GetPixColor16G (const void *pvLine, PIXELS_t x) const
 
COLOR16_t GetPixColor16G (PIXELS_t x, PIXELS_t y) const
 
void SetPixColor16G (void *pvLine, PIXELS_t x, COLOR16_t wVal)
 
void SetPixColor16G (PIXELS_t x, PIXELS_t y, COLOR16_t wVal)
 
COLORREF GetPixColor24g (const void *pvLine, PIXELS_t x) const noexcept
 
D3DCOLOR GetPixColor24d (const void *pvLine, PIXELS_t x) const noexcept
 
void SetPixColor24g (void *pvLine, PIXELS_t x, COLORREF dwColor) noexcept
 
void SetPixColor24d (void *pvLine, PIXELS_t x, D3DCOLOR dwColor) noexcept
 
COLORREF GetPixColor32 (const void *pvLine, PIXELS_t x) const noexcept
 
void SetPixColor32 (void *pvLine, PIXELS_t x, COLORREF dwColor) noexcept
 
COLORREF GetPixColorRef (const void *pvLine, PIXELS_t x) const
 
COLORREF GetPixColorRef (PIXELS_t x, PIXELS_t y) const
 
void SetPixColorRef (void *pvLine, PIXELS_t x, COLORREF c)
 
void SetPixColorRef (PIXELS_t x, PIXELS_t y, COLORREF c)
 
void ScrollPixels (PIXELS_t cx, PIXELS_t cy)
 
void FillColor (COLORREF colorBack)
 
void SwapTopBottom ()
 
void SetErase ()
 
virtual HRESULT SetPixelData (const cSurfaceBase &rSurfSrc)
 
virtual HRESULT SetCopySurface (const cSurfaceBase &rSurfSrc)
 
void SetCopyFrom (const cSurfaceBase &TexSrc, PIXELS_t itxs=0, PIXELS_t itys=0, bool bTextureXReverse=false, bool bTextureYReverse=false, bool bColorReverse=false)
 
void CopyTo (cSurfaceBase &TexDst, PIXELS_t itxs=0, PIXELS_t itys=0, bool bTextureXReverse=false, bool bTextureYReverse=false) const
 
HRESULT InitTestPattern ()
 
 UNITTEST_FRIEND (cSurfaceBase)
 

Static Public Member Functions

static bool GetPixColor1P (const void *pvLine, PIXELS_t x) noexcept
 
static void SetPixColor1P (void *pvLine, PIXELS_t x, bool b) noexcept
 

Protected Member Functions

cSurfaceBaseoperator= (const cSurfaceBase &rSurf)
 
bool InitSurfaceInfo (const cSurfaceInfo &rInfo)
 
bool InitSurfaceAlign (PIXELS_t cx, PIXELS_t cy, size_t nAlignBytes, SURF_FORM_TYPE ePixelFormat)
 
bool InitSurfacePitch (PIXELS_t cx, PIXELS_t cy, size_t uPitchBytes, SURF_FORM_TYPE ePixelFormat)
 
- Protected Member Functions inherited from Gray::cMemBlock
 cMemBlock () noexcept
 
 cMemBlock (const void *pData, size_t nSize) noexcept
 
 cMemBlock (const cMemBlock &block) noexcept
 
 cMemBlock (const cMemBlock *pBlock) noexcept
 
size_t get_DataSize () const noexcept
 
void * get_Data () const noexcept
 
BYTE * get_DataBytes () const noexcept
 
char * get_DataA () const noexcept
 
 operator const BYTE * () const noexcept
 
bool isValidPtr () const noexcept
 
bool IsValidIndex (size_t i) const noexcept
 
bool IsValidIndex2 (size_t i) const noexcept
 
bool IsValidPtr (const void *p) const noexcept
 
bool IsValidPtr2 (const void *p) const noexcept
 
bool IsZeros () const noexcept
 
bool IsEqualData (const void *pData, size_t nSize) const noexcept
 
bool IsEqualData (const cMemBlock *pData) const noexcept
 
bool IsEqualData (const cMemBlock &data) const noexcept
 
BYTE * GetOffset (size_t nOffset) const
 
const void * get_DataEnd () const noexcept
 
void put_DataPtr (void *pStart) noexcept
 
void put_Size (size_t nSize) noexcept
 
void SetBlock (void *pData, size_t nSize) noexcept
 
void SetEmptyBlock () noexcept
 
void InitZeros () noexcept
 
StrLen_t ConvertToString (char *pszDst, StrLen_t iDstSizeMax) const
 

Protected Attributes

cSurfaceInfo m_Info
 the image size, pitch and pixel format for m_pPixelData below. More...
 
- Protected Attributes inherited from Gray::cMemBlock
size_t m_nSize
 size_t of m_pData in bytes. May be determined at runtime. More...
 
void * m_pData
 

Friends

class cSurfaceDC
 
class cSurfaceDC2
 

Additional Inherited Members

- Static Protected Member Functions inherited from Gray::cMemBlock
static COMPARE_t __stdcall Compare (const void *pData1, size_t iLen1, const void *pData2, size_t iLen2)
 

Detailed Description

A simple surface/DIB. (unknown owner allocation of m_pPixelData in system memory)

Note
Assume nothing about memory pointer allocation/ownership. don't free on destruct. Assume very little about pixel format (color bits). generally assumed to be non compressed. similar to D3DLOCKED_RECT

Constructor & Destructor Documentation

◆ cSurfaceBase() [1/3]

GrayLib::cSurfaceBase::cSurfaceBase ( )
noexcept

◆ cSurfaceBase() [2/3]

GrayLib::cSurfaceBase::cSurfaceBase ( void *  pPixelData,
const cSurfaceInfo rInfo 
)

◆ cSurfaceBase() [3/3]

GrayLib::cSurfaceBase::cSurfaceBase ( void *  pPixelData,
PIXELS_t  cx,
PIXELS_t  cy,
size_t  uPitchBytes,
SURF_FORM_TYPE  ePixelFormat 
)

◆ ~cSurfaceBase()

GrayLib::cSurfaceBase::~cSurfaceBase ( )
virtual

NOT destruct pixel data here.

Member Function Documentation

◆ CopyTo()

void GrayLib::cSurfaceBase::CopyTo ( cSurfaceBase TexDst,
PIXELS_t  itxs = 0,
PIXELS_t  itys = 0,
bool  bTextureXReverse = false,
bool  bTextureYReverse = false 
) const

Copy this whole bitmap into a small part of some other bitmap TexDst. ASSUME same format! else use cSurfaceConv??

◆ FillColor()

void GrayLib::cSurfaceBase::FillColor ( COLORREF  colorBack)

Fill the whole DIB with a color.

Note
leave align padding alone!

◆ get_Height()

PIXELS_t GrayLib::cSurfaceBase::get_Height ( void  ) const
inlinenoexcept

height in pixels not bytes.

◆ get_Info()

const cSurfaceInfo& GrayLib::cSurfaceBase::get_Info ( ) const
inlinenoexcept

◆ get_PitchBytes()

size_t GrayLib::cSurfaceBase::get_PitchBytes ( ) const
inlinenoexcept

row width in bytes not pixels. (AKA Pitch, Stride or BytesPerRow)

◆ get_PixelBytes()

BYTE* GrayLib::cSurfaceBase::get_PixelBytes ( ) const
inlinenoexcept

◆ get_PixelData()

void* GrayLib::cSurfaceBase::get_PixelData ( ) const
inlinenoexcept

pointer to the pixel data. We assume nothing about pixel format. ASSERT(m_pPixelData); // allow this for mouse hits.

◆ get_PixelFormat()

SURF_FORM_TYPE GrayLib::cSurfaceBase::get_PixelFormat ( ) const
inlinenoexcept

◆ get_Width()

PIXELS_t GrayLib::cSurfaceBase::get_Width ( void  ) const
inlinenoexcept

width in pixels not bytes.

◆ GetLinePtr()

void* GrayLib::cSurfaceBase::GetLinePtr ( PIXELS_t  y) const
inlinenoexcept

get a pointer to the start of a line of pixels. assumes nothing about pixel format. adjust Y if this is a bottom up image. get_HeightRaw

◆ GetLinePtrByte()

BYTE* GrayLib::cSurfaceBase::GetLinePtrByte ( PIXELS_t  y) const
inlinenoexcept

Ignore line order. -y.

◆ GetLinePtrRaw()

void* GrayLib::cSurfaceBase::GetLinePtrRaw ( PIXELS_t  y) const
inlinenoexcept

Ignore line order. -y.

◆ GetNextLine()

void* GrayLib::cSurfaceBase::GetNextLine ( const void *  pLinePtr) const
inlinenoexcept

◆ GetPixColor1()

bool GrayLib::cSurfaceBase::GetPixColor1 ( const void *  pvLine,
PIXELS_t  x 
) const
inline

1 BPP

◆ GetPixColor16()

COLOR16_t GrayLib::cSurfaceBase::GetPixColor16 ( const void *  pvLine,
PIXELS_t  x 
) const
inlinenoexcept

get 16 BPP color from surface assumed to be the same format. Stored in SURF_FORM_RGB565 format.

◆ GetPixColor16G() [1/2]

COLOR16_t GrayLib::cSurfaceBase::GetPixColor16G ( const void *  pvLine,
PIXELS_t  x 
) const

get a 16 bit Grey-scale pixel.

◆ GetPixColor16G() [2/2]

COLOR16_t GrayLib::cSurfaceBase::GetPixColor16G ( PIXELS_t  x,
PIXELS_t  y 
) const
inline

◆ GetPixColor1P()

static bool GrayLib::cSurfaceBase::GetPixColor1P ( const void *  pvLine,
PIXELS_t  x 
)
inlinestaticnoexcept

1 BPP

◆ GetPixColor24d()

D3DCOLOR GrayLib::cSurfaceBase::GetPixColor24d ( const void *  pvLine,
PIXELS_t  x 
) const
inlinenoexcept

24 BPP = DX/D3D format. [0]=b Stored in Blue,Green,Red order.

◆ GetPixColor24g()

COLORREF GrayLib::cSurfaceBase::GetPixColor24g ( const void *  pvLine,
PIXELS_t  x 
) const
inlinenoexcept

24 BPP = GDI format. [0]=red

Returns
color in Red,Green,Blue order.

◆ GetPixColor32()

COLORREF GrayLib::cSurfaceBase::GetPixColor32 ( const void *  pvLine,
PIXELS_t  x 
) const
inlinenoexcept

get pixel in 32 BPP = cColorRef or D3DCOLOR

◆ GetPixColor8()

BYTE GrayLib::cSurfaceBase::GetPixColor8 ( const void *  pvLine,
PIXELS_t  x 
) const
inlinenoexcept

8 BPP

◆ GetPixColorRef() [1/2]

COLORREF GrayLib::cSurfaceBase::GetPixColorRef ( const void *  pvLine,
PIXELS_t  x 
) const

get a 32 bit GDI color pixel. convert the pixel to 32 bits if needed. ABGR=COLORREF

Todo:
Use cColorConv

◆ GetPixColorRef() [2/2]

COLORREF GrayLib::cSurfaceBase::GetPixColorRef ( PIXELS_t  x,
PIXELS_t  y 
) const
inline

◆ GetPixPtr() [1/3]

BYTE* GrayLib::cSurfaceBase::GetPixPtr ( const void *  pvLine,
PIXELS_t  x,
size_t  sizePixel 
) const
inlinenoexcept

get a pixel pointer given the byte aligned size of a pixel.

◆ GetPixPtr() [2/3]

BYTE* GrayLib::cSurfaceBase::GetPixPtr ( PIXELS_t  x,
PIXELS_t  y 
) const
inlinenoexcept

Get x,y pixel data location for unknown (mostly) pixel format. this should work for 1 bit pp.

◆ GetPixPtr() [3/3]

BYTE* GrayLib::cSurfaceBase::GetPixPtr ( PIXELS_t  x,
PIXELS_t  y,
size_t  sizePixel 
) const
inlinenoexcept

◆ GetPixPtr16()

COLOR16_t* GrayLib::cSurfaceBase::GetPixPtr16 ( PIXELS_t  x,
PIXELS_t  y 
) const
inlinenoexcept

Assume 16 bit per pixel SURF_FORM_RGB565 colors

◆ InitSurfaceAlign()

bool GrayLib::cSurfaceBase::InitSurfaceAlign ( PIXELS_t  cx,
PIXELS_t  cy,
size_t  nAlignBytes,
SURF_FORM_TYPE  ePixelFormat 
)
protected

Bitmaps require 4 (or X) byte align Other images require diff align.

◆ InitSurfaceInfo()

bool GrayLib::cSurfaceBase::InitSurfaceInfo ( const cSurfaceInfo rInfo)
protected

◆ InitSurfacePitch()

bool GrayLib::cSurfaceBase::InitSurfacePitch ( PIXELS_t  cx,
PIXELS_t  cy,
size_t  uPitchBytes,
SURF_FORM_TYPE  ePixelFormat 
)
protected

◆ InitTestPattern()

HRESULT GrayLib::cSurfaceBase::InitTestPattern ( )

Fill the pixels with the test pattern. Assume pixel format is 888 or 8888 type.

◆ isTopDown()

bool GrayLib::cSurfaceBase::isTopDown ( ) const
inlinenoexcept

◆ isValidCheck()

bool GrayLib::cSurfaceBase::isValidCheck ( ) const
inlinenoexcept

◆ isValidPixelData()

bool GrayLib::cSurfaceBase::isValidPixelData ( ) const
inlinenoexcept

basic attributes.

◆ IsValidPixPtr()

bool GrayLib::cSurfaceBase::IsValidPixPtr ( const void *  p) const
inlinenoexcept

◆ Lock()

bool GrayLib::cSurfaceBase::Lock ( )
inline

do nothing. Emulate DirectX locking stuff.

◆ operator=()

cSurfaceBase& GrayLib::cSurfaceBase::operator= ( const cSurfaceBase rSurf)
inlineprotected

◆ put_Info()

void GrayLib::cSurfaceBase::put_Info ( const cSurfaceInfo rInfo)
inline

◆ put_PixelData()

void GrayLib::cSurfaceBase::put_PixelData ( void *  pPixelData)
inlinenoexcept

pointer to the pixel data. We assume nothing about pixel format. or allocation. allow pPixelData == nullptr for mouse hits throw.

◆ SaveRaw() [1/2]

HRESULT GrayLib::cSurfaceBase::SaveRaw ( const FILECHAR_t pszFilename)

◆ SaveRaw() [2/2]

HRESULT GrayLib::cSurfaceBase::SaveRaw ( cStreamOutput file)

◆ ScrollPixels()

void GrayLib::cSurfaceBase::ScrollPixels ( PIXELS_t  cx,
PIXELS_t  cy 
)

Scroll the bitmap pixel data in dx and dy. ASSUME 8 bit aligned pixels.

◆ SetCopyFrom()

void GrayLib::cSurfaceBase::SetCopyFrom ( const cSurfaceBase TexSrc,
PIXELS_t  itxs = 0,
PIXELS_t  itys = 0,
bool  bTextureXReverse = false,
bool  bTextureYReverse = false,
bool  bColorReverse = false 
)

fill this bitmap from a part of some larger bitmap TexSrc.

  • itxs, itys = location in source rect. ASSUME same format! else use cSurfaceConv??

◆ SetCopySurface()

virtual HRESULT GrayLib::cSurfaceBase::SetCopySurface ( const cSurfaceBase rSurfSrc)
inlinevirtual

Change image format and set pixels from rSrc.

Reimplemented in GrayLib::cImageTGA, GrayLib::cImageBMP, GrayLib::cSurface, and GrayCodec::cImageJP2.

◆ SetEmpty()

void GrayLib::cSurfaceBase::SetEmpty ( )
virtual

Init the surface to invalid values. Some derived class should override this to free any previous m_pPixelData properly. SetEmpty

Reimplemented in GrayLib::cImageTGA, GrayLib::cImageGIF, GrayLib::cImageDDS, GrayLib::cImageBMP, GrayCodec::cImagePNG, GrayCodec::cImageJPG, GrayCodec::cImageJP2, and GrayLib::cSurface.

◆ SetErase()

void GrayLib::cSurfaceBase::SetErase ( )
inline

◆ SetPixColor1()

void GrayLib::cSurfaceBase::SetPixColor1 ( void *  pvLine,
PIXELS_t  x,
bool  b 
)
inline

1 BPP

◆ SetPixColor16()

void GrayLib::cSurfaceBase::SetPixColor16 ( void *  pvLine,
PIXELS_t  x,
COLOR16_t  wColor 
)
inlinenoexcept

16 BPP Stored in SURF_FORM_RGB565 format.

◆ SetPixColor16G() [1/2]

void GrayLib::cSurfaceBase::SetPixColor16G ( PIXELS_t  x,
PIXELS_t  y,
COLOR16_t  wVal 
)
inline

◆ SetPixColor16G() [2/2]

void GrayLib::cSurfaceBase::SetPixColor16G ( void *  pvLine,
PIXELS_t  x,
COLOR16_t  wVal 
)

set a 16 bit Greyscale pixel.

◆ SetPixColor1P()

static void GrayLib::cSurfaceBase::SetPixColor1P ( void *  pvLine,
PIXELS_t  x,
bool  b 
)
inlinestaticnoexcept

1 BPP

◆ SetPixColor24d()

void GrayLib::cSurfaceBase::SetPixColor24d ( void *  pvLine,
PIXELS_t  x,
D3DCOLOR  dwColor 
)
inlinenoexcept

24 BPP = DX/D3D format Stored in Blue,Green,Red order.

◆ SetPixColor24g()

void GrayLib::cSurfaceBase::SetPixColor24g ( void *  pvLine,
PIXELS_t  x,
COLORREF  dwColor 
)
inlinenoexcept

24 BPP = GDI format Stored in Red,Green,Blue order.

◆ SetPixColor32()

void GrayLib::cSurfaceBase::SetPixColor32 ( void *  pvLine,
PIXELS_t  x,
COLORREF  dwColor 
)
inlinenoexcept

set pixel in 32 BPP = cColorRef, GDI byte order storage.

◆ SetPixColor8()

void GrayLib::cSurfaceBase::SetPixColor8 ( void *  pvLine,
PIXELS_t  x,
BYTE  bColor 
)
inlinenoexcept

8 BPP

◆ SetPixColorRef() [1/2]

void GrayLib::cSurfaceBase::SetPixColorRef ( PIXELS_t  x,
PIXELS_t  y,
COLORREF  c 
)
inline

◆ SetPixColorRef() [2/2]

void GrayLib::cSurfaceBase::SetPixColorRef ( void *  pvLine,
PIXELS_t  x,
COLORREF  c 
)

set a cColorRef 32 bit color to a surface of any pixel format. cVal = ABGR

Todo:
Use cColorConv

◆ SetPixelData()

HRESULT GrayLib::cSurfaceBase::SetPixelData ( const cSurfaceBase rSurfSrc)
virtual

copy pixels to this from rSurfSrc. Resample the pSrc to the pDst if needed/possible.

Note
does not change the current pixel format of this. do translation.
Todo:
for each pixel in the new surface, it is potentially a average with its 4 neighbors. ??
  • rSurfSrc = take this whole texture and place in the current texture.

◆ SwapTopBottom()

void GrayLib::cSurfaceBase::SwapTopBottom ( )

related to BMP isTopDown()

◆ UNITTEST_FRIEND()

GrayLib::cSurfaceBase::UNITTEST_FRIEND ( cSurfaceBase  )

◆ Unlock()

void GrayLib::cSurfaceBase::Unlock ( )
inline

do nothing. Emulate DirectX locking stuff.

Friends And Related Function Documentation

◆ cSurfaceDC

friend class cSurfaceDC
friend

◆ cSurfaceDC2

friend class cSurfaceDC2
friend

Member Data Documentation

◆ m_Info

cSurfaceInfo GrayLib::cSurfaceBase::m_Info
protected

the image size, pitch and pixel format for m_pPixelData below.


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