Metodo ID2D1RenderTarget::CreateLayer(constD2D1_SIZE_F*,ID2D1Layer**) (d2d1.h)
Crea una risorsa livello che può essere usata con questa destinazione di rendering e le relative destinazioni di rendering compatibili.
Sintassi
HRESULT CreateLayer(
const D2D1_SIZE_F *size,
ID2D1Layer **layer
);
Parametri
size
Tipo: [in] const D2D1_SIZE_F*
Se viene specificato (0, 0), non viene creato alcun archivio di backup dietro la risorsa livello. La risorsa livello viene allocata alla dimensione minima quando viene chiamato PushLayer .
layer
Tipo: [out] ID2D1Layer**
Quando il metodo restituisce, contiene un puntatore a un puntatore al nuovo livello. Questo parametro viene passato non inizializzato.
Valore restituito
Tipo: HRESULT
Se questo metodo ha esito positivo, restituisce S_OK. In caso contrario, restituisce un codice di errore HRESULT .
Commenti
Il livello si ridimensiona automaticamente, in base alle esigenze.
Esempio
Nell'esempio seguente viene usato un livello per ritagliare una bitmap in una maschera geometrica. Per l'esempio completo, vedere Come ritagliare una maschera geometrica.
HRESULT DemoApp::RenderWithLayer(ID2D1RenderTarget *pRT)
{
HRESULT hr = S_OK;
// Create a layer.
ID2D1Layer *pLayer = NULL;
hr = pRT->CreateLayer(NULL, &pLayer);
if (SUCCEEDED(hr))
{
pRT->SetTransform(D2D1::Matrix3x2F::Translation(350, 50));
// Push the layer with the geometric mask.
pRT->PushLayer(
D2D1::LayerParameters(D2D1::InfiniteRect(), m_pPathGeometry),
pLayer
);
pRT->DrawBitmap(m_pOrigBitmap, D2D1::RectF(0, 0, 200, 133));
pRT->FillRectangle(D2D1::RectF(0.f, 0.f, 25.f, 25.f), m_pSolidColorBrush);
pRT->FillRectangle(D2D1::RectF(25.f, 25.f, 50.f, 50.f), m_pSolidColorBrush);
pRT->FillRectangle(D2D1::RectF(50.f, 50.f, 75.f, 75.f), m_pSolidColorBrush);
pRT->FillRectangle(D2D1::RectF(75.f, 75.f, 100.f, 100.f), m_pSolidColorBrush);
pRT->FillRectangle(D2D1::RectF(100.f, 100.f, 125.f, 125.f), m_pSolidColorBrush);
pRT->FillRectangle(D2D1::RectF(125.f, 125.f, 150.f, 150.f), m_pSolidColorBrush);
pRT->PopLayer();
}
SafeRelease(&pLayer);
return hr;
}
Requisiti
Requisito | Valore |
---|---|
Piattaforma di destinazione | Windows |
Intestazione | d2d1.h |
Libreria | D2d1.lib |
DLL | D2d1.dll |