Update CImg to v.3.3.5

This commit is contained in:
GitHub Actions 2024-04-17 20:26:24 +00:00
parent 56bac07109
commit a5b9c64c7a
2 changed files with 98 additions and 15 deletions

View file

@ -23,7 +23,7 @@ jobs:
name: Update CImg.h name: Update CImg.h
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: check-version needs: check-version
if: ${{ needs.check-version.outputs.latest-tag != 'v.3.3.4' }} if: ${{ needs.check-version.outputs.latest-tag != 'v.3.3.5' }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
name: Checkout this repository name: Checkout this repository
@ -36,7 +36,7 @@ jobs:
location: 'src' location: 'src'
- name: Commit new CImg version (and update script) - name: Commit new CImg version (and update script)
run: | run: |
sed -i 's/v.3.3.4/${{ needs.check-version.outputs.latest-tag }}/' .github/workflows/cimg.yml sed -i 's/v.3.3.5/${{ needs.check-version.outputs.latest-tag }}/' .github/workflows/cimg.yml
git config user.name 'GitHub Actions' git config user.name 'GitHub Actions'
git config user.email 'actions@github.com' git config user.email 'actions@github.com'
git commit -am "Update CImg to ${{ needs.check-version.outputs.latest-tag }}" git commit -am "Update CImg to ${{ needs.check-version.outputs.latest-tag }}"

View file

@ -54,7 +54,7 @@
// Set version number of the library. // Set version number of the library.
#ifndef cimg_version #ifndef cimg_version
#define cimg_version 334 #define cimg_version 335
/*----------------------------------------------------------- /*-----------------------------------------------------------
# #
@ -20599,9 +20599,7 @@ namespace cimg_library {
(*ns!=')' || level[ns - expr._data]!=clevel)) ++ns; (*ns!=')' || level[ns - expr._data]!=clevel)) ++ns;
arg2 = compile(s,ns,depth1,0,block_flags); arg2 = compile(s,ns,depth1,0,block_flags);
if (is_vector(arg2)) // Vector argument allowed to specify cordinates and color if (is_vector(arg2)) // Vector argument allowed to specify cordinates and color
CImg<ulongT>::sequence(size(arg2),arg2 + 1, CImg<ulongT>::sequence(size(arg2),arg2 + 1,arg2 + (ulongT)size(arg2)).move_to(l_opcode);
arg2 + (ulongT)size(arg2)).
move_to(l_opcode);
else else
CImg<ulongT>::vector(arg2).move_to(l_opcode); CImg<ulongT>::vector(arg2).move_to(l_opcode);
s = ns; s = ns;
@ -20887,6 +20885,32 @@ namespace cimg_library {
_cimg_mp_return(p3); _cimg_mp_return(p3);
} }
if (!std::strncmp(ss,"flood(",6)) { // Flood fill image
if (!is_inside_critical) is_parallelizable = false;
_cimg_mp_op("Function 'flood()'");
if (*ss6=='#') { // Index specified
s0 = ss7; while (s0<se1 && (*s0!=',' || level[s0 - expr._data]!=clevel1)) ++s0;
p1 = compile(ss7,s0++,depth1,0,block_flags);
_cimg_mp_check_notnan_index(p1);
_cimg_mp_check_list();
} else { p1 = ~0U; s0 = ss6; }
CImg<ulongT>::vector((ulongT)mp_flood,_cimg_mp_slot_nan,0,p1).move_to(l_opcode);
for (s = s0; s<se1; ++s) {
ns = s; while (ns<se && (*ns!=',' || level[ns - expr._data]!=clevel1) &&
(*ns!=')' || level[ns - expr._data]!=clevel)) ++ns;
arg2 = compile(s,ns,depth1,0,block_flags);
if (is_vector(arg2)) // Vector argument allowed to specify cordinates and color
CImg<ulongT>::sequence(size(arg2),arg2 + 1,arg2 + (ulongT)size(arg2)).move_to(l_opcode);
else
CImg<ulongT>::vector(arg2).move_to(l_opcode);
s = ns;
}
(l_opcode>'y').move_to(opcode);
opcode[2] = opcode._height;
opcode.move_to(code);
_cimg_mp_return_nan();
}
if (!std::strncmp(ss,"floor(",6)) { // Floor if (!std::strncmp(ss,"floor(",6)) { // Floor
_cimg_mp_op("Function 'floor()'"); _cimg_mp_op("Function 'floor()'");
arg1 = compile(ss6,se1,depth1,0,block_flags); arg1 = compile(ss6,se1,depth1,0,block_flags);
@ -21274,12 +21298,27 @@ namespace cimg_library {
if (!std::strncmp(ss,"isint(",6)) { // Is integer? if (!std::strncmp(ss,"isint(",6)) { // Is integer?
_cimg_mp_op("Function 'isint()'"); _cimg_mp_op("Function 'isint()'");
if (ss6==se1) _cimg_mp_return(0); if (ss6==se1) _cimg_mp_return(0);
try { arg1 = compile(ss6,se1,depth1,0,block_flags); } s1 = ss6; while (s1<se1 && (*s1!=',' || level[s1 - expr._data]!=clevel1)) ++s1;
try { arg1 = compile(ss6,s1,depth1,0,block_flags); }
catch (CImgException&) { _cimg_mp_return(0); } catch (CImgException&) { _cimg_mp_return(0); }
if (is_vector(arg1)) _cimg_mp_vector1_v(mp_isint,arg1); arg2 = arg3 = ~0U;
if (is_const_scalar(arg1)) if (s1<se1) {
_cimg_mp_return((unsigned int)((double)(longT)mem[arg1]==mem[arg1])); s2 = ++s1; while (s2<se1 && (*s2!=',' || level[s2 - expr._data]!=clevel1)) ++s2;
_cimg_mp_scalar1(mp_isint,arg1); arg2 = compile(s1,s2,depth1,0,block_flags);
arg3 = s2<se1?compile(++s2,se1,depth1,0,block_flags):~0U;
}
if (arg2!=~0U) _cimg_mp_check_type(arg2,2,1,0);
if (arg3!=~0U) _cimg_mp_check_type(arg3,3,1,0);
if (is_vector(arg1)) _cimg_mp_vector3_vss(mp_isint,arg1,arg2,arg3);
if (is_const_scalar(arg1) && (arg2==~0U || is_const_scalar(arg2)) &&
(arg3==~0U || is_const_scalar(arg3))) {
val = mem[arg1];
is_sth = std::modf(val,&val1)==0;
if (arg2==~0U) _cimg_mp_return(is_sth);
if (arg3==~0U) _cimg_mp_return(is_sth && val>=mem[arg2]);
_cimg_mp_return(is_sth && val>=mem[arg2] && val<=mem[arg3]);
}
_cimg_mp_scalar3(mp_isint,arg1,arg2,arg3);
} }
if (!std::strncmp(ss,"isnan(",6)) { // Is NaN? if (!std::strncmp(ss,"isnan(",6)) { // Is NaN?
@ -25668,6 +25707,46 @@ namespace cimg_library {
return p2<ptr2e?-1.:(double)(ptr1 - ptr1b); return p2<ptr2e?-1.:(double)(ptr1 - ptr1b);
} }
static double mp_flood(_cimg_math_parser& mp) {
const unsigned int i_end = (unsigned int)mp.opcode[2];
unsigned int ind = (unsigned int)mp.opcode[3];
if (ind!=~0U) {
mp_check_list(mp,"flood");
ind = (unsigned int)cimg::mod((int)_mp_arg(3),mp.imglist.width());
}
CImg<T> &img = ind==~0U?mp.imgout:mp.imglist[ind];
CImg<T> color(img._spectrum,1,1,1,0);
bool is_high_connectivity = false;
float tolerance = 0, opacity = 1;
int x0 = 0, y0 = 0, z0 = 0;
unsigned int i = 4;
if (i<i_end) {
x0 = (int)cimg::round(_mp_arg(i++));
if (i<i_end) {
y0 = (int)cimg::round(_mp_arg(i++));
if (i<i_end) {
z0 = (int)cimg::round(_mp_arg(i++));
if (i<i_end) {
tolerance = (float)_mp_arg(i++);
if (i<i_end) {
is_high_connectivity = (bool)_mp_arg(i++);
if (i<i_end) {
opacity = (float)_mp_arg(i++);
if (i<i_end) {
cimg_forX(color,k) if (i<i_end) color[k] = (T)_mp_arg(i++);
else { color.resize(k,1,1,1,-1); break; }
color.resize(img._spectrum,1,1,1,0,2);
}
}
}
}
}
}
}
img.draw_fill(x0,y0,z0,color._data,opacity,tolerance,is_high_connectivity);
return cimg::type<double>::nan();
}
static double mp_floor(_cimg_math_parser& mp) { static double mp_floor(_cimg_math_parser& mp) {
return std::floor(_mp_arg(2)); return std::floor(_mp_arg(2));
} }
@ -26177,7 +26256,11 @@ namespace cimg_library {
} }
static double mp_isint(_cimg_math_parser& mp) { static double mp_isint(_cimg_math_parser& mp) {
return (double)((double)(longT)_mp_arg(2)==_mp_arg(2)); double val = _mp_arg(2), intpart;
const bool is_int = std::modf(val,&intpart)==0;
if (mp.opcode[3]==~0U) return is_int;
if (mp.opcode[4]==~0U) return is_int && val>=_mp_arg(3);
return is_int && val>=_mp_arg(3) && val<=_mp_arg(4);
} }
static double mp_isfile(_cimg_math_parser& mp) { static double mp_isfile(_cimg_math_parser& mp) {