ID2D1DeviceContext::CreateImageBrush(ID2D1Image*,constD2D1_IMAGE_BRUSH_PROPERTIES&,constD2D1_BRUSH_PROPERTIES&,ID2D1ImageBrush**) (d2d1_1.h)

Crea un pincel de imagen. La imagen de entrada puede ser cualquier tipo de imagen, incluido un mapa de bits, un efecto o una lista de comandos.

Sintaxis

HRESULT CreateImageBrush(
  [in]                ID2D1Image                          *image,
  [in, ref]           const D2D1_IMAGE_BRUSH_PROPERTIES & imageBrushProperties,
  [in, ref, optional] const D2D1_BRUSH_PROPERTIES &       brushProperties,
  [out]               ID2D1ImageBrush                     **imageBrush
);

Parámetros

[in] image

Tipo: ID2D1Image*

Imagen que se va a usar como origen para el pincel de imagen.

[in, ref] imageBrushProperties

Tipo: const D2D1_IMAGE_BRUSH_PROPERTIES

Propiedades específicas de un pincel de imagen.

[in, ref, optional] brushProperties

Tipo: const D2D1_BRUSH_PROPERTIES

Propiedades comunes a todos los pinceles.

[out] imageBrush

Tipo: ID2D1ImageBrush**

Cuando este método devuelve , contiene la dirección de un puntero a los rectángulos de entrada.

Valor devuelto

Tipo: HRESULT

El método devuelve un valor HRESULT. Entre los valores posibles se incluyen los que se indican en la tabla siguiente, entre otros.

HRESULT Descripción
S_OK No se ha producido ningún error.
E_OUTOFMEMORY Direct2D no pudo asignar suficiente memoria para completar la llamada.
E_INVALIDARG Se pasó un valor no válido al método .

Comentarios

El pincel de imagen se puede usar para rellenar una geometría arbitraria, una máscara de opacidad o texto.

En este ejemplo se muestra cómo dibujar un rectángulo con un pincel de imagen.

HRESULT
CreatePatternBrush(
     __in ID2D1DeviceContext *pDeviceContext,
     __deref_out ID2D1ImageBrush **ppImageBrush
     )
{
    HRESULT hr = S_OK;
    ID2D1Image *pOldTarget = NULL;
    pDeviceContext->GetTarget(&pOldTarget);

    ID2D1CommandList *pCommandList = NULL;
    hr = pDeviceContext->CreateCommandList(&pCommandList);
     
    if (SUCCEEDED(hr))
    {   
        pDeviceContext->SetTarget(pCommandList);
        hr = RenderPatternToCommandList(pDeviceContext);
    }

    pDeviceContext->SetTarget(pOldTarget);

    ID2D1ImageBrush *pImageBrush = NULL;

    if (SUCCEEDED(hr))
    {        
         hr = pDeviceContext->CreateImageBrush(
            pCommandList,
            D2D1::ImageBrushProperties(
                D2D1::RectF(198, 298, 370, 470),
                D2D1_EXTEND_MODE_WRAP,
                D2D1_EXTEND_MODE_WRAP,
                D2D1_INTERPOLATION_MODE_LINEAR
                ),
            &pImageBrush
            );
    }
    
    // Fill a rectangle with the image brush.
    if (SUCCEEDED(hr))
    {
        pDeviceContext->FillRectangle(
            D2D1::RectF(0, 0, 100, 100), pImageBrush);
    }

    SafeRelease(&pImageBrush);
    SafeRelease(&pCommandList);
    SafeRelease(&pOldTarget);
    return hr;
}

Requisitos

Requisito Value
Cliente mínimo compatible Windows 8 y actualización de plataforma para Windows 7 [aplicaciones de escritorio | Aplicaciones para UWP]
Servidor mínimo compatible Windows Server 2012 y actualización de plataforma para Windows Server 2008 R2 [aplicaciones de escritorio | Aplicaciones para UWP]
Plataforma de destino Windows
Encabezado d2d1_1.h
Archivo DLL D2d1.dll

Consulte también

D2D1_BRUSH_PROPERTIES

D2D1_IMAGE_BRUSH_PROPERTIES

ID2D1DeviceContext

ID2D1DeviceContext::CreateCommandList

ID2D1DeviceContext::CreateEffect

ID2D1RenderTarget::D rawGeometry

ID2D1RenderTarget::FillGeometry