diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-12-28 17:29:33 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-12-28 17:29:33 +0400 |
commit | b9ff5840a617ec836f2d09bb0f04d60e5c3b8f67 (patch) | |
tree | 8a196777f4ee32e3ee089c12b667caa2c82dec75 /source/blender/nodes | |
parent | 1f02209957fc8afde957b48f1be41fc399a725b0 (diff) |
Code refactoring: add unified image buffer functions for doing float => byte,
byte => float, float => float, byte => byte conversions with profile, dither
and predivide. Previously code for this was spread out too much.
There should be no functional changes, this is so the predivide/table/dither
patches can work correctly.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/composite/node_composite_util.c | 11 | ||||
-rw-r--r-- | source/blender/nodes/composite/nodes/node_composite_image.c | 13 |
2 files changed, 17 insertions, 7 deletions
diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c index 99a36691b10..8aaf1771b68 100644 --- a/source/blender/nodes/composite/node_composite_util.c +++ b/source/blender/nodes/composite/node_composite_util.c @@ -606,7 +606,9 @@ void generate_preview(void *data, bNode *node, CompBuf *stackbuf) RenderData *rd= data; bNodePreview *preview= node->preview; int xsize, ysize; - int color_manage= rd->color_mgt_flag & R_COLOR_MANAGEMENT; + int profile_from= (rd->color_mgt_flag & R_COLOR_MANAGEMENT)? IB_PROFILE_LINEAR_RGB: IB_PROFILE_SRGB; + int predivide= 0; + int dither= 0; unsigned char *rect; if(preview && stackbuf) { @@ -633,10 +635,9 @@ void generate_preview(void *data, bNode *node, CompBuf *stackbuf) /* convert to byte for preview */ rect= MEM_callocN(sizeof(unsigned char)*4*xsize*ysize, "bNodePreview.rect"); - if(color_manage) - floatbuf_to_srgb_byte(cbuf->rect, rect, 0, xsize, 0, ysize, xsize); - else - floatbuf_to_byte(cbuf->rect, rect, 0, xsize, 0, ysize, xsize); + IMB_buffer_byte_from_float(rect, cbuf->rect, + 4, dither, IB_PROFILE_SRGB, profile_from, predivide, + xsize, ysize, xsize, xsize); free_compbuf(cbuf); if(stackbuf_use!=stackbuf) diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index 9920cdab039..fd7c87adea2 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -62,6 +62,7 @@ static bNodeSocketTemplate cmp_node_rlayers_out[]= { float *node_composit_get_float_buffer(RenderData *rd, ImBuf *ibuf, int *alloc) { float *rect; + int predivide= 0; *alloc= FALSE; @@ -71,7 +72,11 @@ float *node_composit_get_float_buffer(RenderData *rd, ImBuf *ibuf, int *alloc) } else { rect= MEM_mapallocN(sizeof(float) * 4 * ibuf->x * ibuf->y, "node_composit_get_image"); - srgb_to_linearrgb_rgba_rgba_buf(rect, ibuf->rect_float, ibuf->x * ibuf->y); + + IMB_buffer_float_from_float(rect, ibuf->rect_float, + 4, IB_PROFILE_LINEAR_RGB, IB_PROFILE_SRGB, predivide, + ibuf->x, ibuf->y, ibuf->x, ibuf->x); + *alloc= TRUE; } } @@ -81,7 +86,11 @@ float *node_composit_get_float_buffer(RenderData *rd, ImBuf *ibuf, int *alloc) } else { rect= MEM_mapallocN(sizeof(float) * 4 * ibuf->x * ibuf->y, "node_composit_get_image"); - linearrgb_to_srgb_rgba_rgba_buf(rect, ibuf->rect_float, ibuf->x * ibuf->y); + + IMB_buffer_float_from_float(rect, ibuf->rect_float, + 4, IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB, predivide, + ibuf->x, ibuf->y, ibuf->x, ibuf->x); + *alloc= TRUE; } } |