// Cofniecie ostatniej operacji;
 internal void goBack(MyBitmap myBitmap)
 {
     Bitmap tmp = (Bitmap)myBitmap.PreviousBitmap.Clone();
     myBitmap.CurrentBitmap = myBitmap.PreviousBitmap;
     myBitmap.PreviousBitmap = tmp;
     myBitmap.updateArrays();
 }
Example #2
0
        // Cofniecie ostatniej operacji;
        internal void goBack(MyBitmap myBitmap)
        {
            Bitmap tmp = (Bitmap)myBitmap.PreviousBitmap.Clone();

            myBitmap.CurrentBitmap  = myBitmap.PreviousBitmap;
            myBitmap.PreviousBitmap = tmp;
            myBitmap.updateArrays();
        }
Example #3
0
        // Obraz wyostrzony maską 3x3
        internal void sharpenBitmap(MyBitmap myBitmap)
        {
            myBitmap.PreviousBitmap = (Bitmap)myBitmap.CurrentBitmap.Clone();
            Bitmap sharpenImage = new Bitmap(myBitmap.BitmapInfo.SizeX, myBitmap.BitmapInfo.SizeY);
            int    filterWidth  = 3;
            int    filterHeight = 3;
            int    width        = myBitmap.BitmapInfo.SizeX;
            int    height       = myBitmap.BitmapInfo.SizeY;

            // Tablica maski.
            int[,] filter   = { { -1, -1, -1 }, { -1, 9, -1 }, { -1, -1, -1 } };
            Color[,] result = new Color[width, height];

            for (int x = 0; x < width; ++x)
            {
                for (int y = 0; y < height; ++y)
                {
                    int   red = 0, green = 0, blue = 0;
                    Color imageColor = myBitmap.CurrentBitmap.GetPixel(x, y);

                    for (int filterX = 0; filterX < filterWidth; filterX++)
                    {
                        for (int filterY = 0; filterY < filterHeight; filterY++)
                        {
                            int imageX = (x - filterWidth / 2 + filterX + width) % width;
                            int imageY = (y - filterHeight / 2 + filterY + height) % height;

                            Color bmpColor = myBitmap.CurrentBitmap.GetPixel(imageX, imageY);
                            red   += bmpColor.R * filter[filterX, filterY];
                            green += bmpColor.G * filter[filterX, filterY];
                            blue  += bmpColor.B * filter[filterX, filterY];
                        }
                        // Ustawiamy wartość na zakres <0,255> jesli nie miesci sie w tym przedziale;
                        int r = Math.Min(Math.Max(red, 0), 255);
                        int g = Math.Min(Math.Max(green, 0), 255);
                        int b = Math.Min(Math.Max(blue, 0), 255);

                        result[x, y] = Color.FromArgb(r, g, b);
                    }
                }
            }
            for (int i = 0; i < width; ++i)
            {
                for (int j = 0; j < height; ++j)
                {
                    sharpenImage.SetPixel(i, j, result[i, j]);
                }
            }
            myBitmap.CurrentBitmap = MyBitmap.convertTo24bpp(sharpenImage);
            myBitmap.updateArrays();
        }
