Beispiel #1
0
        public Bitmap ApplyFilter(Bitmap mask, Bitmap image, double power)
        {
            int          w            = image.Width;
            int          h            = image.Height;
            ImagerBitmap currentImage = new ImagerBitmap(image.Clone() as Bitmap);
            ImagerBitmap currentMask  = new ImagerBitmap(mask.Clone() as Bitmap);

            Enumerable.Range(0, w).AsParallel().ForAll(x =>
            {
                for (int y = 0; y < h; y++)
                {
                    Color currentImageColor = currentImage.GetPixel(x, y);
                    Color maskColor         = currentMask.GetPixel(x, y);
                    Color resultColor       = Color.FromArgb(255,
                                                             (byte)(currentImageColor.R * (1 - power) + maskColor.R * power),
                                                             (byte)(currentImageColor.G * (1 - power) + maskColor.G * power),
                                                             (byte)(currentImageColor.B * (1 - power) + maskColor.B * power));
                    currentImage.SetPixel(x, y, resultColor);
                }
            });

            currentImage.UnlockBitmap();
            currentMask.UnlockBitmap();

            return(currentImage.Bitmap);
        }
Beispiel #2
0
        void nashville()
        {
            GC.Collect();
            win = new Bitmap(one_click.Properties.Resources.nashville, (int)w, (int)h);
            dst = new ImagerBitmap(image_l);
            dsp = new ImagerBitmap(win);

            Enumerable.Range(0, (int)w).AsParallel().ForAll(x =>
            {
                var color  = new Color();
                var color1 = new Color();
                for (int y = 0; y < (int)h; y++)
                {
                    color       = dst.GetPixel(x, y);
                    color1      = dsp.GetPixel(x, y);
                    float brght = color.GetBrightness();

                    byte r = color.R;
                    byte g = color.G;
                    byte b = color.B;

                    byte r1 = color1.R;
                    byte g1 = color1.G;
                    byte b1 = color1.B;

                    b = (byte)(255 * brght);

                    dst.SetPixel(x, y, Color.FromArgb((byte)(r * 0.55 + r1 * 0.45), (byte)(g * 0.95 + g1 * 0.05), (byte)(b * 0.6 + b1 * 0.4)));
                }
            });

            dst.UnlockBitmap();
            dsp.UnlockBitmap();
            image_l = dst.Bitmap;
        }
Beispiel #3
0
        public Bitmap ApplyFilter(Bitmap mask)
        {
            int          w           = mask.Width;
            int          h           = mask.Height;
            ImagerBitmap currentMask = new ImagerBitmap(mask.Clone() as Bitmap);

            Enumerable.Range(0, w).AsParallel().ForAll(x =>
            {
                for (int y = 0; y < h; y++)
                {
                    Color color = currentMask.GetPixel(x, y);
                    float red   = color.R;
                    float green = color.G;
                    float blue  = color.B;

                    red   = 224f / 255f * red + 31;
                    green = 236f / 255f * green;
                    blue  = 59f / 255f * blue + 102;
                    color = Color.FromArgb(255, (int)red, (int)green, (int)blue);
                    currentMask.SetPixel(x, y, color);
                }
            });

            currentMask.UnlockBitmap();
            return(currentMask.Bitmap);
        }
Beispiel #4
0
        public static Bitmap Nashville(Bitmap mask)
        {
            int          w           = mask.Width;
            int          h           = mask.Height;
            ImagerBitmap currentMask = new ImagerBitmap(mask);

            Enumerable.Range(0, w).AsParallel().ForAll(x =>
            {
                for (int y = 0; y < h; y++)
                {
                    Color color = currentMask.GetPixel(x, y);
                    float blue  = color.B;
                    float red   = color.R;
                    blue        = blue + 150 * (1 - color.GetBrightness());
                    red         = color.G * (color.GetBrightness());
                    if (blue > 255)
                    {
                        blue = 255;
                    }
                    if (red > 255)
                    {
                        red = 255;
                    }
                    color = Color.FromArgb(255, (int)red, color.G, (int)blue);
                    currentMask.SetPixel(x, y, color);
                }
            });

            currentMask.UnlockBitmap();
            return(currentMask.Bitmap);
        }
