I have a bmp file and am trying to convert it to jpeg format. A jpeg created using the following code loses a lot of clarity. I tried to configure many settings to no avail.
Does anyone have a function that converts a BMP file to 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 II . Many people answered that jpeg is not a graphical type to use in this case. I get it. Not to beat a dead horse, but I was able to use other programs (i.e. Photoshop) and convert this to a beautiful gpeg. And the tool that I use to create the chart (fusioncharts) can also export it to a pretty jpeg (see below). What is the difference?
, JPEG - - , , JPEG!
Paint.Net / (PNG, JPEG, GIF, BMP ..), , .
Paint.net JPEG , Delphi, , ( Delphi)...
UPDATE: ...
JPEG; , .
, FusionCharts Photoshop . , JPEG LOSSY.
, JPEG , JPEG , . , PNG . PNG- 30% , JPEG (71K 101K)
, , .. CompressionQuality := 100.
CompressionQuality := 100
JPG . JPG . ( > ~ 80), , ..
JPG , . , , .., , .., JPG. PNG. PNG (, !), .
, , JPG ! PNG!
, . .
1) TsdJpegGraphic NativeJPG Delphi TJPEGImage. .
2) :
var Bmp: TBitmap; Jpg: TsdJpegGraphic; begin Bmp := TBitmap.Create; Jpg := TsdJpegGraphic.Create; try Bmp.LoadFromFile(BmpFileName); Jpg.CompressionQuality := 100; // !!! Jpg.Assign(Bmp); Jpg.SaveToFile(JpgFileName); finally Jpg.Free; Bmp.Free; end; end;
CompressionQuality, Jpg! , (= 80%) CompressionQuality.
, CompressionQuality 100. , - ( SO) :https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-5031886.html#
, . , . :https://web.archive.org/web/1/http://techrepublic%2ecom%2ecom/html/tr/sidebars/5031886-1.html
, jpg.CompressionQuality. jpg.Compress(), ...
- :
jpg: = TJPEGImage.Create(); jpg.LoadFromFile( 'foo.jpg'); jpg.DIBNeeded(); jpg.CompressionQuality: = 25; jpg.Compress(); jpg.SaveToFile( 'bar.jpg'); jpg.Free();
,