|
-
Apr 5th, 2007, 04:47 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [02/03] Stamping an icon on mouse click - similar to paintbrush
I want a form with an image in the background. I would then like to be able to select one of 5 stamps from a dropdown menu on the side. Then whenever I click on the form it stamps a small image. When all said and done I want to save the form image to a jpg and save it in a database.
My question is, can someone provide some sample code for stamping icons on a blank form wherever the mouse is clicked. The rest I have figured out.
Project is for a injury reporting system. A cartoon human body will be displayed on form with type of injury stamped onto the location of injury. This image will accompany an electronically submitted report. I just need help with stamping images onto the form. I have the rest pretty much done including saving an image of the form to a bitmap and then to a database.
Thanks
-
Apr 5th, 2007, 04:55 PM
#2
Re: [02/03] Stamping an icon on mouse click - similar to paintbrush
Take a look at my code for a simple drawing program.
http://www.vbforums.com/showthread.php?t=426684
That code keeps a record of the start and end points of lines that get drawn on the form and later saved. You can do basically the same thing but in your case it will be the locations of images. You will use the Graphics.DrawImage method to draw those images where I've used Graphics.DrawLine to draw the lines. The principles are exactly the same though. You just have to determine the most appropriate way to store the control data for the drawing and then how to read it in the Paint event handler.
-
Apr 5th, 2007, 06:56 PM
#3
Thread Starter
Hyperactive Member
Re: [02/03] Stamping an icon on mouse click - similar to paintbrush
So I've gotten this far from looking at your code. I don't get the rest.
vb Code:
Private Sub imgInjury_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles imgInjury.MouseDown
Dim g As Graphics = Graphics.FromImage(Me.imgInjury.Image)
Dim newImage As Bitmap
g.DrawImage(imgWound.Image, e.X, e.Y)
Where do I go from here? I don't see the wound appearing on the imgInjury picturebox. I have near zero graphics experience in VB. I'm a pure data and database guy. I have saved bitmaps to sql fields before but they were bitmaps already in existance or provided by another source.
-
Apr 6th, 2007, 02:27 PM
#4
Thread Starter
Hyperactive Member
Re: [02/03] Stamping an icon on mouse click - similar to paintbrush
I got it. It was much easier than I thought it was going to be. Thanks for pointing me in the right direction.
Code:
Dim bm_out As New Bitmap(imgInjury.Image)
Dim gr_out As Graphics = Graphics.FromImage(bm_out)
gr_out.DrawImage(bm_out, 0, 0)
gr_out.DrawImage(imgInjuryType.Image, e.X, e.Y)
imgInjury.Image = bm_out
With each new mouse click the cartoon body gets updated with a new injury type.
-
Apr 6th, 2007, 07:43 PM
#5
Re: [RESOLVED] [02/03] Stamping an icon on mouse click - similar to paintbrush
Don't forget to dispose your Graphics object when you're done with it. That's very important.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|