The core bitmap container class used by You.i Engine.
#include <graphics/YiBitmap.h>
Public Types | |
| enum | OWNERSHIP { SHARED, PRIVATE } |
| enum | COLOR_MODE { COLOR_MODE_RGBA8888, COLOR_MODE_RGBA4444, COLOR_MODE_RGB565 } |
| enum | DITHERING_MODE { DITHERING_NONE, DITHERING_FLOYD_STEINBERG } |
Public Member Functions | |
| CYIBitmap () | |
| virtual | ~CYIBitmap () |
| std::unique_ptr< CYIBitmap > | Clone () const |
| virtual bool | Create (int32_t nWidth, int32_t nHeight) |
| void | Draw (const CYIBitmap &srcImage, int32_t nDestX, int32_t nDestY) |
| void | Draw (const CYIBitmap &srcImage, int32_t nDestX, int32_t nDestY, const YI_RECT_REL &clipRegion) |
| void | Draw (const CYIBitmap &srcImage, int32_t nDestX, int32_t nDestY, int32_t nClipWidth, int32_t nClipHeight) |
| void | DrawScale (const CYIBitmap &srcImage, const YI_RECT_REL *pDest, const YI_RECT_REL *pSrc) |
| void | Fill (const CYIColor &color) |
| void | Fill (const CYIColor &color, const YI_RECT ®ion) |
| const uint32_t * | GetPixels () const |
| uint32_t * | GetPixels () |
| void | FreePixels () |
| virtual int32_t | GetHeight () const |
| void | ReduceHeightTo (int32_t nNewHeight) |
| virtual int32_t | GetWidth () const |
| int32_t | GetXPitch () const |
| int32_t | GetYPitch () const |
| virtual int32_t | GetDepth () const |
| uint32_t | GetBytesPerPixel () const |
| virtual int32_t | GetSize () const |
| void | SetPixels (uint32_t *pBits, int32_t nWidth, int32_t nHeight, CYIBitmap::OWNERSHIP ownership=CYIBitmap::PRIVATE) |
| void | SetPixel (int32_t nX, int32_t nY, const CYIColor &color) |
| virtual void | SetPixelPacked (int32_t nX, int32_t nY, uint32_t color) |
| void | SetPixelRaw (int32_t nX, int32_t nY, uint32_t color) |
| CYIColor | GetPixel (int32_t nX, int32_t nY) const |
| virtual uint32_t | GetPixelPacked (int32_t nX, int32_t nY) const |
| uint32_t | GetPixelRaw (int32_t nX, int32_t nY) const |
| COLOR_MODE | GetColorMode () const |
| std::unique_ptr< CYIBitmap > | ToColorMode (COLOR_MODE eColorMode, DITHERING_MODE eDitheringMode=DITHERING_NONE) const |
| bool | operator== (const CYIBitmap &other) const |
| bool | operator!= (const CYIBitmap &other) const |
Friends | |
| class | CYIBitmapPriv |
The color modes that this bitmap class supports. By default, bitmaps use COLOR_MODE_RGBA8888.
The dithering modes that can be used when converting between color modes.
| Enumerator | |
|---|---|
| DITHERING_NONE |
No dithering. |
| DITHERING_FLOYD_STEINBERG |
Indicates that Floyd-Steinberg dithering should be used. |
| enum CYIBitmap::OWNERSHIP |
| Enumerator | |
|---|---|
| SHARED |
Memory is managed by the application and it is responsible for deleting it |
| PRIVATE |
Memory is managed by CYIBitmap and must not be deleted |
| CYIBitmap::CYIBitmap | ( | ) |
|
virtual |
| std::unique_ptr<CYIBitmap> CYIBitmap::Clone | ( | ) | const |
Create an exact copy of this bitmap.
|
virtual |
Creates an bitmap image of the specified size. The created image uses a 32 bit ABGR (high to low byte packed) color encoding format.
| void CYIBitmap::Draw | ( | const CYIBitmap & | srcImage, |
| int32_t | nDestX, | ||
| int32_t | nDestY | ||
| ) |
Draw the source image at the specified coordinates. The source image will be clipped if its dimensions exceed the boundaries of this bitmap.
| void CYIBitmap::Draw | ( | const CYIBitmap & | srcImage, |
| int32_t | nDestX, | ||
| int32_t | nDestY, | ||
| const YI_RECT_REL & | clipRegion | ||
| ) |
Draw the source image at the destination coordinates and clip it against the specified clipping region. The region defaults to a zero width and height and will be ignored by default.
| void CYIBitmap::Draw | ( | const CYIBitmap & | srcImage, |
| int32_t | nDestX, | ||
| int32_t | nDestY, | ||
| int32_t | nClipWidth, | ||
| int32_t | nClipHeight | ||
| ) |
The following method is a convenience method for the above function. It assumes the clipping region begins at (0, 0) of the source image.
| void CYIBitmap::DrawScale | ( | const CYIBitmap & | srcImage, |
| const YI_RECT_REL * | pDest, | ||
| const YI_RECT_REL * | pSrc | ||
| ) |
Draw a source image region, onto a destination image region, scaling up or down into destination and not preserving aspect ratios. If source or destination regions are ommitted, entire image regions are uses
| void CYIBitmap::Fill | ( | const CYIColor & | color | ) |
Fills the buffer with the specified color.
Fills the buffer with the specified color.
| void CYIBitmap::FreePixels | ( | ) |
Destroys the buffer of pixels associated with this bitmap.
| uint32_t CYIBitmap::GetBytesPerPixel | ( | ) | const |
Returns the number of bytes used for a single pixel. Equivalent to GetDepth() / 8.
| COLOR_MODE CYIBitmap::GetColorMode | ( | ) | const |
Returns the color mode of this bitmap. By default, bitmaps use the COLOR_MODE_RGBA8888 color mode.
|
virtual |
Returns the color depth of the bitmap.
|
virtual |
Returns the height of this buffer in pixels.
| CYIColor CYIBitmap::GetPixel | ( | int32_t | nX, |
| int32_t | nY | ||
| ) | const |
Returns the pixel color at the specified coordinate.
|
virtual |
Returns the pixel color at the specified coordinate. The returned color is in RGBA packed format.
| uint32_t CYIBitmap::GetPixelRaw | ( | int32_t | nX, |
| int32_t | nY | ||
| ) | const |
Returns the pixel color at the specified coordinate. The format of the returned color depends on the color mode of this bitmap.
| const uint32_t* CYIBitmap::GetPixels | ( | ) | const |
Returns the pixels representing this image; the pixel format used by the bitmap class is ABGR. Do not delete these pixels and do not attempt to use them if new pixels are set.
| uint32_t* CYIBitmap::GetPixels | ( | ) |
Returns the pixels representing this image; the pixel format used by the bitmap class is ABGR. Do not delete these pixels and do not attempt to use them if new pixels are set.
|
virtual |
Returns the size of the buffer in bytes used to hold the bitmap data.
|
virtual |
Returns the width of this buffer in pixels.
| int32_t CYIBitmap::GetXPitch | ( | ) | const |
Returns the distance, in bytes, between two horizontal pixels. In all cases this is equivalent to GetBytesPerPixel().
| int32_t CYIBitmap::GetYPitch | ( | ) | const |
Returns the distance, in bytes, between two vertical pixels. In most cases this is equal to GetWidth() * GetBytesPerPixel(), but for some color modes rows are required to be aligned to 4 bytes and the Y pitch can be different. Use this value when reading from the raw pixels pointer and incrementing by one row.
| bool CYIBitmap::operator!= | ( | const CYIBitmap & | other | ) | const |
Returns true if other contains different pixel data or has a different configuration than this bitmap. Returns false otherwise;
| bool CYIBitmap::operator== | ( | const CYIBitmap & | other | ) | const |
Returns true if other contains the same pixel data and has the same configuration as this bitmap. Returns false otherwise.
| void CYIBitmap::ReduceHeightTo | ( | int32_t | nNewHeight | ) |
Crops the image by discarding the bottom lines such that the final height is nNewHeight Does not cause a memory reallocation, but memory used by the discarded lines is wasted. No effect if nNewHeight is greater than the current height.
| void CYIBitmap::SetPixel | ( | int32_t | nX, |
| int32_t | nY, | ||
| const CYIColor & | color | ||
| ) |
Sets a pixel color at the specified coordinate.
|
virtual |
Sets a pixel color at the specified coordinate. The color is expected to be in RGBA packed format.
| void CYIBitmap::SetPixelRaw | ( | int32_t | nX, |
| int32_t | nY, | ||
| uint32_t | color | ||
| ) |
Sets a pixel color at the specified coordinate. The format of the color needs to match the format used by the color mode of this bitmap.
| void CYIBitmap::SetPixels | ( | uint32_t * | pBits, |
| int32_t | nWidth, | ||
| int32_t | nHeight, | ||
| CYIBitmap::OWNERSHIP | ownership = CYIBitmap::PRIVATE |
||
| ) |
Set the bits used by this bitmap. The old bitmap will be deleted. If the ownership is PRIVATE, pBits has to have been allocated using YI_MALLOC.
| std::unique_ptr<CYIBitmap> CYIBitmap::ToColorMode | ( | COLOR_MODE | eColorMode, |
| DITHERING_MODE | eDitheringMode = DITHERING_NONE |
||
| ) | const |
Creates and returns a new CYIBitmap with the specified color mode. When converting to a non-32bit color mode, a dithering mode can be specified.
|
friend |