0
我有一個程序,我試圖使用SlimDX和VB.net將Direct2D中的圖像渲染到四邊形上。通過BitmapBrush繪製位圖到SlimDX幾何(VB.NET)
程序從服務器獲取4個點的數組,這是一個四邊形,圖像應該放在上面。
的點(例如)是:
points(0) = 20,10 <--Top left, where the geometry starts from
points(1) = 40,10 <-- Top right
points(2) = 40,40 <-- Bottom right
points(3) = 20,40 <-- Bottom left
...構造一個BitmapBrush時加載和位圖可以呈現精細,而是試圖渲染到四邊形的時候,我只得到(它似乎......)右下角的一部分。
供參考:這是我想要繪製圖像: http://i.imgur.com/Dt3iHQ3.png
這裏是我在嘗試使用(繪製圖像)的代碼。 R是點列表(參見上面),RenderBrush是從該圖像的20x30版本創建的BitmapBrush。
Private Sub DrawPoly(R() As PointF, ByRef RenderBrush As SlimDX.Direct2D.BitmapBrush)
'Create the geometry
Dim Path As PathGeometry
Path = New PathGeometry(factoryD2D)
Console.Clear()
'Get a handle to the Geometry
Dim Geometry = Path.Open()
'Set UP Geometry
Geometry.BeginFigure(R(0), FigureBegin.Filled)
Geometry.AddLines(R)
Geometry.EndFigure(FigureEnd.Closed)
Geometry.Close()
'Render
D2DRenderTarget.FillGeometry(Path, RenderBrush)
'and GC
Geometry.Dispose()
Path.Dispose()
End Sub
在此先感謝您的幫助!
我還不確定,畫筆似乎並沒有繪製... –