BsBitmapWriter.h 1.8 KB

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