CartoType C++ API 8.8-7-gb35e4dc71
for Windows, Linux, Qt and other platforms supporting C++ development
|
#include <cartotype_bitmap.h>
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 | |
BitmapView & | operator= (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::Palette > | Palette () 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::Palette > | iPalette |
uint32_t | iWidth = 0 |
uint32_t | iHeight = 0 |
uint32_t | iRowBytes = 0 |
BitmapType | iType = BitmapType::A8 |
A bitmap that does not take ownership of pixel data.
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.
|
inline |
Create a bitmap with a specified type, data, and dimensions.
|
inline |
Return the bitmap depth: the number of bits used to store each pixel.
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.
|
inline |
Clear the pixel data to zeroes.
|
inline |
Clear the pixel data to ones (normally white).
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.
Creates a bitmap that is a clipped version of this bitmap. The clip rectangle is in pixels.
|
staticprotected |
Returns the color at (aX,aY) for a 16-bit color bitmap.
|
staticprotected |
Returns the color at (aX,aY) for a a6-bit monochrome bitmap.
|
staticprotected |
Returns the color at (aX,aY) for a one-bit monochrome bitmap.
|
staticprotected |
Returns the color at (aX,aY) for a 24-bit color bitmap.
|
staticprotected |
Returns the color at (aX,aY) for a 32-bit color bitmap.
|
staticprotected |
Returns the color at (aX,aY) for an 8-bit color bitmap.
|
staticprotected |
Returns the color at (aX,aY) for an 8-bit color bitmap with a palette.
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.
|
staticprotected |
A dummy color function to return transparent black for any position.
Bitmap CartoTypeCore::BitmapView::Copy | ( | int32_t | aExpansion = 0 | ) | const |
Copies a bitmap, optionally expanding it by aExpansion pixels all round.
|
inline |
Return a writable pointer to the start of the pixel data.
|
inline |
Return a constant pointer to the start of the pixel data.
|
inline |
Return the number of bytes actually used to store the data. This may include padding at the ends of rows.
|
inline |
Return the height in pixels.
|
inline |
The less-than operator. Assumes that the bitmaps are of the same type.
|
inline |
The equality operator. Assumes that the bitmaps are of the same type.
|
inline |
Return the palette if any.
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.
|
inline |
Return the number of bytes used to store each horizontal row of pixels.
|
inline |
Set the palette.
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.
|
inline |
Return the bitmap type, which indicates its depth and whether it is colored.
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.
|
inline |
Return the width in pixels.
Result CartoTypeCore::BitmapView::Write | ( | OutputStream & | aOutput | ) | const |
Writes a bitmap in serialized form.
Result CartoTypeCore::BitmapView::WritePng | ( | OutputStream & | aOutputStream, |
bool | aPalettize | ||
) | const |
Writes a bitmap to an output stream in PNG format, optionally palettizing it.
|
protected |
The bitmap data.
|
protected |
The height in pixels.
|
protected |
The palette if any.
|
protected |
The number of bytes in each row of pixels.
|
protected |
The bitmap type.
|
protected |
The width in pixels.