CImg
CImg copied to clipboard
Is Cimg function map() OK ??
The for(ff..) loop in the code below generates run time error:
Failed to allocate memory (22.1 Gio) for image (366,366,1,177147).
terminate called after throwing an instance of 'cimg_library::CImgInstanceException'
what(): [instance(0,0,0,0,(nil),non-shared)] CImg
#include "CImg.h" using namespace cimg_library;
typedef unsigned char u8 ; typedef unsigned int u32 ;
int main(int argc, char **arg)
{
int W=366, H=366 ; CImg
// define a color palette:
int npal= 5; u8 cc[3npal]= {255,0,0, 0,255,0, 0,0,255, 240,240,240, 0,0,0} ;
CImg
for( int ff=0; ff<15; ff++) { int np= -1; for(int xp=0; xp <W; xp++) for(int yp= H; yp >0; yp--) { np++ ; img (xp,yp) = (np< WH/3) ? 0x00:(np< WH*2/3) ? 0x01 :0x02 ; } img.map(pal); // map the color palette to img disp.display(img).wait(2000); printf(" end ff= %d\n",ff); fflush(stdout); } return 0; }
Your code does not compile.