本文介绍了使用 WPF 进行透视变换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WPF 允许在图形对象上指定线性仿射变换.有了它,您可以进行平移、旋转、缩放、倾斜或它们的组合.您可以指定一个 2x3 矩阵.

WPF allows to specify linear affine transform on graphical objects. With this you can do translation, rotation, scaling, skewing, or a combination of that. You can specify a 2x3 matrix.

我想做的是在 2D 空间中的透视变换,它需要一个 3x3 的矩阵,并且在 Photoshop 或 GIMP 中已知,您可以在其中独立拖动图像的所有 4 个角.

What I want to do is a perspective transform in 2D space, which requires a 3x3 matrix, and is known from Photoshop or GIMP, where you can drag all 4 corners of an image independently.

我尝试使用 WPF 的 3D 功能,设置一个 Viewport3D、一个 OrthographicCamera 并将(2D)对象放置在 xy 平面上.

I tried to use the 3D features of WPF, set up a Viewport3D, an OrthographicCamera and placed the (2D) objects onto the xy-plane.

但我想知道是否有更简单的方法来完成 WPF 中的透视变换?

But I'm wondering if there is no easier way to accomplish the perspective transform in WPF?

我这么问也是因为我想对文本进行透视变换:在 2D 中我可以使用 TextBlock,在 3D 中它变得更加复杂,我必须创建一个Brush 出一个 Geometry 出一个 FormattedText.

I'm asking also because I'd like to do the perspective transform on text: in 2D I can use a TextBlock, in 3D it gets more compliacted, I'd have to create a Brush out of a Geometry out of a FormattedText.

推荐答案

尽你所能 阅读此处 有一些 3rd 方库为 WPF 实现了 Silverlight 的 PlaneProjection.

As you can read here there are some 3rd party libraries that implement Silverlight's PlaneProjection for WPF.

否则你将被迫自己编写代码.(也许微软会在 .NET 的未来版本中添加 PlaneProjection)

Otherwise you will be forced to code it yourself. (Perhaps Microsoft will add the PlaneProjection in a future version of .NET)

这篇关于使用 WPF 进行透视变换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 10:26
查看更多