BsBitmapWriter.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include "BsPrerequisitesUtil.h"
  3. namespace BansheeEngine
  4. {
  5. /**
  6. * @brief Utility class from generating BMP images.
  7. */
  8. class BS_UTILITY_EXPORT BitmapWriter
  9. {
  10. public:
  11. /**
  12. * @brief Generates bytes representing the BMP image format, from a set of raw RGB or RGBA pixels.
  13. *
  14. * @param input The input set of bytes in RGB or RGBA format. Starting byte represents the top left pixel of the image
  15. * and following pixels need to be set going from left to right, row after row.
  16. * @param [out] output Preallocated buffer where the BMP bytes will be stored. Use "getBMPSize" to retrieve the size needed for this buffer.
  17. * @param width The width of the image in pixels.
  18. * @param height The height of the image in pixels.
  19. * @param bytesPerPixel Number of bytes per pixel. 3 for RGB images and 4 for RGBA images. Other values not supported.
  20. */
  21. static void rawPixelsToBMP(const UINT8* input, UINT8* output, UINT32 width, UINT32 height, UINT32 bytesPerPixel);
  22. /**
  23. * @brief Returns the size of the BMP output buffer that needs to be allocated before calling "rawPixelsToBMP".
  24. *
  25. * @param width The width of the image in pixels.
  26. * @param height The height of the image in pixels.
  27. * @param bytesPerPixel Number of bytes per pixel. 3 for RGB images and 4 for RGBA images. Other values not supported.
  28. *
  29. * @return Size of the BMP output buffer needed to write a BMP of the specified size & bpp.
  30. */
  31. static UINT32 getBMPSize(UINT32 width, UINT32 height, UINT32 bytesPerPixel);
  32. };
  33. }