Beispiel #5
0
        void hope()
        {
            GC.Collect();
            dst = new ImagerBitmap(image_l);

            Enumerable.Range(0, (int)w - 1).AsParallel().WithDegreeOfParallelism(1).ForAll(x =>
            {
                var color = new Color();
                for (int y = 0; y < (int)h - 1; y++)
                {
                    color = dst.GetPixel(x, y);

                    float brght = color.GetBrightness();
                    byte r      = color.R;
                    byte g      = color.G;
                    byte b      = color.B;

                    if (brght <= 0.35)
                    {
                        r = 0;
                        g = 50;
                        b = 77;
                    }
                    ;
                    if (brght > 0.35 & brght <= 0.55)
                    {
                        r = 215;
                        g = 26;
                        b = 33;
                    }
                    ;
                    if (brght > 0.55)
                    {
                        r = 252;
                        g = 228;
                        b = 168;
                    }
                    ;

                    dst.SetPixel(x, y, Color.FromArgb(r, g, b));
                }
            });


            dst.UnlockBitmap();
            image_l = dst.Bitmap;
        }
Beispiel #6
0
        public Bitmap ApplyFilter(Bitmap mask)
        {
            int          w           = mask.Width;
            int          h           = mask.Height;
            ImagerBitmap currentMask = new ImagerBitmap(mask.Clone() as Bitmap);

            Enumerable.Range(0, w).AsParallel().ForAll(x =>
            {
                for (int y = 0; y < h; y++)
                {
                    var color = currentMask.GetPixel(x, y);
                    color     = Color.FromArgb(255, color.G, color.G, color.G);
                    currentMask.SetPixel(x, y, color);
                }
            });
            currentMask.UnlockBitmap();
            return(currentMask.Bitmap);
        }
Beispiel #7
0
        void heat()
        {
            GC.Collect();
            win = new Bitmap(one_click.Properties.Resources.vignette, (int)w, (int)h);
            dst = new ImagerBitmap(image_l);
            dsp = new ImagerBitmap(win);

            Enumerable.Range(0, (int)w).AsParallel().ForAll(x =>
            {
                var color  = new Color();
                var color1 = new Color();
                for (int y = 0; y < (int)h; y++)
                {
                    color  = dst.GetPixel(x, y);
                    color1 = dsp.GetPixel(x, y);

                    float brght  = color.GetBrightness();
                    float brght1 = color1.GetBrightness();

                    byte r = color.R;
                    byte g = color.G;
                    byte b = color.B;

                    byte r1 = color1.R;
                    byte g1 = color1.G;
                    byte b1 = color1.B;

                    g = (byte)((g * 0.65 + ((brght) * g + (1 - brght) * 120) * 0.35));


                    g = (byte)((g * 0.75 + ((1 - brght) * g + (brght) * 120) * 0.25));
                    r = (byte)((r * 0.75 + ((1 - brght) * r + (brght) * 255) * 0.25));
                    b = (byte)((b * 0.6 + ((1 - brght) * b + (brght) * 25) * 0.4));

                    // dst.SetPixel(x, y, Color.FromArgb((byte)( r1 ), (byte)( g1 ), (byte)( b1 )));
                    dst.SetPixel(x, y, Color.FromArgb((byte)(r * brght1 + r1 * (1 - brght1)), (byte)(g * brght1 + g1 * (1 - brght1)), (byte)(b * brght1 + b1 * (1 - brght1))));
                }
            });

            dst.UnlockBitmap();

            image_l = dst.Bitmap;
        }
