private void glControl_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (_imageProvider != null)
            {
                if (e.KeyChar == Convert.ToChar(Keys.Q))
                {
                    this.Text = "Original matrix";
                    _image    = _imageProvider.GetOriginalImage();
                }

                if (e.KeyChar == Convert.ToChar(Keys.W))
                {
                    this.Text = "N matrix";
                    _image    = _imageProvider.GetFilteredImageWithNMask();
                }

                if (e.KeyChar == Convert.ToChar(Keys.E))
                {
                    this.Text = "S matrix";
                    _image    = _imageProvider.GetFilteredImageWithSMask();
                }

                if (e.KeyChar == Convert.ToChar(Keys.R))
                {
                    this.Text = "Se matrix";
                    _image    = _imageProvider.GetFilteredImageWithSeMask();
                }

                BindTexture(_image);

                this.Invoke(new MethodInvoker(glControl.Refresh));
            }
        }
 private void BindTexture(Image image, PixelInternalFormat pixelInternalFormat = PixelInternalFormat.Luminance,
                          PixelFormat pixelFormat = PixelFormat.Luminance)
 {
     GL.BindTexture(TextureTarget.Texture2D, _texId);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
     GL.TexImage2D(TextureTarget.Texture2D, 0, pixelInternalFormat, image.Width, image.Height, 0,
                   pixelFormat, PixelType.UnsignedByte, image.ImageArray);
 }
        private async void glControl_Load(object sender, EventArgs e)
        {
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            GL.Enable(EnableCap.Texture2D);

            _dicomImageLoader = new DicomImageLoader();

            _imageProvider = new Dictionary <string, Image>();

            _image = await _dicomImageLoader.LoadDcmImage();

            _imageProvider.UpsertOriginalImage(_image);

            _imageLoadingState = ImageLoadingState.Loaded;

            this.Invoke(new MethodInvoker(glControl.Refresh));

            glControl.SwapBuffers();
        }