共用方式為


繪製填滿紋理的線條

您可以使用紋理繪製,而不是使用純色繪製線條或曲線。 若要使用紋理繪製線條和曲線,請建立 TextureBrush 物件,並將該 TextureBrush 物件的位址傳遞至 Pen 建構函 。 與紋理筆刷相關聯的影像是用來將平面並排 (不可見) ,而當畫筆繪製線條或曲線時,畫筆的筆劃會發現磚化紋理的特定圖元。

下列範例會從檔案Texture1.jpg建立 Image 物件。 該影像用來建構 TextureBrush 物件,而 TextureBrush 物件則用來建構 Pen 物件。 呼叫 Graphics::D rawImage時,會將影像的左上角繪製 (0, 0) 。 呼叫 Graphics::D rawEllipse會使用Pen物件繪製紋理橢圓形。

Image         image(L"Texture1.jpg");
TextureBrush  tBrush(&image);
Pen           texturedPen(&tBrush, 30);

graphics.DrawImage(&image, 0, 0, image.GetWidth(), image.GetHeight());
graphics.DrawEllipse(&texturedPen, 100, 20, 200, 100);

下圖顯示影像和紋理橢圓形。

顯示小型矩形影像的圖例,然後填入原始影像的橢圓線段