You are here: Start » FIL.NET » FabImage Library .NET Usage » Settings

Settings

The following example presents enabling the diagnostic mode with the EnableFilDiagnosticOutputs function.

The application is a single-form application that calls the GradientImage function for a test image. The function has one diagnostic output which provides directions image available only if diagnostic mode is enabled. User can change the mode with the Diagnostic mode tool strip button.

The main window is composed of three PictureBox objects, one ToolStripButton and a ToolStripComboBox that enables choosing a test image:

using Fil;
using Fil.Utils;
using System;
using System.Windows.Forms;

namespace Settings
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            foreach (var imageType in Enum.GetNames(typeof(Fil.TestImageId)))
                testImageTypeCombo.Items.Add(imageType);

            testImageTypeCombo.SelectedIndex = 0;

            UpdateImages();
        }

        private void diagnosticModeButton_CheckedChanged(object sender, EventArgs e)
        {
            Fil.Invoke.EnableFilDiagnosticOutputs((sender as ToolStripButton).Checked);

            UpdateImages();
        }

        private static void ResetPictureBox(PictureBox pictureBox)
        {
            pictureBox.Image?.Dispose();
            pictureBox.Image = null;
        }

        private void UpdateImages()
        {
            // Reset picture boxes
            ResetPictureBox(gradientImagePictureBox);
            ResetPictureBox(originalImagePictureBox);
            ResetPictureBox(directionsImagePictureBox);

            using Disposables disposables = new();

            Image rgbImage = new Image().DisposeWith(disposables);
            Image gradientImage = new Image().DisposeWith(disposables);
            Image directionsImage = new Image().DisposeWith(disposables);

            TestImageId testImageId = (TestImageId)Enum.Parse(typeof(TestImageId), testImageTypeCombo.SelectedItem.ToString());

            // Call FilNet functions
            Fil.Invoke.TestImage(testImageId, rgbImage, null);
            Fil.Invoke.GradientImage(rgbImage, null, GradientOperator.Gauss, 2.0f, null, gradientImage, directionsImage);

            // Set picture box images
            originalImagePictureBox.Image = rgbImage.ToBitmap();
            gradientImagePictureBox.Image = gradientImage.ToBitmap();

            if (directionsImage.IsValid)
                directionsImagePictureBox.Image = directionsImage.ToBitmap();
        }

        private void testImageTypeCombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            UpdateImages();
        }
    }
}
Previous: FIL.NET Designers example Next: Function Reference