2012-01-08 219 views
1

我有一个图像和三个顶点与它的位置和它的texcoord。绘制纹理三角形

如何在picturebox中绘制纹理三角形?

这是一张说明它是什么:

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 2012-01-08 02:25:30

+0

@Blau:可能是你想要的结果的图片会有帮助吗? – Ryan 2012-01-08 02:48:17

+0

我已经为问题添加了图片网址。 – Blau 2012-01-08 03:19:32