Code written for Lazarus only should not use scanline unless the same code should work on Delphi too. Use TRawImage.
When using scanline it is your responsibility to write the data in the correct order/alignment the bitmap requires. This is valid for windows too.