BsBitmapWriter.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //__________________________ Banshee Project - A modern game development toolkit _________________________________//
  2. //_____________________________________ www.banshee-project.com __________________________________________________//
  3. //________________________ Copyright (c) 2014 Marko Pintera. All rights reserved. ________________________________//
  4. #pragma once
  5. #include "BsPrerequisitesUtil.h"
  6. namespace BansheeEngine
  7. {
  8. /**
  9. * @brief Utility class from generating BMP images.
  10. */
  11. class BS_UTILITY_EXPORT BitmapWriter
  12. {
  13. public:
  14. /**
  15. * @brief Generates bytes representing the BMP image format, from a set of raw RGB or RGBA pixels.
  16. *
  17. * @param 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 width The width of the image in pixels.
  21. * @param height The height of the image in pixels.
  22. * @param 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. * @brief Returns the size of the BMP output buffer that needs to be allocated before calling "rawPixelsToBMP".
  27. *
  28. * @param width The width of the image in pixels.
  29. * @param height The height of the image in pixels.
  30. * @param 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. }