Example #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];
                }
            }
        }
Example #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;
        }
Example #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;
        }
Example #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;
        }
Example #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]);
         }
     }
 }
Example #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);
 }
Example #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;
        }