怎么将RichViewEdit打印成一张张bmp图片(bmp长宽要自定义)
看了这个,但不知道在cb中要怎么用.谁能帮忙改一下,比如我要一页页打印成200*50这么大的bmp.
http://blog.csdn.net/qq752923276/article/details/7869711
1: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;
2: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;
RVReportHelper1->Init(Canvas, 200);
while (RVReportHelper1->FormatNextPage(VERYLARGEVALUE));
TMetafile *wmf = new TMetafile();
wmf->Width = 200;
wmf->Height = RVReportHelper1->EndAt;
TMetafileCanvas *pCanvas = new TMetafileCanvas(wmf, 0);
RVReportHelper1->DrawPage(1, pCanvas, true, RVReportHelper1->EndAt);
delete pCanvas;
Image2->Picture->Graphic = wmf;
delete wmf;
RichView1->HScrollPos = 0;
RichView1->VScrollPos = 0;
RichView1->Deselect();
RichView1->Invalidate();
int nWidth = RichView1->RVData->DocumentWidth - RichView1->LeftMargin - RichView1->RightMargin;
int nHeight = RichView1->RVData->DocumentHeight;
TMetafile *wmf = new TMetafile();
wmf->Width = nWidth;
wmf->Height = nHeight;
TMetafileCanvas *pCanvas = new TMetafileCanvas(wmf, 0);
pCanvas->Brush->Color = clWindow;
pCanvas->FillRect(Rect(0, 0, nWidth, nHeight));
RichView1->RVData->PaintTo(pCanvas, Rect(0, 0, VERYLARGEVALUE, VERYLARGEVALUE));
delete pCanvas;
Image1->Picture->Graphic = wmf;
delete wmf;