Beispiel #8
0
        public Bitmap ApplyFilter(Bitmap mask)
        {
            int          w           = mask.Width;
            int          h           = mask.Height;
            ImagerBitmap currentMask = new ImagerBitmap(mask.Clone() as Bitmap);

            Enumerable.Range(0, w).AsParallel().ForAll(x =>
            {
                for (int y = 0; y < h; y++)
                {
                    Color color = currentMask.GetPixel(x, y);
                    float red   = color.R;
                    float green = color.G;
                    float blue  = color.B;

                    if (color.GetBrightness() <= 0.35)
                    {
                        red   = 0;
                        green = 50;
                        blue  = 77;
                    }

                    if (color.GetBrightness() > 0.35 & color.GetBrightness() <= 0.55)
                    {
                        red   = 215;
                        green = 26;
                        blue  = 33;
                    }
                    if (color.GetBrightness() > 0.55)
                    {
                        red   = 252;
                        green = 228;
                        blue  = 168;
                    }

                    color = Color.FromArgb(255, (int)red, (int)green, (int)blue);
                    currentMask.SetPixel(x, y, color);
                }
            });

            currentMask.UnlockBitmap();
            return(currentMask.Bitmap);
        }
Beispiel #9
0
        void bp()
        {
            GC.Collect();
            win = new Bitmap(one_click.Properties.Resources.pb, (int)w, (int)h);
            dst = new ImagerBitmap(image_l);
            dsp = new ImagerBitmap(win);

            Enumerable.Range(0, (int)w).AsParallel().ForAll(x =>
            {
                var color  = new Color();
                var color1 = new Color();
                for (int y = 0; y < (int)h; y++)
                {
                    color       = dst.GetPixel(x, y);
                    color1      = dsp.GetPixel(x, y);
                    float brght = color.GetBrightness();

                    byte r = color.R;
                    byte g = color.G;
                    byte b = color.B;

                    float brght1 = color1.GetBrightness();
                    byte r1      = color1.R;
                    byte g1      = color1.G;
                    byte b1      = color1.B;

                    if (brght < 0.15)
                    {
                        b = 50;
                    }

                    dst.SetPixel(x, y, Color.FromArgb((byte)(r * 0.3 + r1 * 0.7), (byte)(g * 0.9 + g1 * 0.1), (byte)(b * 0.9 + b1 * 0.1)));
                }
            });

            dst.UnlockBitmap();
            dsp.UnlockBitmap();
            image_l = dst.Bitmap;
            win.Dispose();
        }
Beispiel #10
0
        void cold()
        {
            GC.Collect();
            win = new Bitmap(one_click.Properties.Resources.ramka, (int)w, (int)h);
            dst = new ImagerBitmap(image_l);
            dsp = new ImagerBitmap(win);

            Enumerable.Range(0, (int)w).AsParallel().ForAll(x =>
            {
                var color  = new Color();
                var color1 = new Color();
                for (int y = 0; y < (int)h; y++)
                {
                    color  = dst.GetPixel(x, y);
                    color1 = dsp.GetPixel(x, y);

                    float brght = color.GetBrightness();

                    byte r = color.R;
                    byte g = color.G;
                    byte b = color.B;

                    float brght1 = color1.GetBrightness();

                    byte r1 = color1.R;
                    byte g1 = color1.G;
                    byte b1 = color1.B;

                    r = (byte)((r * 0.35 + ((brght) * r + (1 - brght) * 100) * 0.65));
                    b = (byte)((b * 0.7 + ((1 - brght) * b + (brght) * 255) * 0.3));

                    dst.SetPixel(x, y, Color.FromArgb((byte)(r * (1 - brght1) + r1 * brght1), (byte)(g * (1 - brght1) + g1 * brght1), (byte)(b * (1 - brght1) + b1 * brght1)));
                }
            });

            dst.UnlockBitmap();
            dsp.UnlockBitmap();
            image_l = dst.Bitmap;
        }
