I have a bmp file and am trying to convert it to jpeg format. The jpeg created using the following code loses a lot of clarity. I have tried tweaking many settings to no avail.
Does anyone have a function which will convert a bmp file to a jpeg?
var
Bmp: TBitmap;
Jpg: TJPEGImage;
begin
Bmp := TBitmap.Create;
Jpg := TJPEGImage.Create;
try
Bmp.LoadFromFile(BmpFileName);
Jpg.Assign(Bmp);
jpg.PixelFormat :=jf24bit; // or jf8bit
Jpg.CompressionQuality := 100;
Jpg.ProgressiveDisplay := False;
Jpg.ProgressiveEncoding := False;
Jpg.SaveToFile(JpgFileName);
finally
Jpg.Free;
Bmp.Free;
end;
end;
Update I figure it might be good to add references to the actual graphics.
Here is the bmp file:
Here is the converted jpg file:
Update II A lot of people have responded that jpeg is not the graphic type to use in this case. Understood. Not to beat a dead horse, but I have been able to use other programs (i.e. Photoshop) and convert this to a nice looking jpeg. And the tool I am using to create the chart (fusioncharts) is able to export it to a nice looking jpeg too (see below). What is the difference?