[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13684] trunk/blender/source/blender: The "premul" option for images had a very bad implementation.

Joseph Eagar joeedh at gmail.com
Thu Feb 14 13:19:37 CET 2008


Revision: 13684
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13684
Author:   joeedh
Date:     2008-02-14 13:19:37 +0100 (Thu, 14 Feb 2008)

Log Message:
-----------
The "premul" option for images had a very bad implementation.  It
basically flagged the image so that on next load/reload, the image
data would be converted to premul.  This was very confusing to the
user, as it meant premul wouldn't take effect will the image was
reloaded, and it would also change the image data, which the user
might've been painting.

To fix this, I've removed this behaviour and instead made the premul
option apply at render time.  During render while evaluating an image
texture, if the image has the premul flag set then the premul operation
is done on the texture result data, thus not touching the image data
at all.

Also, I've made premul be turned on by default.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/image.c
    trunk/blender/source/blender/render/intern/source/texture.c

Modified: trunk/blender/source/blender/blenkernel/intern/image.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/image.c	2008-02-14 10:42:53 UTC (rev 13683)
+++ trunk/blender/source/blender/blenkernel/intern/image.c	2008-02-14 12:19:37 UTC (rev 13684)
@@ -276,6 +276,7 @@
 		
 		ima->source= source;
 		ima->type= type;
+		ima->flag = IMA_DO_PREMUL;
 	}
 	return ima;
 }
@@ -1663,8 +1664,11 @@
 				ima->packedfile = newPackedFile(str);
 		}
 		
-		if(ima->flag & IMA_DO_PREMUL)
-			converttopremul(ibuf);
+		/*ok, this is *not* what a user expects when he clicks the premul
+		  button, that his image is actually changed.  This should be a
+		  render-time option, not a modification to the image! - joeedh*/
+		/*if(ima->flag & IMA_DO_PREMUL)
+			converttopremul(ibuf);*/
 	}
 	else
 		ima->ok= 0;

Modified: trunk/blender/source/blender/render/intern/source/texture.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/texture.c	2008-02-14 10:42:53 UTC (rev 13683)
+++ trunk/blender/source/blender/render/intern/source/texture.c	2008-02-14 12:19:37 UTC (rev 13684)
@@ -1138,6 +1138,13 @@
 		if(osatex) retval= imagewraposa(tex, tex->ima, NULL, texvec, dxt, dyt, texres); 
 		else retval= imagewrap(tex, tex->ima, NULL, texvec, texres); 
 		tag_image_time(tex->ima); /* tag image as having being used */
+		
+		/*do premul if necassary*/
+		if (tex->ima && tex->ima->flag & IMA_DO_PREMUL) {
+			texres->tr *= texres->ta;
+			texres->tg *= texres->ta;
+			texres->tb *= texres->ta;
+		}
 		break;
 	case TEX_PLUGIN:
 		retval= plugintex(tex, texvec, dxt, dyt, osatex, texres);





More information about the Bf-blender-cvs mailing list