A paint device for rendering to a raster image. More...
#include <Wt/WRasterImage>
A paint device for rendering to a raster image.
A WRasterImage paint device provides support for creating raster images (such as PNG or GIF images).
It implements two main use-cases:
On Linux, the rendering is provided by GraphicsMagick, and this class is included in the library only if
libgraphicsmagick was found during the build of the library. As an alternative, Wt supports certain versions of skia. In general skia is a good and performant renderer, but since it does not have releases, and a not very stable API, we don't recommend it. On Windows, Direct2D is used for rendering, which means that no extra dependencies have to be installed.
If Wt is built to use
libpango for font support, then text rendering is done using this library. On Windows, DirectWrite is used for font support functions. In other cases, you may want to configure TrueType font search directories using addFontCollection().
You can use the image as a resource and specialize handleRequest() to paint the contents on the fly. Alternatively can also use write() to serialize to an image file (std::ostream).
The latter usage is illustrated by the code below:
This paint device has the following limitations:
Creates a raster image.
type indicates an image type. The mime type of the resource is
"image/"
type.
Wt supports the following image types (amongst others):
Adds a font collection.
If Wt has been configured to use
libpango, then font matching and character selection is done by libpango, which is seeded with information on installed fonts by fontconfig. In that case, invocations for this method is ignored.
If Wt has not been configured to use
libpango, then this method may be used to indicate the location of true type).
Clears the image.
Fills the image with a white background, or transparent if possible.
Finishes painting on the device.
This method is called when a WPainter stopped painting.
Implements Wt::WPaintDevice.
Draws.
If clipPoint is not null, a check is performed whether the point is inside of the current clip area. If not, the text is not drawn.
Implements Wt::WPaintDevice.
Returns font metrics.
This returns font metrics for the current font.
Throws a std::logic_error if the underlying device does not provide font metrics.
Implements Wt::WPaintDevice.
Low-level paint method.
Use this method to directly get the color for an individual pixel, when using the paint device without a painter.
Low-level pixel retrieval.
This is a more efficient alternative than calling getPixel() for every pixel.
Parameter data must point to an allocated memory region of width*height 32-bit words. The pixels will be written in row-order from top-left to bottom-right, in RGBA format...
Low-level paint method.
Use this method to directly set colors for individual pixels, when using the paint device without a painter.
Returns the device width.
The device width, in pixels, establishes the width of the device coordinate system.
Implements Wt::WPaintDevice.