Solved

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

Posted on 2002-05-15
4
276 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now