Jump to content
bazzer747

A Strange thing with TImage

Recommended Posts

Hi,

I came across an oddity a few days ago in a report I had created some years ago (this was with Ace Reporter). This report had a jpg image which I wanted to replace with a png image. I deleted the image from the report then placed a TSctImageLabel (the equivalent of a TImage the reporter requires for inserting images). Problem was, whilst the 'Picture' property was there with the 3 dots ready for selection of an image, it was sort of greyed out, in that I couldn't click on the dots. I thought this might be an issue with the report component (and have put in a support request to them).

 

However, today, on a different project, I had need to insert an image onto a form. Lo and behold, when I added a TImage to the form the 'Picture' property behaved the same way. I couldn't select an image. I've now also created a new VCL project and just added a TImage and can't select an image.

 

I can load the image I want successfully from code with: Image1.Picture.LoadFromFile('D:\logo3.png'); - setting whatever properties I want from the object inspector. But I really need this image 'included' in the executable and not have to distribute it with the exe.

 

Could this be a problem with my Delphi installation (I use 10.4.1 with all patches applied), or the TImage itself? Or have I messed up somewhere (even I think this is most likely! but I can't see how)

Share this post


Link to post

Since the TImage.Picture property is operating correctly at run-time, this sounds like it is just a design-time issue.  I'm guessing that maybe a 3rd party package has registered its own design-time editor for TPicture that is interfering with the IDE's native TPicture editor.  I would suggest turning off all non-essential packages and see if the problem goes away.

 

If you can't solve the design-time issue, there is a run-time workaround.  You can store the PNG in the app's resources at compile-time, then use a TResourceStream to load it into the TImage.Picture at run-time via TPicture.LoadFromStream() or TPngImage.LoadFromStream().  At least that way you don't have to distribute the PNG as a separate file.

Edited by Remy Lebeau

Share this post


Link to post

Got it! 

 

I have been systematically removing add-ons and testing the TImage 'Picture' property.

 

In a recent webinar Embarcadero were giving a 'free' component from Dev Express - a VCL NavBar toolbar component. Whiuch I downloaded and tried, very nice it was. However, as soon as I removed the DevExpress component TImage worked OK.

 

I've informed DevExpress, maybe Embarcadero should make sure any giveaways they do work correctly 🙂

 

Thanks for the suggestion Remy.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×