private void btnOK_Click(object sender, EventArgs e) { double angle = 0; if (list.Count > 0) { for (int i = 0; i < list.Count; i++) { angle += (double)list[i]; } } else { angle = (double)numericUpDown1.Value; } //取水平角度 if (angle > -90 && angle < -45) { angle += 90; } //取垂直角度 if (angle > 45 && angle < 90) { angle -= 90; } if (angle != 0) { Bitmap source = new Bitmap(ImagePath); Bitmap image = ImageClass.KiRotate(source, (float)angle, Color.White); source.Dispose(); image.Save(ImagePath); this.DialogResult = DialogResult.OK; } this.Close(); }
private void btnView_Click(object sender, EventArgs e) { if (Angle != 0) { list.Add(Angle); double angle = 0; for (int i = 0; i < list.Count; i++) { angle += (double)list[i]; } //取水平角度 if (angle > -90 && angle < -45) { angle += 90; } //取垂直角度 if (angle > 45 && angle < 90) { angle -= 90; } SourceImage = ImageClass.KiRotate(FileImage, (float)angle, Color.White); SourceImage = new Bitmap(ImageClass.GetThumbnail2(SourceImage, maxborder)); picImage.Image = SourceImage; TempImage = SourceImage; int x = (pnlImage.Width - picImage.Width) / 2; int y = (pnlImage.Height - picImage.Height) / 2; this.picImage.Location = new Point(x, y); Angle = 0; numericUpDown1.Value = 0; _originalPoint = new Point(0, 0); _lastPoint = new Point(0, 0); } }