Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Eagar <joeedh@gmail.com>2008-02-14 16:36:59 +0300
committerJoseph Eagar <joeedh@gmail.com>2008-02-14 16:36:59 +0300
commitac5d28a13c6db6837fd1f00cfecd9cef06e8d92a (patch)
tree769774a6344e0903daf3d076bb335a2c9c46839e /source/blender/nodes
parent6907bcc79bff47d5b861305631d4f765d0778049 (diff)
Added another 2 checks for if an image has the premul flag set, 1 in the image
compositor node, another in render_realtime_texture. Note that multilayer images in the image compositor node do not respect the premul flag (though I did write commented out code for it). As far as I can tell, the premul option never worked for multilayer images in the image node, so I'm a little nervous about making it work properly there. ton, any comments?
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_image.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_image.c b/source/blender/nodes/intern/CMP_nodes/CMP_image.c
index 0984aa4bfe1..659629457f8 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_image.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_image.c
@@ -79,6 +79,21 @@ static CompBuf *node_composit_get_image(RenderData *rd, Image *ima, ImageUser *i
stackbuf->rect= ibuf->rect_float;
}
+ /*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;
+
+ for (i=0; i<stackbuf->x*stackbuf->y; i++, pixel += 4) {
+ pixel[0] *= pixel[3];
+ pixel[1] *= pixel[3];
+ pixel[2] *= pixel[3];
+ }
+ }
+ */
return stackbuf;
};
@@ -186,7 +201,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) {
+
+ /*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*/
+ int i;
+ float *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;