draw in imagebox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zsolt szabo
    New Member
    • Jan 2012
    • 8

    draw in imagebox

    hi, i`ve got 2 imageboxes on each other.
    the one at the bottom displays a picture (image1), the other one is for drawing (imagedraw).
    imagedraw shows a line when i move the mouse on it, and if i move it a bit furthen than the previous line going to be deleted using "CLS", theres a "zoom" function which is changeing the size of the boxes, and strech them, when this happens the line has dissapear.

    i want to add the line to imagedraw or image1 whitout deleting its content.
    by the way, i think imagedraw is drawing the line in the form surface, but im not sure...

    Code:
    private sub imagedraw_mousemove.....
    cls
    line (x1, y1) - (x2, y2)
    regards: Zsolt
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    Did you place the line in the PICTUREBOX (not possible to place a line in a IMAGEBOX !) ?
    Try to cut the line and paste it in the PICTUREBOX.

    Is it possible to attach your project in Bytes so I can see what you exactly want to do with the pictures?

    Comment

    • Guido Geurs
      Recognized Expert Contributor
      • Oct 2009
      • 767

      #3
      You can't put a line in an imagebox, only in a picturebox.
      This is the code:

      Code:
      Option Explicit
      
      Dim Xstart As Integer
      Dim Ystart As Integer
      
      Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
          Xstart = X
          Ystart = Y
      End Sub
      
      Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
          Picture1.Line (Xstart, Ystart)-(X, Y)
      End Sub

      Comment

      • zsolt szabo
        New Member
        • Jan 2012
        • 8

        #4
        sorry for late response
        now i know i cant draw in an image box...
        but i need to create 2 layers of image, the point is you`ll be able to look trough the one at the top to see the one at the back.
        both must be an imagebox because i need to strech them.
        i have an idea for this:
        the pic at the back will allways be the same (except the strech function), and the one at the top shall allways ready for use...
        now what if i draw a line by an imagebox (at a specified position) and draw a same line to a hidden picturebox with the imagebox mouse move function/event, save it to specified path, then open it in the top imagebox

        i`ll be able to strech it, because im able to strech images wich are loaded as a picture.

        but im stuck, i dont know how to save the drawn lines from the picturebox, it saves a blank picture.
        i think this may work what do you think?

        Comment

        • Guido Geurs
          Recognized Expert Contributor
          • Oct 2009
          • 767

          #5
          You can solve this by placing an image and a line IN a picturebox. Use NOT Picturebox.Line because the line IS NOT AN ELEMENT and you can't scale or distort it.
          Calculate, each time you make an adaption on the image, the new coordinates of the line.

          Attached is a demo.
          Draw the line by MouseDown - Drag - MouseUp in the image.
          Attached Files

          Comment

          • Guido Geurs
            Recognized Expert Contributor
            • Oct 2009
            • 767

            #6
            Attached is an expurgated version with comments.
            Attached Files

            Comment

            • zsolt szabo
              New Member
              • Jan 2012
              • 8

              #7
              thanks its working now

              Comment

              Working...