我可以通过以下方式旋转图像:
RotateTransform aRotateTransform = new RotateTransform();
aRotateTransform.CenterX = 0.5;
aRotateTransform.CenterY = 0.5;
tateTransform.Angle = rotationAngle;
ImageBrush bgbrush = new ImageBrush();
bgbrush.RelativeTransform = aRotateTransform;
ScaleTransform s = new ScaleTransform();
s.ScaleX = -1; // how to set without overriding the rotation?
...我怎样才能扩大它的规模?我试过使用矩阵但没有成功。
发布于 2014-11-06 10:07:30
您可以使用这样的TransformGroup:
TransformGroup tg = new Transformgroup();
tg.Children.Add(rotateTransform);
tg.Children.Add(scaleTransform);
bgbrush.RelativeTransform = tg;发布于 2014-11-06 10:01:03
您可以使用CompositeTransform,它将平移、旋转和缩放组合在一个矩阵中。
发布于 2014-11-06 11:33:46
只是为了完整。使用矩阵转换,您将通过以下方式获得预期的结果:
var transform = Matrix.Identity;
transform.RotateAt(rotationAngle, 0.5, 0.5);
transform.Scale(-1, 1);
bgbrush.RelativeTransform = new MatrixTransform(transform);但是,我想实际上您希望保持图像中心化,所以您可以使用ScaleAt而不是Scale
var transform = Matrix.Identity;
transform.RotateAt(rotationAngle, 0.5, 0.5);
transform.ScaleAt(-1, 1, 0.5, 0.5);
bgBrush.RelativeTransform = new MatrixTransform(transform);https://stackoverflow.com/questions/26776447
复制相似问题