BsPixelDataEx.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsScriptEnginePrerequisites.h"
  5. #include "Image/BsColor.h"
  6. #include "Image/BsPixelData.h"
  7. namespace bs
  8. {
  9. /** @addtogroup ScriptInteropEngine
  10. * @{
  11. */
  12. /** @cond SCRIPT_EXTENSIONS */
  13. /** Extension class for PixelData, for adding additional functionality for the script version of PixelData. */
  14. class BS_SCRIPT_EXPORT(e:PixelData) PixelDataEx
  15. {
  16. public:
  17. BS_SCRIPT_EXPORT(ec:PixelData)
  18. static SPtr<PixelData> create(const PixelVolume& volume, PixelFormat format = PF_BGRA8);
  19. BS_SCRIPT_EXPORT(ec:PixelData)
  20. static SPtr<PixelData> create(UINT32 width, UINT32 height, UINT32 depth = 1, PixelFormat pixelFormat = PF_BGRA8);
  21. /**
  22. * Returns a pixel at the specified location in the buffer.
  23. *
  24. * @param[in] x X coordinate of the pixel.
  25. * @param[in] y Y coordinate of the pixel.
  26. * @param[in] z Z coordinate of the pixel.
  27. * @return Value of the pixel, or undefined value if coordinates are out of range.
  28. */
  29. BS_SCRIPT_EXPORT(e:PixelData,n:GetPixel)
  30. static Color getPixel(const SPtr<PixelData>& thisPtr, int x, int y, int z = 0);
  31. /**
  32. * Sets a pixel at the specified location in the buffer.
  33. *
  34. * @param[in] value Color of the pixel to set.
  35. * @param[in] x X coordinate of the pixel.
  36. * @param[in] y Y coordinate of the pixel.
  37. * @param[in] z Z coordinate of the pixel.
  38. */
  39. BS_SCRIPT_EXPORT(e:PixelData,n:SetPixel)
  40. static void setPixel(const SPtr<PixelData>& thisPtr, const Color& value, int x, int y, int z = 0);
  41. /**
  42. * Returns values of all pixels.
  43. *
  44. * @return All pixels in the buffer ordered consecutively. Pixels are stored as a succession of "depth" slices,
  45. * each containing "height" rows of "width" pixels.
  46. */
  47. BS_SCRIPT_EXPORT(e:PixelData,n:GetPixels)
  48. static Vector<Color> getPixels(const SPtr<PixelData>& thisPtr);
  49. /**
  50. * Sets all pixels in the buffer.Caller must ensure that number of pixels match the extends of the buffer.
  51. *
  52. * @param value All pixels in the buffer ordered consecutively. Pixels are stored as a succession of "depth" slices,
  53. * each containing "height" rows of "width" pixels.
  54. */
  55. BS_SCRIPT_EXPORT(e:PixelData,n:SetPixels)
  56. static void setPixels(const SPtr<PixelData>& thisPtr, const Vector<Color>& value);
  57. /**
  58. * Returns all pixels in the buffer as raw bytes.
  59. *
  60. * @return Raw pixel bytes. It is up to the caller to interpret the pixel format and account for potential
  61. * row and slice pitch values.
  62. */
  63. BS_SCRIPT_EXPORT(e:PixelData,n:GetRawPixels)
  64. static Vector<char> getRawPixels(const SPtr<PixelData>& thisPtr);
  65. /**
  66. * Sets all pixels in the buffer as raw bytes.
  67. *
  68. * @param[in] value Raw pixel bytes. It is up to the caller to interpret the pixel format and account for
  69. * potential row and slice pitch values.
  70. */
  71. BS_SCRIPT_EXPORT(e:PixelData,n:SetRawPixels)
  72. static void setRawPixels(const SPtr<PixelData>& thisPtr, const Vector<char>& value);
  73. static bool checkIsLocked(const SPtr<PixelData>& thisPtr);
  74. };
  75. /** @endcond */
  76. /** @} */
  77. }