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); }
public N64Rgba32Codec() { Width = DefaultWidth; Height = DefaultHeight; _foreignBuffer = new byte[(StorageSize + 7) / 8]; _nativeBuffer = new ColorRgba32[Height, Width]; _bitReader = BitStream.OpenRead(_foreignBuffer, StorageSize); }
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); }
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); }
private void Initialize() { _foreignBuffer = new byte[(StorageSize + 7) / 8]; _nativeBuffer = new byte[Height, Width]; _bitReader = BitStream.OpenRead(_foreignBuffer, StorageSize); }