图片旋转

2014-10-24 14:15:15  访问(2199) 赞(0) 踩(0)


        /// <summary>
        /// 图片旋转
        /// </summary>
        /// <param name="sourceFileName"></param>
        /// <param name="rotateFlipTypeValue"></param>
        public static void RotateImg
            (
                string sourceFileName,
                System.Drawing.RotateFlipType rotateFlipTypeValue
            )
        {
            RotateImg
                (
                    sourceFileName, 
                    sourceFileName, 
                    rotateFlipTypeValue
                );
        }

        /// <summary>
        /// 图片旋转
        /// </summary>
        /// <param name="sourceFileName"></param>
        /// <param name="outputFileName"></param>
        /// <param name="rotateFlipTypeValue"></param>
        /// <param name="?"></param>
        public static void RotateImg
            (
                string sourceFileName,
                string outputFileName,
                System.Drawing.RotateFlipType rotateFlipTypeValue
            )
        {
            if (sourceFileName == null || sourceFileName.Length == 0)
                throw new Exception("sourceFileName == null || sourceFileName.Length == 0");

            if (!File.Exists(sourceFileName))
                throw new Exception("string sourceFileName[" + sourceFileName + "]文件不存在");

            if (outputFileName == null || outputFileName.Length == 0)
                throw new Exception("outputFileName == null || outputFileName.Length == 0");

            Bitmap userimage = null;

            try
            {

                userimage = new Bitmap(sourceFileName);

                userimage.RotateFlip(rotateFlipTypeValue);

                userimage.Save(outputFileName);
            }
            catch (Exception err)
            {
                throw err;
            }
            finally
            {
                if (userimage != null)
                    userimage.Dispose();
            }
        }


示例程序


标签:图片旋转    .net程序    RotateImg 

上一条:

下一条:


 

相关评论

评论加载中……
 

发表评论

类型:
内容:
  (Alt+Enter)