Método ID2D1BitmapRenderTarget::GetBitmap (d2d1.h)

Recupera el mapa de bits para este destino de representación. El mapa de bits devuelto se puede usar para las operaciones de dibujo.

Sintaxis

HRESULT GetBitmap(
  [out] ID2D1Bitmap **bitmap
);

Parámetros

[out] bitmap

Tipo: ID2D1Bitmap**

Cuando este método vuelve, contiene la dirección de un puntero al mapa de bits de este destino de representación. Este mapa de bits se puede usar para las operaciones de dibujo.

Valor devuelto

Tipo: HRESULT

Si este método se realiza correctamente, devuelve S_OK. De lo contrario, devuelve un código de error HRESULT .

Comentarios

El valor de PPP para id2D1Bitmap obtenido de GetBitmap será el valor de PPP del ID2D1BitmapRenderTarget cuando se creó el destino de representación. Cambiar el valor de PPP de ID2D1BitmapRenderTarget mediante una llamada a SetDpi no afecta a la PPP del mapa de bits, incluso si se llama a SetDpi antes de GetBitmap. El uso de SetDpi para cambiar el valor de PPP de ID2D1BitmapRenderTarget afecta a cómo se representa el contenido en el mapa de bits: simplemente no afecta al VALOR de PPP del mapa de bits recuperado por GetBitmap.

Ejemplos

En el ejemplo siguiente se usa el método CreateCompatibleRenderTarget para crear un id2D1BitmapRenderTarget y usarlo para dibujar un patrón de cuadrícula. El patrón de cuadrícula se usa como origen de 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;
}

En el ejemplo de código siguiente se usa el pincel para pintar un patrón.

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

El código se ha omitido en este ejemplo.

Requisitos

Requisito Value
Cliente mínimo compatible Windows 7, Windows Vista con SP2 y Platform Update para Windows Vista [aplicaciones de escritorio | Aplicaciones para UWP]
Servidor mínimo compatible Windows Server 2008 R2, Windows Server 2008 con SP2 y Actualización de plataforma para Windows Server 2008 [aplicaciones de escritorio | Aplicaciones para UWP]
Plataforma de destino Windows
Encabezado d2d1.h
Library D2d1.lib
Archivo DLL D2d1.dll

Consulte también

ID2D1BitmapRenderTarget