trichview.com

trichview.support




Re: Save entire document to image file


Return to index


Author

Message

Sergey Tkachenko

Posted: 03/17/2003 14:50:05


> Well, now I get a file but it is not a BMP.  I am not sure what it is...

:-)


I think it is definitely a metafile :)


Here is code for saving to bitmap:


function TFMain.ExportToBMP(FileName: string): boolean;

var

  bmp : TBitmap;

   Width  : integer;

   Height : integer;

begin

   try

     rvEdit.HScrollPos := 0;

     rvEdit.VScrollPos := 0;

     rvEdit.Deselect;

     rvEdit.Invalidate;

     Width  := rvEdit.RVData.DocumentWidth +

      rvEdit.LeftMargin+rvEdit.RightMargin;

     Height := rvEdit.RVData.DocumentHeight;

     bmp := TBitmap.Create;

     bmp.Width := Width;

     bmp.Height := Height;

     bmp.Canvas.Brush.Color := clWindow;

     bmp.Canvas.FillRect(rect(0, 0, Width, Height));

     rvEdit.RVData.PaintTo(bmp.Canvas, rect(0,0,500000, 500000));

     bmp.SaveToFile(FileName);

     bmp.Free;

     Result := true;

  except

    Result := false;

  end;

end;




>

> Here is the code I am using:

>

> function TFMain.ExportToBMP(FileName: string): boolean;

> var

>    wmf    : TMetaFile;

>    Width  : integer;

>    Height : integer;

>    Canvas : TMetaFileCanvas;

> begin

>    // save to BMP

>    rvEdit.HScrollPos := 0;

>    rvEdit.VScrollPos := 0;

>    rvEdit.Deselect;

>    rvEdit.Invalidate;

>    Width  := rvEdit.RVData.DocumentWidth +

> rvEdit.LeftMargin+rvEdit.RightMargin;

>    Height := rvEdit.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));

>    rvEdit.RVData.PaintTo(Canvas, rect(0,0,500000, 500000));

>    Canvas.Free;

>

>    wmf.SaveToFile(FileName);

>

>    Wmf.Free;

>    Result := true;

> end;

>

> Am I just drinking too much coffee & missing the obvious?

> Sergey, if you ever get to visit Las Vegas, let me know and I will get you

a

> nice hotel room.  It is the least I can do for all of your help!


Thanks


>

> Ken

> (In Las Vegas)

>

> "Sergey Tkachenko" <svt@trichview.com> wrote in message

> news:3e74e0af@support.torry.net...

> > Make sure that you save it after freeing MetafileCanvas

> >

> > > Thanks for the info, but when I do :

> > >

> > > wmf.SaveToFile(FileName);

> > >

> > > It saves an empty file.

> > >

> > > Any ideas???

> > >

> > > TNX

> > > Ken

> > >

> >

> >

> >

>

>





Powered by ABC Amber Outlook Express Converter