Scalabium Software

SMExport advertising
Knowledge for your independence'.
Home Delphi and C++Builder tips


#42: Convert the bitmap to Jpeg and vice versa

You can use the next code for conversion of bitmap into jpeg or jpeg into bitmap:

uses Jpeg;

procedure Bmp2Jpeg(const BmpFileName, JpgFileName: string);
var
  Bmp: TBitmap;
  Jpg: TJPEGImage;
begin
  Bmp := TBitmap.Create;
  Jpg := TJPEGImage.Create;
  try
    Bmp.LoadFromFile(BmpFileName);
    Jpg.Assign(Bmp);
    Jpg.SaveToFile(JpgFileName);
  finally
    Jpg.Free;
    Bmp.Free;
  end;
end;

procedure Jpeg2Bmp(const BmpFileName, JpgFileName: string);
var
  Bmp: TBitmap;
  Jpg: TJPEGImage;
begin
  Bmp := TBitmap.Create;
  Jpg := TJPEGImage.Create;
  try
    Jpg.LoadFromFile(JpgFileName);
    Bmp.Assign(Jpg);
    Bmp.SaveToFile(BmpFileName);
  finally
    Jpg.Free;
    Bmp.Free;
  end;
end;

I uses these procedures for picture format changing in own PictView application.


Published: November 16, 1999

See also
 
dBase Viewer
Paradox to Text converter
Paradox Viewer
DBISAM Viewer
SMDBGrid
Viewer for TNEF-files (winmail.dat)
SMMsg suite
ABA Database Convert
SMImport suite
Excel Reader (dll)
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2023, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMExport advertising