Jump to content
alogrep

Uwe: PngComponents again not show old glyph with tpngiobject

Recommended Posts

Hello Uwe. I am in trouble again.

I left my project, after everythig was ok,  for a month, and now again have the same problem: the old legacy glyphs with tpngobject do not show the images. 

The design components show in installed packages, but the unit with tpngobject  images do now show the image.

I uninstalled the package., I re-installed PngComponentsDesign.dpk from the sydney folder.

I also re-named  pngcomponents\pngobject to make sure it does not interfere in any way. But the (content of the) images are not shown.

Any clue, please?

Share this post


Link to post

Make sure that RegisterOldPngFormat is defined in the PngComponents project.

  • Like 1

Share this post


Link to post

Thanks very much again! That was it (although I did not do it myself the first time around, or at least I do not remember doing it).

Share this post


Link to post

HelloUwe.

Sorry again. But something weird happens: all works fine, UNTIL I exit Delphi Id and re-start it.

At restart the images are not shown anymore. 

I define RegisterOldPngFormat  in both runtime and design packages  (in the release configuration). 

I work on a PC win64. For the runtime package (pngcompnents) I put target platform 64bit.. 

Build the 2 components creates the bpl's whown in the attached image. 

What's happening? why it workds if i stay in the IDE, but it does not work anylonger when i re-starte it?

I appreciate very much your patient help.

s1.jpg

Share this post


Link to post
2 hours ago, alogrep said:

For the runtime package (pngcompnents) I put target platform 64bit.. 

The 32-Bit design package also needs the 32-Bit runtime package. The 64-Bit runtime package is only needed if you build a 64-Bit exe and build it with packages.

Share this post


Link to post

I re-installed the pngcomponents. I build it and Installed. The old pngs show OK.

I close the IDE, re-start it, and they do not show at all. What happens when I cose the IDE? What is that "disappears" at closing th e IDE? It is beyond my comprehension. 

Hese are the files created when instaling the packages:

 

Directory of C:\hmxe\pngcomp\packagessydney\Win32\Release

25/10/2021  04:36 p. m.    <DIR>          .
25/10/2021  04:36 p. m.    <DIR>          ..
25/10/2021  04:36 p. m.            15,739 PngBitBtn.dcu
25/10/2021  04:36 p. m.             2,156 PngButtonFunctions.dcu
25/10/2021  04:36 p. m.            10,046 PngCheckListBox.dcu
25/10/2021  04:36 p. m.            14,954 PngComponentEditors.dcu
25/10/2021  04:36 p. m.             1,990 PngComponentsRegister.dcu
25/10/2021  04:36 p. m.            12,207 PngFunctions.dcu
25/10/2021  04:36 p. m.            42,691 PngImageList.dcu
25/10/2021  04:36 p. m.            40,318 PngImageListEditor.dcu
25/10/2021  04:36 p. m.             8,050 PngSpeedButton.dcu

Directory of C:\Users\Public\Documents\Embarcadero\Studio\21.0\Bpl

25/10/2021  04:36 p. m.           103,424 PngComponents270.bpl
25/10/2021  04:36 p. m.           121,344 PngComponentsDesign270.bpl
               2 File(s)        224,768 bytes

 Directory of C:\Users\Public\Documents\Embarcadero\Studio\21.0\Bpl\Win64

25/10/2021  04:33 p. m.           147,968 PngComponents270.bpl

Share this post


Link to post

Looks all pretty decent to me. I'm out of ideas what can be the cause of these problems.

Share this post


Link to post

Hello Uwe, I hope I am not abusing your patience.

I found this behaviour, perheaps you can give me a clue as to what is wrong or at least a hint for a workaround.

Start the IDE, open a unit with old png (tpngobject): the images are not shown.

I close this unit.

I open a dummy unit that has only this component in it: TPngImageCollection.

Then I re-open the unit with the old png's and MAGICALLY the iomages are shown. Any idea?

Thanks very much.

 

Share this post


Link to post

I suspect smart loading is tripping in here. The registration of TPngObject is done when the TPngComponents package is loaded. As TPngComponents is a runtime package, is it loaded when the design time package PngComponentsDesign is loaded. The smart loading feature of the IDE loads design time packages when a component registered by that package is needed, be it by opening a form containing such a component or by dropping such a component onto a form.

 

