c# pictureBox放转显示

Image image = Image.FromFile(@"c:/fp.bmp");
Bitmap bmp = new Bitmap(image);
image.Dispose(); //释放文件占用,这句话很重要
pictureBox1.Image = Rotate(bmp, RotateFlipType.Rotate180FlipNone);

 

 

 

//旋转
private Bitmap Rotate(Bitmap source, RotateFlipType rotateFlipType)
{
Rectangle rect = new Rectangle(0, 0, source.Width, source.Height);
Bitmap target = source.Clone(rect, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
target.RotateFlip(rotateFlipType);
return target;
}

上一篇:HTTP与HTTPS的区别


下一篇:如何防御SQL注入攻击