/// <summary> /// Loads and processes an image from the filesystem. /// </summary> /// <param name="ImagePath">The path on the filesystem of the image to load</param> private void LoadImage(string ImagePath) { // Clear the previous image if there was one Image preview = this.FindControl <Image>("Preview"); preview.Source = null; preview.InvalidateVisual(); // Process and draw the new image ImageToEtch = new EtchableImage(ImagePath); Slider luminanceSlider = this.FindControl <Slider>("LuminanceSlider"); ImageToEtch.ProcessImage(1.0 - luminanceSlider.Value); preview.Source = ImageToEtch.Bitmap; preview.InvalidateVisual(); // Set the image dimension labels TextBlock imageWidthLabel = this.FindControl <TextBlock>("ImageWidthLabel"); TextBlock imageHeightLabel = this.FindControl <TextBlock>("ImageHeightLabel"); imageWidthLabel.Text = $"{ImageToEtch.Width} px"; imageHeightLabel.Text = $"{ImageToEtch.Height} px"; // Route it RecalculateRoute(); }
/// <summary> /// Updates the luminance threshold when the brightness slider's value changes. /// </summary> /// <param name="sender">Not used</param> /// <param name="e">The args containing the new slider value</param> public void LuminanceSlider_Changed(object sender, AvaloniaPropertyChangedEventArgs e) { if (e.Property.Name != "Value") { return; } double newThreshold = (double)e.NewValue; if (ImageToEtch != null) { Image preview = this.FindControl <Image>("Preview"); ImageToEtch.ProcessImage(1.0 - newThreshold); preview.InvalidateVisual(); Button exportButton = this.FindControl <Button>("ExportButton"); exportButton.IsEnabled = false; } }