Merged behaviour from ContourMask into AlphaMask.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1181 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-08-30 17:15:22 +00:00
parent db09cdb5bc
commit acb3493b59
10 changed files with 89 additions and 92 deletions
+2 -4
View File
@@ -77,11 +77,9 @@ void mask_blend(Image& img1, const Image& img2, const Image& mask) {
// ----------------------------------------------------------------------------- : Alpha
void set_alpha(Image& img, const Image& img_alpha) {
if (img.GetWidth() != img_alpha.GetWidth() || img.GetHeight() != img_alpha.GetHeight()) {
throw Error(_("Image must have same size as mask"));
}
Image img_alpha_resampled = resample(img_alpha, img.GetWidth(), img.GetHeight());
if (!img.HasAlpha()) img.InitAlpha();
Byte *im = img.GetAlpha(), *al = img_alpha.GetData();
Byte *im = img.GetAlpha(), *al = img_alpha_resampled.GetData();
size_t size = img.GetWidth() * img.GetHeight();
for (size_t i = 0 ; i < size ; ++i) {
im[i] = (im[i] * al[i*3]) / 255;