这些都很简单。旋转: private Bitmap rotateImage(Bitmap b, float angle) { //create a new empty bitmap to hold rotated image Bitmap returnBitmap = new Bitmap (b.Width, b.Height); //make a graphics object from the empty bitmap Graphics g = Graphics .FromImage(returnBitmap); //move rotation point to center of image g.TranslateTransform((float )b.Width / 2, (float )b.Height / 2); //rotate g.RotateTransform(angle); //move image back g.TranslateTransform(-(float )b.Width / 2, -(float )b.Height / 2); } 删除: System.IO.File.Delete() 全屏就是将窗口边框去掉,最大化,再拉伸图片(注意考虑横宽比例)总之都是极其简单的问题。
两种方法都可以! 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); }方法二似乎更加简单! Image img = Image.FromFile("C:\\1.jpeg"); img.RotateFlip(RotateFlipType.Rotate90FlipX); //System.Drawing.RotateFlipType枚举 img.Save("C:\\2.jpeg");
private Bitmap rotateImage(Bitmap b, float angle) { //create a new empty bitmap to hold rotated image Bitmap returnBitmap = new Bitmap (b.Width, b.Height); //make a graphics object from the empty bitmap Graphics g = Graphics .FromImage(returnBitmap); //move rotation point to center of image g.TranslateTransform((float )b.Width / 2, (float )b.Height / 2); //rotate g.RotateTransform(angle); //move image back g.TranslateTransform(-(float )b.Width / 2, -(float )b.Height / 2); }
删除:
System.IO.File.Delete()
全屏就是将窗口边框去掉,最大化,再拉伸图片(注意考虑横宽比例)总之都是极其简单的问题。
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);
}方法二似乎更加简单!
Image img = Image.FromFile("C:\\1.jpeg");
img.RotateFlip(RotateFlipType.Rotate90FlipX); //System.Drawing.RotateFlipType枚举
img.Save("C:\\2.jpeg");