D-Type Shape Engine is just one level above D-Type Rasterizer. Its function is to render custom vectorial shapes (outlines) that are described using straight or curved segments to the output surface of the application's choice. In this process, colors and, optionally, advanced style effects are applied.
D-Type Shape Engine consists of the following main components:
A typical life cycle of an application that relies on D-Type Shape Engine is briefly summarized in the following table:
Step | Function |
---|---|
1. Initialize D-Type Engine | dtEngineIniViaStream |
2. Set destination surface (D-Type's Memory Surface or Windows Device Context) and its clipping region to the Output | dtOutputSetAsMDC, dtOutputSetAsHDC |
3. Select a style to the Output. | dtOutputSetStyleAttribs or dtOutputSetStyleEffects |
4. Define and draw shapes | dtShapesDoOutput |
5. Deinitialize D-Type Engine | dtEngineExt |
Please note that the above table only identifies the most important steps and functions. Your application might need additional steps and/or functions.
As mentioned earlier, D-Type Shape Engine relies on D-Type Rasterizer which utilizes a set of extremely fast routines for generating 8-bpp grayscale bitmaps (256 levels of gray). When instructed, D-Type Shape Engine will draw a shape to a dynamically allocated 8-bpp memory buffer (off-surface) and then blend the resulting bitmap into the provided D-Type Memory Surface (MDC) or copy it to the Windows Device Context (HDC). In this process color, transparency and special effects (e.g. pattern fills, shadows, blur effects) are applied.
If the width or height of the shape is very large, D-Type Shape Engine may need to re-use the same buffer a few times in order to render the entire shape. However, if the width and height of the shape does not exceed the maximum width and height to render in a single pass (set in dtype.inf or via dtRasterizerRealloc), D-Type Shape Engine will be able to render the shape in a single pass and provide a pointer to this buffer via the DT_BMP structure. This is useful for applications that store or post-manipulate the bitmap's 8-bit grayscale data. Applications that do not require access to the bitmap's bytes can either free the bitmap themselves using the dtBitmapFree function or instruct D-Type Shape Engine not to return the bitmap in the first place. See the dtShapeDoOutput function for more details.
When drawing to D-Type's Memory Surfaces (MDC), such as 8-bpp grayscale, 24-bpp and 32-bpp RGB memory surfaces, D-Type Shape Engine can render directly to the surface's memory (on-surface), without the need to use a dynamically allocated 8-bpp memory buffer. For this reason, drawing to D-Type's Memory Surfaces is extremely fast and by far superior compared to drawing to Windows Device Context (HDC). In fact, modern applications should draw to D-Type's Memory Surfaces exclusively. Support for Windows Device Context is available primarily for backward-compatibility reasons.
Note: The maximum width and height to render in a single pass can be set in the dtype.inf initialization file or by calling the dtRasterizerRealloc function.