您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (assimp)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2012, assimp team
  6. All rights reserved.
  7. Redistribution and use of this software in source and binary forms,
  8. with or without modification, are permitted provided that the following
  9. conditions are met:
  10. * Redistributions of source code must retain the above
  11. copyright notice, this list of conditions and the
  12. following disclaimer.
  13. * Redistributions in binary form must reproduce the above
  14. copyright notice, this list of conditions and the
  15. following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. * Neither the name of the assimp team, nor the names of its
  18. contributors may be used to endorse or promote products
  19. derived from this software without specific prior
  20. written permission of the assimp team.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ---------------------------------------------------------------------------
  33. */
  34. /** @file Bitmap.h
  35. * @brief Defines bitmap format helper for textures
  36. *
  37. * Used for file formats which embed their textures into the model file.
  38. */
  39. #ifndef AI_BITMAP_H_INC
  40. #define AI_BITMAP_H_INC
  41. namespace Assimp {
  42. class Bitmap {
  43. protected:
  44. struct Header {
  45. uint16_t type;
  46. uint32_t size;
  47. uint16_t reserved1;
  48. uint16_t reserved2;
  49. uint32_t offset;
  50. // We define the struct size because sizeof(Header) might return a wrong result because of structure padding.
  51. // Moreover, we must use this ugly and error prone syntax because Visual Studio neither support constexpr or sizeof(name_of_field).
  52. static const std::size_t header_size =
  53. sizeof(uint16_t) + // type
  54. sizeof(uint32_t) + // size
  55. sizeof(uint16_t) + // reserved1
  56. sizeof(uint16_t) + // reserved2
  57. sizeof(uint32_t); // offset
  58. };
  59. struct DIB {
  60. uint32_t size;
  61. int32_t width;
  62. int32_t height;
  63. uint16_t planes;
  64. uint16_t bits_per_pixel;
  65. uint32_t compression;
  66. uint32_t image_size;
  67. int32_t x_resolution;
  68. int32_t y_resolution;
  69. uint32_t nb_colors;
  70. uint32_t nb_important_colors;
  71. // We define the struct size because sizeof(DIB) might return a wrong result because of structure padding.
  72. // Moreover, we must use this ugly and error prone syntax because Visual Studio neither support constexpr or sizeof(name_of_field).
  73. static const std::size_t dib_size =
  74. sizeof(uint32_t) + // size
  75. sizeof(int32_t) + // width
  76. sizeof(int32_t) + // height
  77. sizeof(uint16_t) + // planes
  78. sizeof(uint16_t) + // bits_per_pixel
  79. sizeof(uint32_t) + // compression
  80. sizeof(uint32_t) + // image_size
  81. sizeof(int32_t) + // x_resolution
  82. sizeof(int32_t) + // y_resolution
  83. sizeof(uint32_t) + // nb_colors
  84. sizeof(uint32_t); // nb_important_colors
  85. };
  86. static const std::size_t mBytesPerPixel = 4;
  87. public:
  88. static void Save(aiTexture* texture, IOStream* file);
  89. protected:
  90. static void WriteHeader(Header& header, IOStream* file);
  91. static void WriteDIB(DIB& dib, IOStream* file);
  92. static void WriteData(aiTexture* texture, IOStream* file);
  93. };
  94. }
  95. #endif // AI_BITMAP_H_INC