How Export rvf file to Jpeg

ScaleRichView support and discussion (TRichView add-on for WYSIWYG editing)
Post Reply
billychou
Posts: 6
Joined: Fri Feb 06, 2015 6:24 am

How Export rvf file to Jpeg

Post by billychou »

How Export rvf file to Jpeg.


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

Post by Sergey Tkachenko »

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 »

Thanks
Post Reply