private void OutPutBtn_Click(object sender, RoutedEventArgs e) { if (OutPutPath.Text.Trim() == "") { MessageBox.Show("请输入输出路径"); return; } if (OutPutName.Text.Trim() == "") { MessageBox.Show("请输入输出文件名"); return; } Image tempImg = ImageSourceToBitmap(ImagePreview.Source); if (comboBox.SelectedIndex == 0) { tempImg.Save(OutPutPath.Text + "\\" + OutPutName.Text + ".png", ImageFormat.Png); } else if (comboBox.SelectedIndex == 1) { Bitmap bitmapImage = CommenUtils.doOperation((Bitmap)tempImg, int.Parse(RoundCornerSize.Text)); bitmapImage.Save(OutPutPath.Text + "\\" + OutPutName.Text + ".png", ImageFormat.Png); } MessageBox.Show("导出成功!", "提示信息"); }
private void OperationBtn_Click(object sender, RoutedEventArgs e) { if (RoundCornerSize.Text.Trim() == "") { MessageBox.Show("请输入圆角大小"); return; } if (null == ImagePreview.Source) { MessageBox.Show("请先导入图像"); return; } Image tempImg = ImageSourceToBitmap(ImagePreview.Source); tempImg = CommenUtils.CreateRoundedCorner(tempImg, RoundCornerSize.Text, CommenUtils.RoundRectanglePosition.TopLeft); tempImg = CommenUtils.CreateRoundedCorner(tempImg, RoundCornerSize.Text, CommenUtils.RoundRectanglePosition.TopRight); tempImg = CommenUtils.CreateRoundedCorner(tempImg, RoundCornerSize.Text, CommenUtils.RoundRectanglePosition.BottomLeft); tempImg = CommenUtils.CreateRoundedCorner(tempImg, RoundCornerSize.Text, CommenUtils.RoundRectanglePosition.BottomRight); ImagePreview.Source = BitmapToBitmapImageFromBitmap((Bitmap)tempImg); }