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

  1. #if NET40 || NET461
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Drawing;
  5. using System.Drawing.Imaging;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace Apewer.Surface
  11. {
  12. /// <summary></summary>
  13. public static class Extensions
  14. {
  15. /// <summary>保存为 PNG 文件。</summary>
  16. public static byte[] SaveAsPng(this Image @this, bool disposeImage = false)
  17. {
  18. return ImageUtility.SaveAsBytes(@this, ImageFormat.Png, disposeImage);
  19. }
  20. /// <summary>保存为 JPEG 文件。</summary>
  21. public static byte[] SaveAsJpeg(this Image @this, bool disposeImage = false)
  22. {
  23. return ImageUtility.SaveAsBytes(@this, ImageFormat.Jpeg, disposeImage);
  24. }
  25. /// <summary></summary>
  26. public static void BeginInvoke(this Control control, Action action)
  27. {
  28. if (action == null) return;
  29. control.BeginInvoke(action as Delegate);
  30. }
  31. /// <summary></summary>
  32. public static void Invoke(this Control control, Action action)
  33. {
  34. if (action == null) return;
  35. control.Invoke(action as Delegate);
  36. }
  37. }
  38. }
  39. #endif