Ah now I see the issue, too...
It looks as if the line drawn onto the Image.Canvas becomes transparent. Well, in fact it is: I loaded the lazarus cheetah.jpg at designtime and it becomes as 32-bit bitmap. The 32-bit value of clBlue is $00FF0000 - the left-most zeros are the alpha channel, alpha=0 means: fully transparent...
I do not see a different behavior between loading the image at designtime and runtime. (Maybe because i am on Windows, and you, Handoko, are not?).
The attached demo loads the Lazarus cheetah into two images, one at designtime, the other one at runtime.
- When I press button (2) the blue line is drawn across both images. BUT: When you do the minimize/restore trick the blue line will be gone.
- When I press button (1) first (which calls ScanLine), then button (2), the line is drawn again, but now it is transparent as I tried to explain. Now the line is persistent, i.e. the minimize/restore trick has no effect.
I must say that I do not understand what TImage is doing here when the ScanLine of the loaded Bitmap is called (I said: TImage is too complex...). And I somehow refrain from trying to understand it more deeply because painting in OnClick is wrong anyway.