コード例 #1
0
        protected void DrawImage()
        {
            var stream = new MemoryStream();
            var pixels = ImageFetcher.Image.Pixels;

            using (var image = new Image(PixelFetcher.Pixels, PixelFetcher.Pixels))
            {
                using (var imagePixels = image.Lock())
                {
                    for (var x = 0; x < PixelFetcher.Pixels; x++)
                    {
                        for (var y = 0; y < PixelFetcher.Pixels; y++)
                        {
                            var color      = pixels[x, y].Color;
                            var imageColor = new Rgba32();
                            imageColor.PackFromBytes(color[0], color[1], color[2], 0xFF);
                            imagePixels[x, y] = imageColor;
                        }
                    }
                }
                image.SaveAsPng(stream);
            }
            stream.Seek(0, SeekOrigin.Begin);
            _stream = stream;
        }