A.M. Hoornweg 144 Posted March 21, 2022 (edited) Hello all, does anyone else have the issue that a TImage containing a JPG does not re-size when the form is dragged to a screen with a different resolution? The weird thing: This only happens when the contained picture is a *.JPG. If the picture is a BMP or PNG then it *does* work OK. See attached image: The property "Stretch" is set to True in all 3 cases. (Edit) compiler version is Delphi 11.1 Alexandria. Edited March 21, 2022 by A.M. Hoornweg Share this post Link to post
Stano 143 Posted March 21, 2022 OT: I recommend using TImageCollection and TVirtualImageList. This significantly increases the quality of the images. I don't know if the problem will solve it. Share this post Link to post
Anders Melander 1815 Posted March 21, 2022 1 hour ago, Stano said: OT: I recommend using TImageCollection and TVirtualImageList. This significantly increases the quality of the images. I don't know if the problem will solve it. That's pretty useless - "OT" or not. He's using a TImage. Share this post Link to post
Anders Melander 1815 Posted March 21, 2022 2 hours ago, A.M. Hoornweg said: The weird thing: This only happens when the contained picture is a *.JPG. If the picture is a BMP or PNG then it *does* work OK. Weird indeed. Can you tell if it's the TImage itself or only the content which isn't being scaled? Share this post Link to post
Uwe Raabe 2064 Posted March 21, 2022 4 minutes ago, Anders Melander said: That's pretty useless - "OT" or not. He's using a TImage. I guess he meant TVirtualImage instead of TVirtualImageList. Share this post Link to post
Vandrovnik 215 Posted March 21, 2022 It is possible to load a JPG image in original size, or 1/2, 1/4 or 1/8 of original size. Maybe it firsts loads it optimized in, for example, 1/4 of its original size, and later it does not have "pixels enough" to scale up? Share this post Link to post
Anders Melander 1815 Posted March 21, 2022 6 minutes ago, Vandrovnik said: Maybe it firsts loads it optimized in, for example, 1/4 of its original size, and later it does not have "pixels enough" to scale up? That shouldn't matter. Regardless of the dimensions of the jpeg image, it (or rather the internal TBitmap representing the decoded image) will be stretched to fit the target rect. procedure TJPEGImage.Draw(ACanvas: TCanvas; const Rect: TRect); begin ACanvas.StretchDraw(Rect, Bitmap); end; Share this post Link to post
Stano 143 Posted March 21, 2022 2 hours ago, Uwe Raabe said: 2 hours ago, Anders Melander said: That's pretty useless - "OT" or not. He's using a TImage. I guess he meant TVirtualImage instead of TVirtualImageList. OT because I wrote about image quality. Not about the subject of the question. Uwe is right. I did it with ActionToolBar. I didn't realize the difference. Share this post Link to post
A.M. Hoornweg 144 Posted March 22, 2022 OK, this is getting even weirder. I've placed a tTimer on the form plus an event handler to display the size of the 3 images. The size of the bitmap is 78x98 pixels in all 3 cases. procedure TForm25.check(img: timage; lbl: tlabel; fmt:String); begin lbl.Caption:=format('%s %d x %d',[fmt, img.Width, img.height]); end; procedure TForm25.Timer1Timer(Sender: TObject); begin check (image1,label1,'JPG'); check (image2,label2,'BMP'); check (image3,label3,'PNG'); end; Now look what happens if I drag the form to a high-resolution screen (250% zoom). The tImage having the JPG did not resize but claims to have done so anyway. The tImage with the BMP scaled correctly but still returns the unscaled size. And finally, the tImage with the PNG scaled correctly and returns the scaled size. Share this post Link to post