Pixmap.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using PixiEditor.DrawingApi.Core.Bridge;
  3. using PixiEditor.DrawingApi.Core.Surface.ImageData;
  4. namespace PixiEditor.DrawingApi.Core.Surface;
  5. public class Pixmap : NativeObject
  6. {
  7. internal Pixmap(IntPtr objPtr) : base(objPtr)
  8. {
  9. }
  10. public Pixmap(ImageInfo imgInfo, IntPtr dataPtr) : base(dataPtr)
  11. {
  12. ObjectPointer = DrawingBackendApi.Current.PixmapImplementation.Construct(dataPtr, imgInfo);
  13. }
  14. public int Width
  15. {
  16. get => DrawingBackendApi.Current.PixmapImplementation.GetWidth(this);
  17. }
  18. public int Height
  19. {
  20. get => DrawingBackendApi.Current.PixmapImplementation.GetHeight(this);
  21. }
  22. public override void Dispose()
  23. {
  24. DrawingBackendApi.Current.PixmapImplementation.Dispose(ObjectPointer);
  25. }
  26. public IntPtr GetPixels()
  27. {
  28. return DrawingBackendApi.Current.PixmapImplementation.GetPixels(ObjectPointer);
  29. }
  30. public Span<T> GetPixelSpan<T>() where T : unmanaged
  31. {
  32. return DrawingBackendApi.Current.PixmapImplementation.GetPixelSpan<T>(this);
  33. }
  34. }