本文整理匯總了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;
}
示例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;
}