Recent

Author Topic: bmp to jpg  (Read 2267 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 1998
    • Lazarus and Free Pascal italian community
bmp to jpg
« on: July 23, 2012, 03:47:54 pm »
how convert bmp image to jpg image?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

KpjComp

  • Hero Member
  • *****
  • Posts: 680
Re: bmp to jpg
« Reply #1 on: July 23, 2012, 04:06:23 pm »
Something like ->

Code: [Select]
uses LazJPG;

procedure TForm1.Button1Click(Sender: TObject);
var
  j:TJPEGImage;
begin
  j := TJPEGImage.Create;
  try
    j.Assign(image1.picture.Bitmap);
    j.CompressionQuality:=90;
    j.savetofile('test.jpg');
  finally
    j.free;
  end;
end;

You will need to make sure you have ImagesForLazarus as part of your project dependancy.

xinyiman

  • Hero Member
  • *****
  • Posts: 1998
    • Lazarus and Free Pascal italian community
Re: bmp to jpg
« Reply #2 on: July 23, 2012, 04:09:27 pm »
Thank you :)
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1