Results 1 to 4 of 4

Thread: GDI+ Save Image

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2002
    Location
    London
    Posts
    32

    GDI+ Save Image

    Hi,
    I’m new to VB.NET
    Q - How can I save an image drawn on picturebox ?

    In VB 6 when we draw lines and shapes on picture box we used use Image property to get Image on the picture box

    In .NET we have only one “Image” property instead of “picture” and “image” properties that will give only Background picture of Picture box not the Image on Picture box

    I’ve tried this -- created an image and drew all the things on the image and finally set Picture box image property to this image, This causing problems that it is always erasing last image(I think certainly this is the wrong way)

    I’m working on small designing application like paint

    (sorry for my poor English)

    Thanks in advance

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Not really sure about your problem.

    Maybe you want to save the images in an ImageList.?

    So then you can refer back to previous images...

    VB Code:
    1. 'create image container
    2. Dim myList As new ImageList
    3.  
    4. 'add current picturebox image to container list
    5. myList.Images.Add(Me.picturebox1.Image)
    6.  
    7. 'clear the current picturebox image from the picturebox
    8. Picturebox1.Image = Nothing
    9.  
    10. Messagebox.Show("Abra Cadabra")
    11.  
    12. 'set the image in the container to the picturebox
    13. PictureBox1.Image = myList.Images(0)

  3. #3
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: GDI+ Save Image

    well if I understand correctly, you have some things drawn in the picturebox and you want to draw some other things over that, right? if you want to do that, you can create an image from whatever you have in the picturebox, then draw on that image

    I dont have VS.NET to test it right now, hope this works fine:
    VB Code:
    1. dim bmp as bitmap
    2.  
    3. ' Originally the image property if set to nothing, when no picture is inside
    4. if myPictureBox.image is nothing then
    5.    bmp = new bitmap (myPictureBox.Width, myPictureBox.height)
    6. else
    7.    bmp = new bitmap (myPictureBox.image)
    8. end if
    9.  
    10. dim gr as graphics = graphics.fromImage(bmp)
    11.  
    12. bmp.draw....
    13. gr.dispose()  'hmm I'm not sure if this is really needed, someone tell me plz :D
    14.  
    15. myPictureBox.image = bmp

    should work
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2002
    Location
    London
    Posts
    32
    Hi MrPolit
    Thanks for your Asnwar
    Thats exacltly what I need
    I'll try that
    Thanks

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