Link to home
Start Free TrialLog in
Avatar of sruel
sruel

asked on

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

Hi,

I have a TBitmap and I want to draw a black line around the image. How can I do that ?
ASKER CERTIFIED SOLUTION
Avatar of Manuel Lopez-Michelone
Manuel Lopez-Michelone
Flag of Mexico image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tongalite
tongalite

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.
Avatar of sruel

ASKER

I prefer the method of tongalite but how can I replace the old .bmp with the new image with the black rectangle ???
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)