What you did is probably not a good idea : The destructor ~CImg<T>
will try to dealloc the buffer associated to your CImg<T>
instance, and as you have forced its value to be matrix
, you will get into big troubles. I suggest to use shared images instead, it is efficient (no additional memory copy) and safe to use :
CImg<float> img(matrix,width,height,1,1,true); // img is a 'shared' image.
img.display("Test");