This code is wrong:
procedure TPaintThread.SetAll(src: TBitmap; msk: TBitmap; img: TImage);
begin
Source := src ;
mask := msk ;
img := img ; // OOPS!
mBit := TBitmap.Create ;
end;
When you write img := img;
you are doing nothing – that is a no-op. You meant to write:
image := img;
And that's why image
is nil
in DoWritePix
which explains the access violation.
Don't be helpless when you face a runtime error. Run the code under the debugger and let the debugger tell you which variable is not initialised.