|
-
Dec 23rd, 2001, 07:09 AM
#1
Thread Starter
Member
Placing graphic in clipboard to screen?
Ok...I have found 1000's of pages with info on how to copy the screen, the whole screen and nothing but the screen (well, bitmaps too) to the clipboard. But I can't find a single thing about putting what is in the clipboard BACK onto the screen.
What I did was modify some code which created a transparent bmp and placed it on the clipboard. Now I want to put that modified bmp back onto the screen. How can I do this? Does the clipboard have a DC that I can get somehow?
Now the world is gone I'm just one...
-
Dec 23rd, 2001, 07:58 PM
#2
Thread Starter
Member
Ok...I've got it so I can put images to the screen, save them as jpgs and whatnot. Now, my problem lies within starcraft. I'm trying to capture images from the game without using its whole screen capture, but they're coming out extremely dark...like completely black 99% of the time. I tried capturing in Counter-Strike, and the images came out fine.
Any ideas? Is SC just so old and screwed up that it doesn't like external programs capturing it, or what?
Here is the function I use to get an image:
Code:
Public Function xGet(ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal Width As Long, ByVal Height As Long) As IPictureDisp
Dim targetDC As Long
Dim hdc As Long
Dim tempPict As Long
Dim oldPict As Long
Dim wndWidth As Long
Dim wndHeight As Long
Dim Pic As PICTDESC
Dim rcWindow As RECT
Dim guid(3) As Long
' provide the right handle for the desktop window
If hwnd = 0 Then hwnd = GetDesktopWindow
' get window's size
GetWindowRect hwnd, rcWindow
wndWidth = Width
wndHeight = Height
' get window's device context
targetDC = GetWindowDC(hwnd)
' create a compatible DC
hdc = CreateCompatibleDC(targetDC)
' create a memory bitmap in the DC just created
' the has the size of the window we're capturing
tempPict = CreateCompatibleBitmap(targetDC, wndWidth, wndHeight)
oldPict = SelectObject(hdc, tempPict)
' copy the screen image into the DC
BitBlt hdc, 0, 0, wndWidth, wndHeight, targetDC, x, y, vbSrcCopy
' set the old DC image and release the DC
tempPict = SelectObject(hdc, oldPict)
DeleteDC hdc
ReleaseDC GetDesktopWindow, targetDC
' fill the ScreenPic structure
With Pic
.cbSize = Len(Pic)
.pictType = 1 ' means picture
.hIcon = tempPict
.hPal = 0 ' (you can omit this of course)
End With
' convert the image to a IpictureDisp object
' this is the IPicture GUID {7BF80980-BF32-101A-8BBB-00AA00300CAB}
' we use an array of Long to initialize it faster
guid(0) = &H7BF80980
guid(1) = &H101ABF32
guid(2) = &HAA00BB8B
guid(3) = &HAB0C3000
' create the picture,
' return an object reference right into the function result
OleCreatePictureIndirect Pic, guid(0), True, xGet
End Function
Then in my form when the button is pressed, I have this:
Code:
Private Sub getImage_Click()
Dim wide, high As Long
Dim x, y As Long
wide = CLng(txtWidth.Text)
high = CLng(txtHeight.Text)
x = CLng(txtX.Text)
y = CLng(txtY.Text)
Picture1 = xGet(CLng(lblHandle.Caption), x, y, wide, high)
End Sub
Private Sub saveImage_Click()
Dim cdibpic As New cDIBSection
Dim FileName As String
FileName = "test.jpg"
cdibpic.CreateFromPicture Picture1.Picture
SaveJPG cdibpic, FileName, 70
End Sub
Now the world is gone I'm just one...
-
Dec 23rd, 2001, 07:59 PM
#3
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
|