storing graphics in form of Bitmap
Posted on 2005-04-28
Hi all. I draw lines in my pictureBox in the paint event...:
Now, I want to make a bitmap of the image of the pictureBox OR basically a bitmap displaying my lines. This way I can manage to rotate, stretch, print, and save it.(I know that I do not need a bitmap, but it would make everything much simpler...)
How can I do something like: bitmap1.darwLine(...) ?
and how to save the graphic? the image property of pictureBox stays empty !
Look. I have already tried to retrieve the hdc and it works, but it captures any form lying over the pictureBox and ruines my picture:
'==========the following cannot possibly work correctly:
' Make a Bitmap to hold the image.
Dim bm As New Bitmap(PictureBoxGraph.Width, PictureBoxGraph.Height, me_gr)
Dim bm_gr As Graphics = me_gr.FromImage(bm)
Dim bm_hdc As IntPtr = bm_gr.GetHdc
' Get the PictureBoxGraph's hDC. We must do this after
' creating the new Bitmap, which uses me_gr.
Dim me_hdc As IntPtr = me_gr.GetHdc
' BitBlt the PictureBoxGraph's image onto the Bitmap.
BitBlt(bm_hdc, 0, 0, PictureBoxGraph.ClientSize.Width, PictureBoxGraph.ClientSize.Height, _
me_hdc, 0, 0, SRCCOPY)