You can try to fix that by yourself: Open PngComponentsRegister.pas and add the line ForceDemandLoadState(dlDisable); at the beginning of the Register procedure. Then compile and install the design time package again.

procedure Register;
begin
  ForceDemandLoadState(dlDisable);
  //Register all components
  RegisterComponents(SPageName, [TPngSpeedButton, TPngBitBtn, TPngImageList,
    TPngImageCollection, TPngCheckListBox]);

  //Register component editors

 

Share this post


Link to post

I hope I am not becoming a nuissance, but it works ONLY PARTIALLY.

The images are shown. But running an app with an image picture(Tpngoject), as shown the objecti Ispector, and trying to resize the image, the picture.graphic is shown as NIL on inspection. . and the resizing function crashes. 

I use this 

   with image1 do
        PngSmoothResizeit(Tpngobject(picture.graphic),width-1,height-1);

which works fine in oder delphi.  (PngSmoothResizeit is takn from the original functions for tpngobject).

Why is picture.graphic = NIL, if the image is shown? What is whown, if there is no graphic? 

Share this post


Link to post

I can understand that you want to get the old TPngObject images read from the DFM, but why do you want to work with the TPngObject class? After all it is declared in the implementation part of PngFunctions.pas. Can you show which declaration of TPngObject is used in the code snippet shown?

Share this post


Link to post

 

Thanks.

I do not necessarely want to use the Pngobject.

But

a) the image picture graphic shows = NIL. What does it mean? (the image IS show)

b) I need occasionally to resize the image. any other way to do it?

I attach the resizing code in the  file.

code.txt

Share this post


Link to post

If you actually use that code literally, where is the type TPNGObject declared? It is not available in Delphi nor is it in PngComponents (at least not public).

Edited by Uwe Raabe

Share this post


Link to post

Sorry, I can not answer that question. I had done an update for Tokyo (I think was another pngoject compunets package, not yours) and there it worked fine.. When I put the cursor ofer the Tpngobjec it shows the hint "Tpngimage   Defined in <blank>

However if I comment out the resizing function and run the App, the image is NOT show, although at design time it IS shown. 

Share this post


Link to post

Hello.

I can not answer that question = I do not know the answer.

However, the problem has something to do with path or dll delayed loading. 

I use a splashform in the app.

I added a pngcomponet (the button, visible = false) to it and the main form with the png image DOES now show the image. 

If I remove that png button from the splash form, it does not.

Share this post


Link to post
13 minutes ago, alogrep said:

I can not answer that question

Well, I can. The problem is that TPngObject is declared as an alias for TPngImage in Vcl.Imaging.PngImage.pas. Unfortunately an alias cannot be registered as an alternative type, because internally it is the same type.

 

PngFunctions.pas declares its own TPngObject as descendant from TPngImage, but these two TPngObject are not the same types. These both types don't play well together somehow.

 

To get things straight please remove the RegisterOldPngFormat define and compile the PngComponent packages again. Then open all your DFMs in a text editor (convert them first in case they are still binary) and replace all TPNGObject  references with TPngImage.

Share this post


Link to post

. There is no Tpngobject word in the DFM.  It just has this:

object Image1: TImage
    Left = 0
    Top = 0
    Width = 1008
    Height = 740
    Picture.Data = {
      0A54504E474F626A65637489504E470D0A1A0A0000000D494844520000078000...... etc.

However, that pngcomponet in the splash form seems to do the trick. 

And I also need to keep the dfm compatile with XRE am my older Delphi for a while.

Share this post


Link to post

I went step by step, and I found out than in the splashform creation process, it creates the png button wich in turns create the png image of the button.

             constructor TPngImage.Create;

That  is in Vcl.Imaging.PngImage.pas.

At that point the alias (tpngobject) is set to tpngimage. Whis is something it could not be done at app start (as you said, an alias cannot be registered). I think that is what happens. 

But, whatever it is, the trick seems to work. 

Share this post


Link to post

If you manage to load the old TPngObject instances hidden in Picture.Data, you can export those as PNG files and load them again. This way they should end up as TPngImage.

8 hours ago, alogrep said:

And I also need to keep the dfm compatile with XRE am my older Delphi for a while.

Not sure what XRE means, but TPngImage exists in Delphi since Delphi 2009.

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

×