image editor help

Anything not covered in the other sections like Computer trouble - Hardware Issues - Upgrades and other technical stuff to be asked in here please.
4 posts Page 1 of 1
Contributors
User avatar
Cheatmasterbw
Coding God
Coding God
Posts: 1506
Joined: Fri Jan 01, 2010 2:30 pm

image editor help
Cheatmasterbw
hi, i am working on an image editor, like MSPaint. whenever i minimize the screen and re-open it, the drawn image completely vanishes. is there any way to prevent this? thanks!

P.S.

the program was made in vb 2008

-and-

I have uploaded the source!
vvvvvvvvvvvvvvvvvvvvvvvvvvv
You do not have the required permissions to view the files attached to this post.
http://www.megaapps.tk/
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: image editor help
mandai
Its because you aren't actually drawing to the image in the picturebox, just on the picturebox itself.
With any control on a form if you draw over it and then it refreshes later, your changes will be lost (unless you recreate them after the refresh has occured).

You might be looking to make a graphics object from an image that you load into the picturebox, then you can draw using that and refresh your picturebox and your drawing will be preserved.
User avatar
Cheatmasterbw
Coding God
Coding God
Posts: 1506
Joined: Fri Jan 01, 2010 2:30 pm

Re: image editor help
Cheatmasterbw
could you post an example?
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: image editor help
mandai
Code: Select all
Dim gfx As Graphics

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim bmp As Bitmap = New Bitmap(PictureBox1.Width, PictureBox1.Height)
        PictureBox1.Image = bmp
        gfx = Graphics.FromImage(picturebox1.Image)
End Sub

Private Sub PictureBox1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
        gfx.FillRectangle(Brushes.Black, New Rectangle(e.X, e.Y, 10, 10))
        PictureBox1.Refresh()
End Sub
4 posts Page 1 of 1
Return to “General Help”