DECLARE SUB SaveBMP (X1%, Y1%, X2%, Y2%, filename$)
REM $INCLUDE: 'future.bi'

set320x200 8

file$ = "test.bmp"

Future.box 100, 100, 150, 150, 15
Future.fillbox 101, 101, 149, 149, 1


SaveBMP 100, 100, 150, 150, file$


resetscreen

SUB SaveBMP (X1%, Y1%, X2%, Y2%, filename$)
'saves part of the screen to bmp

Xsize% = ABS(X2% - X1%) + 1
Ysize% = ABS(Y2% - Y1%) + 1

handle% = AllExpMem(SizeOf(Xsize%, Ysize%))

Future.EMSget X1%, Y1%, X2%, Y2%, handle%

DefineEMSbufferSize handle%, Xsize% - 1, Ysize% - 1, 0

Future.Snapshot filename$

DeallExpMem handle%

SetPage 0

END SUB

