You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.2 KiB

#if NET40 || NET461
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Apewer.Surface
{
/// <summary></summary>
public static class Extensions
{
/// <summary>保存为 PNG 文件。</summary>
public static byte[] SaveAsPng(this Image @this, bool disposeImage = false)
{
return ImageUtility.SaveAsBytes(@this, ImageFormat.Png, disposeImage);
}
/// <summary>保存为 JPEG 文件。</summary>
public static byte[] SaveAsJpeg(this Image @this, bool disposeImage = false)
{
return ImageUtility.SaveAsBytes(@this, ImageFormat.Jpeg, disposeImage);
}
/// <summary></summary>
public static void BeginInvoke(this Control control, Action action)
{
if (action == null) return;
control.BeginInvoke(action as Delegate);
}
/// <summary></summary>
public static void Invoke(this Control control, Action action)
{
if (action == null) return;
control.Invoke(action as Delegate);
}
}
}
#endif