PNG Pictures lost in Delphi 2009
PNG Pictures lost in Delphi 2009
I moved my project from Delphi 2007 to Delphi 2009 and TRichView 10 to TRichView 11.
PNG images that were in Delphi 2007 version of the document disappeared in Delphi 2009 project. They are still there but TRichView 11 compiled in D2009 can't see them. And everything is ok when opening in D2007 version again.
For PNG support I'm using PngComponents 1.0 RC 2 in D2007 and D2009 too.
PNG images that were in Delphi 2007 version of the document disappeared in Delphi 2009 project. They are still there but TRichView 11 compiled in D2009 can't see them. And everything is ok when opening in D2007 version again.
For PNG support I'm using PngComponents 1.0 RC 2 in D2007 and D2009 too.
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
As I understand, both Delphi 2009 and PngComponents have PNG support based PngImage by Gustavo Huffenbacher Daud.
But PngComponents use quite an old version.
Probably the problem is in the same name of unit used for png support: PngImage.pas. I do not know how it's possible to compile a project with 2 different units of the same name.
But PngComponents use quite an old version.
Probably the problem is in the same name of unit used for png support: PngImage.pas. I do not know how it's possible to compile a project with 2 different units of the same name.
I'm using PNGComponents 1.1 adapted to Delphi 2009.
In delphi it's TPNGImage and here it's TPNGObject.
Delphi's PNGImage is really buggy (tried to move).
In delphi it's TPNGImage and here it's TPNGObject.
Code: Select all
RegisterClass(TPNGObject);
RV_RegisterHTMLGraphicFormat(TPNGObject);
RV_RegisterPngGraphic(TPNGObject);
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I am afraid I have no idea why it does not work.
In RVF files, when a picture is saved, its class name is written. It should be 'TPNGObject'. When TRichView reads this image, it first creates the proper class using GetClass(GraphicClassName).Create.
Well, try to make this test - exclude rvfwUnknownPicFmt from RichView.RVFOptions. Then, if GetClass fails, RVF loading fails too (LoadRVF will return False)
In RVF files, when a picture is saved, its class name is written. It should be 'TPNGObject'. When TRichView reads this image, it first creates the proper class using GetClass(GraphicClassName).Create.
Well, try to make this test - exclude rvfwUnknownPicFmt from RichView.RVFOptions. Then, if GetClass fails, RVF loading fails too (LoadRVF will return False)
-
- Posts: 49
- Joined: Thu Jan 03, 2008 6:11 pm
- Location: South-Africa
-
- Posts: 49
- Joined: Thu Jan 03, 2008 6:11 pm
- Location: South-Africa
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
You can exclude all references to PngImage unit from your application, and write line :
After that, all png objects will be loaded in TLMDPNGImage classes (of course, TPNGObject must be registered using RegisterClass)
Code: Select all
type
TPNGObject = class TLMDPNGImage;
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Ok, I can see the problem.
In older versions of Delphi, you used TPngObject class for PNG images, and this class name is written in RVF files.
In Delphi 2009/2010, the class for PNG is not TPngObject but TPngImage. TPngObject is declared, but it is declared not as a class, but as an alternative name of TPngImage:
Because of this, even if you add the line
it will not help, because this line still registers TPngImage instead of TPngObject. So, when loading RVF file, 'TPngImage' class is still unknown for TRichView.
How to solve this problem? Create your own class with the name TPngObject and register it:
All other registering code can still be for TPngImage:
In older versions of Delphi, you used TPngObject class for PNG images, and this class name is written in RVF files.
In Delphi 2009/2010, the class for PNG is not TPngObject but TPngImage. TPngObject is declared, but it is declared not as a class, but as an alternative name of TPngImage:
Code: Select all
TPNGObject = TPngImage
Code: Select all
RegisterClass(TPngObject)
How to solve this problem? Create your own class with the name TPngObject and register it:
Code: Select all
type TPngObject = class (TPngImage);
...
RegisterClass(TPngObject);
Code: Select all
RegisterClass(TPngImage);
RV_RegisterHTMLGraphicFormat(TPngImage);
RV_RegisterPngGraphic(TPngImage);
Just found another problem. This code
returns an empty string for old TPNGObject.
Code: Select all
ext:=GraphicExtension(TGraphicClass(gr.ClassType));
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
A better solution is suggested here: http://www.trichview.com/forums/viewtop ... 4676#14676
Moved my project to Delphi XE and PNG does not save to RVF.
Inserting PNG image to RVE works but it does NOT save it to file.
TRichView 12.0.5
Inserting PNG image to RVE works but it does NOT save it to file.
Code: Select all
RegisterClass(TPNGImage);
RegisterClassAlias(TPNGImage,'TPNGObject');
RV_RegisterHTMLGraphicFormat(TPNGImage);
RV_RegisterPngGraphic(TPNGImage);