コード例 #1
0
        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);
            }
        }
コード例 #2
0
        public void ImageProcessor_Can_ConvertBytesFromPixels()
        {
            var image = _imageProcessor.GetBytesFromPixels(new[] { Rgba32.OldLace }, 1, 1);

            Assert.NotNull(image);
        }