暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

BitmapLayer.cs 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System.Collections.Generic;
  2. namespace PDNWrapper
  3. {
  4. internal static class Layer
  5. {
  6. public static BitmapLayer CreateBackgroundLayer(int w, int h)
  7. {
  8. return new BitmapLayer(new Rectangle(0, 0, w, h));
  9. }
  10. }
  11. internal class BitmapLayer
  12. {
  13. public int LayerID { get; set; }
  14. public bool IsGroup {get; set; }
  15. public BitmapLayer ParentLayer {get; set; }
  16. public IEnumerable<BitmapLayer> ChildLayer => m_ChildLayers;
  17. public string Name { get; set; }
  18. public byte Opacity { get; set; }
  19. public bool Visible { get; set; }
  20. public LayerBlendMode BlendMode { get; set; }
  21. public Surface Surface { get; }
  22. public Rectangle documentRect { get; private set; }
  23. public Rectangle localRect { get; }
  24. readonly List<BitmapLayer> m_ChildLayers;
  25. public void Dispose()
  26. {
  27. Surface.Dispose();
  28. foreach (var layer in m_ChildLayers)
  29. layer.Dispose();
  30. }
  31. public BitmapLayer(Rectangle documentRect)
  32. {
  33. localRect = new Rectangle(0, 0, documentRect.Width, documentRect.Height);
  34. this.documentRect = documentRect;
  35. Surface = new Surface(localRect.Width, localRect.Height);
  36. m_ChildLayers = new List<BitmapLayer>();
  37. IsGroup = false;
  38. }
  39. public void AddChildLayer(BitmapLayer c)
  40. {
  41. m_ChildLayers.Add(c);
  42. var bound = c.documentRect;
  43. foreach (var child in ChildLayer)
  44. {
  45. bound.Y = bound.Y > child.documentRect.Y ? child.documentRect.Y : bound.Y;
  46. bound.X = bound.X > child.documentRect.X ? child.documentRect.X : bound.X;
  47. bound.Width = bound.Right < child.documentRect.Right ? child.documentRect.Right - bound.X : bound.Width;
  48. bound.Height = bound.Bottom < child.documentRect.Bottom ? child.documentRect.Bottom - bound.Y : bound.Height;
  49. }
  50. documentRect = bound;
  51. }
  52. }
  53. }