MCPcopy Create free account
hub / github.com/DentonW/DevIL / float2rgbe

Function float2rgbe

DevIL/src-IL/src/il_hdr.cpp:417–436  ·  view source on GitHub ↗

standard conversion from float pixels to rgbe pixels */ note: you can remove the "inline"s if your compiler complains about it */ static INLINE void

Source from the content-addressed store, hash-verified

415/* note: you can remove the "inline"s if your compiler complains about it */
416//static INLINE void
417static void
418float2rgbe(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
439typedef struct {

Callers 2

RGBE_WritePixelsFunction · 0.85
iSaveHdrInternalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected