예제 #1
0
        static aRGBA[] loadCMPR(aBinaryReader reader, int width, int height)
        {
            var       data = new aRGBA[width * height];
            const int cTileWidth = 8, cTileHeight = 8;
            const int cBlockWidth = 4, cBlockHeight = 4;

            for (var y = 0; y < height; y += cTileHeight)               // tile
            {
                for (var x = 0; x < width; x += cTileWidth)
                {
                    for (var by = 0; by < cTileHeight; by += cBlockHeight)                       // block
                    {
                        for (var bx = 0; bx < cTileWidth; bx += cBlockWidth)
                        {
                            var colors = aRGBA.FromST3C1(reader.Read64());
                            for (var ty = 0; ty < cBlockHeight && y + by + ty < height; ty++)                               // texel
                            {
                                for (var tx = 0; tx < cBlockWidth && x + bx + tx < width; tx++)
                                {
                                    data[width * (y + by + ty) + (x + bx + tx)] = colors[(ty * cBlockWidth) + tx];
                                }
                            }
                        }
                    }
                }
            }
            return(data);
        }