Can use PRINT and INPUT instead of PUT and GET if you prefer. Also, you can modify it to decode to an array instead of to the screen if you want to, though it would probably be more efficient to just decode to the screen and GET it to an array.
DEFINT A-Z
SUB SAVEIMG(X1, Y1, X2, Y2, file$)
OPEN file$ FOR BINARY AS #1
c=0:count=0
FOR y = Y1 to Y2
FOR x = X1 to X2
IF POINT(x,y) <> c THEN PUT #1, , count: c = c XOR 1 ELSE count = count + 1
NEXT
NEXT
CLOSE #1
END SUB
SUB LOADIMG(X1, Y1, X2, Y2, file$)
OPEN file$ FOR BINARY AS #1
c=0:count=0
FOR y = Y1 to Y2
FOR x = X1 to X2
IF count=0 THEN GET #1, ,count: c = c XOR 1 ELSE PSET(x,y): count=count-1
NEXT
NEXT
END IF
|