Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Capturing Image
#1
I want to capture a image on the screen for e.g. from 500,700 coords to 600,950 coords. How should i code it.

I saw this in the resources but Not sure how to use it
Code:
Copy      Help
/
function# x y width height [$saveToBmpFile] [int&getHbitmap]

Captures a rectangle region on the screen.
Returns: 1 success, 0 failed.

x, y, width, height - rectangle coordinates.
saveToBmpFile - will save to this bmp file. Use "" if don't want to save.
getHbitmap - int variable that receives bitmap handle. Use 0 if not needed. Later call DeleteObject.

REMARKS
Unlike <help>CaptureImageOrColor</help>, this function immediately captures the specified rectangle and does not interact with the user.
Can save the captured image to a bmp file, or get bitmap handle, or store in the clipboard.
If saveToBmpFile and getHbitmap not used, stores in the clipboard.

EXAMPLE
CaptureImageOnScreen 100 100 200 200


__MemBmp b
if(!b.Create(width height 1 x y)) ret

int r(1) action

if(!empty(saveToBmpFile)) ;;save
    action|1
    r=SaveBitmap(b.bm saveToBmpFile)
    
if(&getHbitmap and r) ;;get HBITMAP
    action|2
    getHbitmap=b.Detach
    
if(!action) ;;store to the clipboard
    r=OpenClipboard(_hwndqm)
    if(r) EmptyClipboard; r=SetClipboardData(CF_BITMAP b.Detach)!0; CloseClipboard

ret r
#2
Look in this code, there is EXAMPLE, and 1 line below it. It stores the image in the clipboard. You can use the 5-th or 6-th argument to save in a file or get HBITMAP object in memory.

The function uses width and height. If you want to use bottom-left corner coordinates, it is easy to calculate, for example:
Macro Macro2716
Code:
Copy      Help
RECT r; SetRect 500 700 600 950
CaptureImageOnScreen(r.left r.top r.right-r.left r.bottom-r.top)
#3
Gintaras Wrote:Look in this code, there is EXAMPLE, and 1 line below it. It stores the image in the clipboard. You can use the 5-th or 6-th argument to save in a file or get HBITMAP object in memory.

The function uses width and height. If you want to use bottom-left corner coordinates, it is easy to calculate, for example:
Macro Macro2716
Code:
Copy      Help
RECT r; SetRect 500 700 600 950
CaptureImageOnScreen(r.left r.top r.right-r.left r.bottom-r.top)
OMG. I was such a retard. I went to change the function. LMAO.
You're such a great help


Forum Jump:


Users browsing this thread: 1 Guest(s)