Example #1
0
        public ConvertToDialog(RasterImage image, ConversionColorFormat srcFormat)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            InitClass(image, srcFormat);
        }
Example #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();
        }
Example #3
0
        private void ConvertToColorSpace(ConversionColorFormat colorFormat)
        {
            if (_btnOK.Enabled)
            {
                using (WaitCursor wait = new WaitCursor())
                {
                    try
                    {
                        int bufferSize;

                        if (colorFormat == ConversionColorFormat.Cmyk)
                        {
                            bufferSize = (_bytesPerLine * _height) + ((_bytesPerLine * _height) / 3);
                        }
                        else
                        {
                            bufferSize = _bytesPerLine * _height;
                        }

                        byte[] newBuffer = new byte[bufferSize];

                        RasterColorConverterEngine.ConvertDirect(
                            _srcFormat,
                            colorFormat,
                            _orgBuffer,
                            0,
                            newBuffer,
                            0,
                            _width,
                            _height,
                            0,
                            0);

                        RasterColorConverterEngine.ConvertDirectToImage(
                            colorFormat,
                            _srcFormat,
                            newBuffer,
                            0,
                            _viewer.Image,
                            _width,
                            _height,
                            0,
                            (_bytesPerLine - _width * 3));

                        _viewer.Invalidate();

                        foreach (ConvertItem i in _convertItems)
                        {
                            if (i.Format == colorFormat)
                            {
                                MainForm.ConversionType = i.Name;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Messager.ShowError(this, ex.Message);
                    }
                }
            }
        }
Example #4
0
 public ConvertItem(ConversionColorFormat f, string n)
 {
     Format = f;
     Name   = n;
 }