CartoType C++ API 7.8.2, 2022-03-25
for Windows, Linux, Qt and other platforms supporting C++ development
Public Types | Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
CartoType::TBitmap Class Reference

#include <cartotype_bitmap.h>

Inheritance diagram for CartoType::TBitmap:
CartoType::CBitmap

Public Types

using TColorFunction = TColor(*)(const TBitmap &aBitmap, uint32_t aX, uint32_t aY)
 

Public Member Functions

 TBitmap (TBitmapType aType, uint8_t *aData, uint32_t aWidth, uint32_t aHeight, uint32_t aRowBytes, std::shared_ptr< CPalette > aPalette=nullptr)
 
 TBitmap (const CBitmap &aBitmap)=delete
 
TBitmapoperator= (const CBitmap &aBitmap)=delete
 
TColorFunction ColorFunction () const
 
CBitmap Copy (int32_t aExpansion=0) const
 
CBitmap Blur (bool aGaussian, double aWidth) const
 
CBitmap Palettize () const
 
CBitmap UnPalettize () const
 
CBitmap Trim (TRect &aBounds, bool aTrimLeft=true, bool aTrimRight=true, bool aTrimTop=true, bool aTrimBottom=true) const
 
CBitmap Clip (TRect aClip) const
 
CBitmap Clip (const MPath &aPath, TRect &aNewBounds) const
 
TResult WritePng (MOutputStream &aOutputStream, bool aPalettize) const
 
TResult Write (TDataOutputStream &aOutput) const
 
TBitmapType Type () const
 
int32_t BitsPerPixel () const
 
const uint8_t * Data () const
 
uint8_t * Data ()
 
std::shared_ptr< CPalettePalette () const
 
void SetPalette (std::shared_ptr< CPalette > aPalette)
 
int32_t DataBytes () const
 
int32_t Width () const
 
int32_t Height () const
 
int32_t RowBytes () const
 
void Clear ()
 
void ClearToWhite ()
 
bool operator< (const TBitmap &aOther) const
 
bool operator== (const TBitmap &aOther) const
 

Static Protected Member Functions

static TColor Color1BitMono (const TBitmap &aBitmap, uint32_t aX, uint32_t aY)
 
static TColor Color8BitMono (const TBitmap &aBitmap, uint32_t aX, uint32_t aY)
 
static TColor Color8BitPalette (const TBitmap &aBitmap, uint32_t aX, uint32_t aY)
 
static TColor Color16BitMono (const TBitmap &aBitmap, uint32_t aX, uint32_t aY)
 
static TColor Color16BitColor (const TBitmap &aBitmap, uint32_t aX, uint32_t aY)
 
static TColor Color24BitColor (const TBitmap &aBitmap, uint32_t aX, uint32_t aY)
 
static TColor Color32BitColor (const TBitmap &aBitmap, uint32_t aX, uint32_t aY)
 
static TColor ColorUnsupported (const TBitmap &aBitmap, uint32_t aX, uint32_t aY)
 

Protected Attributes

uint8_t * iData = nullptr
 
std::shared_ptr< CPaletteiPalette
 
uint32_t iWidth = 0
 
uint32_t iHeight = 0
 
uint32_t iRowBytes = 0
 
TBitmapType iType = TBitmapType::A8
 

Detailed Description

A bitmap that does not take ownership of pixel data.

Member Typedef Documentation

◆ TColorFunction

using CartoType::TBitmap::TColorFunction = TColor(*)(const TBitmap& aBitmap,uint32_t aX,uint32_t aY)

A type for functions to supply the color of a pixel at a given point.

Constructor & Destructor Documentation

◆ TBitmap()

CartoType::TBitmap::TBitmap ( TBitmapType  aType,
uint8_t *  aData,
uint32_t  aWidth,
uint32_t  aHeight,
uint32_t  aRowBytes,
std::shared_ptr< CPalette aPalette = nullptr 
)
inline

Create a bitmap with a specified type, data, and dimensions.

Member Function Documentation

◆ BitsPerPixel()

int32_t CartoType::TBitmap::BitsPerPixel ( ) const
inline

Return the bitmap depth: the number of bits used to store each pixel.

◆ Blur()

CBitmap CartoType::TBitmap::Blur ( bool  aGaussian,
double  aWidth 
) const

Creates a blurred bitmap with edges aWidth pixels wide. The new bitmap is wider and taller than the original bitmap by aWidth * 2 pixels.

◆ Clear()

void CartoType::TBitmap::Clear ( )
inline

Clear the pixel data to zeroes.

◆ ClearToWhite()

void CartoType::TBitmap::ClearToWhite ( )
inline

Clear the pixel data to ones (normally white).

◆ Clip() [1/2]

CBitmap CartoType::TBitmap::Clip ( const MPath aPath,
TRect aNewBounds 
) const

Creates a bitmap that is a clipped version of this bitmap. The clip path is in 64ths of pixels. The new bounds of the bitmap, in pixels and relative to the previous bounds, are returned in aNewBounds.

◆ Clip() [2/2]

CBitmap CartoType::TBitmap::Clip ( TRect  aClip) const

Creates a bitmap that is a clipped version of this bitmap. The clip rectangle is in pixels.

◆ Color16BitColor()

TColor CartoType::TBitmap::Color16BitColor ( const TBitmap aBitmap,
uint32_t  aX,
uint32_t  aY 
)
staticprotected

Returns the color at (aX,aY) for a 16-bit color bitmap.

◆ Color16BitMono()

TColor CartoType::TBitmap::Color16BitMono ( const TBitmap aBitmap,
uint32_t  aX,
uint32_t  aY 
)
staticprotected

Returns the color at (aX,aY) for a a6-bit monochrome bitmap.

◆ Color1BitMono()

