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

#include <cImageBMP.h>

Inheritance diagram for GrayLib::cImageBMP:
GrayLib::cImageBase GrayLib::cSurfaceBase Gray::cRefBase Gray::cMemBlock IUnknown GrayLib::cImageGIF

Public Member Functions

 cImageBMP () noexcept
 
 cImageBMP (const cSurfaceBitmapInfo *pBMI)
 
 cImageBMP (const FILECHAR_t *pszFileNameBMP)
 
virtual ~cImageBMP ()
 
virtual void SetEmpty () override
 
virtual bool isValidImage () const noexcept override
 
WORD get_BitsPerPixel (void) const
 
size_t get_ImageSize (void) const
 
cSurfaceBitmapInfoget_BMI () const
 
size_t get_HeaderSize (void) const
 
size_t get_TotalSize (void) const
 
WORD get_NumColors (void) const
 
size_t get_ColorSize (void) const
 
tagRGBQUAD * get_PaletteColors () const
 
HRESULT CreateSurface (const cSurfaceBitmapInfo *pBMI)
 
HRESULT CreateSurfaceBC (const cSurfaceInfo &rInfo)
 
HRESULT CreateSurfaceBC (PIXELS_t x, PIXELS_t y, BIT_ENUM_t iBitsPerPixel, int nColorQtyUsed=0)
 
HRESULT ReadBMP (cStreamInput &file, bool bHeader=true, bool bData=true)
 
HRESULT WriteBMP (cStreamOutput *pFile, bool bHeader=true) const
 
virtual HRESULT ReadStream (cStreamInput &strIn) override
 
virtual HRESULT WriteStream (cStreamOutput *pFile) const override
 
virtual HRESULT SetCopySurface (const cSurfaceBase &Surf) override
 
 UNITTEST2_PREDEF (cImageBMP)
 
- Public Member Functions inherited from GrayLib::cImageBase
 cImageBase () noexcept
 
virtual ~cImageBase ()
 
virtual HRESULT LoadFile (const FILECHAR_t *pszFileName)
 
virtual HRESULT SaveFile (const FILECHAR_t *pszFileName) const
 
- Public Member Functions inherited from GrayLib::cSurfaceBase
 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)
 
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)
 
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)
 
- Public Member Functions inherited from Gray::cRefBase
 cRefBase (int iRefCount=0) noexcept
 
virtual ~cRefBase ()
 
int get_RefCount () const noexcept
 
HASHCODE_t get_HashCode () const noexcept
 
 STDMETHOD_ (HASHCODE_t, get_HashCodeX)() const noexcept
 
virtual void onFinalRelease ()
 
bool isValidObj () const noexcept
 
 STDMETHOD_ (ULONG, AddRef)(void) override
 
 STDMETHOD_ (ULONG, Release)(void) override
 
STDMETHOD() QueryInterface (const IID &riid, void __RPC_FAR *__RPC_FAR *ppvObject) override
 
void IncRefCount ()
 
void DecRefCount ()
 
bool isStaticConstruct () const noexcept
 
void StaticConstruct ()
 
void StaticDestruct ()
 
bool isDestructing () noexcept
 
void SetDestructing ()
 

Static Public Attributes

static const WORD k_DIB_HEADER_MARKER = ((WORD)('M' << 8) | 'B')
 

Additional Inherited Members

- Static Public Member Functions inherited from GrayLib::cSurfaceBase
static bool GetPixColor1P (const void *pvLine, PIXELS_t x) noexcept
 
static void SetPixColor1P (void *pvLine, PIXELS_t x, bool b) noexcept
 
- Protected Member Functions inherited from GrayLib::cSurfaceBase
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
 
- 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)
 
- Protected Attributes inherited from GrayLib::cSurfaceBase
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
 

Detailed Description

a .BMP file read in as a DIB (in system memory) MIME_EXT_bmp DIB has BITMAPINFOHEADER, may have palette info, and pixel data. Rows are always at least 4 bytes aligned ! (pitch/stride) cSurfaceBase has m_pPixelData (we Alloc this) http://en.wikipedia.org/wiki/BMP_file_format

Constructor & Destructor Documentation

◆ cImageBMP() [1/3]

GrayLib::cImageBMP::cImageBMP ( )
noexcept

◆ cImageBMP() [2/3]

GrayLib::cImageBMP::cImageBMP ( const cSurfaceBitmapInfo pBMI)

◆ cImageBMP() [3/3]

GrayLib::cImageBMP::cImageBMP ( const FILECHAR_t pszFileNameBMP)

Read a bitmap BMP file.

  • pszFileName = the name of the bitmap BMP file.

