PNG Support for Delphi 7

kylestimpson013
kylestimpson013 used Ask the Experts™
on
Hi,

I have been trying for days now to get PNG support in Delphi 7 and have had no luck. Please can someone explain to me, how exactly I go about this as I am fairly new to Delphi programming.

Basically I need to insert images that have transparent backgrounds into my form.

Any help will be much appreciated.

Thanks
Kyle
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2011

Commented:
You can use GraphicEx from Soft Gems.

Commented:
to add support of PNG to Delphi 7 use class TPNGImage
http://www.vahac.com.ua/downloads/TPNGImage.zip 
Commented:
if you need PNG support in the IDE you can create a package.
follow these instructions:

1) download pngimage from here;
2) unzip the files somewhere, eg. C:\pngimage
3) go to that directory, create a text file named pngimage_D7.dpk, edit it with notepad and insert the following listing into it:
package pngimage_D7;

{$R *.res}
{$ALIGN 8}
{$ASSERTIONS ON}
{$BOOLEVAL OFF}
{$DEBUGINFO ON}
{$EXTENDEDSYNTAX ON}
{$IMPORTEDDATA ON}
{$IOCHECKS ON}
{$LOCALSYMBOLS ON}
{$LONGSTRINGS ON}
{$OPENSTRINGS ON}
{$OPTIMIZATION ON}
{$OVERFLOWCHECKS OFF}
{$RANGECHECKS OFF}
{$REFERENCEINFO ON}
{$SAFEDIVIDE OFF}
{$STACKFRAMES OFF}
{$TYPEDADDRESS OFF}
{$VARSTRINGCHECKS ON}
{$WRITEABLECONST OFF}
{$MINENUMSIZE 1}
{$IMAGEBASE $400000}
{$DESCRIPTION 'PNG Image Package'}
{$IMPLICITBUILD OFF}

requires
  rtl,
  vcl;

contains
  zlibpas in 'zlibpas.pas',
  pngextra in 'pngextra.pas',
  pngimage in 'pngimage.pas',
  pnglang in 'pnglang.pas';

end.

Open in new window

4) save the file; start Delphi; open the project pngimage_D7.dpk and click install; it should say a new component has been added.
5) make sure C:\pngimage (or whereever you unzipped the files) is on your library search path (tools / environment options / library / library path).

voilà. Delphi can load PNG files in the IDE too (eg. in TImage objects dropped on a form).
the required pngimage unit is automatically added whenever needed.
cheers - Lorenzo -

Author

Commented:
Thank you for all the responses.

I tried all 3 solutions posted but the instructions included with the downloads are not very clear at all, in the end the best solution was posted by lomo74 and worked like a charm on the first attempt.

Thank you so much!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial