c#如何缩放图像?(VS2008)

2024-12-20 20:27:16
推荐回答(3个)
回答1:

MSDN里好像有范例的,

private Bitmap destBitmap;
private double zoomFactor = 1;
private Int32 screenImageWidth = 0;
private Int32 screenImageHeight = 0;

private void zoom(double factor)//将图像缩放至当前图像的指定倍数
{
this.zoomFactor = factor;
Bitmap sourceBitmap = new Bitmap(this.currentImage);
destBitmap = new Bitmap((int)Math.Round((double)(sourceBitmap.Width * factor)), (int)Math.Round((double)(sourceBitmap.Height * factor)));
Graphics.FromImage(destBitmap).DrawImage(sourceBitmap, 0, 0, (int)(destBitmap.Width + 1), (int)(destBitmap.Height + 1));
this.screenImageWidth = destBitmap.Width;
this.screenImageHeight = destBitmap.Height;
this.MainImage.Image = destBitmap;

}

回答2:

你可以用按钮来控制呀,点放大时,图片就载入800*600,当点缩小按钮时就载入400*300

回答3:

用BitMap图像处理包。