Converting to D2009: How to keep PNGs in TImage


if you have been using Gustavo Daud’s PNGImage before and consider migrating existing projects to D2009 you must keep in mind that you will loose all previously assigned PNGs in your TImages.

As you all know Delphi 2009 ships with native PNG support but there are some differences. In PngImage.pas CodeGear declared

  TPNGObject = TPngImage deprecated 'Use TPngImage.';

So the classname for PNGs changed and the old one is marked as deprecated.

The problem: All TImage pictures are stored within the form’s .DFM file. Before inserting the binary data the IDE stores the classname (and it’s length) as a prefix to the data.

When using Gustavo’s component in D2006 it will store 0A54504E474F626A656374 which is in ASCII TPNGObject (the 1st 0A is the length of the following classname). In Delphi 2009 it stores 0954506E67496D616765 which is in ASCII TPngImage (again 09 is the length).

So when opening an existing form in D2009 the IDE searches for TPNGObject classname and as it cannot find it anymore the images are emptied.

With the help of Andreas Hausladen I came up with a solution for this:


  Classes, Graphics, PngImage;

  TPngObject = class(TPngImage);


  TPicture.RegisterFileFormat('PNG', 'Portable Network Graphics (Compatibility Wrapper)', TPngObject);

After discussing the issue Uwe Raabe yesterday published a fix inside of the PngComponents for Delphi 2009.

He used:

  TPNGObject = class(TPngImage);

  TPicture.RegisterFileFormat('', '', TPNGObject);

The empty strings will help to hide the wrapper from the FileOpen Dialog within the filter selection in the IDE.

An updated version if his port of the PngComponents for D2009 is available at CG:
PngComponents for Delphi 2009

Btw: The PngComponents Uwe published is still compatible with older Delphi Versions (tested with Delphi 2006). Only the PngImage Gustavo previously released on SourceForge is not available anymore as the license has been revoked as D2009 now ships with an enhanced version of it.


