Exemplo n.º 1
0
        public void Flip(RotateFlipType rotateFlipType)
        {
            imageHandler.RestorePrevious();
            Bitmap bmap = (Bitmap)imageHandler.CurrentBitmap.Clone();

            bmap.RotateFlip(rotateFlipType);
            imageHandler.CurrentBitmap = (Bitmap)bmap.Clone();
        }
Exemplo n.º 2
0
        public void Insert(string path, int xPosition, int yPosition, int width, int height, float angle, int opacity)
        {
            imageHandler.RestorePrevious();
            Bitmap   bmap = (Bitmap)imageHandler.CurrentBitmap.Clone();
            Graphics gr   = Graphics.FromImage(bmap);

            if (!string.IsNullOrEmpty(path))
            {
                Bitmap i_bitmap = (Bitmap)Bitmap.FromFile(path);
                if (opacity < -255)
                {
                    opacity = -255;
                }
                if (opacity > 255)
                {
                    opacity = 255;
                }
                ColorMatrix cMatrix = new ColorMatrix(CurrentColorMatrix.Array);
                cMatrix.Matrix33 = opacity / 255.0F;
                Bitmap          bmap2         = new Bitmap(i_bitmap.Width, i_bitmap.Height);
                ImageAttributes imgAttributes = new ImageAttributes();
                imgAttributes.SetColorMatrix(cMatrix);
                Graphics g = Graphics.FromImage(bmap2);
                g.InterpolationMode = InterpolationMode.NearestNeighbor;
                g.DrawImage(i_bitmap, new Rectangle(0, 0, i_bitmap.Width, i_bitmap.Height), 0, 0, i_bitmap.Width, i_bitmap.Height, GraphicsUnit.Pixel, imgAttributes);
                i_bitmap = (Bitmap)bmap2.Clone();
                i_bitmap = Rotate(i_bitmap, angle);
                gr.DrawImage(i_bitmap, xPosition, yPosition, width, height);
            }
            imageHandler.CurrentBitmap = (Bitmap)bmap.Clone();
        }
Exemplo n.º 3
0
        public void SetInversion()
        {
            imageHandler.RestorePrevious();
            ColorMatrix cMatrix = new ColorMatrix(CurrentColorMatrix.Array);

            cMatrix.Matrix00 = -1;
            cMatrix.Matrix11 = -1;
            cMatrix.Matrix22 = -1;
            imageHandler.ProcessBitmap(cMatrix);
        }
Exemplo n.º 4
0
        public void SetGrayscale()
        {
            imageHandler.RestorePrevious();
            ColorMatrix cMatrix = new ColorMatrix(CurrentColorMatrix.Array);

            cMatrix.Matrix00 = cMatrix.Matrix01 = cMatrix.Matrix02 = 0.299F;
            cMatrix.Matrix10 = cMatrix.Matrix11 = cMatrix.Matrix12 = 0.587F;
            cMatrix.Matrix20 = cMatrix.Matrix21 = cMatrix.Matrix22 = 0.114F;
            imageHandler.ProcessBitmap(cMatrix);
        }
