Пример #1
0
        public static Dictionary<int, PixelMap[]> GeneratePixelMapping(
            int width,
            int height,
            int startUniverse = 0,
            RgbOrder rgbOrder = RgbOrder.RGB,
            PixelOrder pixelOrder = PixelOrder.HorizontalSnakeTopLeft,
            int channelShift = 0)
        {
            int universe = startUniverse;
            int mappingPos = channelShift;

            var pixelMapping = new Dictionary<int, PixelMap[]>();

            if (pixelOrder == PixelOrder.HorizontalLineWiseTopLeft)
            {
                for (int y = 0; y < height; y++)
                {
                    for (int x = 0; x < width; x++)
                        MapPixelRGB(pixelMapping, x, y, ref universe, ref mappingPos, rgbOrder, channelShift);
                }
            }
            else if (pixelOrder == PixelOrder.HorizontalSnakeTopLeft)
            {
                for (int y = 0; y < height; y++)
                {
                    for (int x = 0; x < width; x++)
                        MapPixelRGB(pixelMapping, x, y, ref universe, ref mappingPos, rgbOrder, channelShift);

                    y++;

                    if (y >= height)
                        break;

                    for (int x = width - 1; x >= 0; x--)
                        MapPixelRGB(pixelMapping, x, y, ref universe, ref mappingPos, rgbOrder, channelShift);
                }
            }

            else if (pixelOrder == PixelOrder.HorizontalSnakeBottomLeft)
            {
                for (int y = height - 1; y >= 0; y--)
                {
                    for (int x = 0; x < width; x++)
                        MapPixelRGB(pixelMapping, x, y, ref universe, ref mappingPos, rgbOrder, channelShift);

                    y--;

                    if (y < 0)
                        break;

                    for (int x = width - 1; x >= 0; x--)
                        MapPixelRGB(pixelMapping, x, y, ref universe, ref mappingPos, rgbOrder, channelShift);
                }
            }

            return pixelMapping;
        }
Пример #2
0
        public static Dictionary <int, PixelMap[]> GeneratePixelMapping(
            int pixels,
            int startUniverse = 0,
            RgbOrder rgbOrder = RgbOrder.RGB,
            int channelShift  = 0)
        {
            int universe   = startUniverse;
            int mappingPos = channelShift;

            var pixelMapping = new Dictionary <int, PixelMap[]>();

            for (int x = 0; x < pixels; x++)
            {
                MapPixelRGB(pixelMapping, x, 0, ref universe, ref mappingPos, rgbOrder, channelShift);
            }

            return(pixelMapping);
        }
Пример #3
0
        private static void MapPixelRGB(Dictionary <int, PixelMap[]> pixelMapping, int x, int y, ref int universe, ref int mappingPos, RgbOrder rgbOrder, int channelShift)
        {
            switch (rgbOrder)
            {
            case RgbOrder.RGB:
                MapPixel(pixelMapping, universe, ColorComponent.R, x, y, ref mappingPos);
                MapPixel(pixelMapping, universe, ColorComponent.G, x, y, ref mappingPos);
                MapPixel(pixelMapping, universe, ColorComponent.B, x, y, ref mappingPos);
                break;
            }

            if (mappingPos + 2 >= 512)
            {
                // Skip to the next universe when we can't fit a full RGB pixel in the current universe
                universe++;
                mappingPos = channelShift;
            }
        }
Пример #4
0
        public static Dictionary <int, PixelMap[]> GeneratePixelMapping(
            int width,
            int height,
            int startUniverse     = 0,
            RgbOrder rgbOrder     = RgbOrder.RGB,
            PixelOrder pixelOrder = PixelOrder.HorizontalSnakeTopLeft,
            int channelShift      = 0)
        {
            int universe   = startUniverse;
            int mappingPos = channelShift;

            var pixelMapping = new Dictionary <int, PixelMap[]>();

            if (pixelOrder == PixelOrder.HorizontalLineWiseTopLeft)
            {
                for (int y = 0; y < height; y++)
                {
                    for (int x = 0; x < width; x++)
                    {
                        MapPixelRGB(pixelMapping, x, y, ref universe, ref mappingPos, rgbOrder, channelShift);
                    }
                }
            }
            else if (pixelOrder == PixelOrder.HorizontalSnakeTopLeft)
            {
                for (int y = 0; y < height; y++)
                {
                    for (int x = 0; x < width; x++)
                    {
                        MapPixelRGB(pixelMapping, x, y, ref universe, ref mappingPos, rgbOrder, channelShift);
                    }

                    y++;

                    if (y >= height)
                    {
                        break;
                    }

                    for (int x = width - 1; x >= 0; x--)
                    {
                        MapPixelRGB(pixelMapping, x, y, ref universe, ref mappingPos, rgbOrder, channelShift);
                    }
                }
            }

            else if (pixelOrder == PixelOrder.HorizontalSnakeBottomLeft)
            {
                for (int y = height - 1; y >= 0; y--)
                {
                    for (int x = 0; x < width; x++)
                    {
                        MapPixelRGB(pixelMapping, x, y, ref universe, ref mappingPos, rgbOrder, channelShift);
                    }

                    y--;

                    if (y < 0)
                    {
                        break;
                    }

                    for (int x = width - 1; x >= 0; x--)
                    {
                        MapPixelRGB(pixelMapping, x, y, ref universe, ref mappingPos, rgbOrder, channelShift);
                    }
                }
            }

            return(pixelMapping);
        }
Пример #5
0
        private static void MapPixelRGB(Dictionary<int, PixelMap[]> pixelMapping, int x, int y, ref int universe, ref int mappingPos, RgbOrder rgbOrder, int channelShift)
        {
            switch (rgbOrder)
            {
                case RgbOrder.RGB:
                    MapPixel(pixelMapping, universe, ColorComponent.R, x, y, ref mappingPos);
                    MapPixel(pixelMapping, universe, ColorComponent.G, x, y, ref mappingPos);
                    MapPixel(pixelMapping, universe, ColorComponent.B, x, y, ref mappingPos);
                    break;
            }

            if (mappingPos + 2 >= 512)
            {
                // Skip to the next universe when we can't fit a full RGB pixel in the current universe
                universe++;
                mappingPos = channelShift;
            }
        }
Пример #6
0
        public static Dictionary<int, PixelMap[]> GeneratePixelMapping(
            int pixels,
            int startUniverse = 0,
            RgbOrder rgbOrder = RgbOrder.RGB,
            int channelShift = 0)
        {
            int universe = startUniverse;
            int mappingPos = channelShift;

            var pixelMapping = new Dictionary<int, PixelMap[]>();

            for (int x = 0; x < pixels; x++)
                MapPixelRGB(pixelMapping, x, 0, ref universe, ref mappingPos, rgbOrder, channelShift);

            return pixelMapping;
        }