Interface ID2D1BitmapRenderTarget (d2d1.h)

Affiche une texture intermédiaire créée par la méthode CreateCompatibleRenderTarget .

Héritage

L’interface ID2D1BitmapRenderTarget hérite de ID2D1RenderTarget. ID2D1BitmapRenderTarget a également les types de membres suivants :

Méthodes

L’interface ID2D1BitmapRenderTarget utilise ces méthodes.

 
ID2D1BitmapRenderTarget ::GetBitmap

Récupère la bitmap pour cette cible de rendu. La bitmap retournée peut être utilisée pour les opérations de dessin.

Remarques

Un ID2D1BitmapRenderTarget écrit dans une texture intermédiaire. Il est utile pour créer des modèles à utiliser avec un objet ID2D1BitmapBrush ou pour mettre en cache des données de dessin qui seront utilisées à plusieurs reprises.

Pour écrire directement dans une bitmap WIC à la place, utilisez la méthode ID2D1Factory ::CreateWicBitmapRenderTarget . Cette méthode retourne un ID2D1RenderTarget qui écrit dans la bitmap WIC spécifiée.

Création d’objets ID2D1BitmapRenderTarget

Pour créer une cible de rendu bitmap, appelez la méthode ID2D1RenderTarget ::CreateCompatibleRenderTarget .

Comme d’autres cibles de rendu, un objet ID2D1BitmapRenderTarget est une ressource dépendante de l’appareil et doit être recréé lorsque l’appareil associé devient indisponible. Pour plus d’informations, consultez Vue d’ensemble des ressources.

Exemples

L’exemple suivant utilise la méthode CreateCompatibleRenderTarget pour créer un ID2D1BitmapRenderTarget et l’utilise pour dessiner un modèle de grille. Le modèle de grille est utilisé comme source d’un OBJET 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;
}

L’exemple de code suivant utilise le pinceau pour peindre un motif.

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

Le code a été omis dans cet exemple.

Configuration requise

Condition requise Valeur
Client minimal pris en charge Windows 7, Windows Vista avec SP2 et Mise à jour de plateforme pour Windows Vista [applications de bureau | Applications UWP]
Serveur minimal pris en charge Windows Server 2008 R2, Windows Server 2008 avec SP2 et Platform Update pour Windows Server 2008 [applications de bureau | Applications UWP]
Plateforme cible Windows
En-tête d2d1.h

Voir aussi

CreateCompatibleRenderTarget

ID2D1Factory ::CreateWicBitmapRenderTarget

ID2D1RenderTarget