public void ImageProcessor_ConvertImages_To_Original() { var originalImage = new[] { Rgba32.Red, Rgba32.Green, Rgba32.Blue, Rgba32.Black, Rgba32.White, Rgba32.Yellow }; var serializedImage = _imageProcessor.GetBytesFromPixels(originalImage, 2, 3); var resultImage = _imageProcessor.GetPixelsFromBytes(serializedImage, 2, 3); Assert.True(AreSame(originalImage, resultImage)); }
protected override async Task ReadStateAsync() { await base.ReadStateAsync(); _chunkKey = this.GetPrimaryKey(); (_battleId, _xChunkIndex, _yChunkIndex) = GuidExtensions.ToKeys(_chunkKey); var battle = await _apiClient.GetBattleAsync(_battleId); _chunkWidth = battle.Settings.ChunkWidth; _chunkHeight = battle.Settings.ChunkHeight; if (State.Image == null) { _pixelsCache = _imageProcessor.GetDefaultImage(_chunkHeight, _chunkWidth); State.ChangeIndex = 0; State.Image = _imageProcessor.GetBytesFromPixels(_pixelsCache, _chunkHeight, _chunkWidth); } else { _pixelsCache = _imageProcessor.GetPixelsFromBytes(State.Image, _chunkHeight, _chunkWidth); } }