mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Merge pull request #14 from G-e-n-e-v-e-n-s-i-S/combine-blend-alpha
make combine_blend function blend alpha channels as well
This commit is contained in:
@@ -295,12 +295,18 @@ COMBINE_FUN(COMBINE_SMALLER_THAN_250, a < 250 ? b : a)
|
||||
/// The results are stored in the image A.
|
||||
template <ImageCombine combine>
|
||||
void combine_image_do(Image& a, Image b) {
|
||||
UInt size = a.GetWidth() * a.GetHeight() * 3;
|
||||
UInt size = a.GetWidth() * a.GetHeight();
|
||||
Byte *dataA = a.GetData(), *dataB = b.GetData();
|
||||
// for each pixel: apply function
|
||||
for (UInt i = 0 ; i < size ; ++i) {
|
||||
for (UInt i = 0 ; i < (size * 3); ++i) {
|
||||
dataA[i] = Combine<combine>::f(dataA[i], dataB[i]);
|
||||
}
|
||||
if (a.HasAlpha() && b.HasAlpha()) {
|
||||
Byte* alphaA = a.GetAlpha(), * alphaB = b.GetAlpha();
|
||||
for (UInt i = 0; i < size; ++i) {
|
||||
alphaA[i] = Combine<combine>::f(alphaA[i], alphaB[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void combine_image(Image& a, const Image& b, ImageCombine combine) {
|
||||
|
||||
Reference in New Issue
Block a user