将Draw String或e.graphic保存为图像

时间:2013-07-03 23:59:48

标签: vb.net system.drawing bmp drawstring save-image

需要帮助请!使用“”抽象图片保存图片,电子邮件“”

Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)

    Dim Bmp As New Bitmap(Width, Height)
    Dim objBitmap As New Bitmap(Width, Height)

    objBitmap.Save("c:\Prompter\checking2.TIFF")

    Dim g As Graphics = Graphics.FromImage(Bmp)
    Dim cx As Integer = Width
    Dim cy As Integer = Height
    Dim pen As New Pen(Color.Black)
    Dim rect As New Rectangle(0, 0, Width, Height)

    Dim drawFormat As New StringFormat()
    drawFormat.Alignment = StringAlignment.Center
    drawFormat.LineAlignment = StringAlignment.Center

    Dim stringFont As New Font("Arial", 50)
    g.DrawString(RichTextBox1.Text, stringFont, New SolidBrush(Color.White), rect, drawFormat)

    Bmp.Save("c:\Prompter\checking2.TIFF", Imaging.ImageFormat.Tiff)

    Using bmp2 As New Drawing.Bitmap(Width, Height)
        DrawToBitmap(Bmp, New Rectangle(0, 0, Bmp.Width, Bmp.Height))
        Bmp.Save("c:\Prompter\screenshoot.bmp")
    End Using 
End Sub

不保存图片只是BLANK图像正在显示!

1 个答案:

答案 0 :(得分:-1)

尝试在保存之前处理图形..

g.Dispose()
Bmp.Save("c:\Prompter\checking2.TIFF", Imaging.ImageFormat.Tiff)