예제 #1
0
        public async Task <byte[]> Get32BppImageByteArrayAsync(ColourPalette palette, SKColorType pixelFormat = SKColorType.Rgba8888, CancellationToken ct = default)
        {
            var output = new byte[_width * _height * 4];

            var tasks = new List <Task>();

            for (var y = 0; y < _height; y++)
            {
                var localY    = y;
                var yRowStart = y * _width;
                tasks.Add(Task.Run(() =>
                {
                    for (var x = 0; x < _width; x++)
                    {
                        _data[x, localY].ToColour(palette).ToBytes(pixelFormat).CopyTo(output, (yRowStart + x) * 4);
                    }
                }, ct));
            }

            await Task.WhenAll(tasks);

            return(output);
        }
예제 #2
0
 public Colour ToColour(ColourPalette palette)
 {
     return(palette.GetColour(100m * Iterations / _totalIterations));
 }