IDWriteBitmapRenderTarget Interface

Encapsulates a 32-bit device independent bitmap and device context, which can be used for rendering glyphs.

Mitglieder

IDWriteBitmapRenderTargetSchnittstelle erbt von der IUnknown-Schnittstelle. IDWriteBitmapRenderTarget umfasst auch die folgenden Typen von Mitgliedern:

  • Methoden

Methoden

IDWriteBitmapRenderTargetSchnittstelle umfasst die folgenden Methoden.

Methode Beschreibung
DrawGlyphRun

Draws a run of glyphs to a bitmap target in a specified black box rectangle.

GetCurrentTransform

Gets the transform that maps abstract coordinate 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. This does not affect the world transform of the underlying device context.

SetPixelsPerDip

Sets the number of bitmap pixels per DIP. A DIP (device-independent pixel) is 1/96 inch so this value is the number if pixels per inch divided by 96.

 

Hinweise

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.

Anforderungen

Mindestens unterstützter Client

Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista

Mindestens unterstützter Server

Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008

Header

Dwrite.h

Bibliothek

Dwrite.lib

DLL

Dwrite.dll