PixelFormat.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. Copyright (c) 2013 Daniele Bartolini, Michele Rossi
  3. Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
  4. Permission is hereby granted, free of charge, to any person
  5. obtaining a copy of this software and associated documentation
  6. files (the "Software"), to deal in the Software without
  7. restriction, including without limitation the rights to use,
  8. copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the
  10. Software is furnished to do so, subject to the following
  11. conditions:
  12. The above copyright notice and this permission notice shall be
  13. included in all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  16. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  18. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  19. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  21. OTHER DEALINGS IN THE SOFTWARE.
  22. */
  23. #pragma once
  24. #include "Types.h"
  25. namespace crown
  26. {
  27. // [0 - 2] -> 8-bit
  28. // [3 - 11] -> 16-bit
  29. // [12 - 13] -> 24-bit
  30. // [14 - 23] -> 32-bit
  31. // [24 - 25] -> 48-bit
  32. // [26 - 31] -> 64-bit
  33. // [32 - 35] -> 96-bit
  34. // [36 - 39] -> 128-bit
  35. // 40 -> Unknown (0-bit)
  36. /// Enumerates pixel formats.
  37. enum PixelFormat
  38. {
  39. PF_L_8 = 0, ///< Luminance only, 8-bit
  40. PF_L_16 = 3, ///< Luminance only, 16-bit
  41. PF_L_32 = 14, ///< Luminance only, 32-bit integer
  42. PF_L_FLOAT_32 = 15, ///< Luminance only, 32-bit flaoting point
  43. PF_LA_8 = 4, ///< Luminance and alpha, 8-bit each
  44. PF_LA_16 = 16, ///< Luminance and alpha, 16-bit each
  45. PF_LA_32 = 26, ///< Luminance and alpha, 32-bit integer each
  46. PF_LA_FLOAT_32 = 27, ///< Luminance and alpha, 32-bit floating point each
  47. PF_AL_8 = 5, ///< Luminance and alpha, 8-bit each
  48. PF_AL_16 = 17, ///< Luminance and alpha, 16-bit each
  49. PF_AL_32 = 28, ///< Luminance and alpha, 32-bit integer each
  50. PF_AL_FLOAT_32 = 29, ///< Luminance and alpha, 32-bit floating point each
  51. PF_RGB_8 = 12, ///< RGB values, 8-bit each
  52. PF_RGB_16 = 24, ///< RGB values, 16-bit each
  53. PF_RGB_32 = 32, ///< RGB values, 32-bit integer each
  54. PF_RGB_FLOAT_32 = 33, ///< RGB values, 32-bit floating point each
  55. PF_RGB_3_3_2 = 1, ///< Packed 8-bit RGB values
  56. PF_RGB_5_6_5 = 6, ///< Packed 16-bit RGB values
  57. PF_BGR_8 = 13, ///< BGR values, 8-bit each
  58. PF_BGR_16 = 25, ///< BGR values, 16-bit each
  59. PF_BGR_32 = 34, ///< BGR values, 32-bit integer each
  60. PF_BGR_FLOAT_32 = 35, ///< BGR values, 32-bit floating point each
  61. PF_BGR_2_3_3 = 2, ///< Packed 8-bit BGR values
  62. PF_BGR_5_6_5 = 7, ///< Packed 16-bit BGR values
  63. PF_RGBA_8 = 18, ///< RGBA values, 8-bit each
  64. PF_RGBA_16 = 30, ///< RGBA values, 16-bit each
  65. PF_RGBA_32 = 36, ///< RGBA values, 32-bit integer each
  66. PF_RGBA_FLOAT_32 = 37, ///< RGBA values, 32-bit floating point each
  67. PF_RGBA_4_4_4_4 = 8, ///< Packed 16-bit RGBA values
  68. PF_RGBA_5_5_5_1 = 9, ///< Packed 16-bit RGBA values
  69. PF_RGBA_8_8_8_8 = 19, ///< Packed 32-bit RGBA values
  70. PF_RGBA_10_10_10_2 = 20,///< Packed 32-bit RGBA values
  71. PF_ABGR_8 = 21, ///< ABGR values, 8-bit each
  72. PF_ABGR_16 = 31, ///< ABGR values, 16-bit each
  73. PF_ABGR_32 = 38, ///< ABGR values, 32-bit integer each
  74. PF_ABGR_FLOAT_32 = 39, ///< ABGR values, 32-bit floating point each
  75. PF_ABGR_4_4_4_4 = 10, ///< Packed 16-bit ABGR values
  76. PF_ABGR_1_5_5_5 = 11, ///< Packed 16-bit ABGR values
  77. PF_ABGR_8_8_8_8 = 22, ///< Packed 32-bit ABGR values
  78. PF_ABGR_2_10_10_10 = 23,///< Packed 32-bit ABGR values
  79. PF_UNKNOWN = 40
  80. };
  81. class Pixel
  82. {
  83. public:
  84. /// Returns the bytes occupied by @a format
  85. static size_t bytes_per_pixel(PixelFormat format);
  86. /// Returns the bits occupied by @a format
  87. static size_t bits_per_pixel(PixelFormat format);
  88. private:
  89. // Disable construction
  90. Pixel();
  91. };
  92. } // namespace crown