Results 1 to 5 of 5

Thread: Problems with SavePicture

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2008
    Posts
    2

    Problems with SavePicture

    Hi Guys!

    I used the following code to draw some shapes:

    Dim item(10) As VB.shape
    Private Sub Form_Load()
    Dim a As Integer
    For a = 0 To 9
    Set shape(a) = Form1.Controls.Add("VB.Shape", "shp" & a)
    item(a).Visible = True
    item(a).Left = 1800 + (a * 150)
    item(a).Top = 1500 + (a * 150)
    Next
    End Sub

    It work fine but then I want to save these shapes into a bitmap. I used the Savepicture statement:

    SavePicture Form1.image, "image.bmp"

    but all it did was it saved the form without any of the shapes (i.e it was a blank form)

    Any advise? Thanks in advance!

    ps. all i want to do is to draw multiple shapes with flexibility of control and save them into a bitmap. am open to all suggestions.

  2. #2
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: Problems with SavePicture

    It's because shape controls are not part of the containers image. If you draw your shapes using the containers drawing methods (Object.Line, Object.Circle) then they are part of the image and can be saved.

    If you want to manipulate your drawn shapes after they have been drawn then you can use an array of some UDT to store there positions and size...
    Code:
    Private type tCircle
       X as Single
       Y as Single
       Radius as Single
       Colour as long
       LineThickness as Long
       Filled as Boolean
       FillColour as Long
    End Type
    
    Private mCircles() as tCircle

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2008
    Posts
    2

    Re: Problems with SavePicture

    Hi Milk,

    Thanks for your reply.

    That was very helpful. There isnt a method for drawing rectangles would there?

    Thanks again!

  4. #4
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: Problems with SavePicture

    The line method.

    The last optional parameter is either B or BF, that means box or filled box.

    Edit: It's worth investigating GDI API if you have loads to draw
    Last edited by Milk; Aug 2nd, 2008 at 07:38 PM.

  5. #5
    Hyperactive Member
    Join Date
    Jan 2006
    Location
    Pakistan
    Posts
    388

    Re: Problems with SavePicture

    Explorer is you want to save your shapes for next time use, you will have to save the value of the properties of your shapes so that next time they can be drawn at the exact positions and in the exact manner. You will need to save the (x,y) cartesian coordinates, the color, the radius/length/width, the fill style, the border/line thickness and then apply these values to your shapes to draw the exact same shapes. I always use this method and it has never failed me.

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