I have an Asp.Net MVC project where I generate an image in memory and would like to download it.
See a snippet of code:
Image imagem = default(Image);
using (Bitmap b = new Bitmap(bitmapWidth, bitmapHeight))
{
using (Graphics g = Graphics.FromImage(b))
{
g.Clear(Color.Red);
var font = new Font("Arial", 50, FontStyle.Bold);
g.DrawString("Stackoverflow", font, Brushes.White, posicaoX, posicaoY);
}
using (MemoryStream stream = new MemoryStream())
{
b.Save(stream, ImageFormat.Jpeg);
imagem = Image.FromStream(stream);
}
}
using (System.Net.WebClient client = new System.Net.WebClient())
{
client.DownloadFile(imagem); // Não sei bem como posso fazer o Download.
}