c#如何缩放图像?(VS2008)
WindowsForm程序,picturebox等可载入图像的控件。相当于降低或增加分辨率的那种,即缩小使总像素数成比例减少,扩大则使总像素数成比例增加。总像素数一定要改...
Windows Form程序,picturebox等可载入图像的控件。
相当于降低或增加分辨率的那种,即缩小 使总像素数成比例减少,扩大 则使总像素数成比例增加。
总像素数一定要改变。 展开
相当于降低或增加分辨率的那种,即缩小 使总像素数成比例减少,扩大 则使总像素数成比例增加。
总像素数一定要改变。 展开
3个回答
展开全部
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;
}
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;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询