Beispiel #1
0
            public override byte[] Decode(byte[] input, int offset, int width, int height, VrPixelCodec PixelCodec)
            {
                byte[] output   = new byte[width * height * 4];
                int StartOffset = offset;

                for (int y = 0; y < height; y++)
                {
                    for (int x = 0; x < width; x++)
                    {
                        byte[] palette = PixelCodec.GetPixelPalette(input, StartOffset + GetSwizzledOffset(x, y, width, height, GetBpp(PixelCodec)));

                        output[(((y * width) + x) * 4) + 3] = palette[3];
                        output[(((y * width) + x) * 4) + 2] = palette[2];
                        output[(((y * width) + x) * 4) + 1] = palette[1];
                        output[(((y * width) + x) * 4) + 0] = palette[0];

                        offset += (GetBpp(PixelCodec) / 8);
                    }
                }

                return output;
            }
Beispiel #2
0
            public override byte[] Decode(byte[] input, int offset, int width, int height, VrPixelCodec PixelCodec)
            {
                byte[] output = new byte[width * height * 4];
                int ChunkSize = Math.Min(width, height);

                TwiddledMap TwiddledMap = new TwiddledMap(ChunkSize, GetBpp(PixelCodec));

                for (int y = 0; y < height; y += ChunkSize)
                {
                    for (int x = 0; x < width; x += ChunkSize)
                    {
                        int StartOffset = offset;

                        for (int y2 = 0; y2 < ChunkSize; y2++)
                        {
                            for (int x2 = 0; x2 < ChunkSize; x2++)
                            {
                                byte[] palette = PixelCodec.GetPixelPalette(input, StartOffset + TwiddledMap.GetTwiddledOffset(x2, y2));

                                output[((((y + y2) * width) + (x + x2)) * 4) + 3] = palette[3];
                                output[((((y + y2) * width) + (x + x2)) * 4) + 2] = palette[2];
                                output[((((y + y2) * width) + (x + x2)) * 4) + 1] = palette[1];
                                output[((((y + y2) * width) + (x + x2)) * 4) + 0] = palette[0];

                                offset += (GetBpp(PixelCodec) / 8);
                            }
                        }
                    }
                }

                return output;
            }