示例#1
0
        public static void Flip(RasterImage image, params string[] parameters)
        {
            FlipCommand cmd        = new FlipCommand();
            bool        horizontal = false;

            if (parameters.Length > 0)
            {
                bool.TryParse(parameters[0], out horizontal);
            }

            cmd.Horizontal = horizontal;
            cmd.Run(image);
        }
示例#2
0
        /// <summary>
        /// Batch 2 Functions
        /// </summary>
        private void DoBatch2()
        {
            // save the current caption
            string tmpCaption = Text;

            // disable the form
            Enabled = false;

            // change cursor
            Cursor = Cursors.SizeNS;

            // Do AntiAlias
            Text = "AntiAliasing Image...";
            AntiAliasingCommand antiAliasingCommand = new AntiAliasingCommand();

            antiAliasingCommand.Threshold = 25;
            antiAliasingCommand.Dimension = 7;
            antiAliasingCommand.Filter    = AntiAliasingCommandType.Type1;
            antiAliasingCommand.Run(_viewer.Image);
            Text = "Image Is AntiAliased";
            _viewer.Refresh();
            Thread.Sleep(2000);

            // change cursor
            Cursor = Cursors.SizeWE;
            // Do Reverse
            Text = "Reversing Image...";
            FlipCommand flipCommand = new FlipCommand();

            flipCommand.Horizontal = true;
            flipCommand.Run(_viewer.Image);
            Text = "Image Is Reversed";
            _viewer.Refresh();
            Thread.Sleep(2000);

            // change cursor
            Cursor = Cursors.SizeNS;
            // Do Grayscale
            Text = "Grayscaling Image...";
            GrayscaleCommand grayScaleCommand = new GrayscaleCommand();

            grayScaleCommand.BitsPerPixel = 8;
            grayScaleCommand.Run(_viewer.Image);
            Text = "Image Is Grayscaled";
            _viewer.Refresh();
            Thread.Sleep(2000);

            // change cursor
            Cursor = Cursors.SizeWE;
            // Do Invert
            Text = "Inverting Image...";
            InvertCommand invertCommand = new InvertCommand();

            invertCommand.Run(_viewer.Image);
            Text = "Image Is Inverted, Batch Is Complete";
            _viewer.Refresh();
            Thread.Sleep(2000);

            // change the cursor to arrow
            Cursor = Cursors.Arrow;

            // enable the form
            Enabled = true;

            // return the old caption
            Text = tmpCaption;
        }
示例#3
0
        /// <summary>
        /// Batch 1 Functions
        /// </summary>
        private void DoBatch1()
        {
            // save the current caption
            string tmpCaption = Text;

            // change cursor
            Cursor = Cursors.SizeNS;
            // disable the form
            Enabled = false;
            // Do Color Resolution
            Text = "Optimizing Image To 8 Bits Per Pixel With Burkes Dithering...";
            ColorResolutionCommand colorResCommand = new ColorResolutionCommand();

            colorResCommand.BitsPerPixel    = 8;
            colorResCommand.DitheringMethod = RasterDitheringMethod.Burkes;
            colorResCommand.PaletteFlags    = ColorResolutionCommandPaletteFlags.Optimized;
            colorResCommand.Mode            = ColorResolutionCommandMode.InPlace;
            colorResCommand.Order           = RasterByteOrder.Bgr;
            colorResCommand.SetPalette(null);
            colorResCommand.Run(_viewer.Image);
            Text = "Image Is Optimized";
            _viewer.Refresh();
            Thread.Sleep(2000);

            // change cursor
            Cursor = Cursors.SizeWE;
            // Do Flip
            Text = "Flipping Image...";
            FlipCommand flipCommand = new FlipCommand();

            flipCommand.Horizontal = false;
            flipCommand.Run(_viewer.Image);
            Text = "Image Is Flipped";
            _viewer.Refresh();
            Thread.Sleep(2000);

            // change cursor
            Cursor = Cursors.SizeNS;
            // Do Lightening
            Text = "Lightening Image...";
            ChangeIntensityCommand changeIntensityCommand = new ChangeIntensityCommand();

            changeIntensityCommand.Brightness = 200;
            changeIntensityCommand.Run(_viewer.Image);
            Text = "Image Is Lightened";
            _viewer.Refresh();
            Thread.Sleep(2000);

            // change cursor
            Cursor = Cursors.SizeWE;
            // Do Resize
            Text = "Resizing Image...";
            ResizeCommand resizeCommand = new ResizeCommand();

            resizeCommand.Flags            = RasterSizeFlags.None;
            resizeCommand.DestinationImage = new RasterImage(RasterMemoryFlags.Conventional,
                                                             (_viewer.Image.Width + 1) / 2,
                                                             (_viewer.Image.Height + 1) / 2,
                                                             _viewer.Image.BitsPerPixel,
                                                             _viewer.Image.Order,
                                                             _viewer.Image.ViewPerspective,
                                                             _viewer.Image.GetPalette(),
                                                             IntPtr.Zero,
                                                             0);
            resizeCommand.Run(_viewer.Image);
            _viewer.Image = resizeCommand.DestinationImage;
            Text          = "Image Is Resized";
            _viewer.Refresh();
            Thread.Sleep(2000);

            Cursor = Cursors.SizeNS;
            // Do Rotate
            Text = "Rotating Image...";
            RotateCommand rotateCommand = new RotateCommand();

            rotateCommand.Angle     = -4500;
            rotateCommand.FillColor = new RasterColor(255, 0, 0);
            rotateCommand.Flags     = RotateCommandFlags.None;

            rotateCommand.Run(_viewer.Image);
            Text = "Image Is Rotated, Batch Is Complete";
            _viewer.Refresh();
            Thread.Sleep(2000);

            // change the cursor to arrow
            Cursor = Cursors.Arrow;

            // return the old caption
            Text = tmpCaption;

            // enable the form
            Enabled = true;
        }