private void GrayscaleRadioButton_Click(object sender, RoutedEventArgs e) { if (GrayscaleButtonClicked == false) { Paint.SetGrayscale(SourceImageColorArray); if (TryGenerate() == true) { GrayscaleButtonClicked = true; Paint.CopyToWriteableBitmap(SourceImageWB, SourceImageColorArray); } else { SourceImageColorArray = (SimpleColor[, ])OriginalSourceImageColorArray.Clone(); } } else { SourceImageColorArray = (SimpleColor[, ])OriginalSourceImageColorArray.Clone(); if (TryGenerate() == true) { GrayscaleButtonClicked = false; Paint.CopyToWriteableBitmap(SourceImageWB, SourceImageColorArray); } else { Paint.SetGrayscale(SourceImageColorArray); } } }
private void CreateImageRadioButton_Click(object sender, RoutedEventArgs e) { if (TryGenerate(false) == false) { return; } var bitmap = new WriteableBitmap(Globals.ImageWidth, Globals.ImageHeight, 96, 96, PixelFormats.Bgr24, null); SourceImageWB = new WriteableBitmap(bitmap); DestImageWB = new WriteableBitmap(bitmap); int width = SourceImageWB.PixelWidth; int height = SourceImageWB.PixelHeight; SourceImageControl.Source = SourceImageWB; SourceImageControl.Width = width; SourceImageControl.Height = height; DestImageControl.Source = DestImageWB; DestImageControl.Width = width; DestImageControl.Height = height; SourceImageColorArray = new SimpleColor[height, width]; DestImageColorArray = new SimpleColor[height, width]; Paint.CreateHSVBitmap(SourceImageColorArray); Paint.CopyToWriteableBitmap(SourceImageWB, SourceImageColorArray); OriginalSourceImageColorArray = (SimpleColor[, ])SourceImageColorArray.Clone(); TryGenerate(); }
private void LoadWritableBitamp(BitmapSource bitmap, bool IsWindowInit) { SourceImageWB = new WriteableBitmap(bitmap); DestImageWB = new WriteableBitmap(bitmap); int width = SourceImageWB.PixelWidth; int height = SourceImageWB.PixelHeight; SourceImageControl.Source = SourceImageWB; SourceImageControl.Width = width; SourceImageControl.Height = height; DestImageControl.Source = DestImageWB; DestImageControl.Width = width; DestImageControl.Height = height; SourceImageColorArray = new SimpleColor[height, width]; DestImageColorArray = new SimpleColor[height, width]; Paint.ReadColorsFromBitmap(SourceImageWB, SourceImageColorArray); OriginalSourceImageColorArray = (SimpleColor[, ])SourceImageColorArray.Clone(); if (IsWindowInit == false) { ColorProfileConverter.ConvertImage(SourceImageColorArray, DestImageColorArray, (ColorProfileEnum)SourceColorSpaceComboBox.SelectedIndex, (ColorProfileEnum)DestColorSpaceComboBox.SelectedIndex); Paint.CopyToWriteableBitmap(DestImageWB, DestImageColorArray); } else { TryGenerate(); } }