diff --git a/CImg.h b/CImg.h index 9e68d5f8..4a3d3dfb 100644 --- a/CImg.h +++ b/CImg.h @@ -24610,7 +24610,10 @@ namespace cimg_library { const int siz1 = siz - 1; if (is_pop_heap) { // Heapify if (dim==1) cimg::swap(img[0],img[siz1]); - else cimg_forC(img,c) cimg::swap(img(0,0,0,c),img(0,siz1,0,c)); + else { + T *ptr0 = img.data(), *ptr1 = img.data(0,siz1); + cimg_forC(img,c) { cimg::swap(*ptr0,*ptr1); ptr0+=img._height; ptr1+=img._height; } + } int index = 0; while (true) { const int child_left = 2*index + 1, child_right = child_left + 1; @@ -24619,7 +24622,10 @@ namespace cimg_library { if (child_right::nan(); if (dim==1) ret = img[siz1]; // Scalar element - else cimg_forC(img,c) ptrd[c] = img(0,siz1,0,c); // Vector element + else { + const T *ptrs = img.data(0,siz1); + cimg_forC(img,c) { ptrd[c] = *ptrs; ptrs+=img._height; } // Vector element + } if (is_pop) { // Remove element from array --siz; if (img.height()>32 && siz1 for (unsigned int k = 0; k0) { // Heapify const int index_parent = (index - 1)/2; if (img[index]