Encapsulates a 32-bit device independent bitmap and device context, which can be used for rendering glyphs.
Members
The IDWriteBitmapRenderTarget interface inherits from the IUnknown interface. IDWriteBitmapRenderTarget also has these types of members:
Methods
The IDWriteBitmapRenderTarget interface has these methods.
| Method | Description |
|---|---|
| DrawGlyphRun |
Draws a run of glyphs to a bitmap target at the specified position. |
| GetCurrentTransform |
Gets the transform that maps abstract coordinates to DIPs. By default this is the identity transform. Note that this is unrelated to the world transform of the underlying device context. |
| GetMemoryDC |
Gets a handle to the memory device context. |
| GetPixelsPerDip |
Gets the number of bitmap pixels per DIP. |
| GetSize |
Gets the dimensions of the target bitmap. |
| Resize |
Resizes the bitmap. |
| SetCurrentTransform |
Sets the transform that maps abstract coordinate to DIPs (device-independent pixel). This does not affect the world transform of the underlying device context. |
| SetPixelsPerDip |
Sets the number of bitmap pixels per DIP (device-independent pixel). A DIP is 1/96 inch, so this value is the number if pixels per inch divided by 96. |
Remarks
You create an IDWriteBitmapRenderTarget by using the IDWriteGdiInterop::CreateBitmapRenderTarget method, as shown in the following code.
if (SUCCEEDED(hr))
{
hr = g_pGdiInterop->CreateBitmapRenderTarget(hdc, r.right, r.bottom, &g_pBitmapRenderTarget);
}
IDWriteGdiInterop::CreateBitmapRenderTarget takes a handle to a DC and the desired width and height. In the above example, the width and height given are the size of the window rect.
Rendering
One way to use a IDWriteBitmapRenderTarget, for rendering to a bitmap, is to implement a custom renderer interface derived from the IDWriteTextRenderer interface. In your implementation of the DrawGlyphRun method of your custom renderer, call the IDWriteBitmapRenderTarget::DrawGlyphRun method to draw the glyphs as shown in the following code.
STDMETHODIMP GdiTextRenderer::DrawGlyphRun(
__maybenull void* clientDrawingContext,
FLOAT baselineOriginX,
FLOAT baselineOriginY,
DWRITE_MEASURING_MODE measuringMode,
__in DWRITE_GLYPH_RUN const* glyphRun,
__in DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription,
IUnknown* clientDrawingEffect
)
{
HRESULT hr = S_OK;
// Pass on the drawing call to the render target to do the real work.
RECT dirtyRect = {0};
hr = pRenderTarget_->DrawGlyphRun(
baselineOriginX,
baselineOriginY,
measuringMode,
glyphRun,
pRenderingParams_,
RGB(0,200,255),
&dirtyRect
);
return hr;
}
The IDWriteBitmapRenderTarget encapsulates and renders to a bitmap in memory. The GetMemoryDC function returns a handle to the device context of this bitmap.
Requirements
|
Minimum supported client | Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | Windows Store apps] |
|---|---|
|
Minimum supported server | Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | Windows Store apps] |
|
Header |
|
|
Library |
|
|
DLL |
|
Send comments about this topic to Microsoft
Build date: 11/22/2012