Results 1 to 8 of 8

Thread: Saving A Picture

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Saving A Picture

    How do I save a Picture that I BitBlt'd on?

    I can save a picture that I printed on by using Picture1.Image but this doesn't work for BitBlt


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  2. #2
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492

    Re: Saving A Picture

    VB.NET MVP 2008 - Present

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Saving A Picture

    Doesn't give me a clue, not even close

    The only remark given was to use SavePicture but that I have already tried and only the picture is saved whether I use Picture1.Picture or Picture1.Image but not anything that was BitBlt'd on it

    It will, however save anything that was printed on it like text from using Picture1.Print


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  4. #4
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Saving A Picture

    Not sure if this would be of use or not?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  5. #5
    Fanatic Member
    Join Date
    Aug 2013
    Posts
    806

    Re: Saving A Picture

    1) If you haven't already, set the Picture box's AutoRedraw property to True.
    2) In your code, add the line "Picture1.Picture = Picture1.Image" just before your SavePicture call.
    3) In the actual SavePicture call, use the .Picture property, e.g. SavePicture Picture1.Picture, "C:\filename.bmp"

    When applying any GDI API calls (BitBlt, SetPixel, StretchDIBits, etc) to a picture box, you must always set the picture box's .Picture equal to its .Image before using internal VB functions like SavePicture.

  6. #6
    Fanatic Member
    Join Date
    Aug 2013
    Posts
    806

    Re: Saving A Picture

    Make sure you set the picture box's .AutoRedraw property to true *before* using BitBlt. (Unless you have reason to do otherwise, set .AutoRedraw to True at design-time.)

    If you do that, does it solve the problem?

    Also, I know it's obvious, but do you have both the picture box and user control .ScaleMode properties set to "3 - Pixel"?

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Saving A Picture

    OMG! Yes, it works. Why it never entered my mind to set AutoRedraw to True before BitBlt'ng I don't know. I'm so stupid at times

    EDIT: I inadvertently deleted my previous post


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  8. #8
    Fanatic Member
    Join Date
    Aug 2013
    Posts
    806

    Re: Saving A Picture

    Nothing stupid about it! Those kind of bugs hit everyone at some point.

    I do a lot of work with graphics in VB, and I have found those steps above (.AutoRedraw = True, do all your API graphics, PictureBox.Picture = PictureBox.Image) to be pretty much foolproof. Also, I really would recommend setting .AutoRedraw to True at design-time. It can save you the headache of tracking down annoying bugs like this one.

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