image.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Copyright 2011-2014 Branimir Karadzic. All rights reserved.
  3. * License: http://www.opensource.org/licenses/BSD-2-Clause
  4. */
  5. #ifndef BGFX_IMAGE_H_HEADER_GUARD
  6. #define BGFX_IMAGE_H_HEADER_GUARD
  7. #include <stdint.h>
  8. namespace bgfx
  9. {
  10. struct ImageContainer
  11. {
  12. void* m_data;
  13. uint32_t m_size;
  14. uint32_t m_offset;
  15. uint32_t m_width;
  16. uint32_t m_height;
  17. uint32_t m_depth;
  18. uint8_t m_format;
  19. uint8_t m_numMips;
  20. bool m_hasAlpha;
  21. bool m_cubeMap;
  22. bool m_ktx;
  23. };
  24. struct ImageMip
  25. {
  26. uint32_t m_width;
  27. uint32_t m_height;
  28. uint32_t m_blockSize;
  29. uint32_t m_size;
  30. uint8_t m_bpp;
  31. uint8_t m_format;
  32. bool m_hasAlpha;
  33. const uint8_t* m_data;
  34. };
  35. struct ImageBlockInfo
  36. {
  37. uint8_t bitsPerPixel;
  38. uint8_t blockWidth;
  39. uint8_t blockHeight;
  40. uint8_t blockSize;
  41. };
  42. ///
  43. bool isCompressed(TextureFormat::Enum _format);
  44. ///
  45. bool isColor(TextureFormat::Enum _format);
  46. ///
  47. bool isDepth(TextureFormat::Enum _format);
  48. ///
  49. uint8_t getBitsPerPixel(TextureFormat::Enum _format);
  50. ///
  51. const ImageBlockInfo& getBlockInfo(TextureFormat::Enum _format);
  52. ///
  53. const char* getName(TextureFormat::Enum _format);
  54. ///
  55. void imageSolid(uint32_t _width, uint32_t _height, uint32_t _solid, void* _dst);
  56. ///
  57. void imageCheckerboard(uint32_t _width, uint32_t _height, uint32_t _step, uint32_t _0, uint32_t _1, void* _dst);
  58. ///
  59. void imageRgba8Downsample2x2(uint32_t _width, uint32_t _height, uint32_t _srcPitch, const void* _src, void* _dst);
  60. ///
  61. void imageSwizzleBgra8(uint32_t _width, uint32_t _height, uint32_t _srcPitch, const void* _src, void* _dst);
  62. ///
  63. void imageCopy(uint32_t _width, uint32_t _height, uint32_t _bpp, uint32_t _srcPitch, const void* _src, void* _dst);
  64. ///
  65. void imageWriteTga(bx::WriterI* _writer, uint32_t _width, uint32_t _height, uint32_t _srcPitch, const void* _src, bool _grayscale, bool _yflip);
  66. ///
  67. bool imageParse(ImageContainer& _imageContainer, bx::ReaderSeekerI* _reader);
  68. ///
  69. bool imageParse(ImageContainer& _imageContainer, const void* _data, uint32_t _size);
  70. ///
  71. void imageDecodeToBgra8(uint8_t* _dst, const uint8_t* _src, uint32_t _width, uint32_t _height, uint32_t _srcPitch, uint8_t _type);
  72. ///
  73. bool imageGetRawData(const ImageContainer& _dds, uint8_t _side, uint8_t _index, const void* _data, uint32_t _size, ImageMip& _mip);
  74. } // namespace bgfx
  75. #endif // BGFX_IMAGE_H_HEADER_GUARD