Beispiel #11
0
        void collage()
        {
            GC.Collect();


            win = new Bitmap(one_click.Properties.Resources.collage, (int)(w + w / 10), (int)(h + h / 10));

            dsp = new ImagerBitmap(image_l);

            dst = new ImagerBitmap(win);


            Enumerable.Range(0, (int)(w / 2)).AsParallel().ForAll(x =>
            {
                var color = new Color();


                for (int y = 0; y < (int)(h / 2); y++)
                {
                    color = dsp.GetPixel(x, y);


                    float brght = color.GetBrightness();


                    byte r = color.R;
                    byte g = color.G;
                    byte b = color.B;

                    if (brght < 0.15)
                    {
                        b = 100;
                    }

                    if (brght >= 0.15 & brght < 0.3)
                    {
                        r = 50;
                        b = 50;
                    }

                    if (brght >= 0.3 & brght < 0.85)
                    {
                        r = 255;
                        g = 0;
                        b = 50;
                    }

                    if (brght >= 0.85)
                    {
                        g = 200;
                        b = 100;
                    }
                    dst.SetPixel((int)(x + w / 30), (int)(y + h / 30), Color.FromArgb(r, g, b));

                    /////////////////////////////////////////////
                    r = color.R;
                    g = color.G;
                    b = color.B;

                    if (brght < 0.15)
                    {
                        r = 20;
                        g = 20;
                    }

                    if (brght >= 0.15 & brght < 0.3)
                    {
                        g = 150;
                        b = 150;
                    }

                    if (brght >= 0.3 & brght < 0.85)
                    {
                        r = 55;
                        b = 255;
                    }

                    if (brght >= 0.85)
                    {
                        r  = 190;
                        g -= 50;
                        b  = 255;
                    }
                    dst.SetPixel((int)(x + 17 * w / 30), (int)(y + h / 30), Color.FromArgb(r, g, b));

                    /////////////////////////////////////////////
                    r = color.R;
                    g = color.G;
                    b = color.B;

                    if (brght < 0.15)
                    {
                        b = 75;
                        r = 75;
                    }

                    if (brght >= 0.15 & brght < 0.3)
                    {
                        r = 50;
                        b = 150;
                    }

                    if (brght >= 0.3 & brght < 0.85)
                    {
                        r = 255;
                        g = 175;
                        // b = 250;
                    }

                    if (brght >= 0.85)
                    {
                        g = 200;
                        b = 100;
                    }
                    dst.SetPixel((int)(x + 17 * w / 30), (int)(y + 17 * h / 30), Color.FromArgb(r, g, b));

                    /////////////////////////////////////////////
                    r = color.R;
                    g = color.G;
                    b = color.B;

                    if (brght < 0.15)
                    {
                        b = 100;
                        g = 100;
                    }

                    if (brght >= 0.15 & brght < 0.3)
                    {
                        r = 50;
                        b = 50;
                    }

                    if (brght >= 0.3 & brght < 0.85)
                    {
                        r -= 10;
                        g  = 250;
                        b += 25;
                    }

                    if (brght >= 0.85)
                    {
                        g = 210;
                        b = 150;
                        r = 15;
                    }
                    dst.SetPixel((int)(x + w / 30), (int)(y + 17 * h / 30), Color.FromArgb(r, g, b));
                }
            });



            dst.UnlockBitmap();
            dsp.UnlockBitmap();

            image_l = dst.Bitmap;
        }
Beispiel #12
0
        void kerng()
        {
            int[] kernel1;
            kernel1 = new int[11];

            kernel1[0]  = 1;
            kernel1[1]  = 2;
            kernel1[2]  = 4;
            kernel1[3]  = 8;
            kernel1[4]  = 16;
            kernel1[5]  = 32;
            kernel1[6]  = 16;
            kernel1[7]  = 8;
            kernel1[8]  = 4;
            kernel1[9]  = 2;
            kernel1[10] = 1;
            div         = 94;
            var dst      = new ImagerBitmap(image_l);
            var image_l1 = new ImagerBitmap(image_l);


            Enumerable.Range(7, (int)w - 7).AsParallel().ForAll(x =>
            {
                var color = new Color();
                int rSum  = 0, gSum = 0, bSum = 0;
                for (int y = 7; y < (int)h - 7; y++)
                {
                    for (int i = 0; i < 11; i++)
                    {
                        color = image_l1.GetPixel(x - 3 + i, y);

                        byte r = color.R;
                        byte g = color.G;
                        byte b = color.B;
                        int a  = kernel1[i];

                        rSum += r * a;
                        gSum += g * a;
                        bSum += b * a;
                    }
                    rSum /= div;
                    gSum /= div;
                    bSum /= div;

                    rSum += offset;
                    gSum += offset;
                    bSum += offset;

                    if (rSum > 255)
                    {
                        rSum = 255;
                    }
                    if (rSum < 0)
                    {
                        rSum = 0;
                    }

                    if (gSum > 255)
                    {
                        gSum = 255;
                    }
                    if (gSum < 0)
                    {
                        gSum = 0;
                    }

                    if (bSum > 255)
                    {
                        bSum = 255;
                    }
                    if (bSum < 0)
                    {
                        bSum = 0;
                    }

                    dst.SetPixel(x, y, Color.FromArgb((byte)rSum, (byte)gSum, (byte)bSum));
                    rSum = gSum = bSum = 0;
                }
            });


            image_l1.UnlockBitmap();
            //   dst.UnlockBitmap();
            image_l1.Bitmap.Dispose();
            image_l = dst.Bitmap;

            var dsp      = dst;
            var image_l2 = dst;


            Enumerable.Range(7, (int)h - 7).AsParallel().ForAll(y =>
            {
                var color = new Color();
                int rSum  = 0, gSum = 0, bSum = 0;
                for (int x = 7; x < (int)w - 7; x++)
                {
                    for (int i = 0; i < 11; i++)
                    {
                        color = dst.GetPixel(x, y - 3 + i);

                        byte r = color.R;
                        byte g = color.G;
                        byte b = color.B;
                        int a  = kernel1[i];

                        rSum += r * a;
                        gSum += g * a;
                        bSum += b * a;
                    }
                    rSum /= div;
                    gSum /= div;
                    bSum /= div;

                    rSum += offset;
                    gSum += offset;
                    bSum += offset;

                    if (rSum > 255)
                    {
                        rSum = 255;
                    }
                    if (rSum < 0)
                    {
                        rSum = 0;
                    }

                    if (gSum > 255)
                    {
                        gSum = 255;
                    }
                    if (gSum < 0)
                    {
                        gSum = 0;
                    }

                    if (bSum > 255)
                    {
                        bSum = 255;
                    }
                    if (bSum < 0)
                    {
                        bSum = 0;
                    }

                    dsp.SetPixel(x, y, Color.FromArgb((byte)rSum, (byte)gSum, (byte)bSum));
                    rSum = gSum = bSum = 0;
                }
            });


            image_l2.UnlockBitmap();
            dsp.UnlockBitmap();
            dst.UnlockBitmap();
            image_l2.Bitmap.Dispose();
            image_l = dsp.Bitmap;
        }
Beispiel #13
0
        void kern()
        {
            var dst      = new ImagerBitmap(image_l);
            var image_l1 = new ImagerBitmap(image_l);


            Enumerable.Range(kernel_h / 2, (int)w - kernel_h / 2 - 1).AsParallel().ForAll(x =>
            {
                var color = new Color();
                int rSum  = 0, gSum = 0, bSum = 0;
                for (int y = kernel_w / 2; y < (int)h - kernel_w / 2 - 1; y++)
                {
                    for (int j = 0; j < kernel_h; j++)
                    {
                        for (int i = 0; i < kernel_w; i++)
                        {
                            color = image_l1.GetPixel(x - kernel_h / 2 + i, y - kernel_h / 2 + j);

                            byte r = color.R;
                            byte g = color.G;
                            byte b = color.B;
                            int a  = kernel[i, j];

                            rSum += r * a;
                            gSum += g * a;
                            bSum += b * a;
                        }
                    }
                    rSum /= div;
                    gSum /= div;
                    bSum /= div;

                    rSum += offset;
                    gSum += offset;
                    bSum += offset;

                    if (rSum > 255)
                    {
                        rSum = 255;
                    }
                    if (rSum < 0)
                    {
                        rSum = 0;
                    }

                    if (gSum > 255)
                    {
                        gSum = 255;
                    }
                    if (gSum < 0)
                    {
                        gSum = 0;
                    }

                    if (bSum > 255)
                    {
                        bSum = 255;
                    }
                    if (bSum < 0)
                    {
                        bSum = 0;
                    }

                    dst.SetPixel(x, y, Color.FromArgb((byte)rSum, (byte)gSum, (byte)bSum));
                    rSum = gSum = bSum = 0;
                }
            });
            image_l1.UnlockBitmap();

            dst.UnlockBitmap();
            image_l1.Bitmap.Dispose();
            image_l = dst.Bitmap;
        }