Exemple #1
0
        /// <summary>
        /// Initialize the application.
        /// </summary>
        private void InitClass()
        {
            // Setup our caption
            Messager.Caption = "LEADTOOLS for .NET C# Color Conversion Demo";
            Text             = Messager.Caption;

            // Conversion type is nothing for now
            _conversionType = String.Empty;

            // Initialize the _viewer object
            _viewer           = new ImageViewer();
            _viewer.Dock      = DockStyle.Fill;
            _viewer.BackColor = Color.DarkGray;
            Controls.Add(_viewer);
            _viewer.BringToFront();

            _viewer.Zoom(ControlSizeMode.Fit, 1, _viewer.DefaultZoomOrigin);

            // initialize the raster codecs object
            _codecs = new RasterCodecs();

            try
            {
                RasterColorConverterEngine.Startup();
            }
            catch (Exception ex)
            {
                Messager.ShowError(this, ex);
            }

            LoadImage(true);
            UpdateMyControls();
        }
Exemple #2
0
        private void InitClass(RasterImage image, ConversionColorFormat srcFormat)
        {
            _viewer           = new ImageViewer();
            _viewer.BackColor = Color.DarkGray;
            _viewer.ViewHorizontalAlignment = ControlAlignment.Near;
            _viewer.Dock = DockStyle.Fill;
            _pnlViewer.Controls.Add(_viewer);
            _viewer.BringToFront();
            _viewer.Zoom(ControlSizeMode.Fit, 1, _viewer.DefaultZoomOrigin);

            _cbFit.Checked = _viewer.SizeMode == ControlSizeMode.Fit;

            // Start up the Color conversion toolkit.
            RasterColorConverterEngine.Startup();
            RasterImage tempImage = image.Clone();

            if (tempImage.ViewPerspective != RasterViewPerspective.TopLeft)
            {
                tempImage.ChangeViewPerspective(RasterViewPerspective.TopLeft);
            }

            _width        = tempImage.Width;
            _height       = tempImage.Height;
            _bytesPerLine = tempImage.BytesPerLine;

            _orgBuffer = new byte[_bytesPerLine * _height];

            tempImage.Access();

            for (int y = 0; y < _height - 1; y++)
            {
                tempImage.GetRow(y, _orgBuffer, (y * _width * 3), _width * 3);
            }

            _viewer.Image = tempImage;

            tempImage.Release();

            _srcFormat = srcFormat;

            foreach (ConvertItem i in _convertItems)
            {
                _cbColorFormat.Items.Add(i);
                if (i.Format == ConversionColorFormat.Yuv)
                {
                    _cbColorFormat.SelectedItem = i;
                }
            }

            UpdateMyControls();
        }