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();

 

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

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值