standard conversion from float pixels to rgbe pixels */ note: you can remove the "inline"s if your compiler complains about it */ static INLINE void
| 415 | /* note: you can remove the "inline"s if your compiler complains about it */ |
| 416 | //static INLINE void |
| 417 | static void |
| 418 | float2rgbe(unsigned char rgbe[4], float red, float green, float blue) |
| 419 | { |
| 420 | float v; |
| 421 | int e; |
| 422 | |
| 423 | v = red; |
| 424 | if (green > v) v = green; |
| 425 | if (blue > v) v = blue; |
| 426 | if (v < 1e-32) { |
| 427 | rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0; |
| 428 | } |
| 429 | else { |
| 430 | v = (float)(frexp(v,&e) * 256.0/v); |
| 431 | rgbe[0] = (unsigned char) (red * v); |
| 432 | rgbe[1] = (unsigned char) (green * v); |
| 433 | rgbe[2] = (unsigned char) (blue * v); |
| 434 | rgbe[3] = (unsigned char) (e + 128); |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | |
| 439 | typedef struct { |
no outgoing calls
no test coverage detected