/// <summary> /// 重置图像. /// </summary> private void btnReset_Click(object sender, EventArgs e) { imgManipulator.Dispose(); // 从本地文件加载位图. Bitmap img = new Bitmap("OneCodeIcon.png"); // 初始化 imgManipulator. imgManipulator = new ImageManipulator(img); // 重绘 pnlImage. imgManipulator.DrawControl(this.pnlImage, adjustment, pen); }
/// <summary> /// Reset the bmpEx. /// </summary> private void btnReset_Click(object sender, EventArgs e) { // Dispose the bmpEx. imgManipulator.Dispose(); // Load a bitmap from a local file. Bitmap img = new Bitmap("OneCodeIcon.png"); // Initialize the bmpEx. imgManipulator = new ImageManipulator(img); // Redraw the pnlImage. imgManipulator.DrawControl(this.pnlImage, adjustment, pen); }
/// <summary> /// 处理按钮 btnRotateLeft, btnRotateRight, btnFlipVertical 和 /// btnFlipHorizontal 的点击事件. /// </summary> private void btnRotateFlip_Click(object sender, EventArgs e) { Button rotateFlipButton = sender as Button; if (rotateFlipButton == null) { return; } RotateFlipType rotateFlipType = RotateFlipType.RotateNoneFlipNone; switch (rotateFlipButton.Name) { case "btnRotateLeft": rotateFlipType = RotateFlipType.Rotate270FlipNone; break; case "btnRotateRight": rotateFlipType = RotateFlipType.Rotate90FlipNone; break; case "btnFlipVertical": rotateFlipType = RotateFlipType.RotateNoneFlipY; break; case "btnFlipHorizontal": rotateFlipType = RotateFlipType.RotateNoneFlipX; break; } // 旋转或翻转图片. imgManipulator.RotateFlip(rotateFlipType); // 重绘 pnlImage. imgManipulator.DrawControl(this.pnlImage, adjustment, pen); }