使用C#在Cuboid周围环绕图像 [英] Wrapping Image around a Cuboid using C#

查看:142
本文介绍了使用C#在Cuboid周围环绕图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,我面临着一项新任务,例如将矩形图像转换或合并为长方体,在asp.net中使用c#将矩形图像转换成长方体

解决方案

< blockquote>将图像放在任何平面上非常容易。您可以使用 System.Drawing.Graphics 。在使用ASP.NET时,您可能需要绘制位图。这根本不是问题,使用从先前创建的位图实例获得的实例:

http://msdn.microsoft.com/en-us/library/system.drawing.graphics.fromimage.aspx [ ^ ]。



现在,假设你已经可以使用一些平行投影绘制一个长方体,以保持简单。如何在长方体的倾斜上画画。在立方体和平行投影的情况下,它非常简单。在进行投影之前,您应该使用矩形或与相关的长方体面相同的尺寸和纵横比进行绘制。但!您需要相应地旋转和倾斜图像,以便在投影后适合脸部。您可以使用转换属性来执行此操作:

http://msdn.microsoft.com/en-us/library/system.drawing.graphics.transform.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/system。 drawing.drawing2d.matrix.aspx [ ^ ]。



变换下的绘图的所有细节都会相应地投影,即使每个角色的形状都是如此,一切。数学是矩阵代数和几何,非常简单(特别是在长方体和平行投影的情况下),但你应该这样做。我做的;外观足够令人印象深刻。 :-)



-SA


Hi friends i faced with a new task like converting or merging the rectangular image into a cuboid some thing like a rectangular image to cuboid using c# in asp.net

解决方案

Putting the image on any flat surface is pretty easy. You can use System.Drawing.Graphics. As you are working with ASP.NET, you will probably need to draw on a bitmap. This is not a problem at all, use the instance obtained from previously created instance of a bitmap:
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.fromimage.aspx[^].

Now, suppose you can already draw a cuboid using some parallel projection, to keep things simple. How to draw on a tilted face of the cuboid. In case of cuboid and parallel projection, it''s really simple. You should do some drawing in a rectangle or the same size and aspect ratio as the cuboid face in question, before doing the projection. But! you need to rotate and skew the image accordingly, to fit the face after projection. You can do it using the Transform property:
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.transform.aspx[^],
http://msdn.microsoft.com/en-us/library/system.drawing.drawing2d.matrix.aspx[^].

All the detail of the drawing under transform will be projected accordingly, even the features if the shape of every character, everything. The mathematics is the matrix algebra and geometry, very simple (especially in case of cuboid an parallel projection), but you should do it. I did it; the look is impressive enough. :-)

—SA


这篇关于使用C#在Cuboid周围环绕图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