![]() |
|
|||
File indexing completed on 2025-02-21 09:30:07
0001 /* 0002 --------------------------------------------------------------------------- 0003 Open Asset Import Library (assimp) 0004 --------------------------------------------------------------------------- 0005 0006 Copyright (c) 2006-2024, assimp team 0007 0008 All rights reserved. 0009 0010 Redistribution and use of this software in source and binary forms, 0011 with or without modification, are permitted provided that the following 0012 conditions are met: 0013 0014 * Redistributions of source code must retain the above 0015 copyright notice, this list of conditions and the 0016 following disclaimer. 0017 0018 * Redistributions in binary form must reproduce the above 0019 copyright notice, this list of conditions and the 0020 following disclaimer in the documentation and/or other 0021 materials provided with the distribution. 0022 0023 * Neither the name of the assimp team, nor the names of its 0024 contributors may be used to endorse or promote products 0025 derived from this software without specific prior 0026 written permission of the assimp team. 0027 0028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 0029 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 0030 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 0031 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 0032 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 0033 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 0034 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0035 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0036 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0037 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 0038 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0039 --------------------------------------------------------------------------- 0040 */ 0041 0042 /** @file Bitmap.h 0043 * @brief Defines bitmap format helper for textures 0044 * 0045 * Used for file formats which embed their textures into the model file. 0046 */ 0047 #pragma once 0048 #ifndef AI_BITMAP_H_INC 0049 #define AI_BITMAP_H_INC 0050 0051 #ifdef __GNUC__ 0052 # pragma GCC system_header 0053 #endif 0054 0055 #include "defs.h" 0056 #include <cstdint> 0057 #include <cstddef> 0058 0059 struct aiTexture; 0060 0061 namespace Assimp { 0062 0063 class IOStream; 0064 0065 // --------------------------------------------------------------------------- 0066 /** 0067 * This class is used to store and write bitmap information. 0068 */ 0069 class ASSIMP_API Bitmap { 0070 protected: 0071 0072 struct Header { 0073 uint16_t type; 0074 uint32_t size; 0075 uint16_t reserved1; 0076 uint16_t reserved2; 0077 uint32_t offset; 0078 0079 // We define the struct size because sizeof(Header) might return a wrong result because of structure padding. 0080 static constexpr std::size_t header_size = 0081 sizeof(uint16_t) + 0082 sizeof(uint32_t) + 0083 sizeof(uint16_t) + 0084 sizeof(uint16_t) + 0085 sizeof(uint32_t); 0086 }; 0087 0088 struct DIB { 0089 uint32_t size; 0090 int32_t width; 0091 int32_t height; 0092 uint16_t planes; 0093 uint16_t bits_per_pixel; 0094 uint32_t compression; 0095 uint32_t image_size; 0096 int32_t x_resolution; 0097 int32_t y_resolution; 0098 uint32_t nb_colors; 0099 uint32_t nb_important_colors; 0100 0101 // We define the struct size because sizeof(DIB) might return a wrong result because of structure padding. 0102 static constexpr std::size_t dib_size = 0103 sizeof(uint32_t) + 0104 sizeof(int32_t) + 0105 sizeof(int32_t) + 0106 sizeof(uint16_t) + 0107 sizeof(uint16_t) + 0108 sizeof(uint32_t) + 0109 sizeof(uint32_t) + 0110 sizeof(int32_t) + 0111 sizeof(int32_t) + 0112 sizeof(uint32_t) + 0113 sizeof(uint32_t); 0114 }; 0115 0116 static constexpr std::size_t mBytesPerPixel = 4; 0117 0118 public: 0119 /// @brief Will save an aiTexture instance as a bitmap. 0120 /// @param texture The pointer to the texture instance 0121 /// @param file The filename to save into. 0122 /// @return true if successfully saved, false if not. 0123 static bool Save(aiTexture* texture, IOStream* file); 0124 0125 protected: 0126 static void WriteHeader(Header& header, IOStream* file); 0127 static void WriteDIB(DIB& dib, IOStream* file); 0128 static void WriteData(aiTexture* texture, IOStream* file); 0129 }; 0130 0131 } 0132 0133 #endif // AI_BITMAP_H_INC
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |