MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / convertToRGBA32Float

Function convertToRGBA32Float

Source/Falcor/Utils/Image/Bitmap.cpp:163–206  ·  view source on GitHub ↗

* Converts an image of the given format to an RGBA float image. */

Source from the content-addressed store, hash-verified

161 * Converts an image of the given format to an RGBA float image.
162 */
163static std::vector<float> convertToRGBA32Float(ResourceFormat format, uint32_t width, uint32_t height, const void* pData)
164{
165 FALCOR_ASSERT(isConvertibleToRGBA32Float(format));
166
167 FormatType type = getFormatType(format);
168 uint32_t channelCount = getFormatChannelCount(format);
169 uint32_t channelBits = getNumChannelBits(format, 0);
170
171 std::vector<float> floatData;
172
173 if (type == FormatType::Float && channelBits == 16)
174 {
175 floatData = convertHalfToRGBA32Float(width, height, channelCount, pData);
176 }
177 else if (type == FormatType::Uint && channelBits == 16)
178 {
179 floatData = convertIntToRGBA32Float<uint16_t>(width, height, channelCount, pData);
180 }
181 else if (type == FormatType::Uint && channelBits == 32)
182 {
183 floatData = convertIntToRGBA32Float<uint32_t>(width, height, channelCount, pData);
184 }
185 else if (type == FormatType::Sint && channelBits == 16)
186 {
187 floatData = convertIntToRGBA32Float<int16_t>(width, height, channelCount, pData);
188 }
189 else if (type == FormatType::Sint && channelBits == 32)
190 {
191 floatData = convertIntToRGBA32Float<int32_t>(width, height, channelCount, pData);
192 }
193 else
194 {
195 FALCOR_UNREACHABLE();
196 }
197
198 // Default alpha channel to 1.
199 if (channelCount < 4)
200 {
201 for (uint32_t i = 0; i < width * height; ++i)
202 floatData[i * 4 + 3] = 1.f;
203 }
204
205 return floatData;
206}
207
208/**
209 * Converts 96bpp to 128bpp RGBA without clamping.

Callers 1

saveImageMethod · 0.85

Calls 5

getFormatTypeFunction · 0.85
getFormatChannelCountFunction · 0.85
getNumChannelBitsFunction · 0.85
convertHalfToRGBA32FloatFunction · 0.85

Tested by

no test coverage detected