BsPixelDataEx.h 3.2 KB

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