Reputation: 23
.net c# code
var mimage = new MemoryStream();
my_image.Save(mimage, System.Drawing.Imaging.ImageFormat.Jpeg);
Delphi code
//bSource HAS THE ORIGINAL IMAGE
bSource := Tbitmap.Create;
//...
//CODES HERE...
//...
//CODES HERE...
//...
bDest := Tbitmap.Create;
bDest.SetSize(r.width , r.height );
bDest.Canvas.FillRect(bDest.Canvas.ClipRect);
//CODES HERE...
//bDest HAS THE IMAGE FROM <<< bSource >>>>
//CODES HERE..
bSource.Free;
jDest := TJpegImage.Create;
jDest.ProgressiveEncoding:=true;
jDest.CompressionQuality :=100;
jDest.Smoothing := True;
jDest.PixelFormat := jf24bit;
jDest.Compress;
jDest.Assign(bDest); //bDest COPY
jDest.SaveToFile('BIG_FILESIZE_THAN.NET.JPEGx3.jpg'); //FILE SIZE IS TIMES 3 BIGGER THAN .NET
jDest.Free;
bDest.Free;
Same image to compare During Saved
Delphi has Filesize of 5k with 200x200 8bpp = BIGGER?
.Net has Filesize of 2k with 200x200 24bpp = SMALLER?
What has to be done in Delphi to make it like the size of .NET?
Upvotes: 0
Views: 115
Reputation: 612954
By default, because it is not specified, the C# code uses a compression quality level of 75 or so (What quality level does Image.Save() use for jpeg files?).
Your Delphi code uses a quality level of 100. Hence the image produced by the Delphi code has better quality but is also larger. Specify a lower quality level to reduce the file size.
Upvotes: 3