MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / stbi__hdr_convert

Function stbi__hdr_convert

Source/Utils/stb_image.h:7128–7153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7126}
7127
7128static void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp)
7129{
7130 if ( input[3] != 0 ) {
7131 float f1;
7132 // Exponent
7133 f1 = (float) ldexp(1.0f, input[3] - (int)(128 + 8));
7134 if (req_comp <= 2)
7135 output[0] = (input[0] + input[1] + input[2]) * f1 / 3;
7136 else {
7137 output[0] = input[0] * f1;
7138 output[1] = input[1] * f1;
7139 output[2] = input[2] * f1;
7140 }
7141 if (req_comp == 2) output[1] = 1;
7142 if (req_comp == 4) output[3] = 1;
7143 } else {
7144 switch (req_comp) {
7145 case 4: output[3] = 1; /* fallthrough */
7146 case 3: output[0] = output[1] = output[2] = 0;
7147 break;
7148 case 2: output[1] = 1; /* fallthrough */
7149 case 1: output[0] = 0;
7150 break;
7151 }
7152 }
7153}
7154
7155static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
7156{

Callers 1

stbi__hdr_loadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected