Solved

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

Posted on 2002-05-15
4
281 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 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

Industry Leaders: 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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

696 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