问题
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.
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.
I tried to use the 3D features of WPF, set up a Viewport3D
, an OrthographicCamera
and placed the (2D) objects onto the xy-plane.
But I'm wondering if there is no easier way to accomplish the perspective transform in WPF?
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
.
回答1:
As you can read here there are some 3rd party libraries that implement Silverlight's PlaneProjection for WPF.
Otherwise you will be forced to code it yourself. (Perhaps Microsoft will add the PlaneProjection in a future version of .NET)
来源:https://stackoverflow.com/questions/10715586/perspective-transform-with-wpf