Skip to content

Commit

Permalink
Update CImg to 2.9.4
Browse files Browse the repository at this point in the history
  • Loading branch information
GenericMadScientist committed Nov 26, 2020
1 parent 6b7d976 commit b6c8700
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 48 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
79 changes: 32 additions & 47 deletions libs/CImg.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

// Set version number of the library.
#ifndef cimg_version
#define cimg_version 293
#define cimg_version 294

/*-----------------------------------------------------------
#
Expand Down Expand Up @@ -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<se1 && (*s1!=',' || level[s1 - expr._data]!=clevel1)) ++s1;
arg1 = compile(ss5,s1,depth1,0,is_critical);
arg2 = arg3 = 1;
if (s1<se1) {
s0 = ++s1; while (s0<se1 && (*s0!=',' || level[s0 - expr._data]!=clevel1)) ++s0;
arg2 = compile(s1,s0,depth1,0,is_critical);
arg3 = s0<se1?compile(++s0,se1,depth1,0,is_critical):1;
}
_cimg_mp_check_type(arg1,1,2,0);
_cimg_mp_check_type(arg2,2,1,0);
_cimg_mp_check_constant(arg3,3,3);
arg3 = (unsigned int)mem[arg3];
p1 = _cimg_mp_size(arg1);
if (p1%arg3) {
_cimg_mp_strerr;
throw CImgArgumentException("[" cimg_appname "_math_parser] "
"CImg<%s>::%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<ulongT>::vector((ulongT)mp_sort,pos,arg1,p1,arg2,arg3).move_to(code);
_cimg_mp_return(pos);

} else { // Image
s1 = ss6; while (s1<se1 && (*s1!=',' || level[s1 - expr._data]!=clevel1)) ++s1;
p1 = compile(ss6,s1,depth1,0,is_critical);
arg1 = 1;
arg2 = constant(-1.);
if (s1<se1) {
s2 = s1 + 1; while (s2<se1 && (*s2!=',' || level[s2 - expr._data]!=clevel1)) ++s2;
arg1 = compile(++s1,s2,depth1,0,is_critical);
if (s2<se1) arg2 = compile(++s2,se1,depth1,0,is_critical);
s1 = ss5; while (s1<se1 && (*s1!=',' || level[s1 - expr._data]!=clevel1)) ++s1;
arg1 = compile(ss5,s1,depth1,0,is_critical);
arg2 = arg4 = 1; arg3 = ~0U;
if (s1<se1) {
s0 = ++s1; while (s0<se1 && (*s0!=',' || level[s0 - expr._data]!=clevel1)) ++s0;
arg2 = compile(s1,s0,depth1,0,is_critical);
if (s0<se1) {
s1 = ++s0; while (s1<se1 && (*s1!=',' || level[s1 - expr._data]!=clevel1)) ++s1;
arg3 = compile(s0,s1,depth1,0,is_critical);
arg4 = s1<se1?compile(++s1,se1,depth1,0,is_critical):1;
}
_cimg_mp_check_type(arg1,2,1,0);
_cimg_mp_check_type(arg2,3,1,0);
_cimg_mp_check_list(true);
CImg<ulongT>::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<ulongT>::vector((ulongT)mp_sort,pos,arg1,p1,arg2,arg3,arg4).move_to(code);
_cimg_mp_return(pos);
}

if (!std::strncmp(ss,"sqr(",4)) { // Square
Expand Down Expand Up @@ -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<doubleT>(ptrd,chunk_siz,siz/chunk_siz,1,1,true) = CImg<doubleT>(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<doubleT>(ptrd,siz_elt,nb_elts,1,1,true) = CImg<doubleT>(ptrs,siz_elt,nb_elts,1,1,true).
get_sort(is_increasing,siz_elt>1?'y':0);
if (sn<siz) CImg<doubleT>(ptrd + sn,siz - sn,1,1,1,true) = CImg<doubleT>(ptrs + sn,siz - sn,1,1,1,true);
return cimg::type<double>::nan();
}

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b6c8700

Please sign in to comment.