Anteckning
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Encapsulates a 32-bit device independent bitmap and device context, which can be used for rendering glyphs.
Inheritance
The IDWriteBitmapRenderTarget interface inherits from the IUnknown interface. IDWriteBitmapRenderTarget also has these types of members:
Methods
The IDWriteBitmapRenderTarget interface has these methods.
| IDWriteBitmapRenderTarget::DrawGlyphRun  Draws a run of glyphs to a bitmap target at the specified position.  | 
| IDWriteBitmapRenderTarget::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.  | 
| IDWriteBitmapRenderTarget::GetMemoryDC  Gets a handle to the memory device context.  | 
| IDWriteBitmapRenderTarget::GetPixelsPerDip  Gets the number of bitmap pixels per DIP.  | 
| IDWriteBitmapRenderTarget::GetSize  Gets the dimensions of the target bitmap.  | 
| IDWriteBitmapRenderTarget::Resize  Resizes the bitmap.  | 
| IDWriteBitmapRenderTarget::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.  | 
| IDWriteBitmapRenderTarget::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
| Requirement | Value | 
|---|---|
| Minimum supported client | Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | UWP apps] | 
| Minimum supported server | Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | UWP apps] | 
| Target Platform | Windows | 
| Header | dwrite.h |