18 thoughts on “Converting to D2009: How to keep PNGs in TImage

  1. Thanks for this article. I would like someone to elaborate on the implications for us all of “open source” type licences being revoked. What implication does it have for existing users who do not upgrade and what impications are there in general for any “open source” software /source code you might have downloaded from source forge or other sites if a company can come along and buy up the rights to the software. Thanks, Richard

  2. Hi Richard,

    > Thanks for this article.

    You’re welcome!

    I generally agree with your thoughts about open source licenses being revoked.

    As far as I know regarding PNGImage there are two things to mention:

    1) PngImage was never really “open source” but had been released under some kind of proprietary freeware license in the past. So there might be a difference for the latter – but this is also depending on user’s legislation.

    2) I have been told that CodeGear still allows usage of existing copies. Publishing the library itself is not allowed anymore. They are actually trying to remove existing copies on the Internet (e.g. the message posted at Microsoft’s CodePlex

    An interesting aspect is the release of open source applications being developed in Delphi. As a fact the same happened to the TntUnicode components as Troy gave (sold) them to TMS Software: Imagine the well-known MySQL Admin Tools. It has been open source, written in Delphi and it used TntUnicode. And then? There are still copies of TntUnicode available but the license has been revoked in a comparable way – only Troy and/or TMS are not trying to remove them from the Internet…

    Best regards

  3. Hi Arvid,

    After I read your article, I am excited and downloaded the PngComponents for D2009. But I have no luck installing it’s packages (*.dpk).

    When I use D2009 install package, it said invalid package.

    How did you install it? Could you please share?


  4. Hi Steve,

    I don’t see such problems here. Be sure to use Uwe’s Version from

    Then first compile PngComponents.dpk and afterwards compile and install the design-time package called PngComponentsDesign.dpk. Both files are located in the PackagesD2009 folder of PngComponents.

    Feel free to post your full error message here!


  5. Thank you…

    I have this problem: when I try to load PNG Image (TPngBitBtn & TPngSeepdButton) I get this error:

    Invalid graphic format

    [20AE8998]{designide120.bpl} PicEdit.TGraphicProperty.Edit (Line 272, “PicEdit.pas” + 10) + $12
    [207ABC62]{coreide120.bpl} PropInsp.TPropertyInspector.PropListEditDblClick (Line 883, “PropInsp.pas” + 20) + $5
    [20BA7451]{vclide120.bpl} IDEInspListBox.TInspListBox.DoEditDblClick (Line 976, “IDEInspListBox.pas” + 2) + $A
    [20BA91E7]{vclide120.bpl} IDEInspListBox.TInspListBox.ListButtonClick (Line 1665, “IDEInspListBox.pas” + 2) + $2
    [501C5BC3]{vcl120.bpl } Controls.TControl.Click (Line 6758, “Controls.pas” + 9) + $8
    [20B9E306]{vclide120.bpl} IDEListBtns.TListButton.WMLButtonUp (Line 582, “IDEListBtns.pas” + 8) + $11
    [501C565A]{vcl120.bpl } Controls.TControl.WndProc (Line 6642, “Controls.pas” + 91) + $6
    [10F43BE9]{cxLibraryD12.bpl} Cxcontainer.TcxCustomInnerListBox.CNDrawItem + $691
    [50006D40]{rtl120.bpl } System.TObject.GetInterface (Line 10013, “System.pas” + 8) + $A
    [501C95F3]{vcl120.bpl } Controls.TWinControl.IsControlMouseMsg (Line 9121, “Controls.pas” + 1) + $9
    [501C9CE7]{vcl120.bpl } Controls.TWinControl.WndProc (Line 9336, “Controls.pas” + 136) + $6
    [501C9400]{vcl120.bpl } Controls.TWinControl.MainWndProc (Line 9065, “Controls.pas” + 3) + $6
    [500591DC]{rtl120.bpl } Classes.StdWndProc (Line 12703, “Classes.pas” + 8) + $0
    [50062E92]{rtl120.bpl } Contnrs.TComponentList.GetItems (Line 380, “Contnrs.pas” + 1) + $4
    [501EEABD]{vcl120.bpl } Forms.TApplication.ProcessMessage (Line 9660, “Forms.pas” + 30) + $1
    [501EEB02]{vcl120.bpl } Forms.TApplication.HandleMessage (Line 9690, “Forms.pas” + 1) + $4
    [501EEE2D]{vcl120.bpl } Forms.TApplication.Run (Line 9827, “Forms.pas” + 26) + $3
    [004259DA]{bds.exe } bds.bds (Line 198, “” + 8) + $FFFB

  6. Hi Daniel,

    > Thank you…
    You’re welcome!

    > I have this problem: when I try to load PNG Image (TPngBitBtn &
    > TPngSeepdButton) I get this error:
    > Invalid graphic format

    Looks like you have another package conflicting with the PNG format used by the Speed and BitBtn. Probably something e.g. from DevExpress or Envision which registered their own PNG handler.

    I worked around such issues by manually editing the DFM source and replacing the header mentioned above to fit “TPngImage”.

    Try with a clean D2009 installation. It will work!


  7. Im having issues installing this into Delphi 2009 as well. Its a fresh install with only a couple of additional packages that I have added (in house built ones).

    I open up the first PngComponents.dpk file, compile it and then open up the second, compile it, but then I can’t get any further as I get an error message…

    [DCC Fatal Error] PngComponentsDesign.dpk(34): E2202 Required package ‘PngComponents’ not found

  8. Hi,


    I verified the download from CodeCentral ( and didn’t encounter such issues.

    Before the Designtime Package can be installed you need to build the Runtime Package – like you did. Did you receive any errors or messages on building the Runtime Package (PngComponent.dpk)?

    Anyway I am quite sure this is not related to the component package provided by Uwe Raabe as this is basic Delphi IDE behaviour…

    Good luck, and feel free to post or mail your results back!

    Best regards,

  9. Hi and thanks for your work, I’m trying to upgrade my app from D7 to D2009, and I encounter a problem with PngComponent. I have installed your fixed version which works well at design time (I haven’t lost any image or imagelist), but some EReadError exceptions are raised at runtime : ” EReadError : Bitmap property does not exist”. This occurs on the TPngImageList objects and when I look at dfm files I see a “Bitmap = {}” property at the end of my IL definition. I have tried to remove them manually but D2009 re-insert it as soon as I open my forms.

    Any idea ?

    Thanks for your GREAT work.

  10. I’m unable to add an item in the tpngbitbnt control 😦

    Invalig Graphic Format

    [20DCC9A0]{designide140.bpl} PicEdit.TGraphicProperty.Edit (Line 272, “PicEdit.pas” + 10) + $12
    [03656F48]{PngComponentsDesign140.bpl} Pngcomponenteditors.TEditProperty.EnumProperty + $34
    [20D99AC3]{designide140.bpl} DesignEditors.GetComponentProperties (Line 2645, “DesignEditors.pas” + 95) + $23
    [03656EC5]{PngComponentsDesign140.bpl} Pngcomponenteditors.TEditProperty + $81
    [03656B19]{PngComponentsDesign140.bpl} Pngcomponenteditors. + $0
    [03656DE1]{PngComponentsDesign140.bpl} Pngcomponenteditors.TPngButtonEditor.ExecuteVerb + $31
    [519EBCA2]{vcldesigner140.bpl} VCLSurface.TVclDesignSurface.ComponentVerb (Line 2503, “VCLSurface.pas” + 3) + $B
    [502801CB]{vcl140.bpl } Menus.TMenuItem.Click (Line 2520, “Menus.pas” + 19) + $8
    [50281787]{vcl140.bpl } Menus.TMenu.DispatchCommand (Line 3383, “Menus.pas” + 5) + $2
    [50282966]{vcl140.bpl } Menus.TPopupList.WndProc (Line 4489, “Menus.pas” + 4) + $E
    [501D2A86]{vcl140.bpl } Graphics.FreeMemoryContexts (Line 6935, “Graphics.pas” + 12) + $F
    [50299D60]{vcl140.bpl } Controls.TWinControl.MainWndProc (Line 9540, “Controls.pas” + 3) + $6
    [502828B5]{vcl140.bpl } Menus.TPopupList.MainWndProc (Line 4464, “Menus.pas” + 2) + $5
    [50076360]{rtl140.bpl } Classes.StdWndProc (Line 13014, “Classes.pas” + 8) + $0
    [502C8749]{vcl140.bpl } Forms.TApplication.ProcessMessage (Line 9784, “Forms.pas” + 30) + $1
    [502C878E]{vcl140.bpl } Forms.TApplication.HandleMessage (Line 9814, “Forms.pas” + 1) + $4
    [502C8AB9]{vcl140.bpl } Forms.TApplication.Run (Line 9951, “Forms.pas” + 26) + $3
    [0043094A]{bds.exe } bds.bds (Line 200, “” + 8) + $12FFB

    Any idea?

  11. After lots of experiments, I’ve fou the package that was confliting with the PNGComponents… GExperts!

    I don’t know exactly why, but I’ll try to find out or contact them directly.

  12. @João Santos

    Hi João,

    thank you for your comments. I didn’t experience such problems but I didn’t try PngComponents together with GExperts on D2010 yet – with D2009 it’s working fine here.

    Have you tried a clean installation just with PngComponents to see if it works? And right after installing GExperts the TPngBitBtn fails?

    Be sure to post a follow-up!

    Cheers and good luck,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s