Condividi tramite


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

Crea un pennello immagine. L'immagine di input può essere qualsiasi tipo di immagine, tra cui una bitmap, un effetto o un elenco di comandi.

Sintassi

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

Parametri

[in] image

Tipo: ID2D1Image*

Immagine da usare come origine per il pennello immagine.

[in, ref] imageBrushProperties

Tipo: const D2D1_IMAGE_BRUSH_PROPERTIES

Proprietà specifiche di un pennello immagine.

[out] imageBrush

Tipo: ID2D1ImageBrush**

Quando termina, questo metodo contiene l'indirizzo di un puntatore ai rettangoli di input.

Valore restituito

Tipo: HRESULT

Il metodo restituisce un valore HRESULT. I valori possibili includono, ma non sono limitati a, quelli indicati nella tabella seguente.

HRESULT Descrizione
S_OK Non si sono verificati errori.
E_OUTOFMEMORY Direct2D non è riuscito ad allocare memoria sufficiente per completare la chiamata.
E_INVALIDARG Un valore non valido è stato passato al metodo .

Commenti

Il pennello immagine può essere usato per riempire una geometria arbitraria, una maschera di opacità o un testo.

Questo esempio illustra il disegno di un rettangolo con un pennello immagine.

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;
}

Requisiti

Requisito Valore
Client minimo supportato Windows 8 e aggiornamento della piattaforma per Windows 7 [app desktop | App UWP]
Server minimo supportato Windows Server 2012 e aggiornamento della piattaforma per Windows Server 2008 R2 [app desktop | App UWP]
Piattaforma di destinazione Windows
Intestazione d2d1_1.h
DLL D2d1.dll

Vedi anche

D2D1_BRUSH_PROPERTIES

D2D1_IMAGE_BRUSH_PROPERTIES

ID2D1DeviceContext

ID2D1DeviceContext::CreateCommandList

ID2D1DeviceContext::CreateEffect

ID2D1RenderTarget::D rawGeometry

ID2D1RenderTarget::FillGeometry