将richview中的文本保存成图片的问题!(100分)

  • 主题发起人 主题发起人 RiverCity
  • 开始时间 开始时间
R

RiverCity

Unregistered / Unconfirmed
GUEST, unregistred user!
我想把richview中的文本,以与其大小相同的
图片的形式保存、显示!如果采用delphi中有的
预览功能,图片就太大(如果能改变大小就好了)。
不知有没有好的办法啊?














 
var wmf: TMetafile;
Canvas: TMetafileCanvas;
Width, Height: Integer;
begin
RVReportHelper1.Init(Self.Canvas, 200 {width});
while RVReportHelper1.FormatNextPage(VERYLARGEVALUE) do;

wmf := TMetafile.Create;
wmf.Width := 200;
wmf.Height := RVReportHelper1.EndAt;

Canvas := TMetafileCanvas.Create(wmf, 0);
RVReportHelper1.DrawPage(1,Canvas,True,RVReportHelper1.EndAt);
Canvas.Free;

Image2.Picture.Graphic := wmf;
wmf.Free;
end;
 
var wmf: TMetafile;
Canvas: TMetafileCanvas;
Width, Height: Integer;
begin
RichView1.HScrollPos := 0;
RichView1.VScrollPos := 0;
RichView1.Deselect;
RichView1.Invalidate;
Width := RichView1.RVData.DocumentWidth+RichView1.LeftMargin+RichView1.RightMargin;
Height := RichView1.RVData.DocumentHeight;

wmf := TMetafile.Create;
wmf.Width := Width;
wmf.Height := Height;

Canvas := TMetafileCanvas.Create(wmf, 0);
Canvas.Brush.Color := clWindow;
Canvas.FillRect(Rect(0,0,Width,Height));
RichView1.RVData.PaintTo(Canvas, Rect(0,0,VERYLARGEVALUE,VERYLARGEVALUE));
Canvas.Free;

Image1.Picture.Graphic := wmf;
wmf.Free;
end;
 
后退
顶部