If I load an image from a file like this Image1.Picture.LoadFromFile(imagePath);
and the JPEG I load is bigger than Image1
which is a TImage
- how do I scale it to fit?

- 65,725
- 40
- 181
- 316

- 38,334
- 103
- 306
- 551
-
7@David et al, I agree that the answer of this other question contains what the OP needs, but it's a different question and I'm not sure I would have found it from a search. – Francesca Apr 09 '12 at 17:16
-
2We're all friends here, so lets leave the chatter out. It makes it easier to search the questions later if we leave out references to what time it is. :-) – Warren P Apr 09 '12 at 18:08
1 Answers
Set the Stretch
property of the TImage
control to True
.
Indicates whether the image should be changed so that it exactly fits the bounds of the image control.
Set Stretch to true to cause the image to assume the size and shape of the image control. When the image control resizes, the image resizes also. Stretch resizes the height and width of the image independently. Thus, unlike a simple change in magnification, Stretch can distort the image if the image control is not the same shape as the image.
As this documentation indicates, a related alternative is the Proportional
property.
Indicates whether the image should be changed, without distortion, so that it fits the bounds of the image control.
Set Proportional to true to ensure that the image can be fully displayed in the image control without any distortion such as occurs with the Stretch property. When Proportional is true, images that are too large to fit in the image control are scaled down (while maintaining the same aspect ratio) until they fit in the image control. Images that are too small are displayed normally. That is, Proportional can reduce the magnification of the image, but does not increase it.
When the image control resizes, the image resizes also.

- 601,492
- 42
- 1,072
- 1,490

- 134,889
- 20
- 356
- 483