?
Solved

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

Posted on 2002-05-15
4
Medium Priority
?
283 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
[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
4 Comments
 
LVL 3

Accepted Solution

by:
lopem earned 200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month11 days, 3 hours left to enroll

770 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