PixelData.generated.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. using System.Runtime.InteropServices;
  4. namespace BansheeEngine
  5. {
  6. /// <summary>
  7. /// A buffer describing a volume (3D), image (2D) or line (1D) of pixels in memory. Pixels are stored as a succession of
  8. /// "depth" slices, each containing "height" rows of "width" pixels.
  9. /// </summary>
  10. public partial class PixelData : ScriptObject
  11. {
  12. private PixelData(bool __dummy0) { }
  13. protected PixelData() { }
  14. public PixelData(PixelVolume volume, PixelFormat format = PixelFormat.BGRA8)
  15. {
  16. Internal_create(this, ref volume, format);
  17. }
  18. public PixelData(uint width, uint height, uint depth = 1, PixelFormat pixelFormat = PixelFormat.BGRA8)
  19. {
  20. Internal_create0(this, width, height, depth, pixelFormat);
  21. }
  22. /// <summary>
  23. /// Returns the number of pixels that offsets one row from another. This can be "width", but doesn't have to be as some
  24. /// buffers require padding.
  25. /// </summary>
  26. public uint RawRowPitch
  27. {
  28. get { return Internal_getRowPitch(mCachedPtr); }
  29. }
  30. /// <summary>
  31. /// Returns the number of pixels that offsets one depth slice from another. This can be "width * height", but doesn't
  32. /// have to be as some buffers require padding.
  33. /// </summary>
  34. public uint RawSlicePitch
  35. {
  36. get { return Internal_getSlicePitch(mCachedPtr); }
  37. }
  38. /// <summary>Returns the pixel format used by the internal buffer for storing the pixels.</summary>
  39. public PixelFormat Format
  40. {
  41. get { return Internal_getFormat(mCachedPtr); }
  42. }
  43. /// <summary>Returns extents of the pixel volume this object is capable of holding.</summary>
  44. public PixelVolume Extents
  45. {
  46. get
  47. {
  48. PixelVolume temp;
  49. Internal_getExtents(mCachedPtr, out temp);
  50. return temp;
  51. }
  52. }
  53. /// <summary>
  54. /// Return whether this buffer is laid out consecutive in memory (meaning the pitches are equal to the dimensions).
  55. /// </summary>
  56. public bool RawIsConsecutive
  57. {
  58. get { return Internal_isConsecutive(mCachedPtr); }
  59. }
  60. /// <summary>Return the size (in bytes) of the buffer this image requires.</summary>
  61. public uint RawSize
  62. {
  63. get { return Internal_getSize(mCachedPtr); }
  64. }
  65. /// <summary>Returns a pixel at the specified location in the buffer.</summary>
  66. /// <param name="x">X coordinate of the pixel.</param>
  67. /// <param name="y">Y coordinate of the pixel.</param>
  68. /// <param name="z">Z coordinate of the pixel.</param>
  69. /// <returns>Value of the pixel, or undefined value if coordinates are out of range.</returns>
  70. public Color GetPixel(int x, int y, int z = 0)
  71. {
  72. Color temp;
  73. Internal_getPixel(mCachedPtr, x, y, z, out temp);
  74. return temp;
  75. }
  76. /// <summary>Sets a pixel at the specified location in the buffer.</summary>
  77. /// <param name="value">Color of the pixel to set.</param>
  78. /// <param name="x">X coordinate of the pixel.</param>
  79. /// <param name="y">Y coordinate of the pixel.</param>
  80. /// <param name="z">Z coordinate of the pixel.</param>
  81. public void SetPixel(Color value, int x, int y, int z = 0)
  82. {
  83. Internal_setPixel(mCachedPtr, ref value, x, y, z);
  84. }
  85. /// <summary>Returns values of all pixels.</summary>
  86. /// <returns>
  87. /// All pixels in the buffer ordered consecutively. Pixels are stored as a succession of "depth" slices, each containing
  88. /// "height" rows of "width" pixels.
  89. /// </returns>
  90. public Color[] GetPixels()
  91. {
  92. return Internal_getPixels(mCachedPtr);
  93. }
  94. /// <summary>
  95. /// Sets all pixels in the buffer.Caller must ensure that number of pixels match the extends of the buffer.
  96. /// </summary>
  97. /// <param name="value">
  98. /// All pixels in the buffer ordered consecutively. Pixels are stored as a succession of "depth" slices, each containing
  99. /// "height" rows of "width" pixels.
  100. /// </param>
  101. public void SetPixels(Color[] value)
  102. {
  103. Internal_setPixels(mCachedPtr, value);
  104. }
  105. /// <summary>Returns all pixels in the buffer as raw bytes.</summary>
  106. /// <returns>
  107. /// Raw pixel bytes. It is up to the caller to interpret the pixel format and account for potential row and slice pitch
  108. /// values.
  109. /// </returns>
  110. public char[] GetRawPixels()
  111. {
  112. return Internal_getRawPixels(mCachedPtr);
  113. }
  114. /// <summary>Sets all pixels in the buffer as raw bytes.</summary>
  115. /// <param name="value">
  116. /// Raw pixel bytes. It is up to the caller to interpret the pixel format and account for potential row and slice pitch
  117. /// values.
  118. /// </param>
  119. public void SetRawPixels(char[] value)
  120. {
  121. Internal_setRawPixels(mCachedPtr, value);
  122. }
  123. [MethodImpl(MethodImplOptions.InternalCall)]
  124. private static extern uint Internal_getRowPitch(IntPtr thisPtr);
  125. [MethodImpl(MethodImplOptions.InternalCall)]
  126. private static extern uint Internal_getSlicePitch(IntPtr thisPtr);
  127. [MethodImpl(MethodImplOptions.InternalCall)]
  128. private static extern PixelFormat Internal_getFormat(IntPtr thisPtr);
  129. [MethodImpl(MethodImplOptions.InternalCall)]
  130. private static extern void Internal_getExtents(IntPtr thisPtr, out PixelVolume __output);
  131. [MethodImpl(MethodImplOptions.InternalCall)]
  132. private static extern bool Internal_isConsecutive(IntPtr thisPtr);
  133. [MethodImpl(MethodImplOptions.InternalCall)]
  134. private static extern uint Internal_getSize(IntPtr thisPtr);
  135. [MethodImpl(MethodImplOptions.InternalCall)]
  136. private static extern void Internal_create(PixelData managedInstance, ref PixelVolume volume, PixelFormat format);
  137. [MethodImpl(MethodImplOptions.InternalCall)]
  138. private static extern void Internal_create0(PixelData managedInstance, uint width, uint height, uint depth, PixelFormat pixelFormat);
  139. [MethodImpl(MethodImplOptions.InternalCall)]
  140. private static extern void Internal_getPixel(IntPtr thisPtr, int x, int y, int z, out Color __output);
  141. [MethodImpl(MethodImplOptions.InternalCall)]
  142. private static extern void Internal_setPixel(IntPtr thisPtr, ref Color value, int x, int y, int z);
  143. [MethodImpl(MethodImplOptions.InternalCall)]
  144. private static extern Color[] Internal_getPixels(IntPtr thisPtr);
  145. [MethodImpl(MethodImplOptions.InternalCall)]
  146. private static extern void Internal_setPixels(IntPtr thisPtr, Color[] value);
  147. [MethodImpl(MethodImplOptions.InternalCall)]
  148. private static extern char[] Internal_getRawPixels(IntPtr thisPtr);
  149. [MethodImpl(MethodImplOptions.InternalCall)]
  150. private static extern void Internal_setRawPixels(IntPtr thisPtr, char[] value);
  151. }
  152. }