Here you go.
1. Open your project
2. click on the image, so that it gets selected in the object inspector.
3. in the object inspector, click on the events tab
4. search for the event OnPaint
5. double click the event, a new event will be added to your code
6. copy your code from your (old) function Image1Paint into the new event function
7. remove the old image1paint code/function
8. save your project
9. compile and run your project
Does it now work for you ?