This is happening because you have Proportional property set to true.
What Proportional
property does is it shrinks the image in order to fit the control while maintaining the aspect ration. But if the size of TImage
is larger than the dimensions of the picture the picture never gets stretched in order to fit the TImage
control.
And since picture position within TImage
control is always aligned to top left corner and you are changing the position of your TImage
control it seems as the image starts moving in left and up direction.
How to solve this? Instead of setting Proportional
property to True
set the Stretch property to True
.
However you will need to make sure that you adjust the Width
and Height
of your TImage
in order to maintain aspect ratio of the loaded picture. After that your code will work just nicely.
How do you do this? Check the FormCreate
event method in the SO answer you got your code from.