Ejemplo n.º 1
0
 /// Init the color block with the contents of the given block.
 public ColorBlock(ColorBlock block)
     : this()
 {
     for (uint i = 0; i < 16; i++)
     {
         Data[(int)i] = block.Color(i);
     }
 }
Ejemplo n.º 2
0
        private static void ReadBlock(ColorBlock rgba, Stream ms)
        {
            var blockBuffer = new byte[Marshal.SizeOf(typeof(BlockDXT5))];

            ms.Read(blockBuffer, 0, blockBuffer.Length);

            var blockdxt5 = Utils.ByteArrayToStructure<BlockDXT5>(blockBuffer);

            blockdxt5.decodeBlock(ref rgba);
        }
Ejemplo n.º 3
0
        private static void ReadBlockFormat(RawImage ret, Stream ms)
        {
            ret.ColFormat = RawImage.Format.Format_ARGB;

            uint w = ret.Width;
            uint h = ret.Height;

            uint bw = (w + 3) / 4;
            uint bh = (h + 3) / 4;

            for (uint by = 0; by < bh; by++)
                for (uint bx = 0; bx < bw; bx++)
                {
                    var block = new ColorBlock();

                    // Read color block.
                    ReadBlock(block, ms);

                    // Write color block.
                    for (uint y = 0; y < Math.Min(4, h - 4 * by); y++)
                        for (uint x = 0; x < Math.Min(4, w - 4 * bx); x++)
                            ret.Data[(4 * by + y) * ret.Width + (4 * bx + x)] = block.Color(x, y);
                }
        }