Futurebasic/Language/Reference/usr getpict
pictHandle&, = USR GETPICT ({rect|#rectAddr&})
Description - This function captures a picture of a portion of the screen using the screen's current color depth, and returns a handle to the picture. Given the handle, you can then draw the picture (using the PICTURE statement), or save the picture as a "PICT" resource (using the ADDRESOURCE Toolbox routine), etc. The captured picture is bound by the rectangle which is specified in rect (which should be an 8-byte variable such a RECT type), or which is pointed to by rectAddr& (which should be a long-integer expression or a POINTER variable). The rectangle should be expressed in the local coordinate system of the current output window. The captured picture is also limited to the "clip region" of the current output window. Therefore, what actually gets captured is the intersection of the clip region and the specified rectangle. The captured picture is not limited to the visible contents of the window. Whatever is on the screen within the specified rectangle (and within the clip region) will get captured. By appropriately adjusting the rectangle and the clip region, you can capture any part of the screen you want.
Example:
This program captures a snapshot of the entire screen, then displays the snapshot at 1/2 scale in a small window. DIM rect.8, pt.4
sWidth = SYSTEM(_scrnWidth)
sHeight = SYSTEM(_scrnHeight)
WINDOW -1,"",(0,0)-(sWidth/2, sHeight/2), _dialogMovable
HANDLEEVENTS'Let Finder refresh things 'Get screen corner in window's local co-ord's:
CALL SETPT(pt, 0, 0)
CALL GLOBALTOLOCAL(pt) 'Define rect as entire screen, in local co-ord's:
CALL SETRECT(rect, pt.h%, pt.v%, pt.h%+sWidth,pt.v%+sHeight) 'Save window's current clip region:
oldClip& = FN NEWRGN
CALL GETCLIP(oldClip&) 'Set clip region to entire screen:
CALL CLIPRECT(rect) 'Snap entire screen:
h& = USR GETPICT(rect) 'Restore old clip region:
CALL SETCLIP(oldClip&)
CALL DISPOSERGN(oldClip&) 'Draw the little picture:
WINDOW 1'make window visible
HANDLEEVENTS'handle initial refresh event
PICTURE (0,0)-(sWidth/2, sHeight/2), h& DEF DISPOSEH(h&) DO HANDLEEVENTS UNTIL _false This LOCAL FN takes a snapshot of the current window's contents, then pastes the picture onto the clipboard. Note that if the window is hidden or partially obscured, other parts of the screen will appear in the captured picture. LOCAL FN Window2Clip
DIM rect.8 CALL SETRECT(rect, 0, 0, WINDOW(_width), WINDOW(_height)) oldClip& = FN NEWRGN'Init a new region CALL GETCLIP(oldClip&)'Save a copy of current clip region CALL CLIPRECT(rect)'Set clip region to this rectangle pictH& = USR GETPICT(rect) 'Get the picture CALL SETCLIP(oldClip&)'Restore the old clip region CALL DISPOSERGN(oldClip&) 'Don't need this copy any more LONG IF FN ZEROSCRAP = _noErr'Clear clipboard contents
CALL HLOCK(pictH&)
OSErr = ¬
FN PUTSCRAP(FN GETHANDLESIZE(pictH&),_"PICT",[pictH&])
END IF KILL PICTURE pictH&'Don't need this any more
END FN
See Also PICTURE statement