Exemplo n.º 1
0
    public Rgb24TiledCodec(int width, int height)
    {
        Width  = width;
        Height = height;

        _foreignBuffer = new byte[(StorageSize + 7) / 8];
        _nativeBuffer  = new ColorRgba32[Height, Width];

        _bitReader = BitStream.OpenRead(_foreignBuffer, StorageSize);
    }
Exemplo n.º 2
0
    public N64Rgba32Codec()
    {
        Width  = DefaultWidth;
        Height = DefaultHeight;

        _foreignBuffer = new byte[(StorageSize + 7) / 8];
        _nativeBuffer  = new ColorRgba32[Height, Width];

        _bitReader = BitStream.OpenRead(_foreignBuffer, StorageSize);
    }
Exemplo n.º 3
0
    private void AllocateBuffers()
    {
        _elementData = new List <byte[]>();
        for (int i = 0; i < Format.ColorDepth; i++)
        {
            byte[] data = new byte[Format.Width * Format.Height];
            _elementData.Add(data);
        }

        _mergedData = new byte[Format.Width * Format.Height];

        _foreignBuffer = new byte[(StorageSize + 7) / 8];
        _nativeBuffer  = new byte[Height, Width];

        _bitReader = BitStream.OpenRead(_foreignBuffer, StorageSize);
    }
Exemplo n.º 4
0
        public static Cell Decode(IBitStreamReader reader, Map map, bool ignoreDirection = false)
        {
            var len = reader.Read(out var id, IdBits);

            if (len < IdBits)
            {
                throw new System.IO.EndOfStreamException($"未能读取完整{nameof(Id)}");
            }
            Cell cell;

            if (ctors[id] is Func <LightColor, Cell> colorCellCtor)
            {
                len = reader.Read(out var color, 3);
                if (len < 3)
                {
                    throw new System.IO.EndOfStreamException($"未能读取完整{nameof(IColor.Color)}");
                }
                cell = colorCellCtor((LightColor)color);
            }
            else
            {
                cell = ctors[id].DynamicInvoke() as Cell;
            }
            len = reader.Read(out var freedom, 1);
            if (len < 1)
            {
                throw new System.IO.EndOfStreamException($"未能读取完整{nameof(Freedom)}");
            }
            cell.Freedom = freedom != 0;
            if (cell.CanRotate && !ignoreDirection)
            {
                len = reader.Read(out var dir, 3);
                if (len < 3)
                {
                    throw new System.IO.EndOfStreamException($"未能读取完整{nameof(CanRotate)}");
                }
                cell.Direction = (Direction)dir;
            }
            if (cell is IMap mapCell)
            {
                mapCell.Map = map;
            }
            return(cell);
        }
Exemplo n.º 5
0
 private void Initialize()
 {
     _foreignBuffer = new byte[(StorageSize + 7) / 8];
     _nativeBuffer  = new byte[Height, Width];
     _bitReader     = BitStream.OpenRead(_foreignBuffer, StorageSize);
 }