diff options
author | Matt Ebb <matt@mke3.net> | 2010-01-09 03:16:35 +0300 |
---|---|---|
committer | Matt Ebb <matt@mke3.net> | 2010-01-09 03:16:35 +0300 |
commit | 04dec46c6a252a401a23c06ece2552f64cfc5892 (patch) | |
tree | d481504bf0db87f68869f1ffe23c61b7bf20b62c /source/blender/blenkernel/intern/colortools.c | |
parent | e62e66fe8af97cb02ae69d6745bc7cc2daa6cb22 (diff) |
Color management fixes
Now it's a bit more robust, tagging images with profiles when they're loaded,
which then get interpreted later on by conversion functions. Just Linear RGB
and sRGB profiles at the moment, same as before.
This commit fixes Martin's problem with EXRs and Multilayer images loading/
saving too dark, and it also makes the sequence editor work correctly with it too.
Also fixes:
[#19647] gamma correction with color management is reset when resetting Curve
[#19454] 2.5: Dither does not work when Color management is enabled
Diffstat (limited to 'source/blender/blenkernel/intern/colortools.c')
-rw-r--r-- | source/blender/blenkernel/intern/colortools.c | 66 |
1 files changed, 41 insertions, 25 deletions
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index cd8c0c24087..d8975c16cc8 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -763,10 +763,16 @@ void colorcorrection_do_ibuf(ImBuf *ibuf, const char *profile) } } - +/* only used for image editor curves */ void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf) { + ImBuf *tmpbuf; int pixel; + char *tmpcbuf; + float *pix_in; + float col[3]; + int stride= 4; + float *pix_out; if(ibuf==NULL) return; @@ -775,35 +781,45 @@ void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf) else if(ibuf->rect==NULL) imb_addrectImBuf(ibuf); + if (!ibuf->rect || !ibuf->rect_float) + return; + + /* work on a temp buffer, so can color manage afterwards. + * No worse off memory wise than comp nodes */ + tmpbuf = IMB_dupImBuf(ibuf); + curvemapping_premultiply(cumap, 0); - if(ibuf->rect_float && ibuf->rect) { - float *pixf= ibuf->rect_float; - float col[3]; - int stride= 4; - char *pixc= (char *)ibuf->rect; - - if(ibuf->channels) - stride= ibuf->channels; - - for(pixel= ibuf->x*ibuf->y; pixel>0; pixel--, pixf+=stride, pixc+=4) { - if(stride<3) { - col[0]= curvemap_evaluateF(cumap->cm, *pixf); - pixc[1]= pixc[2]= pixc[3]= pixc[0]= FTOCHAR(col[0]); - } - else { - curvemapping_evaluate_premulRGBF(cumap, col, pixf); - pixc[0]= FTOCHAR(col[0]); - pixc[1]= FTOCHAR(col[1]); - pixc[2]= FTOCHAR(col[2]); - if(stride>3) - pixc[3]= FTOCHAR(pixf[3]); - else - pixc[3]= 255; - } + pix_in= ibuf->rect_float; + pix_out= tmpbuf->rect_float; +// pixc= (char *)ibuf->rect; + + if(ibuf->channels) + stride= ibuf->channels; + + for(pixel= ibuf->x*ibuf->y; pixel>0; pixel--, pix_in+=stride, pix_out+=4) { + if(stride<3) { + col[0]= curvemap_evaluateF(cumap->cm, *pix_in); + + pix_out[1]= pix_out[2]= pix_out[3]= pix_out[0]= col[0]; + } + else { + curvemapping_evaluate_premulRGBF(cumap, col, pix_in); + pix_out[0]= col[0]; + pix_out[1]= col[1]; + pix_out[2]= col[2]; + if(stride>3) + pix_out[3]= pix_in[3]; + else + pix_out[3]= 1.f; } } + IMB_rect_from_float(tmpbuf); + SWAP(char *, tmpbuf->rect, ibuf->rect); + IMB_freeImBuf(tmpbuf); + + curvemapping_premultiply(cumap, 1); } |