c#如何反转字体
我现在是
[code=C#][/code] GraphicsContainer containerState = gMem.BeginContainer();
PointF currentPf = new PointF();
PointF movePf = new PointF();
currentPf = Vector.pointCurrent; //鼠标单击后的点
movePf = Vector.movePointCurrent;//鼠标移动的点
DrawTools.DrawLineLength(gMem, currentPf, movePf, this.Font, pCanvas);//在两条直线之间显示字符串,里面调用了drawstring函数。 把字体放在 (currentPf + movePf)/2 的位置.
gMem.EndContainer(containerState);
现在我的效果是
字体在线上 是倒过来的,
我用
gMem.ScaleTransform(1, -1); 倒过去的时候 字体又不在线上了。。。怎么办呢
[解决办法]
gMem.ScaleTransform(1, -1);替换为
- C# code
gMem.TranslateTransform(0, (-currentPf.Y - movePf.Y - this.Font.Height) / 2, MatrixOrder.Prepend);gMem.ScaleTransform(1, -1, MatrixOrder.Append);gMem.TranslateTransform(0, (currentPf.Y + movePf.Y + this.Font.Height) / 2, MatrixOrder.Append);
[解决办法]
上面的写错了。用这个
- C# code
using (Graphics G = Graphics.FromHwnd(this.Handle)) { //定义临时图层 using (Bitmap B = new Bitmap(50, 50)) { using (Graphics G2 = Graphics.FromImage(B)) { G2.DrawString("这是翻过来的文字", this.Font, Brushes.Black, new Point(0, 0)); } //将临时图层以Width负长度绘制得到左右倒图(Height负长度将得到垂直倒图) G.DrawImage(B, new Rectangle(100, 100, -50, 50), new Rectangle(0, 0, B.Width, B.Height), GraphicsUnit.Pixel); }}