I will try to provide a walkthrough for those that may have no idea on how to to this or just want to get done with this as fast as possible.
This is how I changed the embedded images on the code, just as the OP showed on the question.
Note: The accepted answer that says that XN Resource Editor can understand Delphi TImage, this seems to be wrong or may not always work!
You will need the following free software:
You may also need image editors, there's free software options:
Finding out which image is to be replaced
If the program has many images, you can find out which is the correct image by following these steps:
- Make a backup copy of the original executable (.exe) file.
- Using a resource editor, open the original executable (.exe) file containing the image you want to replace.
- For every image you find under RCData, check the image size and other details, this can give you the correct image right away or at least reduce your scope. If you are looking for a huge image for example, you will just ignore small images.
- Remove all image data, just delete all that is between brackets under the Picture.Data property so it would look like Picture.Data = {} and compile the script with the Resource editor and save the exe with the changes.
- Execute the application, if the image you want to replace is missing during program execution, then you know that the image data you just removed is the image you want to replace.
You can also check which image is the correct by replace the image with another one, like a blank image, but then you would have to embed the image first into another Delphi program, and the copy and paste the image data from the new application into your own application, see bellow.
Changing the image
- Open the Lazarus IDE, as soon as it opens it should already present you with a new desktop application, including a form (Form1).
- Create a new TImage on the form (Form1) and then choose an image file by selecting the new TImage and on the Objects inspector window selecting the Picture property and then clicking on the three dots button [...]. After loading the image, it should appear on the form. The image size and other properties are not important.
- Save your Delphi application project with the new image somewhere and compile it.
- Using the resource editor, open both the original executable (.exe) file containing the image you want to replace, and the executable (.exe) you just compiled using Lazarus.
- Browse on the new compiled executable (RCData -> TFORM1) and you should locate the new image data under Picture.Data, copy everything between the brackets in Picture.Data and paste on the Picture.Data of the original executable.
- Now that the original executable, has the new image data, compile the script with the Resource editor and save the exe with the changes.
- Run the application and check if the image has been replaced successfully.
Note: Applications may only accept a specific image file format, if the image you used on Lazarus is a .png image and your original executable didn't show anything after replacing the TImage Picture.Data, then this may be the problem. You can try using a .bmp on Lazarus and then copying the .bmp Picture.Data to your original application.