简体   繁体   中英

How to adjust picture in picturebox control

i have picturebox control in my form that SizeMode = StretchImage

when i load 50X250 picture - The picture looks too wide and Ugly

when i load 250X50 picture - the picture looks good.

how to fix it ?

Use the appropriate PictureBox SizeMode :

Normal: The image is placed in the upper-left corner of the PictureBox. The image is clipped if it is larger than the PictureBox it is contained in.

StretchImage : The image within the PictureBox is stretched or shrunk to fit the size of the PictureBox.

AutoSize : The PictureBox is sized equal to the size of the image that it contains.

CenterImage : The image is displayed in the center if the PictureBox is larger than the image. If the image is larger than the PictureBox, the picture is placed in the center of the PictureBox and the outside edges are clipped.

Zoom : The size of the image is increased or decreased maintaining the size ratio.

It sounds like the PictureBox is doing exactly what it's supposed to, when using PictureBoxSizeMode.StretchImage .

If you don't want distortion, use SizeMode=Zoom

You will of course have horizontal or vertical bars next to your image

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM