AlphaMask combines alphas instead of overwriting

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@772 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-12-20 19:40:35 +00:00
parent 306b996ee0
commit 125dbe53af
4 changed files with 25 additions and 5 deletions
+18
View File
@@ -87,6 +87,24 @@ void set_alpha(Image& img, const Image& img_alpha) {
}
}
void set_alpha(Image& img, Byte* al, const wxSize& alpha_size) {
if (img.GetWidth() != alpha_size.GetWidth() || img.GetHeight() != alpha_size.GetHeight()) {
throw Error(_("Image must have same size as mask"));
}
if (!img.HasAlpha()) {
// copy
img.InitAlpha();
memcpy(img.GetAlpha(), al, img.GetWidth() * img.GetHeight());
} else{
// merge
Byte *im = img.GetAlpha();
size_t size = img.GetWidth() * img.GetHeight();
for (size_t i = 0 ; i < size ; ++i) {
im[i] = (im[i] * al[i]) / 255;
}
}
}
void set_alpha(Image& img, double alpha) {
Byte b_alpha = alpha * 255;
if (!img.HasAlpha()) {