如何使用bitmapimage下载图像.保存方法

本文关键字:保存 方法 图像 下载 何使用 bitmapimage | 更新日期: 2023-09-27 18:18:09

我刚刚在图片上添加了文字。当我使用位图时。方法,它只在浏览器中显示图像。但我想让它自动要求下载图像。我使用下面的代码:

      graphicImage.DrawString(TextBox1.Text,
      new Font("Times New Roman", 24, FontStyle.Bold),
      new SolidBrush(Color.White), new Point(200, 350));
      Response.ContentType = "image/jpeg";
      bitMapImage.Save (Response.OutputStream, ImageFormat.Jpeg);

如何使用bitmapimage下载图像.保存方法

    Bitmap bitMapImage = new
       System.Drawing.Bitmap(Server.MapPath(imageurl));
    Graphics graphicImage = Graphics.FromImage(bitMapImage);
    graphicImage.SmoothingMode = SmoothingMode.AntiAlias; 
    graphicImage.DrawString(TextBox1.Text,
         new Font("Times New Roman", 24, FontStyle.Bold),
          new SolidBrush(Color.White), new Point(200, 350));
  Response.ContentType = "image/jpeg";
  bitMapImage.Save (Response.OutputStream, ImageFormat.Jpeg);