* Converts 96bpp to 128bpp RGBA without clamping. * Note that we can't use FreeImage_ConvertToRGBAF() as it clamps to [0,1]. */
| 210 | * Note that we can't use FreeImage_ConvertToRGBAF() as it clamps to [0,1]. |
| 211 | */ |
| 212 | static FIBITMAP* convertToRGBAF(FIBITMAP* pDib) |
| 213 | { |
| 214 | const unsigned width = FreeImage_GetWidth(pDib); |
| 215 | const unsigned height = FreeImage_GetHeight(pDib); |
| 216 | |
| 217 | auto pNew = FreeImage_AllocateT(FIT_RGBAF, width, height); |
| 218 | FreeImage_CloneMetadata(pNew, pDib); |
| 219 | |
| 220 | const unsigned src_pitch = FreeImage_GetPitch(pDib); |
| 221 | const unsigned dst_pitch = FreeImage_GetPitch(pNew); |
| 222 | |
| 223 | const BYTE* src_bits = (BYTE*)FreeImage_GetBits(pDib); |
| 224 | BYTE* dst_bits = (BYTE*)FreeImage_GetBits(pNew); |
| 225 | |
| 226 | for (unsigned y = 0; y < height; y++) |
| 227 | { |
| 228 | const FIRGBF* src_pixel = (FIRGBF*)src_bits; |
| 229 | FIRGBAF* dst_pixel = (FIRGBAF*)dst_bits; |
| 230 | |
| 231 | for (unsigned x = 0; x < width; x++) |
| 232 | { |
| 233 | // Convert pixels directly, while adding a "dummy" alpha of 1.0 |
| 234 | dst_pixel[x].red = src_pixel[x].red; |
| 235 | dst_pixel[x].green = src_pixel[x].green; |
| 236 | dst_pixel[x].blue = src_pixel[x].blue; |
| 237 | dst_pixel[x].alpha = 1.0F; |
| 238 | } |
| 239 | src_bits += src_pitch; |
| 240 | dst_bits += dst_pitch; |
| 241 | } |
| 242 | return pNew; |
| 243 | } |
| 244 | |
| 245 | /** |
| 246 | * Converts 96/128bpp to 64bpp RGBA floating-point image. |