Solved

Canvas to Tgraphic

Posted on 1997-11-02
2
857 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
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
LAN or WAN ? 11 106
Need Help Delphi 2010 CheckBox1 Stored value in memo 13 78
Delphi: making a BW image transparent 10 94
enhance the following code 3 42
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 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