From 59a184e2b20b22e6426c3a0fb28bd27fba56794b Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Sun, 22 Sep 2024 16:51:23 +0200 Subject: [PATCH] revert combine_blend changes --- src/gfx/combine_image.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/gfx/combine_image.cpp b/src/gfx/combine_image.cpp index 2c5630c6..d8df1bc4 100644 --- a/src/gfx/combine_image.cpp +++ b/src/gfx/combine_image.cpp @@ -295,24 +295,23 @@ COMBINE_FUN(COMBINE_SMALLER_THAN_250, a < 250 ? b : a) /// The results are stored in the image A. template void combine_image_do(Image& a, Image b) { - UInt size = a.GetWidth() * a.GetHeight(); - Byte *dataA = a.GetData(), *dataB = b.GetData(); + UInt size = a.GetWidth() * a.GetHeight() * 3; + Byte* dataA = a.GetData(), * dataB = b.GetData(); // for each pixel: apply function - for (UInt i = 0 ; i < (size * 3); ++i) { + for (UInt i = 0; i < size; ++i) { dataA[i] = 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::f(alphaA[i], alphaB[i]); - } } } void combine_image(Image& a, const Image& b, ImageCombine combine) { // Images must have same size if (a.GetWidth() != b.GetWidth() || a.GetHeight() != b.GetHeight()) { - throw Error(_ERROR_("images used for combine blending must have the same size")); + throw Error(_ERROR_("images used for combine blending must have the same size")); + } + // Copy alpha channel? + if (b.HasAlpha()) { + if (!a.HasAlpha()) a.InitAlpha(); + memcpy(a.GetAlpha(), b.GetAlpha(), a.GetWidth() * a.GetHeight()); } // Combine image data, by dispatching to combineImageDo switch(combine) {