; GrabImage Example ; ----------------- Graphics 640,480,0,2 SetBuffer BackBuffer() ; A colourful photo to grab pieces from logo=LoadImage("media/b3dlogo.jpg") ; GrabImage needs an existing image to grab INTO - its size (100x100) ; decides how much of the buffer is grabbed stamp=CreateImage(100,100) grabbed=0 While Not KeyDown(1) Cls DrawImage logo,120,140 ; Keep the grab region fully on screen gx=MouseX()-50 gy=MouseY()-50 If gx<0 Then gx=0 If gx>540 Then gx=540 If gy<0 Then gy=0 If gy>380 Then gy=380 ; Space grabs the boxed region of the back buffer into the stamp image If KeyHit(57) Then GrabImage stamp,gx,gy grabbed=1 End If ; Box the region that would be grabbed Color 255,255,0 Rect gx,gy,100,100,False ; Show the grabbed image in the corner once we have one If grabbed=1 Then DrawImage stamp,530,10 Color 255,255,255 Rect 530,10,100,100,False Text 580,114,"grabbed",True End If Text 0,0,"Space: grab the boxed region Esc: exit" Text 0,20,"GrabImage stamp,"+gx+","+gy Flip Wend End