|
-
Apr 25th, 2001, 02:54 PM
#1
Thread Starter
Frenzied Member
Bitmap
How would I create a bitmap from scratch in VB? So I could make something like msPaint.
-
Apr 25th, 2001, 04:09 PM
#2
Hyperactive Member
This is actually pretty easy, depending on how advanced you want to make the drawing tools.
Try This:
- Open a new project in VB
- Add a PictureBox control (Picture1)
- Add a CommandButton (Command1)
- Copy the code below to the form
Code:
Private Sub Form_Load()
Picture1.AutoRedraw = True
Command1.Caption = "SAVE"
End Sub
Private Sub Command1_Click()
SavePicture Picture1.Image, "C:\MyPicture.bmp"
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static LastX As Single
Static LastY As Single
If Button = vbLeftButton Then
Picture1.Line (LastX, LastY)-(X, Y), vbRed
End If
LastX = X
LastY = Y
End Sub
If you hold down the left mouse button, you can draw on the picture box, and if you press the button, the picture will get saved to C:\MyPicture.bmp.
You can use the Picture1.PSet method to draw a dot at a give x,y location.
You can use the Picture1.Line method to draw lines, open boxes, and filled boxes.
You can use the Picture1.Circle methode to draw open circles, filled circles, open elipses and filled elipses.
Have fun !!!
-
Apr 29th, 2001, 10:39 AM
#3
Thread Starter
Frenzied Member
Thank you. I 've been looking everywhere for that. It's exactly what I needed. You rock!
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
|