将文本添加到图像,然后保存到文件

时间:2017-11-17 20:11:15

标签: vb.net

我尝试向图片添加文字然后保存。以下实际上保存了图像,但是当我尝试打开它时,它表示它不是有效的格式。它被保存为'礼品券'没有.png扩展名。任何帮助表示赞赏..

Dim newimage As bitmap
newimage = system.drawing.Image.FromFile(server.mappath("files/images/gift-voucher.png"))

Dim gr As Graphics = Graphics.FromImage(newimage)
Dim myFontLabels as New Font("Arial", 10)
Dim myBrushLabels As New SolidBrush(Color.White)

gr.DrawString("SOLD",myFontLabels, myBrushLabels,10, 190)
newimage.Save("C:\Inetpub\vhosts\onlinecarbooty.com\httpdocs\catalog\images\gift-voucher", System.Drawing.Imaging.ImageFormat.png)
newimage.Dispose()

0 个答案:

没有答案