I want to save three shape[rectangle] as a single bmp file.. is there option to save it..
my code is
Public Class Form1
Dim bmp As New Bitmap(Me.Width, Me.Height)
Private Sub PaintTheForm()
Dim bmp As New Bitmap(Me.Width, Me.Height)
Using g As Graphics = Graphics.FromImage(bmp)
Dim blackPen As New Pen(Color.Black, 1)
'to draw first rectangle rectangle
Dim rect As New Rectangle(0, 0, 30, 16)
g.DrawRectangle(Pens.Black, rect)
'to draw second rectangle
Dim rect1 As New Rectangle(30, 0, 114, 8)
g.DrawRectangle(Pens.Black, rect1)
'to draw thrid rectangle
Dim rect2 As New Rectangle(30, 8, 114, 8)
g.DrawRectangle(Pens.Black, rect2)
' To type text
Dim big_font As New Font("Comic Sans MS", 12, FontStyle.Bold, GraphicsUnit.Pixel)
g.TextRenderingHint = Drawing.Text.TextRenderingHint.SingleBitPerPixel
g.DrawString("helo", big_font, Brushes.Black, 0, 0)
g.Dispose()
' End Sub
Me.BackgroundImage = bmp
End Using
End Sub
Private Sub btnPaint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPaint.Click
PaintTheForm()
End Sub
Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click
SaveFileDialog1.FileName = ""
If SaveFileDialog1.ShowDialog <> 1 Then Exit Sub
Try
Select Case SaveFileDialog1.FilterIndex
Case 1
bmp.Save(SaveFileDialog1.FileName, Imaging.ImageFormat.Bmp)
Case 2
End Select
Catch
MsgBox("Can not save the LED image!", 48, "LED Saving")
End Try
End Sub
End Class
when I tried to save this I could not save the three rectangle box... so can anyone help in solving my problem
thanks
Anonymous User
30-Mar-2015Hi madhu
Try this code:
If you want to save the image that is displayed in the picture box, complete with any lines that may have been drawn on top of it during run-time, you can use the Control.DrawToBitmap method
Here's an example of a complete solution. First, the user is prompted by a save dialog (entitled "Save Image" and filtering to bitmap images (*.bmp) by default). If they click OK, the image displayed in the picture box is drawn to a temporary bitmap, and that temporary bitmap is saved to the location they specified. If they click Cancel, the file is not saved and the method simply exits.