◆ ~cImageBMP()

GrayLib::cImageBMP::~cImageBMP ( )
virtual

Member Function Documentation

◆ CreateSurface()

HRESULT GrayLib::cImageBMP::CreateSurface ( const cSurfaceBitmapInfo pBMI)

◆ CreateSurfaceBC() [1/2]

HRESULT GrayLib::cImageBMP::CreateSurfaceBC ( const cSurfaceInfo rInfo)

◆ CreateSurfaceBC() [2/2]

HRESULT GrayLib::cImageBMP::CreateSurfaceBC ( PIXELS_t  x,
PIXELS_t  y,
BIT_ENUM_t  iBitsPerPixel,
int  nColorQtyUsed = 0 
)

Set to a new bitmap of this size. Rows are always at least 4 bytes aligned !

  • nColorQtyUsed = Specifies the number of color indexes in the color table that are actually used by the bitmap.

◆ get_BitsPerPixel()

WORD GrayLib::cImageBMP::get_BitsPerPixel ( void  ) const
inline

m_uBitsPerPixel BIT_ENUM_t

◆ get_BMI()

cSurfaceBitmapInfo* GrayLib::cImageBMP::get_BMI ( ) const
inline

◆ get_ColorSize()

size_t GrayLib::cImageBMP::get_ColorSize ( void  ) const
inline

◆ get_HeaderSize()

size_t GrayLib::cImageBMP::get_HeaderSize ( void  ) const
inline

bytes

◆ get_ImageSize()

size_t GrayLib::cImageBMP::get_ImageSize ( void  ) const
inline

bytes for surface pixel data size

◆ get_NumColors()

WORD GrayLib::cImageBMP::get_NumColors ( void  ) const
inline

◆ get_PaletteColors()

tagRGBQUAD* GrayLib::cImageBMP::get_PaletteColors ( ) const
inline

Get the palette table. get_ColorSize(), get_NumColors()

◆ get_TotalSize()

size_t GrayLib::cImageBMP::get_TotalSize ( void  ) const
inline

Total Size including header.

◆ isValidImage()

virtual bool GrayLib::cImageBMP::isValidImage ( ) const
inlineoverridevirtualnoexcept

Reimplemented from GrayLib::cImageBase.

◆ ReadBMP()

HRESULT GrayLib::cImageBMP::ReadBMP ( cStreamInput file,
bool  bHeader = true,
bool  bData = true 
)

Read the bitmap file data. similar to _WIN32 "::LoadImage()"

Note
File format for DIB file: BITMAPFILEHEADER bmfh; BITMAPINFOHEADER bmih; cSurfaceBitmapInfo tagRGBQUAD aColors[]; BYTE aBitmapBits[];
Scan lines must pad to end on a 32 bit boundary.
  • pFile = the handle to the open file.
Returns
ERROR_BAD_FORMAT, HRESULT_WIN32_C(ERROR_READ_FAULT),

◆ ReadStream()

virtual HRESULT GrayLib::cImageBMP::ReadStream ( cStreamInput strIn)
inlineoverridevirtual

Implements GrayLib::cImageBase.

Reimplemented in GrayLib::cImageGIF.

◆ SetCopySurface()

HRESULT GrayLib::cImageBMP::SetCopySurface ( const cSurfaceBase Surf)
overridevirtual

Copy/Clone the rSurf surface. Destroy existing surface. Do the DIB specific stuff and allocate the memory.

Reimplemented from GrayLib::cSurfaceBase.

◆ SetEmpty()

void GrayLib::cImageBMP::SetEmpty ( )
overridevirtual

Reimplemented from GrayLib::cSurfaceBase.

Reimplemented in GrayLib::cImageGIF.

◆ UNITTEST2_PREDEF()

GrayLib::cImageBMP::UNITTEST2_PREDEF ( cImageBMP  )

◆ WriteBMP()

HRESULT GrayLib::cImageBMP::WriteBMP ( cStreamOutput pFile,
bool  bHeader = true 
) const

Write out the DIB in the specified format to a file. Create a DIB from the DDB provided.

Returns
HRESULT_WIN32_C(ERROR_WRITE_FAULT);

◆ WriteStream()

virtual HRESULT GrayLib::cImageBMP::WriteStream ( cStreamOutput pFile) const
inlineoverridevirtual

Reimplemented from GrayLib::cImageBase.

Reimplemented in GrayLib::cImageGIF.

Member Data Documentation

◆ k_DIB_HEADER_MARKER

const WORD GrayLib::cImageBMP::k_DIB_HEADER_MARKER = ((WORD)('M' << 8) | 'B')
static

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