当前位置: 首页>>代码示例>>C#>>正文


C# Image.SaveImage方法代码示例

本文整理汇总了C#中System.Drawing.Image.SaveImage方法的典型用法代码示例。如果您正苦于以下问题:C# Image.SaveImage方法的具体用法?C# Image.SaveImage怎么用?C# Image.SaveImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Image的用法示例。


在下文中一共展示了Image.SaveImage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PrepareImage

        public static MemoryStream PrepareImage(Workflow wf, ZScreenOptions zo, Image img, out EImageFormat imageFormat,
            bool bConvert = true, bool bTargetFileSize = true)
        {
            imageFormat = wf.ImageFormat;
            MemoryStream stream = img.SaveImage(wf, wf.ImageFormat);

            if (bConvert)
            {
                long streamLength = stream.Length / 1024;
                int sizeLimit = zo.ConfigImageEffects.ImageSizeLimit * 1024;

                if (wf.ImageFormat != wf.ImageFormat2 && sizeLimit > 0 && stream.Length > sizeLimit)
                {
                    stream = img.SaveImage(wf, wf.ImageFormat2);

                    if (bTargetFileSize)
                    {
                        DebugHelper.WriteLine(ConvertImageString(streamLength, wf, stream));
                        while (stream.Length > sizeLimit && wf.ImageFormat2 == EImageFormat.JPEG)
                        {
                            if (wf.ImageJpegQuality == FreeImageJpegQualityType.JPEG_QUALITYBAD)
                            {
                                break;
                            }

                            wf.ImageJpegQuality = wf.ImageJpegQuality - 1;
                            stream = img.SaveImage(wf, EImageFormat.JPEG);
                            DebugHelper.WriteLine(ConvertImageString(streamLength, wf, stream));
                        }
                    }

                    imageFormat = wf.ImageFormat2;
                }
            }

            stream.Position = 0;

            return stream;
        }
开发者ID:modulexcite,项目名称:ZScreen_Google_Code,代码行数:39,代码来源:WorkerTaskHelper.cs

示例2: PrepareImage

        private static MemoryStream PrepareImage(Image img, out EImageFormat imageFormat)
        {
            if (Program.Settings.ImageAutoResize)
            {
                img = ResizeImage(img, Program.Settings.ImageScaleType);
            }

            MemoryStream stream = img.SaveImage(Program.Settings.ImageFormat);

            int sizeLimit = Program.Settings.ImageSizeLimit * 1000;
            if (Program.Settings.ImageFormat != Program.Settings.ImageFormat2 && sizeLimit > 0 && stream.Length > sizeLimit)
            {
                stream = img.SaveImage(Program.Settings.ImageFormat2);
                imageFormat = Program.Settings.ImageFormat2;
            }
            else
            {
                imageFormat = Program.Settings.ImageFormat;
            }

            stream.Position = 0;

            return stream;
        }
开发者ID:modulexcite,项目名称:ZScreen_Google_Code,代码行数:24,代码来源:TaskHelper.cs


注:本文中的System.Drawing.Image.SaveImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。