Condividi tramite


Interfaccia ID2D1BitmapRenderTarget (d2d1.h)

Esegue il rendering di una trama intermedia creata dal metodo CreateCompatibleRenderTarget .

Ereditarietà

L'interfaccia ID2D1BitmapRenderTarget eredita da ID2D1RenderTarget. ID2D1BitmapRenderTarget include anche questi tipi di membri:

Metodi

L'interfaccia ID2D1BitmapRenderTarget include questi metodi.

 
ID2D1BitmapRenderTarget::GetBitmap

Recupera la bitmap per questa destinazione di rendering. La bitmap restituita può essere usata per le operazioni di disegno.

Commenti

Un ID2D1BitmapRenderTarget scrive in una trama intermedia. È utile creare modelli da usare con un ID2D1BitmapBrush o memorizzare nella cache i dati di disegno che verranno usati ripetutamente.

Per scrivere direttamente in una bitmap WIC, usare invece il metodo ID2D1Factory::CreateWicBitmapRenderTarget . Questo metodo restituisce un ID2D1RenderTarget che scrive nella bitmap WIC specificata.

Creazione di oggetti ID2D1BitmapRenderTarget

Per creare una destinazione di rendering bitmap, chiamare il metodo ID2D1RenderTarget::CreateCompatibleRenderTarget .

Come altre destinazioni di rendering, un ID2D1BitmapRenderTarget è una risorsa dipendente dal dispositivo e deve essere ricreata quando il dispositivo associato non è disponibile. Per altre informazioni, vedere Panoramica delle risorse.

Esempio

Nell'esempio seguente viene usato il metodo CreateCompatibleRenderTarget per creare un ID2D1BitmapRenderTarget e usarlo per disegnare un modello di griglia. Il modello di griglia viene usato come origine di un ID2D1BitmapBrush.

HRESULT DemoApp::CreateGridPatternBrush(
    ID2D1RenderTarget *pRenderTarget,
    ID2D1BitmapBrush **ppBitmapBrush
    )
{
    // Create a compatible render target.
    ID2D1BitmapRenderTarget *pCompatibleRenderTarget = NULL;
    HRESULT hr = pRenderTarget->CreateCompatibleRenderTarget(
        D2D1::SizeF(10.0f, 10.0f),
        &pCompatibleRenderTarget
        );
    if (SUCCEEDED(hr))
    {
        // Draw a pattern.
        ID2D1SolidColorBrush *pGridBrush = NULL;
        hr = pCompatibleRenderTarget->CreateSolidColorBrush(
            D2D1::ColorF(D2D1::ColorF(0.93f, 0.94f, 0.96f, 1.0f)),
            &pGridBrush
            );
        if (SUCCEEDED(hr))
        {
            pCompatibleRenderTarget->BeginDraw();
            pCompatibleRenderTarget->FillRectangle(D2D1::RectF(0.0f, 0.0f, 10.0f, 1.0f), pGridBrush);
            pCompatibleRenderTarget->FillRectangle(D2D1::RectF(0.0f, 0.1f, 1.0f, 10.0f), pGridBrush);
            pCompatibleRenderTarget->EndDraw();

            // Retrieve the bitmap from the render target.
            ID2D1Bitmap *pGridBitmap = NULL;
            hr = pCompatibleRenderTarget->GetBitmap(&pGridBitmap);
            if (SUCCEEDED(hr))
            {
                // Choose the tiling mode for the bitmap brush.
                D2D1_BITMAP_BRUSH_PROPERTIES brushProperties =
                    D2D1::BitmapBrushProperties(D2D1_EXTEND_MODE_WRAP, D2D1_EXTEND_MODE_WRAP);

                // Create the bitmap brush.
                hr = m_pRenderTarget->CreateBitmapBrush(pGridBitmap, brushProperties, ppBitmapBrush);

                pGridBitmap->Release();
            }

            pGridBrush->Release();
        }

        pCompatibleRenderTarget->Release();
    }

    return hr;
}

Nell'esempio di codice seguente viene usato il pennello per disegnare un modello.

// Paint a grid background.
m_pRenderTarget->FillRectangle(
    D2D1::RectF(0.0f, 0.0f, renderTargetSize.width, renderTargetSize.height),
    m_pGridPatternBitmapBrush
    );

Il codice è stato omesso da questo esempio.

Requisiti

Requisito Valore
Client minimo supportato Windows 7, Windows Vista con SP2 e Aggiornamento della piattaforma per Windows Vista [app desktop | App UWP]
Server minimo supportato Windows Server 2008 R2, Windows Server 2008 con SP2 e Platform Update per Windows Server 2008 [app desktop | App UWP]
Piattaforma di destinazione Windows
Intestazione d2d1.h

Vedi anche

CreateCompatibleRenderTarget

ID2D1Factory::CreateWicBitmapRenderTarget

ID2D1RenderTarget