Exemplo n.º 1
0
        private void AddRectanglePixelsInmatrix(ImagePixel[,] pixels, ImageRectangle rectangle, int xRectanglePosition, int yRectanglePosition)
        {
            ImagePixel[,] rectanglePixels = rectangle.PixelsMatrix;

            for (int m = 0, i = xRectanglePosition * rectangle.M; m < rectangle.M; m++, i++)
            {
                for (int n = 0, j = yRectanglePosition * rectangle.N; n < rectangle.N; n++, j++)
                {
                    pixels[i, j] = rectanglePixels[m, n];
                }
            }
        }
Exemplo n.º 2
0
        private Image AssembleImageFromPixels(ImagePixel[,] pixels, int height, int width)
        {
            Bitmap bitmap = new Bitmap(width, height);

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    ImagePixel pixel = pixels[i, j];
                    if (pixel == null)
                    {
                        pixel = new ImagePixel(0, 0, 0);
                    }
                    Color color = Color.FromArgb((Int32)pixel.R, (Int32)pixel.G, (Int32)pixel.B);
                    bitmap.SetPixel(i, j, color);
                }
            }

            return bitmap as Image;
        }
Exemplo n.º 3
0
        private ImagePixel[,] GetConvertedPixels(Color[,] pixels)
        {
            ImagePixel[,] pixelsMatrix = new ImagePixel[m, n];

            for (int i = 0; i < m; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    pixelsMatrix[i, j] = GetConvertedPixel(pixels, i, j);
                }
            }

            return pixelsMatrix;
        }
Exemplo n.º 4
0
        private ImagePixel GetConvertedPixel(Color[,] pixels, int i, int j)
        {
            double r = pixels[i, j].R;
            double g = pixels[i, j].G;
            double b = pixels[i, j].B;

            ImagePixel pixel = new ImagePixel(Convert(r), Convert(g), Convert(b));

            return pixel;
        }
Exemplo n.º 5
0
 private void ConvertPixelsInStandardForm(ImagePixel[,] pixels, int height, int width)
 {
     for (int i = 0; i < width; i++)
     {
         for (int j = 0; j < height; j++)
         {
             ConvertPixelInStandardForm(pixels[i, j]);
         }
     }
 }
Exemplo n.º 6
0
 private void ConvertPixelInStandardForm(ImagePixel pixel)
 {
     if (pixel == null)
     {
         pixel = new ImagePixel(0, 0, 0);
         return;
     }
     pixel.R = ConvertToStandardForm(pixel.R);
     pixel.G = ConvertToStandardForm(pixel.G);
     pixel.B = ConvertToStandardForm(pixel.B);
 }
Exemplo n.º 7
0
        private ImagePixel[,] AssembleRectanglesToPixelMatrix(ImageRectangle[] pixelsRectangels, int height, int width)
        {
            ImagePixel[,] pixels = new ImagePixel[width, height];

            int xRectanglePosition = 0;
            int yRectanglePosition = 0;

            for (int p = 0; p < pixelsRectangels.Length; p++)
            {
                ImageRectangle rectangle = pixelsRectangels[p];

                AddRectanglePixelsInmatrix(pixels, rectangle, xRectanglePosition, yRectanglePosition);

                if (xRectanglePosition >= (width / rectangle.M) - 1)
                {
                    xRectanglePosition = 0;
                    yRectanglePosition++;
                }
                else
                {
                    xRectanglePosition++;
                }
            }

            return pixels;
        }