Results 1 to 3 of 3

Thread: Bitmap

  1. #1

    Thread Starter
    Frenzied Member blindlizard's Avatar
    Join Date
    Feb 2001
    Location
    Austin, TX - United States of America
    Posts
    1,141

    Question Bitmap

    How would I create a bitmap from scratch in VB? So I could make something like msPaint.

  2. #2
    Hyperactive Member techman2553's Avatar
    Join Date
    Mar 2001
    Location
    <- To your left.
    Posts
    362
    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 !!!
    ----------

  3. #3

    Thread Starter
    Frenzied Member blindlizard's Avatar
    Join Date
    Feb 2001
    Location
    Austin, TX - United States of America
    Posts
    1,141

    Thumbs up

    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
  •  



Click Here to Expand Forum to Full Width