Solved

Canvas to Tgraphic

Posted on 1997-11-02
2
865 Views
Last Modified: 2012-06-21
To place a Graphic onto a Canvas you simply call canvas.draw(x,y,graphic). But how do I go the other
way i.e. I have drawn some stuff on the canvas and want
to make a Bitmap (Graphic) out of it?
I envision something like Copyrect where you would pass it a
rectangle and the Bitmap would be made from that.
0
Comment
Question by:AndrewEarl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 100 total points
ID: 1349377
Hi

The following code draws some lines on the form's canvas, copies that section of the form's canvas to a bitmap and saves the bitmap to disk.

procedure TForm1.Button1Click(Sender: TObject);
var
    Bmp: TBitmap;
begin
    // Draw on form's canvas.
    Canvas.MoveTo(5, 5);
    Canvas.LineTo(90, 80);
    Canvas.Pen.Color := clRed;
    Canvas.LineTo(40, 90);

    // Create bitmap.
    Bmp := TBitmap.Create;
    Bmp.Height := 100;
    Bmp.Width := 100;

    // Copy form's canvas onto the bitmap.
    Bmp.Canvas.CopyRect(Rect(0, 0, 100, 100), Self.Canvas, Rect(0, 0, 100, 100));

    // Save bitmap, and free it.
    Bmp.SaveToFile('C:\Temp.bmp');
    Bmp.Free;
end;

Hope this helps you.
JB
0
 

Author Comment

by:AndrewEarl
ID: 1349378
Thank you. Works well.

I'm actually using Tpicture, but I get the idea.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question