How to save an image from RVE to file?

General TRichView support forum. Please post your questions here
Post Reply
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

How to save an image from RVE to file?

Post by Marsianin »

I didn't find any answers to this question (may be because search function for this forum is ugly).

How can I save an image from TRichViewEdit to a file? Also I need to know what format it has (BMP, PNG, JPG, GIF) if it's important for saving.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Do you want to draw the content of TRichView on the picture (and then save it to file)?
See the demo in Demos\Delphi\Assorted\Graphics\ToImage\
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin »

No. If current object is TGraphics I want to save it to disk. Just one attached picture.
And I need to know first what format it has (PNG, GIF, JPG, BMP) to save it in appropriate format.
Like export to HTML does.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

You can get the graphic object at the position of caret using GetCurrentPictureInfo method, and save using gr.SaveToFile.
The problem is in finding the proper file extension.
This extension is returned by the function GraphicExtension:
ext := GraphicExtension(TGraphicClass(gr.ClassType));
This function works only for graphic classes with registered file extensions.
They can be registered using TPicture.RegisterFileFormat procedure. They are already registered for standard graphic classes.
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin »

Ya, it works :D
Post Reply