Example #4
0
        // Obraz w negatywie;
        internal void inverseBitmap(MyBitmap myBitmap)
        {
            myBitmap.PreviousBitmap = (Bitmap)myBitmap.CurrentBitmap.Clone();
            Graphics g = Graphics.FromImage(myBitmap.CurrentBitmap);

            ColorMatrix colorMatrix = new ColorMatrix(new[]
            {
                new[] { -1.0f, 0.0f, 0.0f, 0, 0 },
                new[] { 0.0f, -1.0f, 0.0f, 0, 0 },
                new[] { 0.0f, 0.0f, -1.0f, 0, 0 },
                new[] { 0.0f, 0.0f, 0.0f, 1, 0 },
                new[] { 1.0f, 1.0f, 1.0f, 0, 1 }
            });

            ImageAttributes attributes = new ImageAttributes();

            attributes.SetColorMatrix(colorMatrix);
            int x = myBitmap.BitmapInfo.SizeX;
            int y = myBitmap.BitmapInfo.SizeY;

            g.DrawImage(myBitmap.CurrentBitmap, new Rectangle(0, 0, x, y), 0, 0, x, y, GraphicsUnit.Pixel, attributes);
            g.Dispose();
            myBitmap.updateArrays();
        }
        // Obraz wyostrzony maską 3x3
        internal void sharpenBitmap(MyBitmap myBitmap)
        {
            myBitmap.PreviousBitmap = (Bitmap)myBitmap.CurrentBitmap.Clone();
            Bitmap sharpenImage = new Bitmap(myBitmap.BitmapInfo.SizeX, myBitmap.BitmapInfo.SizeY);
            int filterWidth = 3;
            int filterHeight = 3;
            int width = myBitmap.BitmapInfo.SizeX;
            int height = myBitmap.BitmapInfo.SizeY;
            // Tablica maski.
            int[,] filter = { { -1, -1, -1 }, { -1, 9, -1 }, { -1, -1, -1 } };
            Color[,] result = new Color[width, height];

            for (int x = 0; x < width; ++x)
            {
                for (int y = 0; y < height; ++y)
                {
                    int red = 0, green = 0, blue = 0;
                    Color imageColor = myBitmap.CurrentBitmap.GetPixel(x, y);

                    for (int filterX = 0; filterX < filterWidth; filterX++)
                    {
                        for (int filterY = 0; filterY < filterHeight; filterY++)
                        {
                            int imageX = (x - filterWidth / 2 + filterX + width) % width;
                            int imageY = (y - filterHeight / 2 + filterY + height) % height;

                            Color bmpColor = myBitmap.CurrentBitmap.GetPixel(imageX, imageY);
                            red += bmpColor.R * filter[filterX, filterY];
                            green += bmpColor.G * filter[filterX, filterY];
                            blue += bmpColor.B * filter[filterX, filterY];
                        }
                        // Ustawiamy wartość na zakres <0,255> jesli nie miesci sie w tym przedziale;
                        int r = Math.Min(Math.Max(red, 0), 255);
                        int g = Math.Min(Math.Max(green, 0), 255);
                        int b = Math.Min(Math.Max(blue, 0), 255);

                        result[x, y] = Color.FromArgb(r, g, b);
                    }
                }
            }
            for (int i = 0; i < width; ++i)
            {
                for (int j = 0; j < height; ++j) sharpenImage.SetPixel(i, j, result[i, j]);
            }
            myBitmap.CurrentBitmap = MyBitmap.convertTo24bpp(sharpenImage);
            myBitmap.updateArrays();
        }
        // Obraz w negatywie;
        internal void inverseBitmap(MyBitmap myBitmap)
        {
            myBitmap.PreviousBitmap = (Bitmap)myBitmap.CurrentBitmap.Clone();
            Graphics g = Graphics.FromImage(myBitmap.CurrentBitmap);

            ColorMatrix colorMatrix = new ColorMatrix(new[]
            {
                new[] {-1.0f, 0.0f, 0.0f, 0, 0},
                new[] {0.0f, -1.0f, 0.0f, 0, 0},
                new[] {0.0f, 0.0f, -1.0f, 0, 0},
                new[] {0.0f, 0.0f, 0.0f, 1, 0},
                new[] {1.0f, 1.0f, 1.0f, 0, 1}
            });

            ImageAttributes attributes = new ImageAttributes();
            attributes.SetColorMatrix(colorMatrix);
            int x = myBitmap.BitmapInfo.SizeX;
            int y = myBitmap.BitmapInfo.SizeY;
            g.DrawImage(myBitmap.CurrentBitmap, new Rectangle(0, 0, x, y), 0, 0, x, y, GraphicsUnit.Pixel, attributes);
            g.Dispose();
            myBitmap.updateArrays();
        }