I'm kinda confused
when I load a image into a Timage and save it, then the file gets really big
the input is a jpg 250Kb and the output a PNG 1.8 Mb
why?
This is what I used
FImage := TSingleImage.Create;
ConvertBitmapToImage(Timage1Picture.Bitmap, FImage);
FImage.SaveToFile('c:\test.png');
I must say, that I nowhere set something that it needs to be a PNG file.
maybe that's it... but where do I need to put it and what?
also the image = 1200x800
i am loading it into the Timage at 320x240 and have it set to fix so i can see the whole thing.
how can i save it with that sizeformat? now when I save it's still 1200x800
thank you very much
JPEG uses lossy compression - it throws away some image information away and it's never going back.
PNG on the other hand uses lossless compressions - so no information is lost during compression.
So It's to be expected that the same image in PNG file would take up more disk space than JPEG.
TImage just displays assigned TGraphic/TBitmap, it doesn't modify it in any way. You need to resize the bitmap manualy (from your code sample - either Timage1Picture.Bitmap.SetSize or FImage.Resize).
if i use the Timage1Picture.Bitmap.SetSize then it just grabs that piece from the picture (org size 1280x1800). even though it shows the full pic inside the Timage.
Tried also the FImage.Resize but then the original Aspect Ratio is not correct anymore.
Just keep the aspect ratio in mind when resizing.
aspectratio := FImage.width / FImage.height;
FImage.Resize(img, newwidth, newwidth / aspectratio, rfBicubic);
Delphi doesn't take that. Extended vs Integer
Did a Round( ) but then the ratio = 1 so ain't right.
Do the Round on newwidth / aspectratio, not on FImage.width / FImage.height.
Aspectratio variable should be real number.
var aspectratio: Single;
aspectratio := FImage.width / FImage.height;
FImage.Resize(img, newwidth, Round(newwidth / aspectratio), rfBicubic);