Пример #1
0
        protected override bool PerformProcessingAction()
        {
            Processor proc = null;

            try
            {
                Point currentScrollPosition;
                if (imageXView2.Image == null)
                {
                    currentScrollPosition = imageXView1.ScrollPosition;
                }
                else
                {
                    currentScrollPosition = imageXView2.ScrollPosition;
                }

                proc         = new Processor(imagXpress1, imageXView1.Image.Copy());
                outputBitmap = proc.GetAlphaChannelAsBitmap();

                imageXView2.ScrollPosition = currentScrollPosition;

                using (ImageX img = ImageX.FromBitmap(imagXpress1, outputBitmap))
                {
                    UpdateOutputImage(img.Copy());
                }

                return(true);
            }
            catch (ProcessorException ex)
            {
                MessageBox.Show(ex.Message, Constants.processingErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            catch (ImageXException ex)
            {
                MessageBox.Show(ex.Message, Constants.processingErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            finally
            {
                if (proc != null)
                {
                    if (proc.Image != null)
                    {
                        proc.Image.Dispose();
                        proc.Image = null;
                    }
                    proc.Dispose();
                    proc = null;
                }
            }
        }
Пример #2
0
        protected override bool PerformProcessingAction()
        {
            Processor proc = null;

            try
            {
                proc = new Processor(imagXpress1, imageXView1.Image.Copy());
                Helper.TransformIfGrayscale(proc.Image);
                DisposeOfOutputBitmaps(null);

                Point currentScrollPosition;
                if (imageXView2.Image == null)
                {
                    currentScrollPosition = imageXView1.ScrollPosition;
                }
                else
                {
                    currentScrollPosition = imageXView2.ScrollPosition;
                }

                proc.ColorSeparation((SeparationType)SeparationTypeComboBox.SelectedIndex, out bitmap1, out bitmap2, out bitmap3, out bitmap4);

                switch ((SeparationType)SeparationTypeComboBox.SelectedIndex)
                {
                case SeparationType.Rgb:
                {
                    if (RedRgbRadioButton.Checked)
                    {
                        outputBitmap = bitmap1;
                        DisposeOfOutputBitmaps(bitmap1);
                    }
                    else if (GreenRgbRadioButton.Checked)
                    {
                        outputBitmap = bitmap2;
                        DisposeOfOutputBitmaps(bitmap2);
                    }
                    else if (BlueRgbRadioButton.Checked)
                    {
                        outputBitmap = bitmap3;
                        DisposeOfOutputBitmaps(bitmap3);
                    }

                    break;
                }

                case SeparationType.Hsl:
                {
                    if (HueRadioButton.Checked)
                    {
                        outputBitmap = bitmap1;
                        DisposeOfOutputBitmaps(bitmap1);
                    }
                    else if (SaturationRadioButton.Checked)
                    {
                        outputBitmap = bitmap2;
                        DisposeOfOutputBitmaps(bitmap2);
                    }
                    else if (LuminanceRadioButton.Checked)
                    {
                        outputBitmap = bitmap3;
                        DisposeOfOutputBitmaps(bitmap3);
                    }

                    break;
                }

                case SeparationType.Cmy:
                {
                    if (CyanCmyRadioButton.Checked)
                    {
                        outputBitmap = bitmap1;
                        DisposeOfOutputBitmaps(bitmap1);
                    }
                    else if (MagentaCmyRadioButton.Checked)
                    {
                        outputBitmap = bitmap2;
                        DisposeOfOutputBitmaps(bitmap2);
                    }
                    else if (YellowCmyRadioButton.Checked)
                    {
                        outputBitmap = bitmap3;
                        DisposeOfOutputBitmaps(bitmap3);
                    }

                    break;
                }

                case SeparationType.Cmyk:
                {
                    if (CyanCmykRadioButton.Checked)
                    {
                        outputBitmap = bitmap1;
                        DisposeOfOutputBitmaps(bitmap1);
                    }
                    else if (MagentaCmykRadioButton.Checked)
                    {
                        outputBitmap = bitmap2;
                        DisposeOfOutputBitmaps(bitmap2);
                    }
                    else if (YellowCmykRadioButton.Checked)
                    {
                        outputBitmap = bitmap3;
                        DisposeOfOutputBitmaps(bitmap3);
                    }
                    else if (BlackCmykRadioButton.Checked)
                    {
                        outputBitmap = bitmap4;
                        DisposeOfOutputBitmaps(bitmap4);
                    }

                    break;
                }

                case SeparationType.Rgba:
                {
                    if (RedRgbaRadioButton.Checked)
                    {
                        outputBitmap = bitmap1;
                        DisposeOfOutputBitmaps(bitmap1);
                    }
                    else if (GreenRgbaRadioButton.Checked)
                    {
                        outputBitmap = bitmap2;
                        DisposeOfOutputBitmaps(bitmap2);
                    }
                    else if (BlueRgbaRadioButton.Checked)
                    {
                        outputBitmap = bitmap3;
                        DisposeOfOutputBitmaps(bitmap3);
                    }
                    else if (AlphaRgbaRadioButton.Checked)
                    {
                        outputBitmap = bitmap4;
                        DisposeOfOutputBitmaps(bitmap4);
                    }

                    break;
                }
                }

                using (ImageX img = ImageX.FromBitmap(imagXpress1, outputBitmap))
                {
                    UpdateOutputImage(img.Copy());
                }

                imageXView2.ScrollPosition = currentScrollPosition;

                return(true);
            }
            catch (ProcessorException ex)
            {
                MessageBox.Show(ex.Message, Constants.processingErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            catch (ImageXException ex)
            {
                MessageBox.Show(ex.Message, Constants.processingErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            finally
            {
                if (proc != null)
                {
                    if (proc.Image != null)
                    {
                        proc.Image.Dispose();
                        proc.Image = null;
                    }
                    proc.Dispose();
                    proc = null;
                }
            }
        }