我使用了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中的那么多效果么?请教!!!!!!!!!!

解决方案 »

  1.   

    to 如果指定成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);
    不知这个问题如果解决?这是由于图像质量降低而造成的,你可以设置EncoderParameter来设置图片质量ref:
    http://www.codeproject.com/cs/media/bitmapmanip.asp
      

  2.   

    to Knight94
    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!!!
      

  3.   

    看了这个:
    http://www.cnblogs.com/lixianhuei/archive/2006/03/13/348909.html重新试了下,把100改成100L,竟然可以了!为什么?
      

  4.   

    Windows中图片查看器的翻转功能只有几十个字节的差别,而我采用100质量还会把1.4M左右的文件变成2M多,
      

  5.   

    [C#] public EncoderParameter(Encoder, int, int, int, int);构造函数有int啊
    不明白为什么要100L