WPF Tranform-Flip Image
Use a ScaleTransform with a ScaleX of -1 for horizontal and ScaleY of -1 for vertical flipping, applied to the image's RenderTransform
property. Using RenderTransformOrigin="0.5,0.5"
on the image makes sure your image gets flipped around its center, so you won't have to apply an additional TranslateTransform to move it into place:
<Image Source="a.jpg" Padding="5" RenderTransformOrigin="0.5,0.5"> <Image.RenderTransform> <ScaleTransform ScaleX="-1"/> </Image.RenderTransform> </Image>
for horizontal flipping and
<Image Source="a.jpg" Padding="5" RenderTransformOrigin="0.5,0.5"> <Image.RenderTransform> <ScaleTransform ScaleY="-1"/> </Image.RenderTransform> </Image>
for vertical.
If you want to do it in code-behind, in C# it should look something like this:
img.RenderTransformOrigin = new Point(0.5,0.5); ScaleTransform flipTrans = new ScaleTransform(); flipTrans.ScaleX = -1; //flipTrans.ScaleY = -1; img.RenderTransform = flipTrans;
Rotate and scale ImageBrush
TransformGroup tg = new Transformgroup(); tg.Children.Add(rotateTransform); tg.Children.Add(scaleTransform); bgbrush.RelativeTransform = tg;
参考
作者:旭东
出处:http://www.cnblogs.com/HQFZ
关于作者:专注于微软平台项目架构、管理和企业解决方案。现主要从事WinForm、ASP.NET、WPF、WCF、等方面的项目开发、架构、管理。如有问题或建议,请不吝指教!
本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。如有问题,可以联系我,非常感谢。
如果您该文觉得不错或者对你有帮助,请点下推荐,让更多的朋友看到,谢谢!