2012-01-08 17 views
1

私は1つの画像と3つの頂点とその位置とテクスチャを持っています。テクスチャ付き三角形を描く

このテクスチャ付き三角形をピクチャボックスに描画するにはどうすればよいですか?

これはそれが何であるかを説明する画像です:

enter image description here

答えて

2

あなたがGraphicsPathTextureBrushを使用することができます。

// Create the triangle 
GraphicsPath p = new GraphicsPath(); 
p.AddLine(triangleVertex1, triangleVertex2); 
p.AddLine(triangleVertex2, triangleVertex3); 
p.CloseFigure(); 

// Draw the triangle 
Bitmap b = new Bitmap(pictureBox.ClientSize.Width, pictureBox.ClientSize.Height); 

using(Graphics g = Graphics.FromImage(b), TextureBrush t = new TextureBrush(myImage)) { 
    g.FillPath(t, p); 
} 

// Finally, set the PictureBox's image 
pictureBox.Image = b; 
+0

あなたがにテクスチャをマッピングするために念頭に置いてtexcoordsを持っていません頂点。 : – Blau

+0

@Blau:あなたが望む結果の画像は多分助けになりますか? – Ryan

+0

私は質問に画像URLを追加しました。 – Blau

関連する問題