Results 1 to 5 of 5

Thread: Saving Pics Wihtout Picturebox

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2002
    Location
    America
    Posts
    14

    Saving Pics Wihtout Picturebox

    Hey All,

    I use the APi calls StretchBlt, GetDc, to grab a desktop screen and put it into a picturebox. but i want to save it directly to BMP. not first copyig it into the picturebox and then use SavePicture but just by using api calls.

    any ideas?

    TIA

    Djim

  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485
    You have to save it into a container type object because you only have the image in memory which only has the result of directions.

    To recreate it must be in a recognizable format and that info is stored in the container object as a header I think.

    To work around it with the API doesn't sound too practical 'cause in the end your going to be creating a window object with a dc anyway. Take what VB has for free or learn C++ out of spite - it's your choice, but I don't think you'll see any performance difference on this using the API or C++ anyway.

    You can always make the picBox invisible with resize + redraw = true behind the sceens if you want.

  3. #3
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    If you want you can use this class I made that handles offscreen DCs it has a save method on it aswell.
    To do what you were saying you'll need to Create a DC using the class and BitBlt to the class's DC property then run the Save method.
    VB Code:
    1. Dim MyDC As New clsOffScreenDC
    2.  
    3. 'Create New DC to work on...
    4. MyDC.CreateImage Height, Width
    5. 'BitBlt to the DC...
    6. BitBlt MyDC.DC, 0, 0, MyDC.GetWidth, MyDC.GetHeight, YourDC, 0, 0, vbSrcCopy
    7. 'Save the image...
    8. MyDC.SaveFile Filename
    9. 'Unload the class's DC...
    10. MyDC.RemoveDC
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  4. #4
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Opps, forgot to add the file.
    Attached Files Attached Files
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2002
    Location
    America
    Posts
    14
    Thanks Electroman

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