TColor CartoType::TBitmap::Color1BitMono ( const TBitmap aBitmap,
uint32_t  aX,
uint32_t  aY 
)
staticprotected

Returns the color at (aX,aY) for a one-bit monochrome bitmap.

◆ Color24BitColor()

TColor CartoType::TBitmap::Color24BitColor ( const TBitmap aBitmap,
uint32_t  aX,
uint32_t  aY 
)
staticprotected

Returns the color at (aX,aY) for a 24-bit color bitmap.

◆ Color32BitColor()

TColor CartoType::TBitmap::Color32BitColor ( const TBitmap aBitmap,
uint32_t  aX,
uint32_t  aY 
)
staticprotected

Returns the color at (aX,aY) for a 32-bit color bitmap.

◆ Color8BitMono()

TColor CartoType::TBitmap::Color8BitMono ( const TBitmap aBitmap,
uint32_t  aX,
uint32_t  aY 
)
staticprotected

Returns the color at (aX,aY) for an 8-bit color bitmap.

◆ Color8BitPalette()

TColor CartoType::TBitmap::Color8BitPalette ( const TBitmap aBitmap,
uint32_t  aX,
uint32_t  aY 
)
staticprotected

Returns the color at (aX,aY) for an 8-bit color bitmap with a palette.

◆ ColorFunction()

TBitmap::TColorFunction CartoType::TBitmap::ColorFunction ( ) const

Returns a pointer to a function to get the premultiplied-alpha color at a certain point, for this type of bitmap. Monochrome bitmaps return only an alpha level (the low 24 bits of the color value returned are all zeroes).

Color functions take the coordinates modulo the width and height of the bitmap.

◆ ColorUnsupported()

TColor CartoType::TBitmap::ColorUnsupported ( const TBitmap aBitmap,
uint32_t  aX,
uint32_t  aY 
)
staticprotected

A dummy color function to return transparent black for any position.

◆ Copy()

CBitmap CartoType::TBitmap::Copy ( int32_t  aExpansion = 0) const

Copies a bitmap, optionally expanding it by aExpansion pixels all round.

◆ Data() [1/2]

uint8_t * CartoType::TBitmap::Data ( )
inline

Return a writable pointer to the start of the pixel data.

◆ Data() [2/2]

const uint8_t * CartoType::TBitmap::Data ( ) const
inline

Return a constant pointer to the start of the pixel data.

◆ DataBytes()

int32_t CartoType::TBitmap::DataBytes ( ) const
inline

Return the number of bytes actually used to store the data. This may include padding at the ends of rows.

◆ Height()

int32_t CartoType::TBitmap::Height ( ) const
inline

Return the height in pixels.

◆ operator<()

bool CartoType::TBitmap::operator< ( const TBitmap aOther) const
inline

The less-than operator. Assumes that the bitmaps are of the same type.

◆ operator==()

bool CartoType::TBitmap::operator== ( const TBitmap aOther) const
inline

The equality operator. Assumes that the bitmaps are of the same type.

◆ Palette()

std::shared_ptr< CPalette > CartoType::TBitmap::Palette ( ) const
inline

Return the palette if any.

◆ Palettize()

CBitmap CartoType::TBitmap::Palettize ( ) const

Converts a 32bpp colored bitmap to an 8-bit-per-pixel bitmap with a palette with up to 256 entries. The first palette entry is always completely transparent.

If this bitmap isn't a 32bpp colored bitmap, a copy of the original bitmap is returned.

◆ RowBytes()

int32_t CartoType::TBitmap::RowBytes ( ) const
inline

Return the number of bytes used to store each horizontal row of pixels.

◆ SetPalette()

void CartoType::TBitmap::SetPalette ( std::shared_ptr< CPalette aPalette)
inline

Set the palette.

◆ Trim()

CBitmap CartoType::TBitmap::Trim ( TRect aBounds,
bool  aTrimLeft = true,
bool  aTrimRight = true,
bool  aTrimTop = true,
bool  aTrimBottom = true 
) const

Creates a bitmap that is a copy of this bitmap after trimming pixels with the value zero from any combination of the four sides.

Puts the bounds of the new bitmap relative to the old, in pixels, in aBounds.

◆ Type()

TBitmapType CartoType::TBitmap::Type ( ) const
inline

Return the bitmap type, which indicates its depth and whether it is colored.

◆ UnPalettize()

CBitmap CartoType::TBitmap::UnPalettize ( ) const

Converts an 8bpp bitmap with a palette to a 32bpp RGBA bitmap. If this bitmap isn't an 8bpp bitmap with a palette, a copy of the original bitmap is returned.

◆ Width()

int32_t CartoType::TBitmap::Width ( ) const
inline

Return the width in pixels.

◆ Write()

TResult CartoType::TBitmap::Write ( TDataOutputStream aOutput) const

Writes a bitmap in serialized form.

◆ WritePng()

TResult CartoType::TBitmap::WritePng ( MOutputStream aOutputStream,
bool  aPalettize 
) const

Writes a bitmap to an output stream in PNG format, optionally palettizing it.

Member Data Documentation

◆ iData

uint8_t* CartoType::TBitmap::iData = nullptr
protected

The bitmap data.

◆ iHeight

uint32_t CartoType::TBitmap::iHeight = 0
protected

The height in pixels.

◆ iPalette

std::shared_ptr<CPalette> CartoType::TBitmap::iPalette
protected

The palette if any.

◆ iRowBytes

uint32_t CartoType::TBitmap::iRowBytes = 0
protected

The number of bytes in each row of pixels.

◆ iType

TBitmapType CartoType::TBitmap::iType = TBitmapType::A8
protected

The bitmap type.

◆ iWidth

uint32_t CartoType::TBitmap::iWidth = 0
protected

The width in pixels.


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