且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在WPF中旋转时如何避免图像被剪切

更新时间:2023-10-27 22:49:58

由于变换,任何内容都可能被剪切掉.这似乎是一个非常常见的问题,需要了解操作顺序和旋转中心,而没有其他任何事情.还有太多因素:在一般情况下,转换不是可交换的,矩阵乘法也不是可交换的( http://en.wikipedia.org /wiki/Commutative_property [ ^ ]):如果您先进行平移,然后进行旋转变换,然后切换变换顺序,结果将有所不同,但是两次旋转或两次平移是可交换的.

因此,这完全是两个变换(平移和旋转)的效果,它们的顺序以及旋转操作及其变换的中心点的正确组合的问题.这种情况很简单;您可以仅凭一个简单的代码示例就可以了解到每个步骤的结果,并可以了解这些情况.也许首先在C#中进行,而不是在XAML中进行;您将清楚地看到每个变换的效果,并找到适合您的组合.

—SA
Anything can get cut as a result of transform. This looks like a very usual problem with understanding of order of operation and the center of rotation and nothing else. There are too factors: transforms are not commutative in general case, and the matrix multiplication does not commutative (http://en.wikipedia.org/wiki/Commutative_property[^]): if you do translation and then rotation transform and then switch the order of transforms, the results will be different, but two rotations or two translations are commutative.

So, this is all the matter of right combination of the effect of two transforms, translation and rotation, their order, and the center point of rotation operation and its transform. This case if very simple; you can just get a feeling of what''s going on on a simple code sample where you can see the result of each step. Perhaps do it in C# first, not in XAML; and you will clearly see the effect of each transform and find the combination which is right for you.

—SA