Hi,

I have an old legacy application developed by someone else many years ago that we use day to day in our business. My boss would like to update the logos and images used within the application to give it a re-vamp. I do not know what the program was written in, but I have been able to open the application in a resource viewer (Resource Hacker) and update strings and some bitmaps.

My problem however, is that the main logos are not kept with the other bitmaps. They are under the heading of RCDATA in the resource editor (example code below). Is there any way that I can update this image to our new logo? ie. what encoding does the picture.data use so that I can save our new image with that encoding and update the executable.

object Image1: TImage
Left = 0
Top = 0
Width = 417
Height = 257
Picture.Data = {
0A544A5045474.......

Cheers

Nathan

You are looking at the form resource data. Essentially, when the original program was written (in Delphi), the programmer used a TImage component in the forms designer, double clicked the Picture property in the Object Inspector, and Loaded a bitmap file (or anything else his Delphi was able to load) and stored it in the DFM file.

You can replace the image easily by starting a New Application (Win32 -- not console or anything weird), dropping a TImage component on the form, then populate the image from file. By default Delphi takes Microsoft BMP images (so your replacement image should be saved as a 24-bit BMP file). Load it so that it is displaying in the IDE on the form. Save all.

Now, go find your form's DFM file. Find the image object. It starts with the word 'object' and ends with the word 'end'. If you left all names at the default, it will look something like this:

object Image1: TImage
    Left = 136
    Top = 234
    Width = 18
    Height = 18
    Anchors = [akLeft, akBottom]
    Picture.Data = {
      07544269746D617026020000424D2602000000000000BE000000280000001200
      000012000000010008000000000068010000120B0000120B0000220000002200
      0000A4A7A400CFCFCF00D0D0D000D1D1D100D2D2D200D3D3D300D4D4D400D5D5
      D500D6D6D600D7D7D700D8D8D800D9D9D900DADADA00DBDBDB00DCDCDC00DDDD
      DD00DEDEDE00DFDFDF00E0E0E000E1E1E100E2E2E200E3E3E300E4E4E400E5E5
      E500E6E6E600E7E7E700E8E8E800E9E9E900EAEAEA00EBEBEB00ECECEC00EDED
      ED00EEEEEE00EFEFEF0000000000000000000000000000000000000000002121
      2121212121212121212121212121212100001F20202020202020202020202121
      2121212100001D1D1D1D1D1E1E1E1E1E1E1E1E1E1E1E1F1F00001B1B1B1B1B1B
      1B1B1B1C1C1C1C1C1C1C1C1C0000181819191919191919191919191A1A1A1A1A
      0000161616161616171717171717171717171718000014141414141414141414
      1515151515151515000011111112121212121212121212121313131300000F0F
      0F0F0F0F0F101010101010101010101000000D0D0D0D0D0D0D0D0D0D0D0E0E0E
      0E0E0E0E00000A0A0A0A0B0B0B0B0B0B0B0B0B0B0B0B0C0C0000080808080808
      0808090909090909090909090000050606060606060606060606070707070707
      0000030303030304040404040404040404040405000001010101010101010102
      0202020202020202000001010101010101010101010101010101010100000000
      000000000000000000000000000000000000}
    Visible = False
    ExplicitTop = 230
  end

Copy the stuff for the Picture.Data (lines 7 through 25 in my example image above). Depending on the size of the image you added, it could be a pretty long listing. Make sure you get it all.

As you've already noticed, the resource you want to modify has its image object listed the same way. Paste your new image object data in place of the old data.
Be careful that your new image has the same dimensions as the resource you are replacing -- and that you don't modify other parameters either -- unless you know exactly what you are doing. (The length of the 'object''s Picture.Data in the DFM file may vary depending on the image data.)


Now, when the modified application creates the form from the modified DFM resource data, it will use your image instead.

Hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.