Changeset View
Changeset View
Standalone View
Standalone View
source/blender/imbuf/intern/radiance_hdr.c
| Show First 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | else { | ||||
| float f = ldexp(1.0, rgbe[EXP] - (COLXS + 8)); | float f = ldexp(1.0, rgbe[EXP] - (COLXS + 8)); | ||||
| fcol[RED] = f * (rgbe[RED] + 0.5f); | fcol[RED] = f * (rgbe[RED] + 0.5f); | ||||
| fcol[GRN] = f * (rgbe[GRN] + 0.5f); | fcol[GRN] = f * (rgbe[GRN] + 0.5f); | ||||
| fcol[BLU] = f * (rgbe[BLU] + 0.5f); | fcol[BLU] = f * (rgbe[BLU] + 0.5f); | ||||
| } | } | ||||
| } | } | ||||
| /* float color -> rgbe */ | /* float color -> rgbe */ | ||||
| static void FLOAT2RGBE(fCOLOR fcol, RGBE rgbe) | static void FLOAT2RGBE(const fCOLOR fcol, RGBE rgbe) | ||||
| { | { | ||||
| int e; | int e; | ||||
| float d = (fcol[RED] > fcol[GRN]) ? fcol[RED] : fcol[GRN]; | float d = (fcol[RED] > fcol[GRN]) ? fcol[RED] : fcol[GRN]; | ||||
| if (fcol[BLU] > d) { | if (fcol[BLU] > d) { | ||||
| d = fcol[BLU]; | d = fcol[BLU]; | ||||
| } | } | ||||
| if (d <= 1e-32f) { | if (d <= 1e-32f) { | ||||
| rgbe[RED] = rgbe[GRN] = rgbe[BLU] = rgbe[EXP] = 0; | rgbe[RED] = rgbe[GRN] = rgbe[BLU] = rgbe[EXP] = 0; | ||||
| ▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | if (imb_is_a_hdr((void *)mem)) { | ||||
| // else printf("Data not found!\n"); | // else printf("Data not found!\n"); | ||||
| } | } | ||||
| // else printf("Not a valid radiance HDR file!\n"); | // else printf("Not a valid radiance HDR file!\n"); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| /* ImBuf write */ | /* ImBuf write */ | ||||
| static int fwritecolrs(FILE *file, int width, int channels, unsigned char *ibufscan, float *fpscan) | static int fwritecolrs( | ||||
| FILE *file, int width, int channels, const unsigned char *ibufscan, const float *fpscan) | |||||
| { | { | ||||
| int beg, c2, cnt = 0; | int beg, c2, cnt = 0; | ||||
| fCOLOR fcol; | fCOLOR fcol; | ||||
| RGBE rgbe, *rgbe_scan; | RGBE rgbe, *rgbe_scan; | ||||
| if (UNLIKELY((ibufscan == NULL) && (fpscan == NULL))) { | if (UNLIKELY((ibufscan == NULL) && (fpscan == NULL))) { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 130 Lines • Show Last 20 Lines | |||||