Skip to content

Commit

Permalink
Update CImg to v.3.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Apr 17, 2024
1 parent 56bac07 commit a5b9c64
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cimg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
name: Update CImg.h
runs-on: ubuntu-latest
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:
- uses: actions/checkout@v2
name: Checkout this repository
Expand All @@ -36,7 +36,7 @@ jobs:
location: 'src'
- name: Commit new CImg version (and update script)
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.email '[email protected]'
git commit -am "Update CImg to ${{ needs.check-version.outputs.latest-tag }}"
Expand Down
109 changes: 96 additions & 13 deletions src/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 334
#define cimg_version 335

/*-----------------------------------------------------------
#
Expand Down Expand Up @@ -20599,9 +20599,7 @@ namespace cimg_library {
(*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);
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;
Expand Down Expand Up @@ -20887,6 +20885,32 @@ namespace cimg_library {
_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
_cimg_mp_op("Function 'floor()'");
arg1 = compile(ss6,se1,depth1,0,block_flags);
Expand Down Expand Up @@ -21209,7 +21233,7 @@ namespace cimg_library {
_cimg_mp_op("Function 'isbool()'");
if (ss7==se1) _cimg_mp_return(0);
try { arg1 = compile(ss7,se1,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_isbool,arg1);
if (is_const_scalar(arg1)) _cimg_mp_return(mem[arg1]==0. || mem[arg1]==1.);
_cimg_mp_scalar1(mp_isbool,arg1);
Expand All @@ -21219,7 +21243,7 @@ namespace cimg_library {
_cimg_mp_op("Function 'isconst()'");
if (ss8==se1) _cimg_mp_return(0);
try { arg1 = compile(ss8,se1,depth1,0,block_flags); }
catch(CImgException&) { _cimg_mp_return(0); }
catch (CImgException&) { _cimg_mp_return(0); }
if (is_const_scalar(arg1)) _cimg_mp_return(1);
_cimg_mp_return(0);
}
Expand Down Expand Up @@ -21274,12 +21298,27 @@ namespace cimg_library {
if (!std::strncmp(ss,"isint(",6)) { // Is integer?
_cimg_mp_op("Function 'isint()'");
if (ss6==se1) _cimg_mp_return(0);
try { arg1 = compile(ss6,se1,depth1,0,block_flags); }
catch(CImgException&) { _cimg_mp_return(0); }
if (is_vector(arg1)) _cimg_mp_vector1_v(mp_isint,arg1);
if (is_const_scalar(arg1))
_cimg_mp_return((unsigned int)((double)(longT)mem[arg1]==mem[arg1]));
_cimg_mp_scalar1(mp_isint,arg1);
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); }
arg2 = arg3 = ~0U;
if (s1<se1) {
s2 = ++s1; while (s2<se1 && (*s2!=',' || level[s2 - expr._data]!=clevel1)) ++s2;
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?
Expand Down Expand Up @@ -25668,6 +25707,46 @@ namespace cimg_library {
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) {
return std::floor(_mp_arg(2));
}
Expand Down Expand Up @@ -26177,7 +26256,11 @@ namespace cimg_library {
}

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) {
Expand Down

0 comments on commit a5b9c64

Please sign in to comment.