Link to home
Start Free TrialLog in
Avatar of jexd99
jexd99

asked on

Fastest way to make jpg a bmp then back

I know how to convert these, I want to make sure I'm not doing the longggg way around :)
What is the fastest way to convert jpg to bmp, then back to jpg?

    Thanks
Avatar of craig_capel
craig_capel

var
  Bmp : TBitmap;
  Jpg : TJpegImage;
begin
 Bmp:= TBitmap.Create;
 Jpg := TJpegImage.Create;
  Jpg.LoadFromFile('filename.jpg');
  Bmp.Assign(Jpg);
  Bmp.SaveToFile('filename.bmp');
 End;
 Bmp.free;
 Jpg.Free;


var
  Bmp : TBitmap;
  Jpg : TJpegImage;
begin
 Bmp:= TBitmap.Create;
 Jpg := TJpegImage.Create;
  Bmp.LoadFromFile('filename.bmp');
  Jpg.Assign(Bmp);
  Jpg.SaveToFile('filename.jpg');
 End;
 Bmp.free;
 Jpg.Free;
ASKER CERTIFIED SOLUTION
Avatar of craig_capel
craig_capel

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
By the way, you do realize that switching back and forth between BMP anmd JPG formats is a really good way to have increasing numbers of anamolies introduced into you image, don't you?  (JPG is what is termed a "lossy" format and should not be used for images that you will be modifying. ;-)
Avatar of jexd99

ASKER

Yup, I'm aware.  Thanks :)