方法一:旋轉畫圖區,以90度旋轉為例
private void btnRotate90_Click(object sender, EventArgs e)
{
Graphics gs = pictureBox1.CreateGraphics();
string strFile = @"E:\p.jpg";
Bitmap bmp = new Bitmap(strFile);
gs.FillRectangle(Brushes.White, pictureBox1.ClientRectangle);
Point[] destinationPoints = { new Point(ClientRectangle.Width, 0), new Point(ClientRectangle.Width, ClientRectangle.Height), new Point(0, 0) };
gs.DrawImage(bmp, destinationPoints);
}
方法二:旋轉圖像自身,以90度旋轉為例
private void btnRotate90_Click(object sender, EventArgs e)
{
Graphics gs = pictureBox1.CreateGraphics();
string strFile = @"E:\p.jpg";
Image img = Image.FromFile(strFile);
img.RotateFlip(RotateFlipType.Rotate90FlipNone);
gs.DrawImage(img, pictureBox1.ClientRectangle);
}