如题,用Graphics.DrawImage 切图,就是截取一个图片上指定部分的图片draw到另一个图片上,gif失真,请前辈们指教啊,
解决方案 »
- 母版页中如何使用ModalPopupExtender?
- 请教页面加载后的大小如何确定
- datatable.select还有dataview.rowfilter居然都不支持like
- vs.2003 WebForm 在给Repeater 控件绑定DataTable时候,
- 批量修改问题。
- 一个很简单问题,盼解决
- 点击button隐藏和显示table的多行
- 关于新闻显示
- 哪位仁兄碰到过这类问题?
- 我用flash mx2004+asp.net+c#+xml+mssql做的一个网站,大家批批!本想提供源码下载,可是觉得太简单了.: (
- ConnectionString 属性尚未初始化 求解决
- 在asp.net里checkbox问题!SOS求救!
using (System.Drawing.Image oImg = System.Drawing.Image.FromFile(sImagePath))
{
//创建图片
System.Drawing.Bitmap oBit = new System.Drawing.Bitmap(iPartWidth, iPartHeight);
System.Drawing.Graphics oPic = System.Drawing.Graphics.FromImage(oBit);
//目标位置
System.Drawing.Rectangle rDest = new System.Drawing.Rectangle(
new System.Drawing.Point(iPartStartPointX, iPartStartPointY),
new System.Drawing.Size(iPartWidth, iPartHeight));
//原图位置(默认从原图中截取的图片大小等于目标图片的大小)
System.Drawing.Rectangle rOrig = new System.Drawing.Rectangle(
new System.Drawing.Point(iOrigStartPointX, iOrigStartPointY),
new System.Drawing.Size(iPartWidth, iPartHeight));
//生成图片
System.Drawing.Brush bh = new System.Drawing.SolidBrush(System.Drawing.Color.White);
oPic.FillRectangle(bh, rDest);
oPic.DrawImage(oImg, rDest, rOrig, System.Drawing.GraphicsUnit.Pixel);
oImg.Dispose();
//检查文件
if (System.IO.File.Exists(sPath))
{
System.IO.File.SetAttributes(sPath, System.IO.FileAttributes.Normal);
System.IO.File.Delete(sPath);
}
//保存文件
switch (sCode.ToLower())
{
case ".gif": oBit.Save(sPath, System.Drawing.Imaging.ImageFormat.Gif); break;
case ".png": oBit.Save(sPath, System.Drawing.Imaging.ImageFormat.Png); break;
case ".bmp": oBit.Save(sPath, System.Drawing.Imaging.ImageFormat.Bmp); break;
default: oBit.Save(sPath, System.Drawing.Imaging.ImageFormat.Jpeg); break;
}
}