Skip to content

Commit 5d4e7d6

Browse files
committed
.
2 parents ceea85e + a926d48 commit 5d4e7d6

File tree

3 files changed

+33
-14
lines changed

3 files changed

+33
-14
lines changed

CImg.h

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
// Set version number of the library.
5656
#ifndef cimg_version
57-
#define cimg_version 370
57+
#define cimg_version 371
5858

5959
/*-----------------------------------------------------------
6060
#
@@ -17847,7 +17847,7 @@ namespace cimg_library {
1784717847
const CImg<T>& imgin;
1784817848

1784917849
unsigned int break_type, constcache_size, debug_indent, mem_img_index, mem_img_median, mem_img_norm, mempos,
17850-
result_dim, result_end_dim;
17850+
null_index,result_dim, result_end_dim;
1785117851
bool is_end_code, is_fill, is_noncritical_run, is_parallelizable, need_input_copy, return_comp;
1785217852
const char *const calling_function, *s_op, *ss_op;
1785317853
double *result, *result_end;
@@ -17905,7 +17905,7 @@ namespace cimg_library {
1790517905
p_break((CImg<ulongT>*)(cimg_ulong)-2),
1790617906
imgin(img_input),
1790717907
break_type(0),constcache_size(0),debug_indent(0),mem_img_index(~0U),mem_img_median(~0U),mem_img_norm(~0U),
17908-
result_dim(0),result_end_dim(0),
17908+
null_index(~0U),result_dim(0),result_end_dim(0),
1790917909
is_fill(_is_fill),is_noncritical_run(false),is_parallelizable(true),need_input_copy(false),
1791017910
calling_function(funcname?funcname:"cimg_math_parser"),
1791117911
result_end(0),
@@ -17976,19 +17976,20 @@ namespace cimg_library {
1797617976
variable_pos.assign(8);
1797717977

1797817978
reserved_label.assign(128,1,1,1,~0U);
17979-
// reserved_label[0-32] are used to store the memory index of these variables:
17979+
// reserved_label[0-34] are used to store the memory index of these variables:
1798017980
// [0] = wh, [1] = whd, [2] = whds, [3] = pi, [4] = im, [5] = iM, [6] = ia, [7] = iv, [8] = id,
1798117981
// [9] = is, [10] = ip, [11] = ic, [12] = in, [13] = xm, [14] = ym, [15] = zm, [16] = cm, [17] = xM,
17982-
// [18] = yM, [19] = zM, [20] = cM, [21] = i0...[30] = i9, [31] = interpolation, [32] = boundary, [33] = eps
17982+
// [18] = yM, [19] = zM, [20] = cM, [21] = i0...[30] = i9, [31] = interpolation, [32] = boundary, [33] = eps,
17983+
// [34] = null
1798317984

1798417985
// Compile expression into a sequence of opcodes.
1798517986
s_op = ""; ss_op = expr._data;
1798617987
const unsigned int ind_result = compile(expr._data,expr._data + expr._width - 1,0,0,0);
17987-
if (!is_const_scalar(ind_result)) {
17988+
if (!is_const_scalar(ind_result) && ind_result!=_cimg_mp_slot_t && ind_result!=null_index) {
1798817989
if (is_vector(ind_result))
1798917990
CImg<doubleT>(&mem[ind_result] + 1,size(ind_result),1,1,1,true).
1799017991
fill(cimg::type<double>::nan());
17991-
else if (ind_result!=_cimg_mp_slot_t) mem[ind_result] = cimg::type<double>::nan();
17992+
else mem[ind_result] = cimg::type<double>::nan();
1799217993
}
1799317994
if (mem._width>=256 && mem._width - mempos>=mem._width/2) mem.resize(mempos,1,1,1,-1);
1799417995
result_dim = size(ind_result);
@@ -18286,6 +18287,16 @@ namespace cimg_library {
1828618287
} else if (ss4==se) { // Four-chars reserved variable
1828718288
if (*ss=='w' && *ss1=='h' && *ss2=='d' && *ss3=='s') // whds
1828818289
_cimg_mp_return(reserved_label[2]!=~0U?reserved_label[2]:25);
18290+
if (*ss=='n' && *ss1=='u' && *ss2=='l' && *ss3=='l') { // null
18291+
if (reserved_label[34]!=~0U) _cimg_mp_return(reserved_label[34]);
18292+
if (imgin._spectrum<2) _cimg_mp_return(0);
18293+
if (null_index==~0U) {
18294+
null_index = vector(imgin._spectrum);
18295+
std::memset(&mem[null_index] + 1,0,imgin._spectrum*sizeof(double));
18296+
set_reserved_vector(null_index);
18297+
}
18298+
_cimg_mp_return(null_index);
18299+
}
1828918300
}
1829018301

1829118302
pos = ~0U;
@@ -18462,8 +18473,13 @@ namespace cimg_library {
1846218473
s0 = ve1; while (s0>ss && (*s0!='[' || level[s0 - expr._data]!=clevel)) --s0;
1846318474
if (s0>ss && cimg::is_varname(ss,s0 - ss)) {
1846418475
variable_name[s0 - ss] = 0; // Remove brackets in variable name
18465-
get_variable_pos(variable_name,arg1,arg2);
18466-
arg1 = arg2!=~0U?reserved_label[arg2]:arg1!=~0U?variable_pos[arg1]:~0U; // Vector slot
18476+
if (!std::strcmp(variable_name,"null")) // Force 'null' to be allocated
18477+
arg1 = compile(ss,s0,depth1,0,block_flags);
18478+
else {
18479+
get_variable_pos(variable_name,arg1,arg2);
18480+
arg1 = arg2!=~0U?reserved_label[arg2]:arg1!=~0U?variable_pos[arg1]:~0U; // Vector slot
18481+
}
18482+
1846718483
if (arg1==~0U || is_scalar(arg1))
1846818484
compile(ss,s0,depth1,0,block_flags); // Variable does not exist or is not a vector -> error
1846918485

@@ -22604,7 +22620,7 @@ namespace cimg_library {
2260422620
is_sth = false; // blank after operator?
2260522621
if (cimg_sscanf(s1," %3[=-+/*&|minaxor]%c",st_op,&sep)==2 && (sep==')' ||
2260622622
(is_sth=cimg::is_blank(sep)))) {
22607-
if (!is_sth || (is_sth && cimg_sscanf(s1," %*[=+-*/&|minaxor ]%c",&sep)==1 && sep==')')) {
22623+
if (!is_sth || (is_sth && cimg_sscanf(s1," %*[=+-*&/|minaxor ]%c",&sep)==1 && sep==')')) {
2260822624
cimg::strpare(st_op,' ',false,true);
2260922625
if (!st_op[1])
2261022626
arg1 = *st_op=='='?0:*st_op=='+'?1:*st_op=='-'?2:*st_op=='*'?3:*st_op=='/'?4:
@@ -25303,6 +25319,7 @@ namespace cimg_library {
2530325319
c3 = variable_name[2];
2530425320
c4 = variable_name[3];
2530525321
if (c1=='w' && c2=='h' && c3=='d' && c4=='s') rp = 2; // whds
25322+
else if (c1=='n' && c2=='u' && c3=='l' && c4=='l') rp = 34; // null
2530625323
} else if (!std::strcmp(variable_name,"interpolation")) rp = 31; // interpolation
2530725324
else if (!std::strcmp(variable_name,"boundary")) rp = 32; // boundary
2530825325

@@ -29277,7 +29294,8 @@ namespace cimg_library {
2927729294
ptrd = (unsigned int)mp.opcode[1] + 1,
2927829295
siz = (unsigned int)mp.opcode[2];
2927929296
mp_func op = (mp_func)mp.opcode[3];
29280-
CImg<ulongT> l_opcode(1,3);
29297+
ulongT l_data[3];
29298+
CImg<ulongT> l_opcode(l_data,1,3,1,1,true);
2928129299
l_opcode[2] = mp.opcode[4]; // Scalar argument
2928229300
l_opcode.swap(mp.opcode);
2928329301
ulongT &target = mp.opcode[1];
@@ -29292,7 +29310,8 @@ namespace cimg_library {
2929229310
siz = (unsigned int)mp.opcode[2],
2929329311
ptrs = (unsigned int)mp.opcode[4] + 1;
2929429312
mp_func op = (mp_func)mp.opcode[3];
29295-
CImg<ulongT> l_opcode(1,4);
29313+
ulongT l_data[4];
29314+
CImg<ulongT> l_opcode(l_data,1,4,1,1,true);
2929629315
l_opcode.swap(mp.opcode);
2929729316
ulongT &target = mp.opcode[1], &argument = mp.opcode[2];
2929829317
while (siz-->0) { target = ptrd++; argument = ptrs++; (*op)(mp); }

html/header.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<div class="header">
1717
<a href="index.html"><img alt="Logo" src="img/logo_header.jpg" class="center_image" style="margin-top:1em;"/></a>
1818
<h2 style="padding-bottom: 1em">
19-
Latest stable version: <b><a href="http://cimg.eu/files/CImg_3.6.6.zip">3.6.6</a></b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Current pre-release: <b><a href="http://cimg.eu/files/CImg_latest.zip">3.7.0</a></b> (2026/02/12)
19+
Latest stable version: <b><a href="http://cimg.eu/files/CImg_3.7.0.zip">3.7.0</a></b> (2026/02/13)
2020
</h2>
2121

2222
<hr/>

html/header_doxygen.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<div class="header">
2727
<a href="../index.html"><img alt="Logo" src="../img/logo_header.jpg" class="center_image" style="margin-top:1em;"/></a>
2828
<h2 style="padding-bottom: 1em">
29-
Latest stable version: <b><a href="http://cimg.eu/files/CImg_3.6.6.zip">3.6.6</a></b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Current pre-release: <b><a href="http://cimg.eu/files/CImg_latest.zip">3.7.0</a></b> (2026/02/12)
29+
Latest stable version: <b><a href="http://cimg.eu/files/CImg_3.7.0.zip">3.7.0</a></b> (2026/02/13)
3030
</h2>
3131

3232
<hr/>

0 commit comments

Comments
 (0)