Exemplo n.º 5
0
        public void Insert(string text, int xPosition, int yPosition, string fontName, float fontSize, string fontStyle, float angle, int opacity, string color1, string color2, string gradientStyle)
        {
            imageHandler.RestorePrevious();
            Bitmap    bmap = (Bitmap)imageHandler.CurrentBitmap.Clone();
            Graphics  gr   = Graphics.FromImage(bmap);
            Font      font = GetFont(fontName, fontSize, fontStyle);
            SizeF     sF   = gr.MeasureString(text, font, int.MaxValue);
            Rectangle rect = new Rectangle(0, 0, (int)sF.Width, (int)sF.Height);
            Color     col1 = GetColor(color1);
            Color     col2 = new Color();

            if (string.IsNullOrEmpty(color2))
            {
                col2 = col1;
            }
            else
            {
                col2 = GetColor(color2);
            }
            LinearGradientBrush LGBrush = new LinearGradientBrush(rect, col1, col2, GetGradientStyle(gradientStyle));

            Bitmap   i_bitmap = new Bitmap((int)sF.Width, (int)sF.Height);
            Graphics g1       = Graphics.FromImage(i_bitmap);

            g1.FillRectangle(Brushes.Transparent, 0, 0, (int)sF.Width, (int)sF.Height);
            g1.DrawString(text, font, LGBrush, 0, 0);
            if (opacity < -255)
            {
                opacity = -255;
            }
            if (opacity > 255)
            {
                opacity = 255;
            }
            ColorMatrix cMatrix = new ColorMatrix(CurrentColorMatrix.Array);

            cMatrix.Matrix33 = opacity / 255.0F;
            Bitmap          bmap2         = new Bitmap(i_bitmap.Width, i_bitmap.Height);
            ImageAttributes imgAttributes = new ImageAttributes();

            imgAttributes.SetColorMatrix(cMatrix);
            Graphics g2 = Graphics.FromImage(bmap2);

            g2.InterpolationMode = InterpolationMode.NearestNeighbor;
            g2.DrawImage(i_bitmap, new Rectangle(0, 0, i_bitmap.Width, i_bitmap.Height), 0, 0, i_bitmap.Width, i_bitmap.Height, GraphicsUnit.Pixel, imgAttributes);
            i_bitmap = (Bitmap)bmap2.Clone();
            i_bitmap = Rotate(i_bitmap, angle);
            gr.DrawImage(i_bitmap, xPosition, yPosition);
            imageHandler.CurrentBitmap = (Bitmap)bmap.Clone();
        }
Exemplo n.º 6
0
        public void SetColorFilter(ColorFilterTypes colorFilterType)
        {
            imageHandler.RestorePrevious();
            ColorMatrix cMatrix = new ColorMatrix(CurrentColorMatrix.Array);

            switch (colorFilterType)
            {
            case ColorFilterTypes.Red:
                cMatrix.Matrix11 = 0;
                cMatrix.Matrix22 = 0;
                break;

            case ColorFilterTypes.Green:
                cMatrix.Matrix00 = 0;
                cMatrix.Matrix22 = 0;
                break;

            case ColorFilterTypes.Blue:
                cMatrix.Matrix00 = 0;
                cMatrix.Matrix11 = 0;
                break;
            }
            imageHandler.ProcessBitmap(cMatrix);
        }
        public void SetBrightness(int brightness)
        {
            imageHandler.RestorePrevious();
            if (brightness < -255)
            {
                brightness = -255;
            }
            if (brightness > 255)
            {
                brightness = 255;
            }
            ColorMatrix cMatrix = new ColorMatrix(CurrentColorMatrix.Array);

            cMatrix.Matrix40 = cMatrix.Matrix41 = cMatrix.Matrix42 = brightness / 255.0F;
            imageHandler.ProcessBitmap(cMatrix);
        }
Exemplo n.º 8
0
        public void SetSepiaTone()
        {
            imageHandler.RestorePrevious();
            ColorMatrix cMatrix = new ColorMatrix(CurrentColorMatrix.Array);

            cMatrix.Matrix00 = 0.393F;
            cMatrix.Matrix01 = 0.349F;
            cMatrix.Matrix02 = 0.299F;
            cMatrix.Matrix10 = 0.769F;
            cMatrix.Matrix11 = 0.686F;
            cMatrix.Matrix12 = 0.534F;
            cMatrix.Matrix20 = 0.189F;
            cMatrix.Matrix21 = 0.168F;
            cMatrix.Matrix22 = 0.131F;
            imageHandler.ProcessBitmap(cMatrix);
        }
Exemplo n.º 9
0
        public void DrawOutCropArea(int xPosition, int yPosition, int width, int height)
        {
            imageHandler.RestorePrevious();
            _bitmapPrevCropArea = (Bitmap)imageHandler.CurrentBitmap;
            Bitmap    bmap   = (Bitmap)_bitmapPrevCropArea.Clone();
            Graphics  gr     = Graphics.FromImage(bmap);
            Brush     cBrush = new Pen(Color.FromArgb(150, Color.White)).Brush;
            Rectangle rect1  = new Rectangle(0, 0, imageHandler.CurrentBitmap.Width, yPosition);
            Rectangle rect2  = new Rectangle(0, yPosition, xPosition, height);
            Rectangle rect3  = new Rectangle(0, (yPosition + height), imageHandler.CurrentBitmap.Width, imageHandler.CurrentBitmap.Height);
            Rectangle rect4  = new Rectangle((xPosition + width), yPosition, (imageHandler.CurrentBitmap.Width - xPosition - width), height);

            gr.FillRectangle(cBrush, rect1);
            gr.FillRectangle(cBrush, rect2);
            gr.FillRectangle(cBrush, rect3);
            gr.FillRectangle(cBrush, rect4);
            imageHandler.CurrentBitmap = (Bitmap)bmap.Clone();
        }
