diff --git a/src/common/image.cpp b/src/common/image.cpp index c62d0a909f..d6febece49 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -1786,13 +1786,14 @@ wxImage::Paste(const wxImage & image, int x, int y, { // Copy the non masked pixel memcpy(target_data + i, source_data + i, 3); - // Make the copied pixel fully opaque - alpha_target_data[i / 3] = wxALPHA_OPAQUE; + if (alpha_target_data != NULL) // Make the copied pixel fully opaque + alpha_target_data[i / 3] = wxALPHA_OPAQUE; } } source_data += source_step; target_data += target_step; - alpha_target_data += target_alpha_step; + if (alpha_target_data != NULL) + alpha_target_data += target_alpha_step; } } } diff --git a/tests/image/image.cpp b/tests/image/image.cpp index 60248f0f76..c825a445a4 100644 --- a/tests/image/image.cpp +++ b/tests/image/image.cpp @@ -1540,6 +1540,10 @@ TEST_CASE("wxImage::Paste", "[image][paste]") wxImage expected(toggle_equal_size_xpm); actual.Paste(paste, 0, 0); CHECK_THAT(actual, RGBSameAs(expected)); + + // Without alpha using "compose" doesn't change anything. + actual.Paste(paste, 0, 0, wxIMAGE_ALPHA_BLEND_COMPOSE); + CHECK_THAT(actual, RGBSameAs(expected)); } SECTION("Paste larger image")