c# - c# 如何 bitmap.Save(Response.OutputStream)
问题描述
有人可以告诉我为什么这张图片不在浏览器上输出只是我想用我的自定义 ttf 覆盖图像并在浏览器上显示它不想保存在服务器上
protected void Button1_Click(object sender, EventArgs e)
{
string fontName = "sky-bold.ttf";
PrivateFontCollection pfcoll = new PrivateFontCollection();
//put a font file under a Fonts directory within your application root
pfcoll.AddFontFile(Server.MapPath("~/Fonts/" + fontName));
FontFamily ff = pfcoll.Families[0];
string firstText = Label1.Text;
PointF firstLocation = new PointF(233f, 730f);
//put an image file under a Images directory within your application root
string imageFilePath = Server.MapPath("~/HappyEid.jpg");
Bitmap bitmap = (Bitmap)System.Drawing.Image.FromFile(imageFilePath);//load the image file
using (Graphics graphics = Graphics.FromImage(bitmap))
{
using (Font f = new Font(ff, 30, FontStyle.Bold))
{
graphics.DrawString(firstText, f, Brushes.SaddleBrown, firstLocation);
}
}
bitmap.Save(Response.OutputStream, ImageFormat.Png);
}
}
解决方案
推荐阅读
- javascript - 如何摆脱反应图标(引导程序)中的可用空间?
- python - 为什么我不能使用 Gensim 下载 API 下载数据集
- c# - 在 C# 中连接到 MS Access 数据库时出现错误
- python - 尽管网络大、样本量小且数据经过预处理,Tensorflow LSTM 仍无法学习
- swiftui - 检测用户何时停止/暂停在 TextField 中写入 - SwiftUI
- c# - Xamarin.Forms - 根据设备分辨率更改设备方向
- typescript - 如何确保只读属性不可分配给可变属性?
- linux - oomkiller 是否以过量使用率启动
- excel - 如何使用更改事件计算公式并将值插入各个单元格
- python - 我如何将 numpy.ndarray 下面的形状重塑为给定的形状?