我使用了System.Drawing.Image.RotateFlip对图像进行旋转,旋转后如果不指定格式直接Save,1.4M的图像文件就变成了6M还多:System.Drawing.Image imgTmp = System.Drawing.Image.FromFile(@"C:\A.JPG");
imgTmp.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone);
imgTmp.Save(@"C:\A.JPG");如果指定成JPG文件后Save,1.4M的图像文件就变成了250多k:
System.Drawing.Image imgTmp = System.Drawing.Image.FromFile(@"C:\A.JPG");
imgTmp.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone);
imgTmp.Save(@"C:\A.JPG",System.Drawing.Imaging.ImageFormat.Jpeg);不知这个问题如果解决?搜了一下资料见有人通过System.Drawing.Drawing2D.Matrix来实现,
不知怎样实现?能实现System.Drawing.RotateFlipType中的那么多效果么?请教!!!!!!!!!!
imgTmp.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone);
imgTmp.Save(@"C:\A.JPG");如果指定成JPG文件后Save,1.4M的图像文件就变成了250多k:
System.Drawing.Image imgTmp = System.Drawing.Image.FromFile(@"C:\A.JPG");
imgTmp.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone);
imgTmp.Save(@"C:\A.JPG",System.Drawing.Imaging.ImageFormat.Jpeg);不知这个问题如果解决?搜了一下资料见有人通过System.Drawing.Drawing2D.Matrix来实现,
不知怎样实现?能实现System.Drawing.RotateFlipType中的那么多效果么?请教!!!!!!!!!!
解决方案 »
- string 不可以是“可空类型”吗?
- 同一个WebService在VS2008中添加成功,而在VS2010中添加失败!
- FastReport中TfrxPreviewX控件的问题,在线等!!
- Winform CheckBoxList 怎么绑定
- vs2003开发的winform通过webservice访问数据库的超时问题
- c#打开WORD以后,如何获得打开WORD的窗口句柄?
- vs.net2005中的类图 vs Borland_Together的类图
- 一个关于.net框架 的小问题 进着有分
- WPF,控件是在什么时候初始化的?
- socket是引型吧,可为什么两个socket的Connected会不一样?
- 如何把一张图片中的一部分挖出来,保存为图片
- 急问
System.Drawing.Image imgTmp = System.Drawing.Image.FromFile(@"C:\A.JPG");
imgTmp.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone);
imgTmp.Save(@"C:\A.JPG",System.Drawing.Imaging.ImageFormat.Jpeg);
不知这个问题如果解决?这是由于图像质量降低而造成的,你可以设置EncoderParameter来设置图片质量ref:
http://www.codeproject.com/cs/media/bitmapmanip.asp
http://www.codeproject.com/cs/media/bitmapmanip.asp我看了你给我那篇文章及代码,他的ConvertBitmapToJpeg方法中
inputBmp.Save(imgStream, destCodec, destEncParams);
没有一点问题而我代码中,基本跟他的一模一样:
using (System.Drawing.Bitmap imgTmp = (System.Drawing.Bitmap)System.Drawing.Bitmap.FromFile("C:\\A.JPG"))
{
//Get the ImageCodecInfo for the desired target format
System.Drawing.Imaging.ImageCodecInfo destCodec = FindCodecForType(MimeTypeFromImageFormat(System.Drawing.Imaging.ImageFormat.Jpeg)); if (destCodec == null)
{
//No codec available for that format
throw new ArgumentException("The requested format " + MimeTypeFromImageFormat(System.Drawing.Imaging.ImageFormat.Jpeg) + " does not have an available codec installed","destFormat");
} //Create an EncoderParameters collection to contain the
//parameters that control the dest format's encoder
System.Drawing.Imaging.EncoderParameters destEncParams = new System.Drawing.Imaging.EncoderParameters(1); //Use quality parameter
System.Drawing.Imaging.EncoderParameter qualityParam = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100);
destEncParams.Param[0] = qualityParam;
imgTmp.RotateFlip(rfType); System.IO.MemoryStream msTmp = new System.IO.MemoryStream();
//Save w/ the selected codec and encoder parameters
//imgTmp.Save(strPhotoFullPath, destCodec, destEncParams);
imgTmp.Save(msTmp, destCodec, destEncParams); <-------------------参数错误
......
}其中有些函数还是直接COPY过来的,担执行到imgTmp.Save(msTmp, destCodec, destEncParams); 的时候还是会报错:参数错误.找不到总题在哪里,SOS!!!
http://www.cnblogs.com/lixianhuei/archive/2006/03/13/348909.html重新试了下,把100改成100L,竟然可以了!为什么?
不明白为什么要100L