Click to See Complete Forum and Search --> : Saving Pics Wihtout Picturebox
Djim
Jan 30th, 2003, 03:04 PM
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
joey o.
Jan 31st, 2003, 11:54 AM
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.
Electroman
Jan 31st, 2003, 03:27 PM
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.
Dim MyDC As New clsOffScreenDC
'Create New DC to work on...
MyDC.CreateImage Height, Width
'BitBlt to the DC...
BitBlt MyDC.DC, 0, 0, MyDC.GetWidth, MyDC.GetHeight, YourDC, 0, 0, vbSrcCopy
'Save the image...
MyDC.SaveFile Filename
'Unload the class's DC...
MyDC.RemoveDC
Electroman
Jan 31st, 2003, 03:28 PM
Opps, forgot to add the file.
Djim
Feb 2nd, 2003, 03:47 AM
Thanks Electroman
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.