CartoType C++ API 8.8-7-gb35e4dc71
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
CartoTypeCore::BitmapView Class Reference

#include <cartotype_bitmap.h>

Inheritance diagram for CartoTypeCore::BitmapView:
CartoTypeCore::Bitmap

Public Types

using TColorFunction = Color(*)(const BitmapView &aBitmap, uint32_t aX, uint32_t aY)
 

Public Member Functions

 BitmapView (BitmapType aType, uint8_t *aData, uint32_t aWidth, uint32_t aHeight, uint32_t aRowBytes, std::shared_ptr< Palette > aPalette=nullptr)
 
 BitmapView (const Bitmap &aBitmap)=delete
 
BitmapViewoperator= (const Bitmap &aBitmap)=delete
 
TColorFunction ColorFunction () const
 
Bitmap Copy (int32_t aExpansion=0) const
 
Bitmap Blur (bool aGaussian, double aWidth) const
 
Bitmap Palettize () const
 
Bitmap UnPalettize () const
 
Bitmap Trim (Rect &aBounds, bool aTrimLeft=true, bool aTrimRight=true, bool aTrimTop=true, bool aTrimBottom=true) const
 
Bitmap Clip (Rect aClip) const
 
Bitmap Clip (const MPath &aPath, Rect &aNewBounds) const
 
Result WritePng (OutputStream &aOutputStream, bool aPalettize) const
 
Result Write (OutputStream &aOutput) const
 
BitmapType Type () const
 
int32_t BitsPerPixel () const
 
const uint8_t * Data () const
 
uint8_t * Data ()
 
std::shared_ptr< CartoTypeCore::PalettePalette () const
 
void SetPalette (std::shared_ptr< CartoTypeCore::Palette > aPalette)
 
int32_t DataBytes () const
 
int32_t Width () const
 
int32_t Height () const
 
int32_t RowBytes () const
 
void Clear ()
 
void ClearToWhite ()
 
bool operator< (const BitmapView &aOther) const
 
bool operator== (const BitmapView &aOther) const
 

Static Protected Member Functions

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

Protected Attributes

uint8_t * iData = nullptr
 
std::shared_ptr< CartoTypeCore::PaletteiPalette
 
uint32_t iWidth = 0
 
uint32_t iHeight = 0
 
uint32_t iRowBytes = 0
 
BitmapType iType = BitmapType::A8
 

Detailed Description

A bitmap that does not take ownership of pixel data.

Member Typedef Documentation

◆ TColorFunction

