Solved

How can I draw a black line on a bmp file ?

Posted on 2002-05-15
4
280 Views
Last Modified: 2010-04-04
Hi,

I have a TBitmap and I want to draw a black line around the image. How can I do that ?
0
Comment
Question by:sruel
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
lopem earned 50 total points
ID: 7012618
Sruel,

try something like that:

  Image1.Canvas.Pen.Color := clBlack;
  Image1.Canvas.PolyLine([Point(0,0), Point(50, 0), Point(75, 50), Point(25, 50), Point(0, 0)]);

you need to change

       Point(X,Y) for Image1.Top,
                             Image1.left,
                             Image1.top+Image1.height,
                             Image1.left+Image1.width

properly...

I just tested the example above and it works drawing some sort of rectangle into the bitmap.
best regards
Manuel Lopez (lopem)
0
 
LVL 3

Expert Comment

by:tongalite
ID: 7012697
Hi

experiment with this :)


procedure TForm1.Button1Click(Sender: TObject);
begin
 with image1 do begin
Canvas.pen.color := clblack;
Canvas.pen.width := 5;
Canvas.moveto(image1.width,2);
Canvas.lineto(2,2);
Canvas.lineto(2,image1.height);
Canvas.lineto(image1.width,image1.height);
Canvas.lineto(image1.width,2);

end;
end;

t.
0
 

Author Comment

by:sruel
ID: 7013305
I prefer the method of tongalite but how can I replace the old .bmp with the new image with the black rectangle ???
0
 
LVL 3

Expert Comment

by:lopem
ID: 7014968
Hi, Sruel,

if you want to save your image to a JPG file, include the JPEG unit in the USES clause, then do something like this:

var
    jp: TJpegImage; //change to jp: TImage if you
                    //want to save to BMP
begin
  jp := TJpegImage.Create; //change to jp:= TImage.Create;
                           //for BMP
  with jp do
  begin
    Assign(Image1.Picture.Bitmap);
    SaveToFile('newpic.jpg') //use 'newpic.bmp' if using
                             //timage
  end;
  jp.Free;
  ShowMessage('File saved...');
end;

best regards,
Manuel Lopez (lopem)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

860 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