示例#1
0
            public override byte[] Decode(byte[] input, int offset, int width, int height, VrPixelCodec PixelCodec)
            {
                byte[] output = new byte[width * height * 4];
                byte[,] clut  = ClutData;
                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 entry = input[StartOffset + TwiddledMap.GetTwiddledOffset(x2, y2)];
                                entry = (byte)((entry >> ((y2 & 0x01) * 4)) & 0x0F);

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

                                if ((x2 & 0x01) != 0)
                                    offset++;
                            }
                        }
                    }
                }

                return output;
            }
示例#2
0
            public override byte[] Decode(byte[] input, int offset, int width, int height, VrPixelCodec PixelCodec)
            {
                int StartOffset = offset;
                byte[] output   = new byte[width * height * 4];
                byte[,] clut    = ClutData;

                TwiddledMap TwiddledMap = new TwiddledMap(width / 2, GetBpp(PixelCodec));

                for (int y = 0; y < height; y += 2)
                {
                    for (int x = 0; x < width; x += 2)
                    {
                        ushort entry = (ushort)(input[StartOffset + TwiddledMap.GetTwiddledOffset(x >> 1, y >> 1)] * 4);

                        for (int y2 = 0; y2 < 2; y2++)
                        {
                            for (int x2 = 0; x2 < 2; x2++)
                            {
                                output[((((y + y2) * width) + (x + x2)) * 4) + 3] = clut[entry + (x2 * 2) + y2, 3];
                                output[((((y + y2) * width) + (x + x2)) * 4) + 2] = clut[entry + (x2 * 2) + y2, 2];
                                output[((((y + y2) * width) + (x + x2)) * 4) + 1] = clut[entry + (x2 * 2) + y2, 1];
                                output[((((y + y2) * width) + (x + x2)) * 4) + 0] = clut[entry + (x2 * 2) + y2, 0];
                            }
                        }

                        offset++;
                    }
                }

                return output;
            }
示例#3
0
            public override byte[] Decode(byte[] input, int offset, int width, int height, VrPixelCodec PixelCodec)
            {
                int StartOffset = offset;
                byte[] output   = new byte[width * height * 4];
                TwiddledMap TwiddledMap = new TwiddledMap(width, GetBpp(PixelCodec));

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

                        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;
            }
示例#4
0
            public override byte[] Encode(byte[] input, int width, int height, VrPixelCodec PixelCodec)
            {
                byte[] output = new byte[width * height * (GetBpp(PixelCodec) / 8)];
                TwiddledMap TwiddledMap = new TwiddledMap(width, GetBpp(PixelCodec));

                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, TwiddledMap.GetTwiddledOffset(x, y));
                    }
                }

                return output;
            }
示例#5
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;
            }
示例#6
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;
            }
示例#7
0
            public override byte[] Encode(byte[] input, int width, int height, VrPixelCodec PixelCodec)
            {
                int offset = 0;
                byte[] output = new byte[width * height];
                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++)
                            {
                                output[StartOffset + TwiddledMap.GetTwiddledOffset(x2, y2)] = input[(((y + y2) * width) + (x + x2))];
                                offset++;
                            }
                        }
                    }
                }

                return output;
            }