private void btnRotate_Click(object sender, EventArgs e) { if (pictureBox1.Image != null) { Bitmap a = new Bitmap(pictureBox1.Image);//得到图片框中的图片 pictureBox1.Image = GetGraphics.Rotate(a, 90); pictureBox1.Location = panel1.Location; pictureBox1.Refresh();//最后刷新图片框 } }
public bool PreFilterMessage(ref Message m) { TwainCommand cmd = tw.PassMessage(ref m); if (cmd == TwainCommand.Not) { return(false); } switch (cmd) { case TwainCommand.CloseRequest: { EndingScan(); tw.CloseSrc(); break; } case TwainCommand.CloseOk: { EndingScan(); tw.CloseSrc(); break; } case TwainCommand.DeviceEvent: { break; } case TwainCommand.TransferReady: { ArrayList pics = tw.TransferPictures(); EndingScan(); tw.CloseSrc(); int picCount = pics.Count; if (picCount > 0) { string fileName = ""; for (int i = 0; i < picCount; i++) { IntPtr img = (IntPtr)pics[i]; GetGraphics get = new GetGraphics(img); Bitmap b = get.GetImage(); StringBuilder sb = new StringBuilder(); sb.Append("IMG"); sb.Append((i + 1).ToString("0000")); sb.Append(DateTime.UtcNow.ToString("_yyyyMMddHHmmss")); fileName = string.Format(SavePath, sb); b.Save(fileName); listPicture.Items.Add(fileName); if (i == picCount - 1) { pictureBox1.Image = b; } } } break; } } return(true); }