Page 2 of 2

Posted: Thu Dec 08, 2011 6:12 pm
by Sergey Tkachenko
There are no procedures for unregistering. Everything is cleaned up when the application exits.

Posted: Fri Jun 07, 2013 2:52 pm
by Sergey Tkachenko
The first message in this topic is updated for compatibility with TRichView 14.5+:
- now, TRichView uses TPngImage automatically in Delphi 2009+ (unless you define RVDONOTUSEPNGIMAGE in RV_Defs.inc)
- RVGraphicHandler should be used instead of the old functions

Re: [How to] How to use PNG and GIF images in TRichView

Posted: Tue Nov 21, 2017 5:50 pm
by Sergey Tkachenko
This information is useful for users of Delphi 2007 and older. New versions of Delphi have a built-in TPngImage class, it is supported by TRichView automatically.

Once again about using TPngObject.
Information in the first post of this topic describes all necessary steps except for allowing high-quality resizing for PNG images.
You need to add code allowing thumbnails (high-quality sizing) for TPngObject.
The complete initialization code for TPngObject is:

Code: Select all

uses
  PngImage, RVGrHandler, RVThumbMaker;

...

type
  TMyGraphicHandler = class (TRVGraphicHandler)
  public
    function IsTransparent(Graphic: TGraphic): Boolean; override;
  end;

function TMyGraphicHandler.IsTransparent(Graphic: TGraphic): Boolean;
begin
  if Graphic is TPNGObject then
    Result := Graphic.Transparent
  else
    Result := inherited IsTransparent(Graphic);
end;

procedure InitPngObject;
begin
  RVGraphicHandler.Free;
  RVGraphicHandler := TMyGraphicHandler.Create;
  RegisterClass(TPngObject);
  RVGraphicHandler.RegisterHTMLGraphicFormat(TPngObject);
  RVGraphicHandler.RegisterPngGraphic(TPngObject);
  RVThumbnailMaker.AllowThumbnailsFor(TPNGObject);
end;

initialization
  InitPngObject;

end;