预览加载中,请您耐心等待几秒...
1/2
2/2

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

//按比例缩放图片 publicImageZoomPicture(ImageSourceImage,intTargetWidth,intTargetHeight) { intIntWidth;//新的图片宽 intIntHeight;//新的图片高 try { System.Drawing.Imaging.ImageFormatformat=SourceImage.RawFormat; System.Drawing.BitmapSaveImage=newSystem.Drawing.Bitmap(TargetWidth,TargetHeight); Graphicsg=Graphics.FromImage(SaveImage); g.Clear(Color.White); //计算缩放图片的大小 if(SourceImage.Width>TargetWidth&&SourceImage.Height<=TargetHeight)//宽度比目的图片宽度大,长度比目的图片长度小 { IntWidth=TargetWidth; IntHeight=(IntWidth*SourceImage.Height)/SourceImage.Width; } elseif(SourceImage.Width<=TargetWidth&&SourceImage.Height>TargetHeight)//宽度比目的图片宽度小,长度比目的图片长度大 { IntHeight=TargetHeight; IntWidth=(IntHeight*SourceImage.Width)/SourceImage.Height; } elseif(SourceImage.Width<=TargetWidth&&SourceImage.Height<=TargetHeight)//长宽比目的图片长宽都小 { IntHeight(参考:http://www.linbayan8.com)=SourceImage.Width; IntWidth=SourceImage.Height; } else//长宽比目的图片的长宽都大 { IntWidth=TargetWidth; IntHeight=(IntWidth*SourceImage.Height)/SourceImage.Width; if(IntHeight>TargetHeight)//重新计算 { IntHeight=TargetHeight; IntWidth=(IntHeight*SourceImage.Width)/SourceImage.Height; } } g.DrawImage(SourceImage,(TargetWidth-IntWidth)/2,(TargetHeight-IntHeight)/2,IntWidth,IntHeight); SourceImage.Dispose(); returnSaveImage; } catch(Exceptionex) { } returnnull; } 其它: c#在图像上动态加载文字 http://blog.163.com/chenjunfeng_2007/blog/static/11938508320101953010175/ C#图片裁剪与缩放 http://www.2cto.com/kf/201106/94121.html C#图片剪裁类 http://www.oschina.net/code/snippet_250332_9189 C#图片处理高级应用(裁剪,缩放,清晰度,水印) http://www.soaspx.com/dotnet/csharp/csharp_20110221_7226.html