How Export rvf file to Jpeg

Public forum for discussing TScaleRichView (shareware addon to TRichView providing WYSIWYG editing)
Post Reply
billychou
Posts: 6
Joined: Fri Feb 06, 2015 6:24 am

How Export rvf file to Jpeg

Post by billychou » Thu Feb 18, 2016 9:52 am

How Export rvf file to Jpeg.


Thanks.

Sergey Tkachenko
Site Admin
Posts: 13636
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko » Tue Feb 23, 2016 6:22 pm

Code: Select all

procedure SavePageAsJpeg(SRV: TSRichViewEdit; PageNo: Integer; const FileName: String);
var
  bmp: TBitmap;
  jpg: TJPEGImage;
begin
  bmp := TBitmap.Create;
  try
    bmp.Width := SRV.PageWidth100Pix;
    bmp.Height := SRV.PageHeight100Pix;
    SRV.DrawPage(PageNo, bmp.Width, bmp.Height, 0, 0, bmp.Canvas,
      False, True, False, False);
    jpg := TJPEGImage.Create;
    try
      jpg.Assign(bmp);
      jpg.SaveToFile(FileName);
    finally
      jpg.Free;
    end;
  finally
    bmp.Free;
  end;
end;

procedure TForm3.ToolButton79Click(Sender: TObject);
var
  i: Integer;
begin
  for i := 1 to SRichViewEdit1.PageCount do
    SavePageAsJpeg(SRichViewEdit1, i, ExtractFilePath(Application.ExeName) +
      'page' + IntToStr(i) + '.jpg');
end;
PS: jpeg is not a very good format for storing pages, it uses lossy compression, and it is noticeable.
I suggest using PNG instead. The code is the same, but use TPngImage instead of TJPEGImage, and 'png' extension instead of 'jpg'.

billychou
Posts: 6
Joined: Fri Feb 06, 2015 6:24 am

Post by billychou » Fri Mar 04, 2016 12:27 am

Thanks

Post Reply