PNG Pictures lost in Delphi 2009

General TRichView support forum. Please post your questions here
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

PNG Pictures lost in Delphi 2009

Post 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.
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post 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).
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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)
pawnflakes
Posts: 49
Joined: Thu Jan 03, 2008 6:11 pm
Location: South-Africa

Post 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?
pawnflakes
Posts: 49
Joined: Thu Jan 03, 2008 6:11 pm
Location: South-Africa

Post 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.
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post 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?
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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)
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post 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.
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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);
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin »

Yeah, it's clear now and it's working.
Thanks.
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin »

Just found another problem. This code

Code: Select all

ext:=GraphicExtension(TGraphicClass(gr.ClassType));
returns an empty string for old TPNGObject.
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

A better solution is suggested here: http://www.trichview.com/forums/viewtop ... 4676#14676
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post 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
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin »

Sorry, TRichView is 13.0.5
Post Reply