選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

81 行
2.1 KiB

  1. using RenderHookAPI.Interface;
  2. using System;
  3. namespace RenderHookAPI.Hook.Common
  4. {
  5. [Serializable]
  6. public class ImageElement: Element
  7. {
  8. /// <summary>
  9. /// The image file bytes
  10. /// </summary>
  11. public virtual byte[] Image { get; set; }
  12. System.Drawing.Bitmap _bitmap = null;
  13. internal virtual System.Drawing.Bitmap Bitmap {
  14. get
  15. {
  16. if (_bitmap == null && Image != null)
  17. {
  18. _bitmap = Image.ToBitmap();
  19. _ownsBitmap = true;
  20. }
  21. return _bitmap;
  22. }
  23. set { _bitmap = value; }
  24. }
  25. /// <summary>
  26. /// This value is multiplied with the source color (e.g. White will result in same color as source image)
  27. /// </summary>
  28. /// <remarks>
  29. /// Defaults to <see cref="System.Drawing.Color.White"/>.
  30. /// </remarks>
  31. public virtual System.Drawing.Color Tint { get; set; } = System.Drawing.Color.White;
  32. /// <summary>
  33. /// The location of where to render this image element
  34. /// </summary>
  35. public virtual System.Drawing.Point Location { get; set; }
  36. public float Angle { get; set; }
  37. public float Scale { get; set; } = 1.0f;
  38. public string Filename { get; set; }
  39. bool _ownsBitmap = false;
  40. public ImageElement() { }
  41. public ImageElement(string filename):
  42. this(new System.Drawing.Bitmap(filename), true)
  43. {
  44. Filename = filename;
  45. }
  46. public ImageElement(System.Drawing.Bitmap bitmap, bool ownsImage = false)
  47. {
  48. Tint = System.Drawing.Color.White;
  49. this.Bitmap = bitmap;
  50. _ownsBitmap = ownsImage;
  51. Scale = 1.0f;
  52. }
  53. protected override void Dispose(bool disposing)
  54. {
  55. base.Dispose(disposing);
  56. if (disposing)
  57. {
  58. if (_ownsBitmap)
  59. {
  60. SafeDispose(this.Bitmap);
  61. this.Bitmap = null;
  62. }
  63. }
  64. }
  65. }
  66. }