Page 1 of 2

PNG Pictures lost in Delphi 2009

Posted: Wed Sep 23, 2009 1:11 am
by Marsianin
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.

Posted: Wed Sep 23, 2009 4:43 pm
by Sergey Tkachenko
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.

Posted: Thu Sep 24, 2009 5:34 am
by Marsianin
I'm using PNGComponents 1.1 adapted to Delphi 2009.
In delphi it's TPNGImage and here it's TPNGObject.

Code: Select all

RegisterClass(TPNGObject);
RV_RegisterHTMLGraphicFormat(TPNGObject);
RV_RegisterPngGraphic(TPNGObject);
Delphi's PNGImage is really buggy (tried to move).

Posted: Thu Sep 24, 2009 9:04 am
by Sergey Tkachenko
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)

Posted: Sat Oct 31, 2009 8:21 am
by pawnflakes
I'm using DBSRichviewEdit and i'm experiencing the exact same problem. When I save to DB and view, there is nothing. Your above suggestion doesn't work - do you have any other suggestions?

Posted: Sat Oct 31, 2009 8:32 am
by pawnflakes
I found a solution to my problem: I'm using the Devexpress components and added RV_RegisterPngGraphic(TdxPNGImage) to my application. It solves the problem.

Posted: Thu Dec 17, 2009 2:04 am
by Marsianin
I have LMD2010 components installed and there is PNG support too (TLMDPNGImage...)
But if I use it with old documents with TPNGObject images will RVE open them or they'll lost?

Posted: Thu Dec 17, 2009 9:00 am
by Sergey Tkachenko
You can exclude all references to PngImage unit from your application, and write line :

Code: Select all

type
  TPNGObject = class TLMDPNGImage;
After that, all png objects will be loaded in TLMDPNGImage classes (of course, TPNGObject must be registered using RegisterClass)

Posted: Tue Jan 26, 2010 7:56 pm
by Marsianin
The problem still exists.
Please check your email for more detailed explanation and demo file.
rvActionsDemo raises error opening that file.
But my old EXE with RVE v.10 or v.11 compiled under D2007 works fine.

Posted: Tue Jan 26, 2010 8:49 pm
by Sergey Tkachenko
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:

Code: Select all

  TPNGObject = TPngImage
Because of this, even if you add the line

Code: Select all

RegisterClass(TPngObject)
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:

Code: Select all

type TPngObject = class (TPngImage);
...
RegisterClass(TPngObject);
All other registering code can still be for TPngImage:

Code: Select all

  RegisterClass(TPngImage);
  RV_RegisterHTMLGraphicFormat(TPngImage);
  RV_RegisterPngGraphic(TPngImage);

Posted: Tue Jan 26, 2010 10:17 pm
by Marsianin
Yeah, it's clear now and it's working.
Thanks.

Posted: Wed Jan 27, 2010 2:18 am
by Marsianin
Just found another problem. This code

Code: Select all

ext:=GraphicExtension(TGraphicClass(gr.ClassType));
returns an empty string for old TPNGObject.

Posted: Thu Jan 28, 2010 10:29 am
by Sergey Tkachenko
A better solution is suggested here: http://www.trichview.com/forums/viewtop ... 4676#14676

Posted: Mon Jul 04, 2011 2:51 am
by Marsianin
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.

Code: Select all

RegisterClass(TPNGImage);
RegisterClassAlias(TPNGImage,'TPNGObject');
RV_RegisterHTMLGraphicFormat(TPNGImage);
RV_RegisterPngGraphic(TPNGImage);
TRichView 12.0.5

Posted: Mon Jul 04, 2011 2:52 am
by Marsianin
Sorry, TRichView is 13.0.5