示例#1
0
            public override byte[] Encode(byte[] input, int width, int height, VrPixelCodec PixelCodec)
            {
                byte[] output = new byte[width * height * (GetBpp(PixelCodec) / 8)];

                for (int y = 0; y < height; y++)
                {
                    for (int x = 0; x < width; x++)
                    {
                        byte[] palette = PixelCodec.CreatePixelPalette(input, (((y * width) + x) * 4));
                        palette.CopyTo(output, GetSwizzledOffset(x, y, width, height, GetBpp(PixelCodec)));
                    }
                }

                return output;
            }
示例#2
0
            public override byte[] Encode(byte[] input, int width, int height, VrPixelCodec PixelCodec)
            {
                int offset    = 0;
                byte[] output = new byte[width * height * (GetBpp(PixelCodec) / 8)];
                int ChunkSize = Math.Min(width, height);

                TwiddledMap TwiddledMap = new TwiddledMap(width, 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.CreatePixelPalette(input, ((((y + y2) * width) + (x + x2)) * 4));
                                palette.CopyTo(output, StartOffset + TwiddledMap.GetTwiddledOffset(x2, y2));

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

                return output;
            }