2011.03.03 How to rotate FONT or PICTURE in C Sharp language
Graphics g = this.CreateGraphics();
Matrix x = new Matrix();
x.Rotate(45, MatrixOrder.Append);
g.Transform = x;
g.DrawString( "字符串 ", this.Font, SystemBrushes.ControlText, 0, 0);
g.ResetTransform();
图像Graphics.TranslateTransform
string filePath =@"C:\a.jpg";
using (Bitmap bm = new Bitmap(500,500))
{
using (Graphics g = Graphics.FromImage(bm))
{
g.Clear(Color.Wheat);
g.TranslateTransform(0, 0, MatrixOrder.Prepend);
g.RotateTransform(45);
FontFamily ff = new FontFamily("宋体");
Font f =new Font(ff,10);
Brush b = new SolidBrush(Color.Black);
StringFormat sf = new StringFormat();
g.DrawString("", f, b, new PointF(10, 10), sf);
g.DrawString("", f, b, new PointF(10, 10 + 30 + 10), sf);
}
bm.Save(filePath, ImageFormat.Jpeg);
}
Matrix x = new Matrix();
x.Rotate(45, MatrixOrder.Append);
g.Transform = x;
g.DrawString( "字符串 ", this.Font, SystemBrushes.ControlText, 0, 0);
g.ResetTransform();
图像Graphics.TranslateTransform
string filePath =@"C:\a.jpg";
using (Bitmap bm = new Bitmap(500,500))
{
using (Graphics g = Graphics.FromImage(bm))
{
g.Clear(Color.Wheat);
g.TranslateTransform(0, 0, MatrixOrder.Prepend);
g.RotateTransform(45);
FontFamily ff = new FontFamily("宋体");
Font f =new Font(ff,10);
Brush b = new SolidBrush(Color.Black);
StringFormat sf = new StringFormat();
g.DrawString("", f, b, new PointF(10, 10), sf);
g.DrawString("", f, b, new PointF(10, 10 + 30 + 10), sf);
}
bm.Save(filePath, ImageFormat.Jpeg);
}