So I will explain why this works
pad = 4 - (W * 3) MOD 4
IF pad = 4 THEN pad = 0 'pad = multiple of 4
FOR R = H - 1 TO 0 STEP -1
FOR C = 1 TO W * 3 STEP 3
GET #1, R * (W * 3 + pad) + C + OF, t
tt = t + CHR$(255)
_MEMPUT a, a.OFFSET + N, tt
N = N + 4
NEXT C
NEXT R
FOR R = H - 1 TO 0 STEP -1
if say H = 768 then R is from 767 to 0 or 768 rows.
row 0 final
row 1
row 2
. . .
row 767 start
The key thing here is the final row value R = 0 so
when R = 0
0 * (W * 3 + pad) + C + OF = C + OF = the correct offset into row 0
There are (W * 3 + pad ) bytes per row. so when R = 1 then
(W * 3 + pad) + C + OF = the correct offset into row 1
with (W * 3 + pad) being the bytes in the preceding row 0
when R = 2 then
2 * (W * 3 + pad) + C + OF = the correct offset into row 2
with 2 * (W * 3 + pad) = the total bytes of row 0 + row 1
and so on.
in reality the code down counts but the offset will still work out the same