[How to] How to use PNG and GIF images in TRichView
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: [How to] How to use PNG and GIF images in TRichView
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:
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;