Bitmap Class Reference

#include <Pt/Gfx/Bitmap.h>

Off-screen drawing surface backed by an image. More...

Inherits PaintSurface.

Public Member Functions

 Bitmap ()
 Constructs an empty bitmap.
 
 Bitmap (const Gfx::SizeF &size, std::size_t stride=0)
 Constructs a bitmap with the given size and optional stride.
 
virtual ~Bitmap ()
 Destroys the bitmap.
 
void reset ()
 Resets to empty state.
 
void reset (const Gfx::Image &image)
 Replaces the bitmap with an existing image.
 
void reset (const Gfx::SizeF &, std::size_t stride=0)
 Resets the bitmap to a new size in physical pixels.
 
bool empty () const
 Returns true if no image data is available.
 
const Gfx::Imageimage () const
 Returns the underlying image.
 
void setScaleFactor (double scaleFactor)
 Sets the target scale factor.
 
void drawBitmap (const Pt::Gfx::PointF &to, const Bitmap &image, const Gfx::Paint &paint, const Gfx::RectF *rect=0)
 Draws another bitmap into this bitmap.
 
const Gfx::ImageFormatformat () const
 Returns the image format.
 
const Gfx::SizeFsize () const
 Returns the size in physical pixels.
 
const Scalingscaling () const
 Returns the scaling from logical to physical pixels.
 
CanvasgetCanvas (Canvas *canvas)
 Returns a canvas for backend drawing.
 
void sync ()
 Synchronizes pending operations to the surface.
 
void finish ()
 Finishes painting to the surface.
 

Static Public Member Functions

static const std::string & defaultFont ()
 Returns the default font family used by the backend.
 
static void setDefaultFont (const std::string &family)
 Sets the default font family used by the backend.
 
static std::vector< std::string > fontFamilies ()
 Returns the available font families.
 
static std::vector< FontFace > fontFaces (const std::string &family)
 Returns the font faces of a family.
 

Protected Member Functions

virtual const Gfx::ImageFormatonGetFormat () const
 Returns the image format.
 
virtual const Gfx::SizeFonGetSize () const
 Returns the size in physical pixel.
 
virtual const ScalingonGetScaling () const
 Returns the scaling fro logical to physical pixels.
 
virtual Gfx::CanvasonCreateCanvas (Gfx::Canvas *reuse) override
 Creates a Canvas.
 
virtual void onReleaseCanvas () override
 Releases the current Canvas.
 
virtual void onSync () override
 Synchronizes pending operations to the surface.
 
virtual void onFinish () override
 Finishes painting to the surface.
 
void invalidate ()
 Invalidates the currently active paint canvas.
 
virtual Gfx::CanvasonGetCanvas (Gfx::Canvas *reuse)
 Returns a reusable canvas instance.
 

Detailed Description

Bitmap is the standard in-memory PaintSurface implementation. It can be used as a rendering target for Painter and also exposes the rendered image so that drawing results can be copied, inspected or reused by image APIs.