diff options
author | Joseph Eagar <joeedh@gmail.com> | 2008-02-23 01:23:58 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2008-02-23 01:23:58 +0300 |
commit | 0e233b3213a21449399d91b9ee841c235fbba4d7 (patch) | |
tree | da61feed9bf0d7274c7725f909e170a39d0e1561 /source/blender/nodes/intern/CMP_nodes | |
parent | 28fb57804835e41f51da9bfdecda6b49ede439f2 (diff) |
=Reversion of premul bugfix=
Reversion of premul bugfix, as it was apparently not
working all that well.
Note that this brings back the bug where the erase alpha
paint tool won't display correctly, since the UV image
editor just draws images in key alpha now.
Diffstat (limited to 'source/blender/nodes/intern/CMP_nodes')
-rw-r--r-- | source/blender/nodes/intern/CMP_nodes/CMP_image.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_image.c b/source/blender/nodes/intern/CMP_nodes/CMP_image.c index 5df649d6808..6a82e8a9254 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_image.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_image.c @@ -58,7 +58,7 @@ static bNodeSocketType cmp_node_rlayers_out[]= { static CompBuf *node_composit_get_image(RenderData *rd, Image *ima, ImageUser *iuser) { ImBuf *ibuf; - CompBuf *stackbuf, *old; + CompBuf *stackbuf; int type; ibuf= BKE_image_get_ibuf(ima, iuser); @@ -79,11 +79,10 @@ static CompBuf *node_composit_get_image(RenderData *rd, Image *ima, ImageUser *i stackbuf->rect= ibuf->rect_float; } - old = stackbuf; - stackbuf = dupalloc_compbuf(stackbuf); - free_compbuf(old); - - if (type==CB_RGBA && iuser && (iuser->flag & IMA_DO_PREMUL)) { + /*code to respect the premul flag of images; I'm + not sure if this is a good idea for multilayer images, + since it never worked before for them. + if (type==CB_RGBA && ima->flag & IMA_DO_PREMUL) { //premul the image int i; float *pixel = stackbuf->rect; @@ -94,7 +93,7 @@ static CompBuf *node_composit_get_image(RenderData *rd, Image *ima, ImageUser *i pixel[2] *= pixel[3]; } } - + */ return stackbuf; }; @@ -203,6 +202,25 @@ static void node_composit_exec_image(void *data, bNode *node, bNodeStack **in, b else { stackbuf= node_composit_get_image(rd, ima, iuser); + /*respect image premul option*/ + if (stackbuf->type==CB_RGBA && ima->flag & IMA_DO_PREMUL) { + int i; + float *pixel; + + /*first duplicate stackbuf->rect, since it's just a pointer + to the source imbuf, and we don't want to change that.*/ + stackbuf->rect = MEM_dupallocN(stackbuf->rect); + + /*premul the image*/ + + pixel = stackbuf->rect; + for (i=0; i<stackbuf->x*stackbuf->y; i++, pixel += 4) { + pixel[0] *= pixel[3]; + pixel[1] *= pixel[3]; + pixel[2] *= pixel[3]; + } + } + /* put image on stack */ out[0]->data= stackbuf; |