本文整理汇总了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;
}