|
-
Oct 2nd, 2001, 12:02 AM
#1
Thread Starter
Lively Member
getting binary code from a screenshot
ok, im using the following code to get a screenshot....
Dim lngScreenDC As Long
Dim lngScreenH As Long, lngScreenW As Long
Dim lngDC As Long
Dim lngBMP As Long, lngOrigBMP As Long
lngScreenDC = GetDC(GetDesktopWindow())
lngScreenH = Screen.Height \ Screen.TwipsPerPixelY
lngScreenW = Screen.Width \ Screen.TwipsPerPixelX
lngDC = CreateCompatibleDC(lngScreenDC)
lngBMP = CreateCompatibleBitmap(lngScreenDC, lngScreenW, lngScreenH)
lngOrigBMP = SelectObject(lngDC, lngBMP)
BitBlt lngDC, 0, 0, lngScreenW, lngScreenH, lngScreenDC, 0, 0, vbSrcCopy
SelectObject lngDC, lngOrigBMP
DeleteDC lngDC
---------------------
now... how would i go about getting the binary code for the bitmap .... cuz i want to compress that code... so it can be sent over winsock more quickly.... also if anyone has any good compression code i could use..... that would be useful as well.
-
Oct 3rd, 2001, 07:57 AM
#2
Member
Public Sub GetScreen()
keybd_event VK_SNAPSHOT, 1, 0, 0
DoEvents
SavePicture Clipboard.GetData(vbCFBitmap), "C:\curdesk.bmp"
DoEvents
End Sub
//The DoomBringer
System dump?... a dump of systems?
-
Oct 3rd, 2001, 06:33 PM
#3
Fanatic Member
Once you use BitBlt() to copy the screen into your DC, make a dummy bitmap with CreateCompatibleBitmap() with your DC again, and put it into the DC with SelectObject(), saving the return (which is your screen bitmap). Once they're separate, you should be able to use GetDIBits() to get the actual bit data from the bitmap, which will go into a byte array. I believe GetDIBits() expects the bitmap it will be operating on to not actually be in DC, which is why I said to separate it. I can't recall at the moment what MSDN said about that though. After you use that though, you should be able to compress that byte array. Then on the other side, decompress, and use SetDIBitsToDevice() to put the bitmap back into a DC.
Now, given all of that, it might be easier to just use the simple file saving way, open the file in binary, stuff a byte array, and then compress. On the other side, decompress, write the file, and reload where you want it. There's a lot less involved in doing it that way than with all of the GDI APIs I first mentioned.
Last edited by Kaverin; Oct 3rd, 2001 at 06:37 PM.
I'm baaaack...
VB5 Professional Edition, VC++ 6
Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se
I feel special because I finally figured out how to loop midis: Post link
I'm a fanatic too 
-
Oct 6th, 2001, 10:13 AM
#4
Hyperactive Member
An alternative
Goto www.vbaccelerator.com
Search for CDibSection.
It represents a DibSection that lets you access the the Binary Data in a two Dimensional Byte Array.
Use BitBlt or PaintPicture to copy the data into the DibSection.
You should see explanations of how to use the class on that site.
So far I remember, there is a single API function that performs copying the desktop into memory.
Search the API Intensive Sites.
Abu Haider
____________________________
100% Data Validation for the MS DataGrid Control. Plus Support for Custom and Foreign Lists, DatePicker and much more...
The DataGridEnhancer
I often point to a place where the problem has been discussed, instead of giving you the code that solves it. This is for good, may be you will understand some day...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|