From 448a87a44be730ffb3ed6e6c48b60f8a8c8767c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Tschumperl=C3=A9?= <David.Tschumperle@gmail.com> Date: Tue, 25 Sep 2018 21:42:57 +0200 Subject: [PATCH] _math_parser() : Improve behavior of copy() when source or destination are reference to vector-valued pixels. --- CImg.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CImg.h b/CImg.h index 43b08c5..54da20a 100644 --- a/CImg.h +++ b/CImg.h @@ -17603,7 +17603,7 @@ namespace cimg_library_suffixed { arg1 = p1 = compile(ss5,s1,depth1,ref,is_single); s2 = ++s1; while (s2<se1 && (*s2!=',' || level[s2 - expr._data]!=clevel1)) ++s2; arg2 = compile(s1,s2,depth1,ref._data + 7,is_single); - arg3 = ~0U; arg4 = arg5 = arg6 = 1; + arg3 = arg4 = arg5 = ~0U; arg6 = 1; if (s2<se1) { s3 = ++s2; while (s3<se1 && (*s3!=',' || level[s3 - expr._data]!=clevel1)) ++s3; arg3 = compile(s2,s3,depth1,0,is_single); @@ -17617,12 +17617,18 @@ namespace cimg_library_suffixed { } } } - if (_cimg_mp_is_vector(arg1) && !ref[0]) ++arg1; + if (_cimg_mp_is_vector(arg1)) { + if (!ref[0]) ++arg1; + else if (ref[0]>=4 && arg4==~0U) arg4 = scalar1(mp_image_whd,ref[1]); + } if (_cimg_mp_is_vector(arg2)) { if (arg3==~0U) arg3 = constant(_cimg_mp_size(arg2)); if (!ref[7]) ++arg2; + if (ref[7]>=4 && arg5==~0U) arg5 = scalar1(mp_image_whd,ref[8]); } if (arg3==~0U) arg3 = 1; + if (arg4==~0U) arg4 = 1; + if (arg5==~0U) arg5 = 1; _cimg_mp_check_type(arg3,3,1,0); _cimg_mp_check_type(arg4,4,1,0); _cimg_mp_check_type(arg5,5,1,0); -- GitLab