當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。