• GDI+文字旋转


     要使用GDI+,必须先创建Graphics对象,创建Graphics共有三种方法,第一种为

    private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
    {
       Graphics g =e.Graphics;

    第二种为:Graphics gh = this.CreateGraphics();也可以用Graphics gh = Button1.CreateGraphics;

    第三种为:

    Bitmap myBitmap=new Bitmap("C:/myPic.bmp");

    Graphics  g= Graphics.FromImage(myBitmap);

    //使用Graphics 

    g.SmoothingMode=SmoothingMode.Default;

    string tempstr = "章松山";
    SizeF f = g.MeasureString(tempstr, new Font("宋体", 9));

    g.TranslateTransform(f.Height,0);//偏移量
    g.RotateTransform(45);

    Brush myBrush = Brushes.Blue;
    g.DrawString(tempstr, this.Font, myBrush, 0, 0);
    g.DrawRectangle(new Pen(Color.Red), 0, 0, f.Width, f.Height);
    g.ResetTransform();

    //以上绘制了一个带方框的文本。

  • 相关阅读:
    cf C. Vasya and Robot
    zoj 3805 Machine
    cf B. Vasya and Public Transport
    cf D. Queue
    cf C. Find Maximum
    cf B. Two Heaps
    cf C. Jeff and Rounding
    cf B. Jeff and Periods
    cf A. Jeff and Digits
    I Think I Need a Houseboat
  • 原文地址:https://www.cnblogs.com/zhangsongshan/p/2352563.html
Copyright © 2020-2023  润新知