Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Loading a PNG file into a TImage at design time

1 view
Skip to first unread message

Ross McMillan

unread,
Jul 26, 2007, 10:53:00 PM7/26/07
to
I downloaded and installed PngComponents into BDS2006. I have a
TPageControl with several tabsheets and I want to place a PNG image on each
tabsheet.

I drop a TImage onto the Tabsheet and set the Picture property to my PNG
file. No problems so far. I can see the image on the tabsheet and it knows
about the transparency. I compile and run and the app displays the images
as expected.

I can switch to another project and back to this one and everything still
works.

However If I exit Delphi and start up again, when the form is loaded all the
PNG images have gone from the form! The TImage picture property is set back
to (None) and the Transparent property changed from True to False.

I have

uses
PngImages

in my uses clause, which was apparently added by Delphi..

I note that PngComponents uses PngImages but there is a newer version of
PngImages than the one he is using around.

TIA,
Ross


Remy Lebeau (TeamB)

unread,
Jul 27, 2007, 2:23:16 AM7/27/07
to

"Ross McMillan" <nos...@gmail.com> wrote in message
news:46a9...@newsgroups.borland.com...

> I downloaded and installed PngComponents into BDS2006.
> I have a TPageControl with several tabsheets and I want
> to place a PNG image on each tabsheet.

PngComponents has its own TPngImageList component. You should use that to
store your images, and then assign them to the TImage at runtime when
needed.

> I drop a TImage onto the Tabsheet and set the Picture property to my PNG
> file. No problems so far. I can see the image on the tabsheet and it
knows
> about the transparency. I compile and run and the app displays the images
> as expected.

> However If I exit Delphi and start up again, when the form is


> loaded all the PNG images have gone from the form! The
> TImage picture property is set back to (None) and the
> Transparent property changed from True to False.

The Png TGraphic class was likely not registered yet when the DFM was
streamed, so TImage didn't know how to handle the stored data.


Gambit


Ross McMillan

unread,
Jul 27, 2007, 3:05:15 AM7/27/07
to

"Remy Lebeau (TeamB)" <no....@no.spam.com> wrote in message
news:46a98ff9$1...@newsgroups.borland.com...

>
> PngComponents has its own TPngImageList component. You should use that to
> store your images, and then assign them to the TImage at runtime when
> needed.

I am using TPngImageList successfully already. It seems to have no problems.
These images are all different sizes so presumably I can use
TPngImageCollection. How do I assign?

Image1.Picture := PNGImageCollection.Items [0]

I remember as giving a comile error.

Thanks.
Ross


0 new messages