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.
This commit is contained in:
Joseph Eagar
2008-02-14 12:19:37 +00:00
parent 4339c32c6c
commit 139b612b09
2 changed files with 13 additions and 2 deletions

View File

@@ -276,6 +276,7 @@ static Image *image_alloc(const char *name, short source, short type)
ima->source= source;
ima->type= type;
ima->flag = IMA_DO_PREMUL;
}
return ima;
}
@@ -1663,8 +1664,11 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra)
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;

View File

@@ -1138,6 +1138,13 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex,
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);