richrock316
Programmer
Hi,
I've been using some code previously written by Hypetia (thanks Hypetia) to capture the screen image and export it to a bitmap. It has been working great, but now my specs have changed. I need to crop the picture to include only part of the screen. Ive got it so that it eliminates the unnecessary part of the screen when I want to but it leaves a large blank space. Think of it as 2 images side by side, you erase te right one, but you then have half the space being wasted, which sucks when you are creating a BMP. How do I eliminate the unwanted portion?.
Here is the code
v
Function CaptureImage(hwnd As Long, which_save As String) As Picture
Dim hdc As Long, R1 As RECT, R2 As RECT
Contact.Picture1.AutoRedraw = True 'Added 07/25/05 otherwise gives incomplete picture
GetWindowRect hwnd, R1
R2 = R1
hdc = GetWindowDC(hwnd)
ScreenToClient hwnd, R2
If which_save = "whole_screen" Then
BitBlt Picture1.hdc, 0, 0, R1.Right - R1.Left, R1.Bottom - R1.Top, hdc, -R2.Left, -R2.Top, vbSrcCopy
Else
'Here is where the partial screen comes up
BitBlt Picture1.hdc, 0, 0, 570 / screen_res, 550 / screen_res, hdc, -R2.Left, -R2.Top, vbSrcCopy
End If
ReleaseDC hwnd, hdc
Set CaptureImage = Picture1.Image
End Function
thanks
Richard
I've been using some code previously written by Hypetia (thanks Hypetia) to capture the screen image and export it to a bitmap. It has been working great, but now my specs have changed. I need to crop the picture to include only part of the screen. Ive got it so that it eliminates the unnecessary part of the screen when I want to but it leaves a large blank space. Think of it as 2 images side by side, you erase te right one, but you then have half the space being wasted, which sucks when you are creating a BMP. How do I eliminate the unwanted portion?.
Here is the code
v
Function CaptureImage(hwnd As Long, which_save As String) As Picture
Dim hdc As Long, R1 As RECT, R2 As RECT
Contact.Picture1.AutoRedraw = True 'Added 07/25/05 otherwise gives incomplete picture
GetWindowRect hwnd, R1
R2 = R1
hdc = GetWindowDC(hwnd)
ScreenToClient hwnd, R2
If which_save = "whole_screen" Then
BitBlt Picture1.hdc, 0, 0, R1.Right - R1.Left, R1.Bottom - R1.Top, hdc, -R2.Left, -R2.Top, vbSrcCopy
Else
'Here is where the partial screen comes up
BitBlt Picture1.hdc, 0, 0, 570 / screen_res, 550 / screen_res, hdc, -R2.Left, -R2.Top, vbSrcCopy
End If
ReleaseDC hwnd, hdc
Set CaptureImage = Picture1.Image
End Function
thanks
Richard