[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13687] trunk/blender/source/blender: Added another 2 checks for if an image has the premul flag set, 1 in the image
Joseph Eagar
joeedh at gmail.com
Thu Feb 14 14:36:59 CET 2008
Revision: 13687
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13687
Author: joeedh
Date: 2008-02-14 14:36:59 +0100 (Thu, 14 Feb 2008)
Log Message:
-----------
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?
Modified Paths:
--------------
trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_image.c
trunk/blender/source/blender/render/intern/source/texture.c
Modified: trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_image.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_image.c 2008-02-14 12:44:27 UTC (rev 13686)
+++ trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_image.c 2008-02-14 13:36:59 UTC (rev 13687)
@@ -79,6 +79,21 @@
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 @@
}
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;
Modified: trunk/blender/source/blender/render/intern/source/texture.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/texture.c 2008-02-14 12:44:27 UTC (rev 13686)
+++ trunk/blender/source/blender/render/intern/source/texture.c 2008-02-14 13:36:59 UTC (rev 13687)
@@ -2521,7 +2521,13 @@
if(shi->osatex) imagewraposa(tex, ima, NULL, texvec, dx, dy, &texr);
else imagewrap(tex, ima, NULL, texvec, &texr);
-
+
+ if (tex->ima && tex->ima->flag & IMA_DO_PREMUL) {
+ texr.tr *= texr.ta;
+ texr.tg *= texr.ta;
+ texr.tb *= texr.ta;
+ }
+
shi->vcol[0]*= texr.tr;
shi->vcol[1]*= texr.tg;
shi->vcol[2]*= texr.tb;
More information about the Bf-blender-cvs
mailing list