ImageFormat.h 754 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2021, Stephan Unverwerth <s.unverwerth@serenityos.org>
  3. * Copyright (c) 2022, the SerenityOS developers.
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <AK/Types.h>
  9. namespace GPU {
  10. enum class ImageFormat {
  11. RGB565,
  12. RGB888,
  13. BGR888,
  14. RGBA8888,
  15. BGRA8888,
  16. L8,
  17. L8A8,
  18. };
  19. static constexpr size_t element_size(ImageFormat format)
  20. {
  21. switch (format) {
  22. case ImageFormat::L8:
  23. return 1;
  24. case ImageFormat::RGB565:
  25. case ImageFormat::L8A8:
  26. return 2;
  27. case ImageFormat::RGB888:
  28. case ImageFormat::BGR888:
  29. return 3;
  30. case ImageFormat::RGBA8888:
  31. case ImageFormat::BGRA8888:
  32. return 4;
  33. default:
  34. VERIFY_NOT_REACHED();
  35. }
  36. }
  37. }