Exemplo n.º 10
0
        public void SetContrast(float contrast)
        {
            imageHandler.RestorePrevious();
            if (contrast < -100)
            {
                contrast = -100;
            }
            if (contrast > 100)
            {
                contrast = 100;
            }
            contrast  = (100.0F + contrast) / 100.0F;
            contrast *= contrast;
            ColorMatrix cMatrix = new ColorMatrix(CurrentColorMatrix.Array);
            float       tValue  = (1.0F - contrast) / 2.0F;

            cMatrix.Matrix00 = cMatrix.Matrix11 = cMatrix.Matrix22 = contrast;
            cMatrix.Matrix40 = cMatrix.Matrix41 = cMatrix.Matrix42 = tValue;
            imageHandler.ProcessBitmap(cMatrix);
        }
Exemplo n.º 11
0
        public void Insert(string shape, int xPosition, int yPosition, int width, int height, float angle, int opacity, string color1, string color2, string gradientStyle)
        {
            imageHandler.RestorePrevious();
            Bitmap   bmap = (Bitmap)imageHandler.CurrentBitmap.Clone();
            Graphics gr   = Graphics.FromImage(bmap);
            Color    col1 = GetColor(color1);
            Color    col2 = new Color();

            if (string.IsNullOrEmpty(color2))
            {
                col2 = col1;
            }
            else
            {
                col2 = GetColor(color2);
            }
            Rectangle           rect    = new Rectangle(0, 0, width, height);
            LinearGradientBrush LGBrush = new LinearGradientBrush(rect, col1, col2, GetGradientStyle(gradientStyle));
            Bitmap   i_bitmap           = new Bitmap(width, height);
            Graphics g1 = Graphics.FromImage(i_bitmap);

            g1.FillRectangle(Brushes.Transparent, 0, 0, width, height);
            switch (shape.ToLower())
            {
            case "filledellipse":
                g1.FillEllipse(LGBrush, 0, 0, width, height);
                break;

            case "filledrectangle":
                g1.FillRectangle(LGBrush, 0, 0, width, height);
                break;

            case "ellipse":
                g1.DrawEllipse(new Pen(LGBrush), 0, 0, width, height);
                break;

            case "rectangle":
            default:
                g1.DrawRectangle(new Pen(LGBrush), 0, 0, width, height);
                break;
            }
            g1.Dispose();
            if (opacity < -255)
            {
                opacity = -255;
            }
            if (opacity > 255)
            {
                opacity = 255;
            }
            ColorMatrix cMatrix = new ColorMatrix(CurrentColorMatrix.Array);

            cMatrix.Matrix33 = opacity / 255.0F;
            Bitmap          bmap2         = new Bitmap(i_bitmap.Width, i_bitmap.Height);
            ImageAttributes imgAttributes = new ImageAttributes();

            imgAttributes.SetColorMatrix(cMatrix);
            Graphics g2 = Graphics.FromImage(bmap2);

            g2.InterpolationMode = InterpolationMode.NearestNeighbor;
            g2.DrawImage(i_bitmap, new Rectangle(0, 0, i_bitmap.Width, i_bitmap.Height), 0, 0, i_bitmap.Width, i_bitmap.Height, GraphicsUnit.Pixel, imgAttributes);
            i_bitmap = (Bitmap)bmap2.Clone();
            i_bitmap = Rotate(i_bitmap, angle);
            gr.DrawImage(i_bitmap, xPosition, yPosition);
            imageHandler.CurrentBitmap = (Bitmap)bmap.Clone();
        }