BMPWriter.h 745 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) 2020, Ben Jilks <benjyjilks@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/ByteBuffer.h>
  8. namespace Gfx {
  9. class Bitmap;
  10. class BMPWriter {
  11. public:
  12. BMPWriter() = default;
  13. enum class Compression : u32 {
  14. BI_RGB = 0,
  15. BI_BITFIELDS = 3,
  16. };
  17. enum class DibHeader : u32 {
  18. Info = 40,
  19. V3 = 56,
  20. V4 = 108,
  21. };
  22. ByteBuffer dump(const RefPtr<Bitmap>, DibHeader dib_header = DibHeader::V4);
  23. inline void set_compression(Compression compression) { m_compression = compression; }
  24. private:
  25. Compression m_compression { Compression::BI_BITFIELDS };
  26. int m_bytes_per_pixel { 4 };
  27. bool m_include_alpha_channel { true };
  28. };
  29. }