From b6c87004cb58677a9eedff0f63659effb9bb12ed Mon Sep 17 00:00:00 2001 From: Raymond Wright Date: Thu, 26 Nov 2020 06:28:40 +0000 Subject: [PATCH] Update CImg to 2.9.4 --- README.md | 2 +- libs/CImg.h | 79 ++++++++++++++++++++++------------------------------- 2 files changed, 33 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 21825ae7..e7dec8de 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ in cmd then enter to open a command prompt in that folder, then run the command * [argparse](https://github.com/p-ranav/argparse) 2.1 for argument parsing * [Catch2](https://github.com/catchorg/Catch2) 2.13.3 for tests -* [CImg](https://cimg.eu) 2.9.3 to produce images +* [CImg](https://cimg.eu) 2.9.4 to produce images * [libpng](http://libpng.org/pub/png/libpng.html) 1.6.37 to save pngs * [nowide](https://github.com/boostorg/nowide) 11.0.0 to handle UTF-8 filenames on Windows diff --git a/libs/CImg.h b/libs/CImg.h index 549c9938..fee598e2 100644 --- a/libs/CImg.h +++ b/libs/CImg.h @@ -54,7 +54,7 @@ // Set version number of the library. #ifndef cimg_version -#define cimg_version 293 +#define cimg_version 294 /*----------------------------------------------------------- # @@ -21046,49 +21046,26 @@ namespace cimg_library_suffixed { if (!std::strncmp(ss,"sort(",5)) { // Sort vector _cimg_mp_op("Function 'sort()'"); - if (*ss5!='#') { // Vector - s1 = ss5; while (s1::%s: %s: Invalid specified chunk size (%u) for first argument " - "('%s'), in expression '%s%s%s'.", - pixel_type(),_cimg_mp_calling_function,s_op, - arg3,s_type(arg1)._data, - s0>expr._data?"...":"",s0,se<&expr.back()?"...":""); - } - pos = vector(p1); - CImg::vector((ulongT)mp_sort,pos,arg1,p1,arg2,arg3).move_to(code); - _cimg_mp_return(pos); - - } else { // Image - s1 = ss6; while (s1::vector((ulongT)mp_image_sort,_cimg_mp_slot_nan,p1,arg1,arg2).move_to(code); - _cimg_mp_return_nan(); } + _cimg_mp_check_type(arg1,1,2,0); + _cimg_mp_check_type(arg2,2,1,0); + if (arg3!=~0U) _cimg_mp_check_type(arg3,3,1,0); + _cimg_mp_check_type(arg4,4,1,0); + p1 = _cimg_mp_size(arg1); + pos = vector(p1); + CImg::vector((ulongT)mp_sort,pos,arg1,p1,arg2,arg3,arg4).move_to(code); + _cimg_mp_return(pos); } if (!std::strncmp(ss,"sqr(",4)) { // Square @@ -25926,12 +25903,20 @@ namespace cimg_library_suffixed { static double mp_sort(_cimg_math_parser& mp) { double *const ptrd = &_mp_arg(1) + 1; const double *const ptrs = &_mp_arg(2) + 1; + const bool is_increasing = (bool)_mp_arg(4); const unsigned int siz = (unsigned int)mp.opcode[3], - chunk_siz = (unsigned int)mp.opcode[5]; - const bool is_increasing = (bool)_mp_arg(4); - CImg(ptrd,chunk_siz,siz/chunk_siz,1,1,true) = CImg(ptrs,chunk_siz,siz/chunk_siz,1,1,true). - get_sort(is_increasing,chunk_siz>1?'y':0); + nb_elts = mp.opcode[5]==~0U?siz:(unsigned int)_mp_arg(5), + siz_elt = (unsigned int)_mp_arg(6); + const ulongT sn = siz_elt*nb_elts; + if (sn>siz || siz_elt<1) + throw CImgArgumentException("[" cimg_appname "_math_parser] CImg<%s>: Function 'sort()': " + "Arguments 'nb_elts=%g' and 'siz_elt=%g' are invalid " + "for sorting a vector of size %u.", + mp.imgin.pixel_type(),_mp_arg(5),_mp_arg(6),siz); + CImg(ptrd,siz_elt,nb_elts,1,1,true) = CImg(ptrs,siz_elt,nb_elts,1,1,true). + get_sort(is_increasing,siz_elt>1?'y':0); + if (sn(ptrd + sn,siz - sn,1,1,1,true) = CImg(ptrs + sn,siz - sn,1,1,1,true); return cimg::type::nan(); } @@ -63065,7 +63050,7 @@ namespace cimg_library_suffixed { // Render requested font. if (!font) { is_variable_widths[ind] = is_variable_width; - font = basef.get_split('x',256); + basef.get_split('x',256).move_to(font); if (requested_height!=font[0]._height) cimglist_for(font,l) { font[l].resize(std::max(1U,font[l]._width*requested_height/font[l]._height),requested_height,-100,-100,