日期:2014-05-17  浏览次数:20903 次

请问用Matrix 的Scale执行缩放与Graphics的SScaleTransform有什么区别么,是不是可以实现相同的功能
请问用Matrix  的Scale执行缩放与Graphics的SScaleTransform有什么区别么,是不是可以实现相同的功能?

------解决方案--------------------
没有什么区别。比如下面的代码,它们可以实现相同的功能:

public Form1()
{
    InitializeComponent();
}
protected override void OnPaint(PaintEventArgs e)
{
    if (true)
    {
        // 方法一
        e.Graphics.TranslateTransform(this.ClientRectangle.Width, 0);
        e.Graphics.ScaleTransform(-1, 1);
    }
    else
    {
        //方法二
        Matrix matrix = new Matrix();
        matrix.Translate(this.ClientRectangle.Width, 0);
        matrix.Scale(-1, 1);
        e.Graphics.Transform = matrix;
    }
    e.Graphics.DrawString("hello matrix", this.Font, Brushes.Black, 30, 30);
}