using CartoTypeCore::BitmapView::TColorFunction = Color(*)(const BitmapView& 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

◆ BitmapView()

CartoTypeCore::BitmapView::BitmapView ( BitmapType  aType,
uint8_t *  aData,
uint32_t  aWidth,
uint32_t  aHeight,
uint32_t  aRowBytes,
std::shared_ptr< Palette aPalette = nullptr 
)
inline

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

Member Function Documentation

◆ BitsPerPixel()

int32_t CartoTypeCore::BitmapView::BitsPerPixel ( ) const
inline

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

◆ Blur()

Bitmap CartoTypeCore::BitmapView::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 CartoTypeCore::BitmapView::Clear ( )
inline

Clear the pixel data to zeroes.

◆ ClearToWhite()

void CartoTypeCore::BitmapView::ClearToWhite ( )
inline

Clear the pixel data to ones (normally white).

◆ Clip() [1/2]

Bitmap CartoTypeCore::BitmapView::Clip ( const MPath aPath,
Rect 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]

Bitmap CartoTypeCore::BitmapView::Clip ( Rect  aClip) const

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

◆ Color16BitColor()

Color CartoTypeCore::BitmapView::Color16BitColor ( const BitmapView aBitmap,
uint32_t  aX,
uint32_t  aY 
)
staticprotected

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

◆ Color16BitMono()

Color CartoTypeCore::BitmapView::Color16BitMono ( const BitmapView aBitmap,
uint32_t  aX,
uint32_t  aY 
)
staticprotected

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

◆ Color1BitMono()

Color CartoTypeCore::BitmapView::Color1BitMono ( const BitmapView aBitmap,
uint32_t  aX,
uint32_t  aY 
)
staticprotected

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

◆ Color24BitColor()

Color CartoTypeCore::BitmapView::Color24BitColor ( const BitmapView aBitmap,
uint32_t  aX,
uint32_t  aY 
)
staticprotected

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

◆ Color32BitColor()

Color CartoTypeCore::BitmapView::Color32BitColor ( const BitmapView aBitmap,
uint32_t  aX,
uint32_t  aY 
)
staticprotected

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

◆ Color8BitMono()

Color CartoTypeCore::BitmapView::Color8BitMono ( const BitmapView aBitmap,
uint32_t  aX,
uint32_t  aY 
)
staticprotected

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

◆ Color8BitPalette()

Color CartoTypeCore::BitmapView::Color8BitPalette ( const BitmapView aBitmap,
uint32_t  aX,
uint32_t  aY 
)
staticprotected

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

◆ ColorFunction()

BitmapView::TColorFunction CartoTypeCore::BitmapView::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()

Color CartoTypeCore::BitmapView::ColorUnsupported ( const BitmapView aBitmap,
uint32_t  aX,
uint32_t  aY 
)
staticprotected

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

◆ Copy()

Bitmap CartoTypeCore::BitmapView::Copy ( int32_t  aExpansion = 0) const

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

◆ Data() [1/2]

uint8_t * CartoTypeCore::BitmapView::Data ( )
inline

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

◆ Data() [2/2]

const uint8_t * CartoTypeCore::BitmapView::Data ( ) const
inline

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

◆ DataBytes()

int32_t CartoTypeCore::BitmapView::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 CartoTypeCore::BitmapView::Height ( ) const
inline

Return the height in pixels.

◆ operator<()

bool CartoTypeCore::BitmapView::operator< ( const BitmapView aOther) const
inline

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

◆ operator==()

bool CartoTypeCore::BitmapView::operator== ( const BitmapView aOther) const
inline

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

◆ Palette()

std::shared_ptr< CartoTypeCore::Palette > CartoTypeCore::BitmapView::Palette ( ) const
inline

Return the palette if any.

◆ Palettize()

Bitmap CartoTypeCore::BitmapView::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 CartoTypeCore::BitmapView::RowBytes ( ) const
inline

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

◆ SetPalette()

void CartoTypeCore::BitmapView::SetPalette ( std::shared_ptr< CartoTypeCore::Palette aPalette)
inline

Set the palette.

◆ Trim()

Bitmap CartoTypeCore::BitmapView::Trim ( Rect 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()

BitmapType CartoTypeCore::BitmapView::Type ( ) const
inline

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

◆ UnPalettize()

Bitmap CartoTypeCore::BitmapView::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 CartoTypeCore::BitmapView::Width ( ) const
inline

Return the width in pixels.

◆ Write()

Result CartoTypeCore::BitmapView::Write ( OutputStream aOutput) const

Writes a bitmap in serialized form.

◆ WritePng()

Result CartoTypeCore::BitmapView::WritePng ( OutputStream aOutputStream,
bool  aPalettize 
) const

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

Member Data Documentation

◆ iData

uint8_t* CartoTypeCore::BitmapView::iData = nullptr
protected

The bitmap data.

◆ iHeight

uint32_t CartoTypeCore::BitmapView::iHeight = 0
protected

The height in pixels.

◆ iPalette

std::shared_ptr<CartoTypeCore::Palette> CartoTypeCore::BitmapView::iPalette
protected

The palette if any.

◆ iRowBytes

uint32_t CartoTypeCore::BitmapView::iRowBytes = 0
protected

The number of bytes in each row of pixels.

◆ iType

BitmapType CartoTypeCore::BitmapView::iType = BitmapType::A8
protected

The bitmap type.

◆ iWidth

uint32_t CartoTypeCore::BitmapView::iWidth = 0
protected

The width in pixels.


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