56 #define cimg_version 132
83 #if defined(unix) || defined(__unix) || defined(__unix__) \
84 || defined(linux) || defined(__linux) || defined(__linux__) \
85 || defined(sun) || defined(__sun) \
86 || defined(BSD) || defined(__OpenBSD__) || defined(__NetBSD__) \
87 || defined(__FreeBSD__) || defined __DragonFly__ \
88 || defined(sgi) || defined(__sgi) \
89 || defined(__MACOSX__) || defined(__APPLE__) \
90 || defined(__CYGWIN__)
92 #elif defined(_MSC_VER) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \
93 || defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
98 #elif !(cimg_OS==0 || cimg_OS==1 || cimg_OS==2)
99 #error CImg Library : Configuration variable 'cimg_OS' is badly defined.
100 #error (valid values are '0=unknown OS', '1=Unix-like OS', '2=Microsoft Windows').
109 #pragma warning(push)
110 #pragma warning(disable:4311)
111 #pragma warning(disable:4312)
112 #pragma warning(disable:4800)
113 #pragma warning(disable:4804)
114 #pragma warning(disable:4996)
115 #define _CRT_SECURE_NO_DEPRECATE 1
116 #define _CRT_NONSTDC_NO_DEPRECATE 1
121 #include <sys/time.h>
126 #define _WIN32_IE 0x0400
136 #define cimg_stdout stderr
140 #ifndef cimg_file_separator
142 #define cimg_file_separator '\\'
144 #define cimg_file_separator '/'
161 #elif !(cimg_debug==0 || cimg_debug==1 || cimg_debug==2 || cimg_debug==3 || cimg_debug==4)
162 #error CImg Library : Configuration variable 'cimg_debug' is badly defined.
163 #error (valid values are '0=quiet', '1=console', '2=dialog', '3=console+warnings', '4=dialog+warnings').
172 #define cimg_display 0
175 #define cimg_display 0
177 #if defined(__MACOSX__) || defined(__APPLE__)
178 #define cimg_display 1
180 #define cimg_display 1
183 #define cimg_display 2
185 #elif !(cimg_display==0 || cimg_display==1 || cimg_display==2 || cimg_display==3)
186 #error CImg Library : Configuration variable 'cimg_display' is badly defined.
187 #error (valid values are '0=disable', '1=X-Window (X11)', '2=Microsoft GDI32', '3=Apple Carbon').
192 #include <X11/Xlib.h>
193 #include <X11/Xutil.h>
194 #include <X11/keysym.h>
199 #include <X11/extensions/XShm.h>
201 #ifdef cimg_use_xrandr
202 #include <X11/extensions/Xrandr.h>
204 #elif cimg_display==3
205 #include <Carbon/Carbon.h>
216 #ifdef cimg_use_openmp
268 #ifdef cimg_use_ffmpeg
270 #include "avformat.h"
297 #ifdef cimg_use_magick
298 #include "Magick++.h"
308 #ifdef cimg_use_fftw3
322 #ifdef cimg_use_board
325 #define _cimg_redefine_None
338 #ifdef cimg_use_lapack
340 extern void sgetrf_(
int*,
int*,
float*,
int*,
int*,
int*);
341 extern void sgetri_(
int*,
float*,
int*,
int*,
float*,
int*,
int*);
342 extern void sgetrs_(
char*,
int*,
int*,
float*,
int*,
int*,
float*,
int*,
int*);
343 extern void sgesvd_(
char*,
char*,
int*,
int*,
float*,
int*,
float*,
float*,
int*,
float*,
int*,
float*,
int*,
int*);
344 extern void ssyev_(
char*,
char*,
int*,
float*,
int*,
float*,
float*,
int*,
int*);
345 extern void dgetrf_(
int*,
int*,
double*,
int*,
int*,
int*);
346 extern void dgetri_(
int*,
double*,
int*,
int*,
double*,
int*,
int*);
347 extern void dgetrs_(
char*,
int*,
int*,
double*,
int*,
int*,
double*,
int*,
int*);
348 extern void dgesvd_(
char*,
char*,
int*,
int*,
double*,
int*,
double*,
double*,
int*,
double*,
int*,
double*,
int*,
int*);
349 extern void dsyev_(
char*,
char*,
int*,
double*,
int*,
double*,
double*,
int*,
int*);
361 #define _cimg_redefine_min
365 #define _cimg_redefine_max
373 #if cimg_OS==1 && cimg_display==3
374 static struct _cimg_macosx_setcwd {
375 _cimg_macosx_setcwd() {
377 ProcessSerialNumber psn;
378 char filePath[512] = { 0 };
379 if (GetCurrentProcess(&psn)!=noErr)
return;
380 if (GetProcessBundleLocation(&psn,&location)!=noErr)
return;
381 FSRefMakePath(&location,(UInt8*)filePath,
sizeof(filePath)-1);
382 unsigned int p = std::strlen(filePath);
383 while (filePath[p] !=
'/') --p;
387 } cimg_macosx_setcwd;
400 #define cimg_usage(usage) cimg_library::cimg::option((char*)0,argc,argv,(char*)0,usage)
401 #define cimg_help(str) cimg_library::cimg::option((char*)0,argc,argv,str,(char*)0)
402 #define cimg_option(name,defaut,usage) cimg_library::cimg::option(name,argc,argv,defaut,usage)
403 #define cimg_argument(pos) cimg_library::cimg::argument(pos,argc,argv)
404 #define cimg_argument1(pos,s0) cimg_library::cimg::argument(pos,argc,argv,1,s0)
405 #define cimg_argument2(pos,s0,s1) cimg_library::cimg::argument(pos,argc,argv,2,s0,s1)
406 #define cimg_argument3(pos,s0,s1,s2) cimg_library::cimg::argument(pos,argc,argv,3,s0,s1,s2)
407 #define cimg_argument4(pos,s0,s1,s2,s3) cimg_library::cimg::argument(pos,argc,argv,4,s0,s1,s2,s3)
408 #define cimg_argument5(pos,s0,s1,s2,s3,s4) cimg_library::cimg::argument(pos,argc,argv,5,s0,s1,s2,s3,s4)
409 #define cimg_argument6(pos,s0,s1,s2,s3,s4,s5) cimg_library::cimg::argument(pos,argc,argv,6,s0,s1,s2,s3,s4,s5)
410 #define cimg_argument7(pos,s0,s1,s2,s3,s4,s5,s6) cimg_library::cimg::argument(pos,argc,argv,7,s0,s1,s2,s3,s4,s5,s6)
411 #define cimg_argument8(pos,s0,s1,s2,s3,s4,s5,s6,s7) cimg_library::cimg::argument(pos,argc,argv,8,s0,s1,s2,s3,s4,s5,s6,s7)
412 #define cimg_argument9(pos,s0,s1,s2,s3,s4,s5,s6,s7,s8) cimg_library::cimg::argument(pos,argc,argv,9,s0,s1,s2,s3,s4,s5,s6,s7,s8)
415 #define CImg_2x2(I,T) T I[4]; \
416 T& I##cc = I[0]; T& I##nc = I[1]; \
417 T& I##cn = I[2]; T& I##nn = I[3]; \
421 #define CImg_3x3(I,T) T I[9]; \
422 T& I##pp = I[0]; T& I##cp = I[1]; T& I##np = I[2]; \
423 T& I##pc = I[3]; T& I##cc = I[4]; T& I##nc = I[5]; \
424 T& I##pn = I[6]; T& I##cn = I[7]; T& I##nn = I[8]; \
425 I##pp = I##cp = I##np = \
426 I##pc = I##cc = I##nc = \
427 I##pn = I##cn = I##nn = 0
429 #define CImg_4x4(I,T) T I[16]; \
430 T& I##pp = I[0]; T& I##cp = I[1]; T& I##np = I[2]; T& I##ap = I[3]; \
431 T& I##pc = I[4]; T& I##cc = I[5]; T& I##nc = I[6]; T& I##ac = I[7]; \
432 T& I##pn = I[8]; T& I##cn = I[9]; T& I##nn = I[10]; T& I##an = I[11]; \
433 T& I##pa = I[12]; T& I##ca = I[13]; T& I##na = I[14]; T& I##aa = I[15]; \
434 I##pp = I##cp = I##np = I##ap = \
435 I##pc = I##cc = I##nc = I##ac = \
436 I##pn = I##cn = I##nn = I##an = \
437 I##pa = I##ca = I##na = I##aa = 0
439 #define CImg_5x5(I,T) T I[25]; \
440 T& I##bb = I[0]; T& I##pb = I[1]; T& I##cb = I[2]; T& I##nb = I[3]; T& I##ab = I[4]; \
441 T& I##bp = I[5]; T& I##pp = I[6]; T& I##cp = I[7]; T& I##np = I[8]; T& I##ap = I[9]; \
442 T& I##bc = I[10]; T& I##pc = I[11]; T& I##cc = I[12]; T& I##nc = I[13]; T& I##ac = I[14]; \
443 T& I##bn = I[15]; T& I##pn = I[16]; T& I##cn = I[17]; T& I##nn = I[18]; T& I##an = I[19]; \
444 T& I##ba = I[20]; T& I##pa = I[21]; T& I##ca = I[22]; T& I##na = I[23]; T& I##aa = I[24]; \
445 I##bb = I##pb = I##cb = I##nb = I##ab = \
446 I##bp = I##pp = I##cp = I##np = I##ap = \
447 I##bc = I##pc = I##cc = I##nc = I##ac = \
448 I##bn = I##pn = I##cn = I##nn = I##an = \
449 I##ba = I##pa = I##ca = I##na = I##aa = 0
451 #define CImg_2x2x2(I,T) T I[8]; \
452 T& I##ccc = I[0]; T& I##ncc = I[1]; \
453 T& I##cnc = I[2]; T& I##nnc = I[3]; \
454 T& I##ccn = I[4]; T& I##ncn = I[5]; \
455 T& I##cnn = I[6]; T& I##nnn = I[7]; \
461 #define CImg_3x3x3(I,T) T I[27]; \
462 T& I##ppp = I[0]; T& I##cpp = I[1]; T& I##npp = I[2]; \
463 T& I##pcp = I[3]; T& I##ccp = I[4]; T& I##ncp = I[5]; \
464 T& I##pnp = I[6]; T& I##cnp = I[7]; T& I##nnp = I[8]; \
465 T& I##ppc = I[9]; T& I##cpc = I[10]; T& I##npc = I[11]; \
466 T& I##pcc = I[12]; T& I##ccc = I[13]; T& I##ncc = I[14]; \
467 T& I##pnc = I[15]; T& I##cnc = I[16]; T& I##nnc = I[17]; \
468 T& I##ppn = I[18]; T& I##cpn = I[19]; T& I##npn = I[20]; \
469 T& I##pcn = I[21]; T& I##ccn = I[22]; T& I##ncn = I[23]; \
470 T& I##pnn = I[24]; T& I##cnn = I[25]; T& I##nnn = I[26]; \
471 I##ppp = I##cpp = I##npp = \
472 I##pcp = I##ccp = I##ncp = \
473 I##pnp = I##cnp = I##nnp = \
474 I##ppc = I##cpc = I##npc = \
475 I##pcc = I##ccc = I##ncc = \
476 I##pnc = I##cnc = I##nnc = \
477 I##ppn = I##cpn = I##npn = \
478 I##pcn = I##ccn = I##ncn = \
479 I##pnn = I##cnn = I##nnn = 0
481 #define cimg_get2x2(img,x,y,z,v,I) \
482 I[0] = (img)(x,y,z,v), I[1] = (img)(_n1##x,y,z,v), I[2] = (img)(x,_n1##y,z,v), I[3] = (img)(_n1##x,_n1##y,z,v)
484 #define cimg_get3x3(img,x,y,z,v,I) \
485 I[0] = (img)(_p1##x,_p1##y,z,v), I[1] = (img)(x,_p1##y,z,v), I[2] = (img)(_n1##x,_p1##y,z,v), I[3] = (img)(_p1##x,y,z,v), \
486 I[4] = (img)(x,y,z,v), I[5] = (img)(_n1##x,y,z,v), I[6] = (img)(_p1##x,_n1##y,z,v), I[7] = (img)(x,_n1##y,z,v), \
487 I[8] = (img)(_n1##x,_n1##y,z,v)
489 #define cimg_get4x4(img,x,y,z,v,I) \
490 I[0] = (img)(_p1##x,_p1##y,z,v), I[1] = (img)(x,_p1##y,z,v), I[2] = (img)(_n1##x,_p1##y,z,v), I[3] = (img)(_n2##x,_p1##y,z,v), \
491 I[4] = (img)(_p1##x,y,z,v), I[5] = (img)(x,y,z,v), I[6] = (img)(_n1##x,y,z,v), I[7] = (img)(_n2##x,y,z,v), \
492 I[8] = (img)(_p1##x,_n1##y,z,v), I[9] = (img)(x,_n1##y,z,v), I[10] = (img)(_n1##x,_n1##y,z,v), I[11] = (img)(_n2##x,_n1##y,z,v), \
493 I[12] = (img)(_p1##x,_n2##y,z,v), I[13] = (img)(x,_n2##y,z,v), I[14] = (img)(_n1##x,_n2##y,z,v), I[15] = (img)(_n2##x,_n2##y,z,v)
495 #define cimg_get5x5(img,x,y,z,v,I) \
496 I[0] = (img)(_p2##x,_p2##y,z,v), I[1] = (img)(_p1##x,_p2##y,z,v), I[2] = (img)(x,_p2##y,z,v), I[3] = (img)(_n1##x,_p2##y,z,v), \
497 I[4] = (img)(_n2##x,_p2##y,z,v), I[5] = (img)(_p2##x,_p1##y,z,v), I[6] = (img)(_p1##x,_p1##y,z,v), I[7] = (img)(x,_p1##y,z,v), \
498 I[8] = (img)(_n1##x,_p1##y,z,v), I[9] = (img)(_n2##x,_p1##y,z,v), I[10] = (img)(_p2##x,y,z,v), I[11] = (img)(_p1##x,y,z,v), \
499 I[12] = (img)(x,y,z,v), I[13] = (img)(_n1##x,y,z,v), I[14] = (img)(_n2##x,y,z,v), I[15] = (img)(_p2##x,_n1##y,z,v), \
500 I[16] = (img)(_p1##x,_n1##y,z,v), I[17] = (img)(x,_n1##y,z,v), I[18] = (img)(_n1##x,_n1##y,z,v), I[19] = (img)(_n2##x,_n1##y,z,v), \
501 I[20] = (img)(_p2##x,_n2##y,z,v), I[21] = (img)(_p1##x,_n2##y,z,v), I[22] = (img)(x,_n2##y,z,v), I[23] = (img)(_n1##x,_n2##y,z,v), \
502 I[24] = (img)(_n2##x,_n2##y,z,v)
504 #define cimg_get6x6(img,x,y,z,v,I) \
505 I[0] = (img)(_p2##x,_p2##y,z,v), I[1] = (img)(_p1##x,_p2##y,z,v), I[2] = (img)(x,_p2##y,z,v), I[3] = (img)(_n1##x,_p2##y,z,v), \
506 I[4] = (img)(_n2##x,_p2##y,z,v), I[5] = (img)(_n3##x,_p2##y,z,v), I[6] = (img)(_p2##x,_p1##y,z,v), I[7] = (img)(_p1##x,_p1##y,z,v), \
507 I[8] = (img)(x,_p1##y,z,v), I[9] = (img)(_n1##x,_p1##y,z,v), I[10] = (img)(_n2##x,_p1##y,z,v), I[11] = (img)(_n3##x,_p1##y,z,v), \
508 I[12] = (img)(_p2##x,y,z,v), I[13] = (img)(_p1##x,y,z,v), I[14] = (img)(x,y,z,v), I[15] = (img)(_n1##x,y,z,v), \
509 I[16] = (img)(_n2##x,y,z,v), I[17] = (img)(_n3##x,y,z,v), I[18] = (img)(_p2##x,_n1##y,z,v), I[19] = (img)(_p1##x,_n1##y,z,v), \
510 I[20] = (img)(x,_n1##y,z,v), I[21] = (img)(_n1##x,_n1##y,z,v), I[22] = (img)(_n2##x,_n1##y,z,v), I[23] = (img)(_n3##x,_n1##y,z,v), \
511 I[24] = (img)(_p2##x,_n2##y,z,v), I[25] = (img)(_p1##x,_n2##y,z,v), I[26] = (img)(x,_n2##y,z,v), I[27] = (img)(_n1##x,_n2##y,z,v), \
512 I[28] = (img)(_n2##x,_n2##y,z,v), I[29] = (img)(_n3##x,_n2##y,z,v), I[30] = (img)(_p2##x,_n3##y,z,v), I[31] = (img)(_p1##x,_n3##y,z,v), \
513 I[32] = (img)(x,_n3##y,z,v), I[33] = (img)(_n1##x,_n3##y,z,v), I[34] = (img)(_n2##x,_n3##y,z,v), I[35] = (img)(_n3##x,_n3##y,z,v)
515 #define cimg_get7x7(img,x,y,z,v,I) \
516 I[0] = (img)(_p3##x,_p3##y,z,v), I[1] = (img)(_p2##x,_p3##y,z,v), I[2] = (img)(_p1##x,_p3##y,z,v), I[3] = (img)(x,_p3##y,z,v), \
517 I[4] = (img)(_n1##x,_p3##y,z,v), I[5] = (img)(_n2##x,_p3##y,z,v), I[6] = (img)(_n3##x,_p3##y,z,v), I[7] = (img)(_p3##x,_p2##y,z,v), \
518 I[8] = (img)(_p2##x,_p2##y,z,v), I[9] = (img)(_p1##x,_p2##y,z,v), I[10] = (img)(x,_p2##y,z,v), I[11] = (img)(_n1##x,_p2##y,z,v), \
519 I[12] = (img)(_n2##x,_p2##y,z,v), I[13] = (img)(_n3##x,_p2##y,z,v), I[14] = (img)(_p3##x,_p1##y,z,v), I[15] = (img)(_p2##x,_p1##y,z,v), \
520 I[16] = (img)(_p1##x,_p1##y,z,v), I[17] = (img)(x,_p1##y,z,v), I[18] = (img)(_n1##x,_p1##y,z,v), I[19] = (img)(_n2##x,_p1##y,z,v), \
521 I[20] = (img)(_n3##x,_p1##y,z,v), I[21] = (img)(_p3##x,y,z,v), I[22] = (img)(_p2##x,y,z,v), I[23] = (img)(_p1##x,y,z,v), \
522 I[24] = (img)(x,y,z,v), I[25] = (img)(_n1##x,y,z,v), I[26] = (img)(_n2##x,y,z,v), I[27] = (img)(_n3##x,y,z,v), \
523 I[28] = (img)(_p3##x,_n1##y,z,v), I[29] = (img)(_p2##x,_n1##y,z,v), I[30] = (img)(_p1##x,_n1##y,z,v), I[31] = (img)(x,_n1##y,z,v), \
524 I[32] = (img)(_n1##x,_n1##y,z,v), I[33] = (img)(_n2##x,_n1##y,z,v), I[34] = (img)(_n3##x,_n1##y,z,v), I[35] = (img)(_p3##x,_n2##y,z,v), \
525 I[36] = (img)(_p2##x,_n2##y,z,v), I[37] = (img)(_p1##x,_n2##y,z,v), I[38] = (img)(x,_n2##y,z,v), I[39] = (img)(_n1##x,_n2##y,z,v), \
526 I[40] = (img)(_n2##x,_n2##y,z,v), I[41] = (img)(_n3##x,_n2##y,z,v), I[42] = (img)(_p3##x,_n3##y,z,v), I[43] = (img)(_p2##x,_n3##y,z,v), \
527 I[44] = (img)(_p1##x,_n3##y,z,v), I[45] = (img)(x,_n3##y,z,v), I[46] = (img)(_n1##x,_n3##y,z,v), I[47] = (img)(_n2##x,_n3##y,z,v), \
528 I[48] = (img)(_n3##x,_n3##y,z,v)
530 #define cimg_get8x8(img,x,y,z,v,I) \
531 I[0] = (img)(_p3##x,_p3##y,z,v), I[1] = (img)(_p2##x,_p3##y,z,v), I[2] = (img)(_p1##x,_p3##y,z,v), I[3] = (img)(x,_p3##y,z,v), \
532 I[4] = (img)(_n1##x,_p3##y,z,v), I[5] = (img)(_n2##x,_p3##y,z,v), I[6] = (img)(_n3##x,_p3##y,z,v), I[7] = (img)(_n4##x,_p3##y,z,v), \
533 I[8] = (img)(_p3##x,_p2##y,z,v), I[9] = (img)(_p2##x,_p2##y,z,v), I[10] = (img)(_p1##x,_p2##y,z,v), I[11] = (img)(x,_p2##y,z,v), \
534 I[12] = (img)(_n1##x,_p2##y,z,v), I[13] = (img)(_n2##x,_p2##y,z,v), I[14] = (img)(_n3##x,_p2##y,z,v), I[15] = (img)(_n4##x,_p2##y,z,v), \
535 I[16] = (img)(_p3##x,_p1##y,z,v), I[17] = (img)(_p2##x,_p1##y,z,v), I[18] = (img)(_p1##x,_p1##y,z,v), I[19] = (img)(x,_p1##y,z,v), \
536 I[20] = (img)(_n1##x,_p1##y,z,v), I[21] = (img)(_n2##x,_p1##y,z,v), I[22] = (img)(_n3##x,_p1##y,z,v), I[23] = (img)(_n4##x,_p1##y,z,v), \
537 I[24] = (img)(_p3##x,y,z,v), I[25] = (img)(_p2##x,y,z,v), I[26] = (img)(_p1##x,y,z,v), I[27] = (img)(x,y,z,v), \
538 I[28] = (img)(_n1##x,y,z,v), I[29] = (img)(_n2##x,y,z,v), I[30] = (img)(_n3##x,y,z,v), I[31] = (img)(_n4##x,y,z,v), \
539 I[32] = (img)(_p3##x,_n1##y,z,v), I[33] = (img)(_p2##x,_n1##y,z,v), I[34] = (img)(_p1##x,_n1##y,z,v), I[35] = (img)(x,_n1##y,z,v), \
540 I[36] = (img)(_n1##x,_n1##y,z,v), I[37] = (img)(_n2##x,_n1##y,z,v), I[38] = (img)(_n3##x,_n1##y,z,v), I[39] = (img)(_n4##x,_n1##y,z,v), \
541 I[40] = (img)(_p3##x,_n2##y,z,v), I[41] = (img)(_p2##x,_n2##y,z,v), I[42] = (img)(_p1##x,_n2##y,z,v), I[43] = (img)(x,_n2##y,z,v), \
542 I[44] = (img)(_n1##x,_n2##y,z,v), I[45] = (img)(_n2##x,_n2##y,z,v), I[46] = (img)(_n3##x,_n2##y,z,v), I[47] = (img)(_n4##x,_n2##y,z,v), \
543 I[48] = (img)(_p3##x,_n3##y,z,v), I[49] = (img)(_p2##x,_n3##y,z,v), I[50] = (img)(_p1##x,_n3##y,z,v), I[51] = (img)(x,_n3##y,z,v), \
544 I[52] = (img)(_n1##x,_n3##y,z,v), I[53] = (img)(_n2##x,_n3##y,z,v), I[54] = (img)(_n3##x,_n3##y,z,v), I[55] = (img)(_n4##x,_n3##y,z,v), \
545 I[56] = (img)(_p3##x,_n4##y,z,v), I[57] = (img)(_p2##x,_n4##y,z,v), I[58] = (img)(_p1##x,_n4##y,z,v), I[59] = (img)(x,_n4##y,z,v), \
546 I[60] = (img)(_n1##x,_n4##y,z,v), I[61] = (img)(_n2##x,_n4##y,z,v), I[62] = (img)(_n3##x,_n4##y,z,v), I[63] = (img)(_n4##x,_n4##y,z,v);
548 #define cimg_get9x9(img,x,y,z,v,I) \
549 I[0] = (img)(_p4##x,_p4##y,z,v), I[1] = (img)(_p3##x,_p4##y,z,v), I[2] = (img)(_p2##x,_p4##y,z,v), I[3] = (img)(_p1##x,_p4##y,z,v), \
550 I[4] = (img)(x,_p4##y,z,v), I[5] = (img)(_n1##x,_p4##y,z,v), I[6] = (img)(_n2##x,_p4##y,z,v), I[7] = (img)(_n3##x,_p4##y,z,v), \
551 I[8] = (img)(_n4##x,_p4##y,z,v), I[9] = (img)(_p4##x,_p3##y,z,v), I[10] = (img)(_p3##x,_p3##y,z,v), I[11] = (img)(_p2##x,_p3##y,z,v), \
552 I[12] = (img)(_p1##x,_p3##y,z,v), I[13] = (img)(x,_p3##y,z,v), I[14] = (img)(_n1##x,_p3##y,z,v), I[15] = (img)(_n2##x,_p3##y,z,v), \
553 I[16] = (img)(_n3##x,_p3##y,z,v), I[17] = (img)(_n4##x,_p3##y,z,v), I[18] = (img)(_p4##x,_p2##y,z,v), I[19] = (img)(_p3##x,_p2##y,z,v), \
554 I[20] = (img)(_p2##x,_p2##y,z,v), I[21] = (img)(_p1##x,_p2##y,z,v), I[22] = (img)(x,_p2##y,z,v), I[23] = (img)(_n1##x,_p2##y,z,v), \
555 I[24] = (img)(_n2##x,_p2##y,z,v), I[25] = (img)(_n3##x,_p2##y,z,v), I[26] = (img)(_n4##x,_p2##y,z,v), I[27] = (img)(_p4##x,_p1##y,z,v), \
556 I[28] = (img)(_p3##x,_p1##y,z,v), I[29] = (img)(_p2##x,_p1##y,z,v), I[30] = (img)(_p1##x,_p1##y,z,v), I[31] = (img)(x,_p1##y,z,v), \
557 I[32] = (img)(_n1##x,_p1##y,z,v), I[33] = (img)(_n2##x,_p1##y,z,v), I[34] = (img)(_n3##x,_p1##y,z,v), I[35] = (img)(_n4##x,_p1##y,z,v), \
558 I[36] = (img)(_p4##x,y,z,v), I[37] = (img)(_p3##x,y,z,v), I[38] = (img)(_p2##x,y,z,v), I[39] = (img)(_p1##x,y,z,v), \
559 I[40] = (img)(x,y,z,v), I[41] = (img)(_n1##x,y,z,v), I[42] = (img)(_n2##x,y,z,v), I[43] = (img)(_n3##x,y,z,v), \
560 I[44] = (img)(_n4##x,y,z,v), I[45] = (img)(_p4##x,_n1##y,z,v), I[46] = (img)(_p3##x,_n1##y,z,v), I[47] = (img)(_p2##x,_n1##y,z,v), \
561 I[48] = (img)(_p1##x,_n1##y,z,v), I[49] = (img)(x,_n1##y,z,v), I[50] = (img)(_n1##x,_n1##y,z,v), I[51] = (img)(_n2##x,_n1##y,z,v), \
562 I[52] = (img)(_n3##x,_n1##y,z,v), I[53] = (img)(_n4##x,_n1##y,z,v), I[54] = (img)(_p4##x,_n2##y,z,v), I[55] = (img)(_p3##x,_n2##y,z,v), \
563 I[56] = (img)(_p2##x,_n2##y,z,v), I[57] = (img)(_p1##x,_n2##y,z,v), I[58] = (img)(x,_n2##y,z,v), I[59] = (img)(_n1##x,_n2##y,z,v), \
564 I[60] = (img)(_n2##x,_n2##y,z,v), I[61] = (img)(_n3##x,_n2##y,z,v), I[62] = (img)(_n4##x,_n2##y,z,v), I[63] = (img)(_p4##x,_n3##y,z,v), \
565 I[64] = (img)(_p3##x,_n3##y,z,v), I[65] = (img)(_p2##x,_n3##y,z,v), I[66] = (img)(_p1##x,_n3##y,z,v), I[67] = (img)(x,_n3##y,z,v), \
566 I[68] = (img)(_n1##x,_n3##y,z,v), I[69] = (img)(_n2##x,_n3##y,z,v), I[70] = (img)(_n3##x,_n3##y,z,v), I[71] = (img)(_n4##x,_n3##y,z,v), \
567 I[72] = (img)(_p4##x,_n4##y,z,v), I[73] = (img)(_p3##x,_n4##y,z,v), I[74] = (img)(_p2##x,_n4##y,z,v), I[75] = (img)(_p1##x,_n4##y,z,v), \
568 I[76] = (img)(x,_n4##y,z,v), I[77] = (img)(_n1##x,_n4##y,z,v), I[78] = (img)(_n2##x,_n4##y,z,v), I[79] = (img)(_n3##x,_n4##y,z,v), \
569 I[80] = (img)(_n4##x,_n4##y,z,v)
571 #define cimg_get2x2x2(img,x,y,z,v,I) \
572 I[0] = (img)(x,y,z,v), I[1] = (img)(_n1##x,y,z,v), I[2] = (img)(x,_n1##y,z,v), I[3] = (img)(_n1##x,_n1##y,z,v), \
573 I[4] = (img)(x,y,_n1##z,v), I[5] = (img)(_n1##x,y,_n1##z,v), I[6] = (img)(x,_n1##y,_n1##z,v), I[7] = (img)(_n1##x,_n1##y,_n1##z,v)
575 #define cimg_get3x3x3(img,x,y,z,v,I) \
576 I[0] = (img)(_p1##x,_p1##y,_p1##z,v), I[1] = (img)(x,_p1##y,_p1##z,v), I[2] = (img)(_n1##x,_p1##y,_p1##z,v), \
577 I[3] = (img)(_p1##x,y,_p1##z,v), I[4] = (img)(x,y,_p1##z,v), I[5] = (img)(_n1##x,y,_p1##z,v), \
578 I[6] = (img)(_p1##x,_n1##y,_p1##z,v), I[7] = (img)(x,_n1##y,_p1##z,v), I[8] = (img)(_n1##x,_n1##y,_p1##z,v), \
579 I[9] = (img)(_p1##x,_p1##y,z,v), I[10] = (img)(x,_p1##y,z,v), I[11] = (img)(_n1##x,_p1##y,z,v), \
580 I[12] = (img)(_p1##x,y,z,v), I[13] = (img)(x,y,z,v), I[14] = (img)(_n1##x,y,z,v), \
581 I[15] = (img)(_p1##x,_n1##y,z,v), I[16] = (img)(x,_n1##y,z,v), I[17] = (img)(_n1##x,_n1##y,z,v), \
582 I[18] = (img)(_p1##x,_p1##y,_n1##z,v), I[19] = (img)(x,_p1##y,_n1##z,v), I[20] = (img)(_n1##x,_p1##y,_n1##z,v), \
583 I[21] = (img)(_p1##x,y,_n1##z,v), I[22] = (img)(x,y,_n1##z,v), I[23] = (img)(_n1##x,y,_n1##z,v), \
584 I[24] = (img)(_p1##x,_n1##y,_n1##z,v), I[25] = (img)(x,_n1##y,_n1##z,v), I[26] = (img)(_n1##x,_n1##y,_n1##z,v)
589 #define cimg_for(img,ptr,T_ptr) for (T_ptr *ptr = (img).data + (img).size(); (ptr--)>(img).data; )
590 #define cimg_foroff(img,off) for (unsigned int off = 0, _max##off = (unsigned int)(img).size(); off<_max##off; ++off)
592 #define cimg_for1(bound,i) for (int i = 0; i<(int)(bound); ++i)
593 #define cimg_forX(img,x) cimg_for1((img).width,x)
594 #define cimg_forY(img,y) cimg_for1((img).height,y)
595 #define cimg_forZ(img,z) cimg_for1((img).depth,z)
596 #define cimg_forV(img,v) cimg_for1((img).dim,v)
597 #define cimg_forXY(img,x,y) cimg_forY(img,y) cimg_forX(img,x)
598 #define cimg_forXZ(img,x,z) cimg_forZ(img,z) cimg_forX(img,x)
599 #define cimg_forYZ(img,y,z) cimg_forZ(img,z) cimg_forY(img,y)
600 #define cimg_forXV(img,x,v) cimg_forV(img,v) cimg_forX(img,x)
601 #define cimg_forYV(img,y,v) cimg_forV(img,v) cimg_forY(img,y)
602 #define cimg_forZV(img,z,v) cimg_forV(img,v) cimg_forZ(img,z)
603 #define cimg_forXYZ(img,x,y,z) cimg_forZ(img,z) cimg_forXY(img,x,y)
604 #define cimg_forXYV(img,x,y,v) cimg_forV(img,v) cimg_forXY(img,x,y)
605 #define cimg_forXZV(img,x,z,v) cimg_forV(img,v) cimg_forXZ(img,x,z)
606 #define cimg_forYZV(img,y,z,v) cimg_forV(img,v) cimg_forYZ(img,y,z)
607 #define cimg_forXYZV(img,x,y,z,v) cimg_forV(img,v) cimg_forXYZ(img,x,y,z)
609 #define cimg_for_in1(bound,i0,i1,i) \
610 for (int i = (int)(i0)<0?0:(int)(i0), _max##i = (int)(i1)<(int)(bound)?(int)(i1):(int)(bound)-1; i<=_max##i; ++i)
611 #define cimg_for_inX(img,x0,x1,x) cimg_for_in1((img).width,x0,x1,x)
612 #define cimg_for_inY(img,y0,y1,y) cimg_for_in1((img).height,y0,y1,y)
613 #define cimg_for_inZ(img,z0,z1,z) cimg_for_in1((img).depth,z0,z1,z)
614 #define cimg_for_inV(img,v0,v1,v) cimg_for_in1((img).dim,v0,v1,v)
615 #define cimg_for_inXY(img,x0,y0,x1,y1,x,y) cimg_for_inY(img,y0,y1,y) cimg_for_inX(img,x0,x1,x)
616 #define cimg_for_inXZ(img,x0,z0,x1,z1,x,z) cimg_for_inZ(img,z0,z1,z) cimg_for_inX(img,x0,x1,x)
617 #define cimg_for_inXV(img,x0,v0,x1,v1,x,v) cimg_for_inV(img,v0,v1,v) cimg_for_inX(img,x0,x1,x)
618 #define cimg_for_inYZ(img,y0,z0,y1,z1,y,z) cimg_for_inZ(img,x0,z1,z) cimg_for_inY(img,y0,y1,y)
619 #define cimg_for_inYV(img,y0,v0,y1,v1,y,v) cimg_for_inV(img,v0,v1,v) cimg_for_inY(img,y0,y1,y)
620 #define cimg_for_inZV(img,z0,v0,z1,v1,z,v) cimg_for_inV(img,v0,v1,v) cimg_for_inZ(img,z0,z1,z)
621 #define cimg_for_inXYZ(img,x0,y0,z0,x1,y1,z1,x,y,z) cimg_for_inZ(img,z0,z1,z) cimg_for_inXY(img,x0,y0,x1,y1,x,y)
622 #define cimg_for_inXYV(img,x0,y0,v0,x1,y1,v1,x,y,v) cimg_for_inV(img,v0,v1,v) cimg_for_inXY(img,x0,y0,x1,y1,x,y)
623 #define cimg_for_inXZV(img,x0,z0,v0,x1,z1,v1,x,z,v) cimg_for_inV(img,v0,v1,v) cimg_for_inXZ(img,x0,z0,x1,z1,x,z)
624 #define cimg_for_inYZV(img,y0,z0,v0,y1,z1,v1,y,z,v) cimg_for_inV(img,v0,v1,v) cimg_for_inYZ(img,y0,z0,y1,z1,y,z)
625 #define cimg_for_inXYZV(img,x0,y0,z0,v0,x1,y1,z1,v1,x,y,z,v) cimg_for_inV(img,v0,v1,v) cimg_for_inXYZ(img,x0,y0,z0,x1,y1,z1,x,y,z)
626 #define cimg_for_insideX(img,x,n) cimg_for_inX(img,n,(img).width-1-(n),x)
627 #define cimg_for_insideY(img,y,n) cimg_for_inY(img,n,(img).height-1-(n),y)
628 #define cimg_for_insideZ(img,z,n) cimg_for_inZ(img,n,(img).depth-1-(n),z)
629 #define cimg_for_insideV(img,v,n) cimg_for_inV(img,n,(img).dim-1-(n),v)
630 #define cimg_for_insideXY(img,x,y,n) cimg_for_inXY(img,n,n,(img).width-1-(n),(img).height-1-(n),x,y)
631 #define cimg_for_insideXYZ(img,x,y,z,n) cimg_for_inXYZ(img,n,n,n,(img).width-1-(n),(img).height-1-(n),(img).depth-1-(n),x,y,z)
632 #define cimg_for_insideXYZV(img,x,y,z,v,n) cimg_for_inXYZ(img,n,n,n,(img).width-1-(n),(img).height-1-(n),(img).depth-1-(n),x,y,z)
634 #define cimg_for_out1(boundi,i0,i1,i) \
635 for (int i = (int)(i0)>0?0:(int)(i1)+1; i<(int)(boundi); ++i, i = i==(int)(i0)?(int)(i1)+1:i)
636 #define cimg_for_out2(boundi,boundj,i0,j0,i1,j1,i,j) \
637 for (int j = 0; j<(int)(boundj); ++j) \
638 for (int _n1j = (int)(j<(int)(j0) || j>(int)(j1)), i = _n1j?0:(int)(i0)>0?0:(int)(i1)+1; i<(int)(boundi); \
639 ++i, i = _n1j?i:(i==(int)(i0)?(int)(i1)+1:i))
640 #define cimg_for_out3(boundi,boundj,boundk,i0,j0,k0,i1,j1,k1,i,j,k) \
641 for (int k = 0; k<(int)(boundk); ++k) \
642 for (int _n1k = (int)(k<(int)(k0) || k>(int)(k1)), j = 0; j<(int)(boundj); ++j) \
643 for (int _n1j = (int)(j<(int)(j0) || j>(int)(j1)), i = _n1j || _n1k?0:(int)(i0)>0?0:(int)(i1)+1; i<(int)(boundi); \
644 ++i, i = _n1j || _n1k?i:(i==(int)(i0)?(int)(i1)+1:i))
645 #define cimg_for_out4(boundi,boundj,boundk,boundl,i0,j0,k0,l0,i1,j1,k1,l1,i,j,k,l) \
646 for (int l = 0; l<(int)(boundl); ++l) \
647 for (int _n1l = (int)(l<(int)(l0) || l>(int)(l1)), k = 0; k<(int)(boundk); ++k) \
648 for (int _n1k = (int)(k<(int)(k0) || k>(int)(k1)), j = 0; j<(int)(boundj); ++j) \
649 for (int _n1j = (int)(j<(int)(j0) || j>(int)(j1)), i = _n1j || _n1k || _n1l?0:(int)(i0)>0?0:(int)(i1)+1; i<(int)(boundi); \
650 ++i, i = _n1j || _n1k || _n1l?i:(i==(int)(i0)?(int)(i1)+1:i))
651 #define cimg_for_outX(img,x0,x1,x) cimg_for_out1((img).width,x0,x1,x)
652 #define cimg_for_outY(img,y0,y1,y) cimg_for_out1((img).height,y0,y1,y)
653 #define cimg_for_outZ(img,z0,z1,z) cimg_for_out1((img).depth,z0,z1,z)
654 #define cimg_for_outV(img,v0,v1,v) cimg_for_out1((img).dim,v0,v1,v)
655 #define cimg_for_outXY(img,x0,y0,x1,y1,x,y) cimg_for_out2((img).width,(img).height,x0,y0,x1,y1,x,y)
656 #define cimg_for_outXZ(img,x0,z0,x1,z1,x,z) cimg_for_out2((img).width,(img).depth,x0,z0,x1,z1,x,z)
657 #define cimg_for_outXV(img,x0,v0,x1,v1,x,v) cimg_for_out2((img).width,(img).dim,x0,v0,x1,v1,x,v)
658 #define cimg_for_outYZ(img,y0,z0,y1,z1,y,z) cimg_for_out2((img).height,(img).depth,y0,z0,y1,z1,y,z)
659 #define cimg_for_outYV(img,y0,v0,y1,v1,y,v) cimg_for_out2((img).height,(img).dim,y0,v0,y1,v1,y,v)
660 #define cimg_for_outZV(img,z0,v0,z1,v1,z,v) cimg_for_out2((img).depth,(img).dim,z0,v0,z1,v1,z,v)
661 #define cimg_for_outXYZ(img,x0,y0,z0,x1,y1,z1,x,y,z) cimg_for_out3((img).width,(img).height,(img).depth,x0,y0,z0,x1,y1,z1,x,y,z)
662 #define cimg_for_outXYV(img,x0,y0,v0,x1,y1,v1,x,y,v) cimg_for_out3((img).width,(img).height,(img).dim,x0,y0,v0,x1,y1,v1,x,y,v)
663 #define cimg_for_outXZV(img,x0,z0,v0,x1,z1,v1,x,z,v) cimg_for_out3((img).width,(img).depth,(img).dim,x0,z0,v0,x1,z1,v1,x,z,v)
664 #define cimg_for_outYZV(img,y0,z0,v0,y1,z1,v1,y,z,v) cimg_for_out3((img).height,(img).depth,(img).dim,y0,z0,v0,y1,z1,v1,y,z,v)
665 #define cimg_for_outXYZV(img,x0,y0,z0,v0,x1,y1,z1,v1,x,y,z,v) \
666 cimg_for_out4((img).width,(img).height,(img).depth,(img).dim,x0,y0,z0,v0,x1,y1,z1,v1,x,y,z,v)
667 #define cimg_for_borderX(img,x,n) cimg_for_outX(img,n,(img).width-1-(n),x)
668 #define cimg_for_borderY(img,y,n) cimg_for_outY(img,n,(img).height-1-(n),y)
669 #define cimg_for_borderZ(img,z,n) cimg_for_outZ(img,n,(img).depth-1-(n),z)
670 #define cimg_for_borderV(img,v,n) cimg_for_outV(img,n,(img).dim-1-(n),v)
671 #define cimg_for_borderXY(img,x,y,n) cimg_for_outXY(img,n,n,(img).width-1-(n),(img).height-1-(n),x,y)
672 #define cimg_for_borderXYZ(img,x,y,z,n) cimg_for_outXYZ(img,n,n,n,(img).width-1-(n),(img).height-1-(n),(img).depth-1-(n),x,y,z)
673 #define cimg_for_borderXYZV(img,x,y,z,v,n) \
674 cimg_for_outXYZV(img,n,n,n,n,(img).width-1-(n),(img).height-1-(n),(img).depth-1-(n),(img).dim-1-(n),x,y,z,v)
676 #define cimg_for_spiralXY(img,x,y) \
677 for (int x = 0, y = 0, _n1##x = 1, _n1##y = (int)((img).width*(img).height); _n1##y; \
678 --_n1##y, _n1##x += (_n1##x>>2)-((!(_n1##x&3)?--y:((_n1##x&3)==1?(img).width-1-++x:((_n1##x&3)==2?(img).height-1-++y:--x))))?0:1)
680 #define cimg_for_lineXY(x,y,x0,y0,x1,y1) \
681 for (int x = (int)(x0), y = (int)(y0), _sx = 1, _sy = 1, _steep = 0, \
682 _dx=(x1)>(x0)?(int)(x1)-(int)(x0):(_sx=-1,(int)(x0)-(int)(x1)), \
683 _dy=(y1)>(y0)?(int)(y1)-(int)(y0):(_sy=-1,(int)(y0)-(int)(y1)), \
685 _err = _dx>_dy?(_dy>>1):((_steep=1),(_counter=_dy),(_dx>>1)); \
687 --_counter, x+=_steep? \
688 (y+=_sy,(_err-=_dx)<0?_err+=_dy,_sx:0): \
689 (y+=(_err-=_dy)<0?_err+=_dx,_sy:0,_sx))
691 #define cimg_for2(bound,i) \
692 for (int i = 0, _n1##i = 1>=(bound)?(int)(bound)-1:1; \
693 _n1##i<(int)(bound) || i==--_n1##i; \
695 #define cimg_for2X(img,x) cimg_for2((img).width,x)
696 #define cimg_for2Y(img,y) cimg_for2((img).height,y)
697 #define cimg_for2Z(img,z) cimg_for2((img).depth,z)
698 #define cimg_for2V(img,v) cimg_for2((img).dim,v)
699 #define cimg_for2XY(img,x,y) cimg_for2Y(img,y) cimg_for2X(img,x)
700 #define cimg_for2XZ(img,x,z) cimg_for2Z(img,z) cimg_for2X(img,x)
701 #define cimg_for2XV(img,x,v) cimg_for2V(img,v) cimg_for2X(img,x)
702 #define cimg_for2YZ(img,y,z) cimg_for2Z(img,z) cimg_for2Y(img,y)
703 #define cimg_for2YV(img,y,v) cimg_for2V(img,v) cimg_for2Y(img,y)
704 #define cimg_for2ZV(img,z,v) cimg_for2V(img,v) cimg_for2Z(img,z)
705 #define cimg_for2XYZ(img,x,y,z) cimg_for2Z(img,z) cimg_for2XY(img,x,y)
706 #define cimg_for2XZV(img,x,z,v) cimg_for2V(img,v) cimg_for2XZ(img,x,z)
707 #define cimg_for2YZV(img,y,z,v) cimg_for2V(img,v) cimg_for2YZ(img,y,z)
708 #define cimg_for2XYZV(img,x,y,z,v) cimg_for2V(img,v) cimg_for2XYZ(img,x,y,z)
710 #define cimg_for_in2(bound,i0,i1,i) \
711 for (int i = (int)(i0)<0?0:(int)(i0), \
712 _n1##i = i+1>=(int)(bound)?(int)(bound)-1:i+1; \
713 i<=(int)(i1) && (_n1##i<(int)(bound) || i==--_n1##i); \
715 #define cimg_for_in2X(img,x0,x1,x) cimg_for_in2((img).width,x0,x1,x)
716 #define cimg_for_in2Y(img,y0,y1,y) cimg_for_in2((img).height,y0,y1,y)
717 #define cimg_for_in2Z(img,z0,z1,z) cimg_for_in2((img).depth,z0,z1,z)
718 #define cimg_for_in2V(img,v0,v1,v) cimg_for_in2((img).dim,v0,v1,v)
719 #define cimg_for_in2XY(img,x0,y0,x1,y1,x,y) cimg_for_in2Y(img,y0,y1,y) cimg_for_in2X(img,x0,x1,x)
720 #define cimg_for_in2XZ(img,x0,z0,x1,z1,x,z) cimg_for_in2Z(img,z0,z1,z) cimg_for_in2X(img,x0,x1,x)
721 #define cimg_for_in2XV(img,x0,v0,x1,v1,x,v) cimg_for_in2V(img,v0,v1,v) cimg_for_in2X(img,x0,x1,x)
722 #define cimg_for_in2YZ(img,y0,z0,y1,z1,y,z) cimg_for_in2Z(img,z0,z1,z) cimg_for_in2Y(img,y0,y1,y)
723 #define cimg_for_in2YV(img,y0,v0,y1,v1,y,v) cimg_for_in2V(img,v0,v1,v) cimg_for_in2Y(img,y0,y1,y)
724 #define cimg_for_in2ZV(img,z0,v0,z1,v1,z,v) cimg_for_in2V(img,v0,v1,v) cimg_for_in2Z(img,z0,z1,z)
725 #define cimg_for_in2XYZ(img,x0,y0,z0,x1,y1,z1,x,y,z) cimg_for_in2Z(img,z0,z1,z) cimg_for_in2XY(img,x0,y0,x1,y1,x,y)
726 #define cimg_for_in2XZV(img,x0,z0,v0,x1,y1,v1,x,z,v) cimg_for_in2V(img,v0,v1,v) cimg_for_in2XZ(img,x0,y0,x1,y1,x,z)
727 #define cimg_for_in2YZV(img,y0,z0,v0,y1,z1,v1,y,z,v) cimg_for_in2V(img,v0,v1,v) cimg_for_in2YZ(img,y0,z0,y1,z1,y,z)
728 #define cimg_for_in2XYZV(img,x0,y0,z0,v0,x1,y1,z1,v1,x,y,z,v) cimg_for_in2V(img,v0,v1,v) cimg_for_in2XYZ(img,x0,y0,z0,x1,y1,z1,x,y,z)
730 #define cimg_for3(bound,i) \
731 for (int i = 0, _p1##i = 0, \
732 _n1##i = 1>=(bound)?(int)(bound)-1:1; \
733 _n1##i<(int)(bound) || i==--_n1##i; \
734 _p1##i = i++, ++_n1##i)
735 #define cimg_for3X(img,x) cimg_for3((img).width,x)
736 #define cimg_for3Y(img,y) cimg_for3((img).height,y)
737 #define cimg_for3Z(img,z) cimg_for3((img).depth,z)
738 #define cimg_for3V(img,v) cimg_for3((img).dim,v)
739 #define cimg_for3XY(img,x,y) cimg_for3Y(img,y) cimg_for3X(img,x)
740 #define cimg_for3XZ(img,x,z) cimg_for3Z(img,z) cimg_for3X(img,x)
741 #define cimg_for3XV(img,x,v) cimg_for3V(img,v) cimg_for3X(img,x)
742 #define cimg_for3YZ(img,y,z) cimg_for3Z(img,z) cimg_for3Y(img,y)
743 #define cimg_for3YV(img,y,v) cimg_for3V(img,v) cimg_for3Y(img,y)
744 #define cimg_for3ZV(img,z,v) cimg_for3V(img,v) cimg_for3Z(img,z)
745 #define cimg_for3XYZ(img,x,y,z) cimg_for3Z(img,z) cimg_for3XY(img,x,y)
746 #define cimg_for3XZV(img,x,z,v) cimg_for3V(img,v) cimg_for3XZ(img,x,z)
747 #define cimg_for3YZV(img,y,z,v) cimg_for3V(img,v) cimg_for3YZ(img,y,z)
748 #define cimg_for3XYZV(img,x,y,z,v) cimg_for3V(img,v) cimg_for3XYZ(img,x,y,z)
750 #define cimg_for_in3(bound,i0,i1,i) \
751 for (int i = (int)(i0)<0?0:(int)(i0), \
752 _p1##i = i-1<0?0:i-1, \
753 _n1##i = i+1>=(int)(bound)?(int)(bound)-1:i+1; \
754 i<=(int)(i1) && (_n1##i<(int)(bound) || i==--_n1##i); \
755 _p1##i = i++, ++_n1##i)
756 #define cimg_for_in3X(img,x0,x1,x) cimg_for_in3((img).width,x0,x1,x)
757 #define cimg_for_in3Y(img,y0,y1,y) cimg_for_in3((img).height,y0,y1,y)
758 #define cimg_for_in3Z(img,z0,z1,z) cimg_for_in3((img).depth,z0,z1,z)
759 #define cimg_for_in3V(img,v0,v1,v) cimg_for_in3((img).dim,v0,v1,v)
760 #define cimg_for_in3XY(img,x0,y0,x1,y1,x,y) cimg_for_in3Y(img,y0,y1,y) cimg_for_in3X(img,x0,x1,x)
761 #define cimg_for_in3XZ(img,x0,z0,x1,z1,x,z) cimg_for_in3Z(img,z0,z1,z) cimg_for_in3X(img,x0,x1,x)
762 #define cimg_for_in3XV(img,x0,v0,x1,v1,x,v) cimg_for_in3V(img,v0,v1,v) cimg_for_in3X(img,x0,x1,x)
763 #define cimg_for_in3YZ(img,y0,z0,y1,z1,y,z) cimg_for_in3Z(img,z0,z1,z) cimg_for_in3Y(img,y0,y1,y)
764 #define cimg_for_in3YV(img,y0,v0,y1,v1,y,v) cimg_for_in3V(img,v0,v1,v) cimg_for_in3Y(img,y0,y1,y)
765 #define cimg_for_in3ZV(img,z0,v0,z1,v1,z,v) cimg_for_in3V(img,v0,v1,v) cimg_for_in3Z(img,z0,z1,z)
766 #define cimg_for_in3XYZ(img,x0,y0,z0,x1,y1,z1,x,y,z) cimg_for_in3Z(img,z0,z1,z) cimg_for_in3XY(img,x0,y0,x1,y1,x,y)
767 #define cimg_for_in3XZV(img,x0,z0,v0,x1,y1,v1,x,z,v) cimg_for_in3V(img,v0,v1,v) cimg_for_in3XZ(img,x0,y0,x1,y1,x,z)
768 #define cimg_for_in3YZV(img,y0,z0,v0,y1,z1,v1,y,z,v) cimg_for_in3V(img,v0,v1,v) cimg_for_in3YZ(img,y0,z0,y1,z1,y,z)
769 #define cimg_for_in3XYZV(img,x0,y0,z0,v0,x1,y1,z1,v1,x,y,z,v) cimg_for_in3V(img,v0,v1,v) cimg_for_in3XYZ(img,x0,y0,z0,x1,y1,z1,x,y,z)
771 #define cimg_for4(bound,i) \
772 for (int i = 0, _p1##i = 0, _n1##i = 1>=(bound)?(int)(bound)-1:1, \
773 _n2##i = 2>=(bound)?(int)(bound)-1:2; \
774 _n2##i<(int)(bound) || _n1##i==--_n2##i || i==(_n2##i = --_n1##i); \
775 _p1##i = i++, ++_n1##i, ++_n2##i)
776 #define cimg_for4X(img,x) cimg_for4((img).width,x)
777 #define cimg_for4Y(img,y) cimg_for4((img).height,y)
778 #define cimg_for4Z(img,z) cimg_for4((img).depth,z)
779 #define cimg_for4V(img,v) cimg_for4((img).dim,v)
780 #define cimg_for4XY(img,x,y) cimg_for4Y(img,y) cimg_for4X(img,x)
781 #define cimg_for4XZ(img,x,z) cimg_for4Z(img,z) cimg_for4X(img,x)
782 #define cimg_for4XV(img,x,v) cimg_for4V(img,v) cimg_for4X(img,x)
783 #define cimg_for4YZ(img,y,z) cimg_for4Z(img,z) cimg_for4Y(img,y)
784 #define cimg_for4YV(img,y,v) cimg_for4V(img,v) cimg_for4Y(img,y)
785 #define cimg_for4ZV(img,z,v) cimg_for4V(img,v) cimg_for4Z(img,z)
786 #define cimg_for4XYZ(img,x,y,z) cimg_for4Z(img,z) cimg_for4XY(img,x,y)
787 #define cimg_for4XZV(img,x,z,v) cimg_for4V(img,v) cimg_for4XZ(img,x,z)
788 #define cimg_for4YZV(img,y,z,v) cimg_for4V(img,v) cimg_for4YZ(img,y,z)
789 #define cimg_for4XYZV(img,x,y,z,v) cimg_for4V(img,v) cimg_for4XYZ(img,x,y,z)
791 #define cimg_for_in4(bound,i0,i1,i) \
792 for (int i = (int)(i0)<0?0:(int)(i0), \
793 _p1##i = i-1<0?0:i-1, \
794 _n1##i = i+1>=(int)(bound)?(int)(bound)-1:i+1, \
795 _n2##i = i+2>=(int)(bound)?(int)(bound)-1:i+2; \
796 i<=(int)(i1) && (_n2##i<(int)(bound) || _n1##i==--_n2##i || i==(_n2##i = --_n1##i)); \
797 _p1##i = i++, ++_n1##i, ++_n2##i)
798 #define cimg_for_in4X(img,x0,x1,x) cimg_for_in4((img).width,x0,x1,x)
799 #define cimg_for_in4Y(img,y0,y1,y) cimg_for_in4((img).height,y0,y1,y)
800 #define cimg_for_in4Z(img,z0,z1,z) cimg_for_in4((img).depth,z0,z1,z)
801 #define cimg_for_in4V(img,v0,v1,v) cimg_for_in4((img).dim,v0,v1,v)
802 #define cimg_for_in4XY(img,x0,y0,x1,y1,x,y) cimg_for_in4Y(img,y0,y1,y) cimg_for_in4X(img,x0,x1,x)
803 #define cimg_for_in4XZ(img,x0,z0,x1,z1,x,z) cimg_for_in4Z(img,z0,z1,z) cimg_for_in4X(img,x0,x1,x)
804 #define cimg_for_in4XV(img,x0,v0,x1,v1,x,v) cimg_for_in4V(img,v0,v1,v) cimg_for_in4X(img,x0,x1,x)
805 #define cimg_for_in4YZ(img,y0,z0,y1,z1,y,z) cimg_for_in4Z(img,z0,z1,z) cimg_for_in4Y(img,y0,y1,y)
806 #define cimg_for_in4YV(img,y0,v0,y1,v1,y,v) cimg_for_in4V(img,v0,v1,v) cimg_for_in4Y(img,y0,y1,y)
807 #define cimg_for_in4ZV(img,z0,v0,z1,v1,z,v) cimg_for_in4V(img,v0,v1,v) cimg_for_in4Z(img,z0,z1,z)
808 #define cimg_for_in4XYZ(img,x0,y0,z0,x1,y1,z1,x,y,z) cimg_for_in4Z(img,z0,z1,z) cimg_for_in4XY(img,x0,y0,x1,y1,x,y)
809 #define cimg_for_in4XZV(img,x0,z0,v0,x1,y1,v1,x,z,v) cimg_for_in4V(img,v0,v1,v) cimg_for_in4XZ(img,x0,y0,x1,y1,x,z)
810 #define cimg_for_in4YZV(img,y0,z0,v0,y1,z1,v1,y,z,v) cimg_for_in4V(img,v0,v1,v) cimg_for_in4YZ(img,y0,z0,y1,z1,y,z)
811 #define cimg_for_in4XYZV(img,x0,y0,z0,v0,x1,y1,z1,v1,x,y,z,v) cimg_for_in4V(img,v0,v1,v) cimg_for_in4XYZ(img,x0,y0,z0,x1,y1,z1,x,y,z)
813 #define cimg_for5(bound,i) \
814 for (int i = 0, _p2##i = 0, _p1##i = 0, \
815 _n1##i = 1>=(bound)?(int)(bound)-1:1, \
816 _n2##i = 2>=(bound)?(int)(bound)-1:2; \
817 _n2##i<(int)(bound) || _n1##i==--_n2##i || i==(_n2##i = --_n1##i); \
818 _p2##i = _p1##i, _p1##i = i++, ++_n1##i, ++_n2##i)
819 #define cimg_for5X(img,x) cimg_for5((img).width,x)
820 #define cimg_for5Y(img,y) cimg_for5((img).height,y)
821 #define cimg_for5Z(img,z) cimg_for5((img).depth,z)
822 #define cimg_for5V(img,v) cimg_for5((img).dim,v)
823 #define cimg_for5XY(img,x,y) cimg_for5Y(img,y) cimg_for5X(img,x)
824 #define cimg_for5XZ(img,x,z) cimg_for5Z(img,z) cimg_for5X(img,x)
825 #define cimg_for5XV(img,x,v) cimg_for5V(img,v) cimg_for5X(img,x)
826 #define cimg_for5YZ(img,y,z) cimg_for5Z(img,z) cimg_for5Y(img,y)
827 #define cimg_for5YV(img,y,v) cimg_for5V(img,v) cimg_for5Y(img,y)
828 #define cimg_for5ZV(img,z,v) cimg_for5V(img,v) cimg_for5Z(img,z)
829 #define cimg_for5XYZ(img,x,y,z) cimg_for5Z(img,z) cimg_for5XY(img,x,y)
830 #define cimg_for5XZV(img,x,z,v) cimg_for5V(img,v) cimg_for5XZ(img,x,z)
831 #define cimg_for5YZV(img,y,z,v) cimg_for5V(img,v) cimg_for5YZ(img,y,z)
832 #define cimg_for5XYZV(img,x,y,z,v) cimg_for5V(img,v) cimg_for5XYZ(img,x,y,z)
834 #define cimg_for_in5(bound,i0,i1,i) \
835 for (int i = (int)(i0)<0?0:(int)(i0), \
836 _p2##i = i-2<0?0:i-2, \
837 _p1##i = i-1<0?0:i-1, \
838 _n1##i = i+1>=(int)(bound)?(int)(bound)-1:i+1, \
839 _n2##i = i+2>=(int)(bound)?(int)(bound)-1:i+2; \
840 i<=(int)(i1) && (_n2##i<(int)(bound) || _n1##i==--_n2##i || i==(_n2##i = --_n1##i)); \
841 _p2##i = _p1##i, _p1##i = i++, ++_n1##i, ++_n2##i)
842 #define cimg_for_in5X(img,x0,x1,x) cimg_for_in5((img).width,x0,x1,x)
843 #define cimg_for_in5Y(img,y0,y1,y) cimg_for_in5((img).height,y0,y1,y)
844 #define cimg_for_in5Z(img,z0,z1,z) cimg_for_in5((img).depth,z0,z1,z)
845 #define cimg_for_in5V(img,v0,v1,v) cimg_for_in5((img).dim,v0,v1,v)
846 #define cimg_for_in5XY(img,x0,y0,x1,y1,x,y) cimg_for_in5Y(img,y0,y1,y) cimg_for_in5X(img,x0,x1,x)
847 #define cimg_for_in5XZ(img,x0,z0,x1,z1,x,z) cimg_for_in5Z(img,z0,z1,z) cimg_for_in5X(img,x0,x1,x)
848 #define cimg_for_in5XV(img,x0,v0,x1,v1,x,v) cimg_for_in5V(img,v0,v1,v) cimg_for_in5X(img,x0,x1,x)
849 #define cimg_for_in5YZ(img,y0,z0,y1,z1,y,z) cimg_for_in5Z(img,z0,z1,z) cimg_for_in5Y(img,y0,y1,y)
850 #define cimg_for_in5YV(img,y0,v0,y1,v1,y,v) cimg_for_in5V(img,v0,v1,v) cimg_for_in5Y(img,y0,y1,y)
851 #define cimg_for_in5ZV(img,z0,v0,z1,v1,z,v) cimg_for_in5V(img,v0,v1,v) cimg_for_in5Z(img,z0,z1,z)
852 #define cimg_for_in5XYZ(img,x0,y0,z0,x1,y1,z1,x,y,z) cimg_for_in5Z(img,z0,z1,z) cimg_for_in5XY(img,x0,y0,x1,y1,x,y)
853 #define cimg_for_in5XZV(img,x0,z0,v0,x1,y1,v1,x,z,v) cimg_for_in5V(img,v0,v1,v) cimg_for_in5XZ(img,x0,y0,x1,y1,x,z)
854 #define cimg_for_in5YZV(img,y0,z0,v0,y1,z1,v1,y,z,v) cimg_for_in5V(img,v0,v1,v) cimg_for_in5YZ(img,y0,z0,y1,z1,y,z)
855 #define cimg_for_in5XYZV(img,x0,y0,z0,v0,x1,y1,z1,v1,x,y,z,v) cimg_for_in5V(img,v0,v1,v) cimg_for_in5XYZ(img,x0,y0,z0,x1,y1,z1,x,y,z)
857 #define cimg_for6(bound,i) \
858 for (int i = 0, _p2##i = 0, _p1##i = 0, \
859 _n1##i = 1>=(bound)?(int)(bound)-1:1, \
860 _n2##i = 2>=(bound)?(int)(bound)-1:2, \
861 _n3##i = 3>=(bound)?(int)(bound)-1:3; \
862 _n3##i<(int)(bound) || _n2##i==--_n3##i || _n1##i==--_n2##i || i==(_n3##i = _n2##i = --_n1##i); \
863 _p2##i = _p1##i, _p1##i = i++, ++_n1##i, ++_n2##i, ++_n3##i)
864 #define cimg_for6X(img,x) cimg_for6((img).width,x)
865 #define cimg_for6Y(img,y) cimg_for6((img).height,y)
866 #define cimg_for6Z(img,z) cimg_for6((img).depth,z)
867 #define cimg_for6V(img,v) cimg_for6((img).dim,v)
868 #define cimg_for6XY(img,x,y) cimg_for6Y(img,y) cimg_for6X(img,x)
869 #define cimg_for6XZ(img,x,z) cimg_for6Z(img,z) cimg_for6X(img,x)
870 #define cimg_for6XV(img,x,v) cimg_for6V(img,v) cimg_for6X(img,x)
871 #define cimg_for6YZ(img,y,z) cimg_for6Z(img,z) cimg_for6Y(img,y)
872 #define cimg_for6YV(img,y,v) cimg_for6V(img,v) cimg_for6Y(img,y)
873 #define cimg_for6ZV(img,z,v) cimg_for6V(img,v) cimg_for6Z(img,z)
874 #define cimg_for6XYZ(img,x,y,z) cimg_for6Z(img,z) cimg_for6XY(img,x,y)
875 #define cimg_for6XZV(img,x,z,v) cimg_for6V(img,v) cimg_for6XZ(img,x,z)
876 #define cimg_for6YZV(img,y,z,v) cimg_for6V(img,v) cimg_for6YZ(img,y,z)
877 #define cimg_for6XYZV(img,x,y,z,v) cimg_for6V(img,v) cimg_for6XYZ(img,x,y,z)
879 #define cimg_for_in6(bound,i0,i1,i) \
880 for (int i = (int)(i0)<0?0:(int)(i0), \
881 _p2##i = i-2<0?0:i-2, \
882 _p1##i = i-1<0?0:i-1, \
883 _n1##i = i+1>=(int)(bound)?(int)(bound)-1:i+1, \
884 _n2##i = i+2>=(int)(bound)?(int)(bound)-1:i+2, \
885 _n3##i = i+3>=(int)(bound)?(int)(bound)-1:i+3; \
886 i<=(int)(i1) && (_n3##i<(int)(bound) || _n2##i==--_n3##i || _n1##i==--_n2##i || i==(_n3##i = _n2##i = --_n1##i)); \
887 _p2##i = _p1##i, _p1##i = i++, ++_n1##i, ++_n2##i, ++_n3##i)
888 #define cimg_for_in6X(img,x0,x1,x) cimg_for_in6((img).width,x0,x1,x)
889 #define cimg_for_in6Y(img,y0,y1,y) cimg_for_in6((img).height,y0,y1,y)
890 #define cimg_for_in6Z(img,z0,z1,z) cimg_for_in6((img).depth,z0,z1,z)
891 #define cimg_for_in6V(img,v0,v1,v) cimg_for_in6((img).dim,v0,v1,v)
892 #define cimg_for_in6XY(img,x0,y0,x1,y1,x,y) cimg_for_in6Y(img,y0,y1,y) cimg_for_in6X(img,x0,x1,x)
893 #define cimg_for_in6XZ(img,x0,z0,x1,z1,x,z) cimg_for_in6Z(img,z0,z1,z) cimg_for_in6X(img,x0,x1,x)
894 #define cimg_for_in6XV(img,x0,v0,x1,v1,x,v) cimg_for_in6V(img,v0,v1,v) cimg_for_in6X(img,x0,x1,x)
895 #define cimg_for_in6YZ(img,y0,z0,y1,z1,y,z) cimg_for_in6Z(img,z0,z1,z) cimg_for_in6Y(img,y0,y1,y)
896 #define cimg_for_in6YV(img,y0,v0,y1,v1,y,v) cimg_for_in6V(img,v0,v1,v) cimg_for_in6Y(img,y0,y1,y)
897 #define cimg_for_in6ZV(img,z0,v0,z1,v1,z,v) cimg_for_in6V(img,v0,v1,v) cimg_for_in6Z(img,z0,z1,z)
898 #define cimg_for_in6XYZ(img,x0,y0,z0,x1,y1,z1,x,y,z) cimg_for_in6Z(img,z0,z1,z) cimg_for_in6XY(img,x0,y0,x1,y1,x,y)
899 #define cimg_for_in6XZV(img,x0,z0,v0,x1,y1,v1,x,z,v) cimg_for_in6V(img,v0,v1,v) cimg_for_in6XZ(img,x0,y0,x1,y1,x,z)
900 #define cimg_for_in6YZV(img,y0,z0,v0,y1,z1,v1,y,z,v) cimg_for_in6V(img,v0,v1,v) cimg_for_in6YZ(img,y0,z0,y1,z1,y,z)
901 #define cimg_for_in6XYZV(img,x0,y0,z0,v0,x1,y1,z1,v1,x,y,z,v) cimg_for_in6V(img,v0,v1,v) cimg_for_in6XYZ(img,x0,y0,z0,x1,y1,z1,x,y,z)
903 #define cimg_for7(bound,i) \
904 for (int i = 0, _p3##i = 0, _p2##i = 0, _p1##i = 0, \
905 _n1##i = 1>=(bound)?(int)(bound)-1:1, \
906 _n2##i = 2>=(bound)?(int)(bound)-1:2, \
907 _n3##i = 3>=(bound)?(int)(bound)-1:3; \
908 _n3##i<(int)(bound) || _n2##i==--_n3##i || _n1##i==--_n2##i || i==(_n3##i = _n2##i = --_n1##i); \
909 _p3##i = _p2##i, _p2##i = _p1##i, _p1##i = i++, ++_n1##i, ++_n2##i, ++_n3##i)
910 #define cimg_for7X(img,x) cimg_for7((img).width,x)
911 #define cimg_for7Y(img,y) cimg_for7((img).height,y)
912 #define cimg_for7Z(img,z) cimg_for7((img).depth,z)
913 #define cimg_for7V(img,v) cimg_for7((img).dim,v)
914 #define cimg_for7XY(img,x,y) cimg_for7Y(img,y) cimg_for7X(img,x)
915 #define cimg_for7XZ(img,x,z) cimg_for7Z(img,z) cimg_for7X(img,x)
916 #define cimg_for7XV(img,x,v) cimg_for7V(img,v) cimg_for7X(img,x)
917 #define cimg_for7YZ(img,y,z) cimg_for7Z(img,z) cimg_for7Y(img,y)
918 #define cimg_for7YV(img,y,v) cimg_for7V(img,v) cimg_for7Y(img,y)
919 #define cimg_for7ZV(img,z,v) cimg_for7V(img,v) cimg_for7Z(img,z)
920 #define cimg_for7XYZ(img,x,y,z) cimg_for7Z(img,z) cimg_for7XY(img,x,y)
921 #define cimg_for7XZV(img,x,z,v) cimg_for7V(img,v) cimg_for7XZ(img,x,z)
922 #define cimg_for7YZV(img,y,z,v) cimg_for7V(img,v) cimg_for7YZ(img,y,z)
923 #define cimg_for7XYZV(img,x,y,z,v) cimg_for7V(img,v) cimg_for7XYZ(img,x,y,z)
925 #define cimg_for_in7(bound,i0,i1,i) \
926 for (int i = (int)(i0)<0?0:(int)(i0), \
927 _p3##i = i-3<0?0:i-3, \
928 _p2##i = i-2<0?0:i-2, \
929 _p1##i = i-1<0?0:i-1, \
930 _n1##i = i+1>=(int)(bound)?(int)(bound)-1:i+1, \
931 _n2##i = i+2>=(int)(bound)?(int)(bound)-1:i+2, \
932 _n3##i = i+3>=(int)(bound)?(int)(bound)-1:i+3; \
933 i<=(int)(i1) && (_n3##i<(int)(bound) || _n2##i==--_n3##i || _n1##i==--_n2##i || i==(_n3##i = _n2##i = --_n1##i)); \
934 _p3##i = _p2##i, _p2##i = _p1##i, _p1##i = i++, ++_n1##i, ++_n2##i, ++_n3##i)
935 #define cimg_for_in7X(img,x0,x1,x) cimg_for_in7((img).width,x0,x1,x)
936 #define cimg_for_in7Y(img,y0,y1,y) cimg_for_in7((img).height,y0,y1,y)
937 #define cimg_for_in7Z(img,z0,z1,z) cimg_for_in7((img).depth,z0,z1,z)
938 #define cimg_for_in7V(img,v0,v1,v) cimg_for_in7((img).dim,v0,v1,v)
939 #define cimg_for_in7XY(img,x0,y0,x1,y1,x,y) cimg_for_in7Y(img,y0,y1,y) cimg_for_in7X(img,x0,x1,x)
940 #define cimg_for_in7XZ(img,x0,z0,x1,z1,x,z) cimg_for_in7Z(img,z0,z1,z) cimg_for_in7X(img,x0,x1,x)
941 #define cimg_for_in7XV(img,x0,v0,x1,v1,x,v) cimg_for_in7V(img,v0,v1,v) cimg_for_in7X(img,x0,x1,x)
942 #define cimg_for_in7YZ(img,y0,z0,y1,z1,y,z) cimg_for_in7Z(img,z0,z1,z) cimg_for_in7Y(img,y0,y1,y)
943 #define cimg_for_in7YV(img,y0,v0,y1,v1,y,v) cimg_for_in7V(img,v0,v1,v) cimg_for_in7Y(img,y0,y1,y)
944 #define cimg_for_in7ZV(img,z0,v0,z1,v1,z,v) cimg_for_in7V(img,v0,v1,v) cimg_for_in7Z(img,z0,z1,z)
945 #define cimg_for_in7XYZ(img,x0,y0,z0,x1,y1,z1,x,y,z) cimg_for_in7Z(img,z0,z1,z) cimg_for_in7XY(img,x0,y0,x1,y1,x,y)
946 #define cimg_for_in7XZV(img,x0,z0,v0,x1,y1,v1,x,z,v) cimg_for_in7V(img,v0,v1,v) cimg_for_in7XZ(img,x0,y0,x1,y1,x,z)
947 #define cimg_for_in7YZV(img,y0,z0,v0,y1,z1,v1,y,z,v) cimg_for_in7V(img,v0,v1,v) cimg_for_in7YZ(img,y0,z0,y1,z1,y,z)
948 #define cimg_for_in7XYZV(img,x0,y0,z0,v0,x1,y1,z1,v1,x,y,z,v) cimg_for_in7V(img,v0,v1,v) cimg_for_in7XYZ(img,x0,y0,z0,x1,y1,z1,x,y,z)
950 #define cimg_for8(bound,i) \
951 for (int i = 0, _p3##i = 0, _p2##i = 0, _p1##i = 0, \
952 _n1##i = 1>=(bound)?(int)(bound)-1:1, \
953 _n2##i = 2>=(bound)?(int)(bound)-1:2, \
954 _n3##i = 3>=(bound)?(int)(bound)-1:3, \
955 _n4##i = 4>=(bound)?(int)(bound)-1:4; \
956 _n4##i<(int)(bound) || _n3##i==--_n4##i || _n2##i==--_n3##i || _n1##i==--_n2##i || \
957 i==(_n4##i = _n3##i = _n2##i = --_n1##i); \
958 _p3##i = _p2##i, _p2##i = _p1##i, _p1##i = i++, ++_n1##i, ++_n2##i, ++_n3##i, ++_n4##i)
959 #define cimg_for8X(img,x) cimg_for8((img).width,x)
960 #define cimg_for8Y(img,y) cimg_for8((img).height,y)
961 #define cimg_for8Z(img,z) cimg_for8((img).depth,z)
962 #define cimg_for8V(img,v) cimg_for8((img).dim,v)
963 #define cimg_for8XY(img,x,y) cimg_for8Y(img,y) cimg_for8X(img,x)
964 #define cimg_for8XZ(img,x,z) cimg_for8Z(img,z) cimg_for8X(img,x)
965 #define cimg_for8XV(img,x,v) cimg_for8V(img,v) cimg_for8X(img,x)
966 #define cimg_for8YZ(img,y,z) cimg_for8Z(img,z) cimg_for8Y(img,y)
967 #define cimg_for8YV(img,y,v) cimg_for8V(img,v) cimg_for8Y(img,y)
968 #define cimg_for8ZV(img,z,v) cimg_for8V(img,v) cimg_for8Z(img,z)
969 #define cimg_for8XYZ(img,x,y,z) cimg_for8Z(img,z) cimg_for8XY(img,x,y)
970 #define cimg_for8XZV(img,x,z,v) cimg_for8V(img,v) cimg_for8XZ(img,x,z)
971 #define cimg_for8YZV(img,y,z,v) cimg_for8V(img,v) cimg_for8YZ(img,y,z)
972 #define cimg_for8XYZV(img,x,y,z,v) cimg_for8V(img,v) cimg_for8XYZ(img,x,y,z)
974 #define cimg_for_in8(bound,i0,i1,i) \
975 for (int i = (int)(i0)<0?0:(int)(i0), \
976 _p3##i = i-3<0?0:i-3, \
977 _p2##i = i-2<0?0:i-2, \
978 _p1##i = i-1<0?0:i-1, \
979 _n1##i = i+1>=(int)(bound)?(int)(bound)-1:i+1, \
980 _n2##i = i+2>=(int)(bound)?(int)(bound)-1:i+2, \
981 _n3##i = i+3>=(int)(bound)?(int)(bound)-1:i+3, \
982 _n4##i = i+4>=(int)(bound)?(int)(bound)-1:i+4; \
983 i<=(int)(i1) && (_n4##i<(int)(bound) || _n3##i==--_n4##i || _n2##i==--_n3##i || _n1##i==--_n2##i || \
984 i==(_n4##i = _n3##i = _n2##i = --_n1##i)); \
985 _p3##i = _p2##i, _p2##i = _p1##i, _p1##i = i++, ++_n1##i, ++_n2##i, ++_n3##i, ++_n4##i)
986 #define cimg_for_in8X(img,x0,x1,x) cimg_for_in8((img).width,x0,x1,x)
987 #define cimg_for_in8Y(img,y0,y1,y) cimg_for_in8((img).height,y0,y1,y)
988 #define cimg_for_in8Z(img,z0,z1,z) cimg_for_in8((img).depth,z0,z1,z)
989 #define cimg_for_in8V(img,v0,v1,v) cimg_for_in8((img).dim,v0,v1,v)
990 #define cimg_for_in8XY(img,x0,y0,x1,y1,x,y) cimg_for_in8Y(img,y0,y1,y) cimg_for_in8X(img,x0,x1,x)
991 #define cimg_for_in8XZ(img,x0,z0,x1,z1,x,z) cimg_for_in8Z(img,z0,z1,z) cimg_for_in8X(img,x0,x1,x)
992 #define cimg_for_in8XV(img,x0,v0,x1,v1,x,v) cimg_for_in8V(img,v0,v1,v) cimg_for_in8X(img,x0,x1,x)
993 #define cimg_for_in8YZ(img,y0,z0,y1,z1,y,z) cimg_for_in8Z(img,z0,z1,z) cimg_for_in8Y(img,y0,y1,y)
994 #define cimg_for_in8YV(img,y0,v0,y1,v1,y,v) cimg_for_in8V(img,v0,v1,v) cimg_for_in8Y(img,y0,y1,y)
995 #define cimg_for_in8ZV(img,z0,v0,z1,v1,z,v) cimg_for_in8V(img,v0,v1,v) cimg_for_in8Z(img,z0,z1,z)
996 #define cimg_for_in8XYZ(img,x0,y0,z0,x1,y1,z1,x,y,z) cimg_for_in8Z(img,z0,z1,z) cimg_for_in8XY(img,x0,y0,x1,y1,x,y)
997 #define cimg_for_in8XZV(img,x0,z0,v0,x1,y1,v1,x,z,v) cimg_for_in8V(img,v0,v1,v) cimg_for_in8XZ(img,x0,y0,x1,y1,x,z)
998 #define cimg_for_in8YZV(img,y0,z0,v0,y1,z1,v1,y,z,v) cimg_for_in8V(img,v0,v1,v) cimg_for_in8YZ(img,y0,z0,y1,z1,y,z)
999 #define cimg_for_in8XYZV(img,x0,y0,z0,v0,x1,y1,z1,v1,x,y,z,v) cimg_for_in8V(img,v0,v1,v) cimg_for_in8XYZ(img,x0,y0,z0,x1,y1,z1,x,y,z)
1001 #define cimg_for9(bound,i) \
1002 for (int i = 0, _p4##i = 0, _p3##i = 0, _p2##i = 0, _p1##i = 0, \
1003 _n1##i = 1>=(int)(bound)?(int)(bound)-1:1, \
1004 _n2##i = 2>=(int)(bound)?(int)(bound)-1:2, \
1005 _n3##i = 3>=(int)(bound)?(int)(bound)-1:3, \
1006 _n4##i = 4>=(int)(bound)?(int)(bound)-1:4; \
1007 _n4##i<(int)(bound) || _n3##i==--_n4##i || _n2##i==--_n3##i || _n1##i==--_n2##i || \
1008 i==(_n4##i = _n3##i = _n2##i = --_n1##i); \
1009 _p4##i = _p3##i, _p3##i = _p2##i, _p2##i = _p1##i, _p1##i = i++, ++_n1##i, ++_n2##i, ++_n3##i, ++_n4##i)
1010 #define cimg_for9X(img,x) cimg_for9((img).width,x)
1011 #define cimg_for9Y(img,y) cimg_for9((img).height,y)
1012 #define cimg_for9Z(img,z) cimg_for9((img).depth,z)
1013 #define cimg_for9V(img,v) cimg_for9((img).dim,v)
1014 #define cimg_for9XY(img,x,y) cimg_for9Y(img,y) cimg_for9X(img,x)
1015 #define cimg_for9XZ(img,x,z) cimg_for9Z(img,z) cimg_for9X(img,x)
1016 #define cimg_for9XV(img,x,v) cimg_for9V(img,v) cimg_for9X(img,x)
1017 #define cimg_for9YZ(img,y,z) cimg_for9Z(img,z) cimg_for9Y(img,y)
1018 #define cimg_for9YV(img,y,v) cimg_for9V(img,v) cimg_for9Y(img,y)
1019 #define cimg_for9ZV(img,z,v) cimg_for9V(img,v) cimg_for9Z(img,z)
1020 #define cimg_for9XYZ(img,x,y,z) cimg_for9Z(img,z) cimg_for9XY(img,x,y)
1021 #define cimg_for9XZV(img,x,z,v) cimg_for9V(img,v) cimg_for9XZ(img,x,z)
1022 #define cimg_for9YZV(img,y,z,v) cimg_for9V(img,v) cimg_for9YZ(img,y,z)
1023 #define cimg_for9XYZV(img,x,y,z,v) cimg_for9V(img,v) cimg_for9XYZ(img,x,y,z)
1025 #define cimg_for_in9(bound,i0,i1,i) \
1026 for (int i = (int)(i0)<0?0:(int)(i0), \
1027 _p4##i = i-4<0?0:i-4, \
1028 _p3##i = i-3<0?0:i-3, \
1029 _p2##i = i-2<0?0:i-2, \
1030 _p1##i = i-1<0?0:i-1, \
1031 _n1##i = i+1>=(int)(bound)?(int)(bound)-1:i+1, \
1032 _n2##i = i+2>=(int)(bound)?(int)(bound)-1:i+2, \
1033 _n3##i = i+3>=(int)(bound)?(int)(bound)-1:i+3, \
1034 _n4##i = i+4>=(int)(bound)?(int)(bound)-1:i+4; \
1035 i<=(int)(i1) && (_n4##i<(int)(bound) || _n3##i==--_n4##i || _n2##i==--_n3##i || _n1##i==--_n2##i || \
1036 i==(_n4##i = _n3##i = _n2##i = --_n1##i)); \
1037 _p4##i = _p3##i, _p3##i = _p2##i, _p2##i = _p1##i, _p1##i = i++, ++_n1##i, ++_n2##i, ++_n3##i, ++_n4##i)
1038 #define cimg_for_in9X(img,x0,x1,x) cimg_for_in9((img).width,x0,x1,x)
1039 #define cimg_for_in9Y(img,y0,y1,y) cimg_for_in9((img).height,y0,y1,y)
1040 #define cimg_for_in9Z(img,z0,z1,z) cimg_for_in9((img).depth,z0,z1,z)
1041 #define cimg_for_in9V(img,v0,v1,v) cimg_for_in9((img).dim,v0,v1,v)
1042 #define cimg_for_in9XY(img,x0,y0,x1,y1,x,y) cimg_for_in9Y(img,y0,y1,y) cimg_for_in9X(img,x0,x1,x)
1043 #define cimg_for_in9XZ(img,x0,z0,x1,z1,x,z) cimg_for_in9Z(img,z0,z1,z) cimg_for_in9X(img,x0,x1,x)
1044 #define cimg_for_in9XV(img,x0,v0,x1,v1,x,v) cimg_for_in9V(img,v0,v1,v) cimg_for_in9X(img,x0,x1,x)
1045 #define cimg_for_in9YZ(img,y0,z0,y1,z1,y,z) cimg_for_in9Z(img,z0,z1,z) cimg_for_in9Y(img,y0,y1,y)
1046 #define cimg_for_in9YV(img,y0,v0,y1,v1,y,v) cimg_for_in9V(img,v0,v1,v) cimg_for_in9Y(img,y0,y1,y)
1047 #define cimg_for_in9ZV(img,z0,v0,z1,v1,z,v) cimg_for_in9V(img,v0,v1,v) cimg_for_in9Z(img,z0,z1,z)
1048 #define cimg_for_in9XYZ(img,x0,y0,z0,x1,y1,z1,x,y,z) cimg_for_in9Z(img,z0,z1,z) cimg_for_in9XY(img,x0,y0,x1,y1,x,y)
1049 #define cimg_for_in9XZV(img,x0,z0,v0,x1,y1,v1,x,z,v) cimg_for_in9V(img,v0,v1,v) cimg_for_in9XZ(img,x0,y0,x1,y1,x,z)
1050 #define cimg_for_in9YZV(img,y0,z0,v0,y1,z1,v1,y,z,v) cimg_for_in9V(img,v0,v1,v) cimg_for_in9YZ(img,y0,z0,y1,z1,y,z)
1051 #define cimg_for_in9XYZV(img,x0,y0,z0,v0,x1,y1,z1,v1,x,y,z,v) cimg_for_in9V(img,v0,v1,v) cimg_for_in9XYZ(img,x0,y0,z0,x1,y1,z1,x,y,z)
1053 #define cimg_for2x2(img,x,y,z,v,I) \
1054 cimg_for2((img).height,y) for (int x = 0, \
1056 (I[0] = (img)(0,y,z,v)), \
1057 (I[2] = (img)(0,_n1##y,z,v)), \
1058 1>=(img).width?(int)((img).width)-1:1); \
1059 (_n1##x<(int)((img).width) && ( \
1060 (I[1] = (img)(_n1##x,y,z,v)), \
1061 (I[3] = (img)(_n1##x,_n1##y,z,v)),1)) || \
1067 #define cimg_for_in2x2(img,x0,y0,x1,y1,x,y,z,v,I) \
1068 cimg_for_in2((img).height,y0,y1,y) for (int x = (int)(x0)<0?0:(int)(x0), \
1070 (I[0] = (img)(x,y,z,v)), \
1071 (I[2] = (img)(x,_n1##y,z,v)), \
1072 x+1>=(int)(img).width?(int)((img).width)-1:x+1); \
1073 x<=(int)(x1) && ((_n1##x<(int)((img).width) && ( \
1074 (I[1] = (img)(_n1##x,y,z,v)), \
1075 (I[3] = (img)(_n1##x,_n1##y,z,v)),1)) || \
1081 #define cimg_for3x3(img,x,y,z,v,I) \
1082 cimg_for3((img).height,y) for (int x = 0, \
1085 (I[0] = I[1] = (img)(0,_p1##y,z,v)), \
1086 (I[3] = I[4] = (img)(0,y,z,v)), \
1087 (I[6] = I[7] = (img)(0,_n1##y,z,v)), \
1088 1>=(img).width?(int)((img).width)-1:1); \
1089 (_n1##x<(int)((img).width) && ( \
1090 (I[2] = (img)(_n1##x,_p1##y,z,v)), \
1091 (I[5] = (img)(_n1##x,y,z,v)), \
1092 (I[8] = (img)(_n1##x,_n1##y,z,v)),1)) || \
1094 I[0] = I[1], I[1] = I[2], \
1095 I[3] = I[4], I[4] = I[5], \
1096 I[6] = I[7], I[7] = I[8], \
1097 _p1##x = x++, ++_n1##x)
1099 #define cimg_for_in3x3(img,x0,y0,x1,y1,x,y,z,v,I) \
1100 cimg_for_in3((img).height,y0,y1,y) for (int x = (int)(x0)<0?0:(int)(x0), \
1101 _p1##x = x-1<0?0:x-1, \
1103 (I[0] = (img)(_p1##x,_p1##y,z,v)), \
1104 (I[3] = (img)(_p1##x,y,z,v)), \
1105 (I[6] = (img)(_p1##x,_n1##y,z,v)), \
1106 (I[1] = (img)(x,_p1##y,z,v)), \
1107 (I[4] = (img)(x,y,z,v)), \
1108 (I[7] = (img)(x,_n1##y,z,v)), \
1109 x+1>=(int)(img).width?(int)((img).width)-1:x+1); \
1110 x<=(int)(x1) && ((_n1##x<(int)((img).width) && ( \
1111 (I[2] = (img)(_n1##x,_p1##y,z,v)), \
1112 (I[5] = (img)(_n1##x,y,z,v)), \
1113 (I[8] = (img)(_n1##x,_n1##y,z,v)),1)) || \
1115 I[0] = I[1], I[1] = I[2], \
1116 I[3] = I[4], I[4] = I[5], \
1117 I[6] = I[7], I[7] = I[8], \
1118 _p1##x = x++, ++_n1##x)
1120 #define cimg_for4x4(img,x,y,z,v,I) \
1121 cimg_for4((img).height,y) for (int x = 0, \
1123 _n1##x = 1>=(img).width?(int)((img).width)-1:1, \
1125 (I[0] = I[1] = (img)(0,_p1##y,z,v)), \
1126 (I[4] = I[5] = (img)(0,y,z,v)), \
1127 (I[8] = I[9] = (img)(0,_n1##y,z,v)), \
1128 (I[12] = I[13] = (img)(0,_n2##y,z,v)), \
1129 (I[2] = (img)(_n1##x,_p1##y,z,v)), \
1130 (I[6] = (img)(_n1##x,y,z,v)), \
1131 (I[10] = (img)(_n1##x,_n1##y,z,v)), \
1132 (I[14] = (img)(_n1##x,_n2##y,z,v)), \
1133 2>=(img).width?(int)((img).width)-1:2); \
1134 (_n2##x<(int)((img).width) && ( \
1135 (I[3] = (img)(_n2##x,_p1##y,z,v)), \
1136 (I[7] = (img)(_n2##x,y,z,v)), \
1137 (I[11] = (img)(_n2##x,_n1##y,z,v)), \
1138 (I[15] = (img)(_n2##x,_n2##y,z,v)),1)) || \
1139 _n1##x==--_n2##x || x==(_n2##x = --_n1##x); \
1140 I[0] = I[1], I[1] = I[2], I[2] = I[3], \
1141 I[4] = I[5], I[5] = I[6], I[6] = I[7], \
1142 I[8] = I[9], I[9] = I[10], I[10] = I[11], \
1143 I[12] = I[13], I[13] = I[14], I[14] = I[15], \
1144 _p1##x = x++, ++_n1##x, ++_n2##x)
1146 #define cimg_for_in4x4(img,x0,y0,x1,y1,x,y,z,v,I) \
1147 cimg_for_in4((img).height,y0,y1,y) for (int x = (int)(x0)<0?0:(int)(x0), \
1148 _p1##x = x-1<0?0:x-1, \
1149 _n1##x = x+1>=(int)(img).width?(int)((img).width)-1:x+1, \
1151 (I[0] = (img)(_p1##x,_p1##y,z,v)), \
1152 (I[4] = (img)(_p1##x,y,z,v)), \
1153 (I[8] = (img)(_p1##x,_n1##y,z,v)), \
1154 (I[12] = (img)(_p1##x,_n2##y,z,v)), \
1155 (I[1] = (img)(x,_p1##y,z,v)), \
1156 (I[5] = (img)(x,y,z,v)), \
1157 (I[9] = (img)(x,_n1##y,z,v)), \
1158 (I[13] = (img)(x,_n2##y,z,v)), \
1159 (I[2] = (img)(_n1##x,_p1##y,z,v)), \
1160 (I[6] = (img)(_n1##x,y,z,v)), \
1161 (I[10] = (img)(_n1##x,_n1##y,z,v)), \
1162 (I[14] = (img)(_n1##x,_n2##y,z,v)), \
1163 x+2>=(int)(img).width?(int)((img).width)-1:x+2); \
1164 x<=(int)(x1) && ((_n2##x<(int)((img).width) && ( \
1165 (I[3] = (img)(_n2##x,_p1##y,z,v)), \
1166 (I[7] = (img)(_n2##x,y,z,v)), \
1167 (I[11] = (img)(_n2##x,_n1##y,z,v)), \
1168 (I[15] = (img)(_n2##x,_n2##y,z,v)),1)) || \
1169 _n1##x==--_n2##x || x==(_n2##x = --_n1##x)); \
1170 I[0] = I[1], I[1] = I[2], I[2] = I[3], \
1171 I[4] = I[5], I[5] = I[6], I[6] = I[7], \
1172 I[8] = I[9], I[9] = I[10], I[10] = I[11], \
1173 I[12] = I[13], I[13] = I[14], I[14] = I[15], \
1174 _p1##x = x++, ++_n1##x, ++_n2##x)
1176 #define cimg_for5x5(img,x,y,z,v,I) \
1177 cimg_for5((img).height,y) for (int x = 0, \
1178 _p2##x = 0, _p1##x = 0, \
1179 _n1##x = 1>=(img).width?(int)((img).width)-1:1, \
1181 (I[0] = I[1] = I[2] = (img)(0,_p2##y,z,v)), \
1182 (I[5] = I[6] = I[7] = (img)(0,_p1##y,z,v)), \
1183 (I[10] = I[11] = I[12] = (img)(0,y,z,v)), \
1184 (I[15] = I[16] = I[17] = (img)(0,_n1##y,z,v)), \
1185 (I[20] = I[21] = I[22] = (img)(0,_n2##y,z,v)), \
1186 (I[3] = (img)(_n1##x,_p2##y,z,v)), \
1187 (I[8] = (img)(_n1##x,_p1##y,z,v)), \
1188 (I[13] = (img)(_n1##x,y,z,v)), \
1189 (I[18] = (img)(_n1##x,_n1##y,z,v)), \
1190 (I[23] = (img)(_n1##x,_n2##y,z,v)), \
1191 2>=(img).width?(int)((img).width)-1:2); \
1192 (_n2##x<(int)((img).width) && ( \
1193 (I[4] = (img)(_n2##x,_p2##y,z,v)), \
1194 (I[9] = (img)(_n2##x,_p1##y,z,v)), \
1195 (I[14] = (img)(_n2##x,y,z,v)), \
1196 (I[19] = (img)(_n2##x,_n1##y,z,v)), \
1197 (I[24] = (img)(_n2##x,_n2##y,z,v)),1)) || \
1198 _n1##x==--_n2##x || x==(_n2##x = --_n1##x); \
1199 I[0] = I[1], I[1] = I[2], I[2] = I[3], I[3] = I[4], \
1200 I[5] = I[6], I[6] = I[7], I[7] = I[8], I[8] = I[9], \
1201 I[10] = I[11], I[11] = I[12], I[12] = I[13], I[13] = I[14], \
1202 I[15] = I[16], I[16] = I[17], I[17] = I[18], I[18] = I[19], \
1203 I[20] = I[21], I[21] = I[22], I[22] = I[23], I[23] = I[24], \
1204 _p2##x = _p1##x, _p1##x = x++, ++_n1##x, ++_n2##x)
1206 #define cimg_for_in5x5(img,x0,y0,x1,y1,x,y,z,v,I) \
1207 cimg_for_in5((img).height,y0,y1,y) for (int x = (int)(x0)<0?0:(int)(x0), \
1208 _p2##x = x-2<0?0:x-2, \
1209 _p1##x = x-1<0?0:x-1, \
1210 _n1##x = x+1>=(int)(img).width?(int)((img).width)-1:x+1, \
1212 (I[0] = (img)(_p2##x,_p2##y,z,v)), \
1213 (I[5] = (img)(_p2##x,_p1##y,z,v)), \
1214 (I[10] = (img)(_p2##x,y,z,v)), \
1215 (I[15] = (img)(_p2##x,_n1##y,z,v)), \
1216 (I[20] = (img)(_p2##x,_n2##y,z,v)), \
1217 (I[1] = (img)(_p1##x,_p2##y,z,v)), \
1218 (I[6] = (img)(_p1##x,_p1##y,z,v)), \
1219 (I[11] = (img)(_p1##x,y,z,v)), \
1220 (I[16] = (img)(_p1##x,_n1##y,z,v)), \
1221 (I[21] = (img)(_p1##x,_n2##y,z,v)), \
1222 (I[2] = (img)(x,_p2##y,z,v)), \
1223 (I[7] = (img)(x,_p1##y,z,v)), \
1224 (I[12] = (img)(x,y,z,v)), \
1225 (I[17] = (img)(x,_n1##y,z,v)), \
1226 (I[22] = (img)(x,_n2##y,z,v)), \
1227 (I[3] = (img)(_n1##x,_p2##y,z,v)), \
1228 (I[8] = (img)(_n1##x,_p1##y,z,v)), \
1229 (I[13] = (img)(_n1##x,y,z,v)), \
1230 (I[18] = (img)(_n1##x,_n1##y,z,v)), \
1231 (I[23] = (img)(_n1##x,_n2##y,z,v)), \
1232 x+2>=(int)(img).width?(int)((img).width)-1:x+2); \
1233 x<=(int)(x1) && ((_n2##x<(int)((img).width) && ( \
1234 (I[4] = (img)(_n2##x,_p2##y,z,v)), \
1235 (I[9] = (img)(_n2##x,_p1##y,z,v)), \
1236 (I[14] = (img)(_n2##x,y,z,v)), \
1237 (I[19] = (img)(_n2##x,_n1##y,z,v)), \
1238 (I[24] = (img)(_n2##x,_n2##y,z,v)),1)) || \
1239 _n1##x==--_n2##x || x==(_n2##x = --_n1##x)); \
1240 I[0] = I[1], I[1] = I[2], I[2] = I[3], I[3] = I[4], \
1241 I[5] = I[6], I[6] = I[7], I[7] = I[8], I[8] = I[9], \
1242 I[10] = I[11], I[11] = I[12], I[12] = I[13], I[13] = I[14], \
1243 I[15] = I[16], I[16] = I[17], I[17] = I[18], I[18] = I[19], \
1244 I[20] = I[21], I[21] = I[22], I[22] = I[23], I[23] = I[24], \
1245 _p2##x = _p1##x, _p1##x = x++, ++_n1##x, ++_n2##x)
1247 #define cimg_for6x6(img,x,y,z,v,I) \
1248 cimg_for6((img).height,y) for (int x = 0, \
1249 _p2##x = 0, _p1##x = 0, \
1250 _n1##x = 1>=(img).width?(int)((img).width)-1:1, \
1251 _n2##x = 2>=(img).width?(int)((img).width)-1:2, \
1253 (I[0] = I[1] = I[2] = (img)(0,_p2##y,z,v)), \
1254 (I[6] = I[7] = I[8] = (img)(0,_p1##y,z,v)), \
1255 (I[12] = I[13] = I[14] = (img)(0,y,z,v)), \
1256 (I[18] = I[19] = I[20] = (img)(0,_n1##y,z,v)), \
1257 (I[24] = I[25] = I[26] = (img)(0,_n2##y,z,v)), \
1258 (I[30] = I[31] = I[32] = (img)(0,_n3##y,z,v)), \
1259 (I[3] = (img)(_n1##x,_p2##y,z,v)), \
1260 (I[9] = (img)(_n1##x,_p1##y,z,v)), \
1261 (I[15] = (img)(_n1##x,y,z,v)), \
1262 (I[21] = (img)(_n1##x,_n1##y,z,v)), \
1263 (I[27] = (img)(_n1##x,_n2##y,z,v)), \
1264 (I[33] = (img)(_n1##x,_n3##y,z,v)), \
1265 (I[4] = (img)(_n2##x,_p2##y,z,v)), \
1266 (I[10] = (img)(_n2##x,_p1##y,z,v)), \
1267 (I[16] = (img)(_n2##x,y,z,v)), \
1268 (I[22] = (img)(_n2##x,_n1##y,z,v)), \
1269 (I[28] = (img)(_n2##x,_n2##y,z,v)), \
1270 (I[34] = (img)(_n2##x,_n3##y,z,v)), \
1271 3>=(img).width?(int)((img).width)-1:3); \
1272 (_n3##x<(int)((img).width) && ( \
1273 (I[5] = (img)(_n3##x,_p2##y,z,v)), \
1274 (I[11] = (img)(_n3##x,_p1##y,z,v)), \
1275 (I[17] = (img)(_n3##x,y,z,v)), \
1276 (I[23] = (img)(_n3##x,_n1##y,z,v)), \
1277 (I[29] = (img)(_n3##x,_n2##y,z,v)), \
1278 (I[35] = (img)(_n3##x,_n3##y,z,v)),1)) || \
1279 _n2##x==--_n3##x || _n1##x==--_n2##x || x==(_n3## x = _n2##x = --_n1##x); \
1280 I[0] = I[1], I[1] = I[2], I[2] = I[3], I[3] = I[4], I[4] = I[5], \
1281 I[6] = I[7], I[7] = I[8], I[8] = I[9], I[9] = I[10], I[10] = I[11], \
1282 I[12] = I[13], I[13] = I[14], I[14] = I[15], I[15] = I[16], I[16] = I[17], \
1283 I[18] = I[19], I[19] = I[20], I[20] = I[21], I[21] = I[22], I[22] = I[23], \
1284 I[24] = I[25], I[25] = I[26], I[26] = I[27], I[27] = I[28], I[28] = I[29], \
1285 I[30] = I[31], I[31] = I[32], I[32] = I[33], I[33] = I[34], I[34] = I[35], \
1286 _p2##x = _p1##x, _p1##x = x++, ++_n1##x, ++_n2##x, ++_n3##x)
1288 #define cimg_for_in6x6(img,x0,y0,x1,y1,x,y,z,v,I) \
1289 cimg_for_in6((img).height,y0,y1,y) for (int x = (int)(x0)<0?0:(int)x0, \
1290 _p2##x = x-2<0?0:x-2, \
1291 _p1##x = x-1<0?0:x-1, \
1292 _n1##x = x+1>=(int)(img).width?(int)((img).width)-1:x+1, \
1293 _n2##x = x+2>=(int)(img).width?(int)((img).width)-1:x+2, \
1295 (I[0] = (img)(_p2##x,_p2##y,z,v)), \
1296 (I[6] = (img)(_p2##x,_p1##y,z,v)), \
1297 (I[12] = (img)(_p2##x,y,z,v)), \
1298 (I[18] = (img)(_p2##x,_n1##y,z,v)), \
1299 (I[24] = (img)(_p2##x,_n2##y,z,v)), \
1300 (I[30] = (img)(_p2##x,_n3##y,z,v)), \
1301 (I[1] = (img)(_p1##x,_p2##y,z,v)), \
1302 (I[7] = (img)(_p1##x,_p1##y,z,v)), \
1303 (I[13] = (img)(_p1##x,y,z,v)), \
1304 (I[19] = (img)(_p1##x,_n1##y,z,v)), \
1305 (I[25] = (img)(_p1##x,_n2##y,z,v)), \
1306 (I[31] = (img)(_p1##x,_n3##y,z,v)), \
1307 (I[2] = (img)(x,_p2##y,z,v)), \
1308 (I[8] = (img)(x,_p1##y,z,v)), \
1309 (I[14] = (img)(x,y,z,v)), \
1310 (I[20] = (img)(x,_n1##y,z,v)), \
1311 (I[26] = (img)(x,_n2##y,z,v)), \
1312 (I[32] = (img)(x,_n3##y,z,v)), \
1313 (I[3] = (img)(_n1##x,_p2##y,z,v)), \
1314 (I[9] = (img)(_n1##x,_p1##y,z,v)), \
1315 (I[15] = (img)(_n1##x,y,z,v)), \
1316 (I[21] = (img)(_n1##x,_n1##y,z,v)), \
1317 (I[27] = (img)(_n1##x,_n2##y,z,v)), \
1318 (I[33] = (img)(_n1##x,_n3##y,z,v)), \
1319 (I[4] = (img)(_n2##x,_p2##y,z,v)), \
1320 (I[10] = (img)(_n2##x,_p1##y,z,v)), \
1321 (I[16] = (img)(_n2##x,y,z,v)), \
1322 (I[22] = (img)(_n2##x,_n1##y,z,v)), \
1323 (I[28] = (img)(_n2##x,_n2##y,z,v)), \
1324 (I[34] = (img)(_n2##x,_n3##y,z,v)), \
1325 x+3>=(int)(img).width?(int)((img).width)-1:x+3); \
1326 x<=(int)(x1) && ((_n3##x<(int)((img).width) && ( \
1327 (I[5] = (img)(_n3##x,_p2##y,z,v)), \
1328 (I[11] = (img)(_n3##x,_p1##y,z,v)), \
1329 (I[17] = (img)(_n3##x,y,z,v)), \
1330 (I[23] = (img)(_n3##x,_n1##y,z,v)), \
1331 (I[29] = (img)(_n3##x,_n2##y,z,v)), \
1332 (I[35] = (img)(_n3##x,_n3##y,z,v)),1)) || \
1333 _n2##x==--_n3##x || _n1##x==--_n2##x || x==(_n3## x = _n2##x = --_n1##x)); \
1334 I[0] = I[1], I[1] = I[2], I[2] = I[3], I[3] = I[4], I[4] = I[5], \
1335 I[6] = I[7], I[7] = I[8], I[8] = I[9], I[9] = I[10], I[10] = I[11], \
1336 I[12] = I[13], I[13] = I[14], I[14] = I[15], I[15] = I[16], I[16] = I[17], \
1337 I[18] = I[19], I[19] = I[20], I[20] = I[21], I[21] = I[22], I[22] = I[23], \
1338 I[24] = I[25], I[25] = I[26], I[26] = I[27], I[27] = I[28], I[28] = I[29], \
1339 I[30] = I[31], I[31] = I[32], I[32] = I[33], I[33] = I[34], I[34] = I[35], \
1340 _p2##x = _p1##x, _p1##x = x++, ++_n1##x, ++_n2##x, ++_n3##x)
1342 #define cimg_for7x7(img,x,y,z,v,I) \
1343 cimg_for7((img).height,y) for (int x = 0, \
1344 _p3##x = 0, _p2##x = 0, _p1##x = 0, \
1345 _n1##x = 1>=(img).width?(int)((img).width)-1:1, \
1346 _n2##x = 2>=(img).width?(int)((img).width)-1:2, \
1348 (I[0] = I[1] = I[2] = I[3] = (img)(0,_p3##y,z,v)), \
1349 (I[7] = I[8] = I[9] = I[10] = (img)(0,_p2##y,z,v)), \
1350 (I[14] = I[15] = I[16] = I[17] = (img)(0,_p1##y,z,v)), \
1351 (I[21] = I[22] = I[23] = I[24] = (img)(0,y,z,v)), \
1352 (I[28] = I[29] = I[30] = I[31] = (img)(0,_n1##y,z,v)), \
1353 (I[35] = I[36] = I[37] = I[38] = (img)(0,_n2##y,z,v)), \
1354 (I[42] = I[43] = I[44] = I[45] = (img)(0,_n3##y,z,v)), \
1355 (I[4] = (img)(_n1##x,_p3##y,z,v)), \
1356 (I[11] = (img)(_n1##x,_p2##y,z,v)), \
1357 (I[18] = (img)(_n1##x,_p1##y,z,v)), \
1358 (I[25] = (img)(_n1##x,y,z,v)), \
1359 (I[32] = (img)(_n1##x,_n1##y,z,v)), \
1360 (I[39] = (img)(_n1##x,_n2##y,z,v)), \
1361 (I[46] = (img)(_n1##x,_n3##y,z,v)), \
1362 (I[5] = (img)(_n2##x,_p3##y,z,v)), \
1363 (I[12] = (img)(_n2##x,_p2##y,z,v)), \
1364 (I[19] = (img)(_n2##x,_p1##y,z,v)), \
1365 (I[26] = (img)(_n2##x,y,z,v)), \
1366 (I[33] = (img)(_n2##x,_n1##y,z,v)), \
1367 (I[40] = (img)(_n2##x,_n2##y,z,v)), \
1368 (I[47] = (img)(_n2##x,_n3##y,z,v)), \
1369 3>=(img).width?(int)((img).width)-1:3); \
1370 (_n3##x<(int)((img).width) && ( \
1371 (I[6] = (img)(_n3##x,_p3##y,z,v)), \
1372 (I[13] = (img)(_n3##x,_p2##y,z,v)), \
1373 (I[20] = (img)(_n3##x,_p1##y,z,v)), \
1374 (I[27] = (img)(_n3##x,y,z,v)), \
1375 (I[34] = (img)(_n3##x,_n1##y,z,v)), \
1376 (I[41] = (img)(_n3##x,_n2##y,z,v)), \
1377 (I[48] = (img)(_n3##x,_n3##y,z,v)),1)) || \
1378 _n2##x==--_n3##x || _n1##x==--_n2##x || x==(_n3##x = _n2##x = --_n1##x); \
1379 I[0] = I[1], I[1] = I[2], I[2] = I[3], I[3] = I[4], I[4] = I[5], I[5] = I[6], \
1380 I[7] = I[8], I[8] = I[9], I[9] = I[10], I[10] = I[11], I[11] = I[12], I[12] = I[13], \
1381 I[14] = I[15], I[15] = I[16], I[16] = I[17], I[17] = I[18], I[18] = I[19], I[19] = I[20], \
1382 I[21] = I[22], I[22] = I[23], I[23] = I[24], I[24] = I[25], I[25] = I[26], I[26] = I[27], \
1383 I[28] = I[29], I[29] = I[30], I[30] = I[31], I[31] = I[32], I[32] = I[33], I[33] = I[34], \
1384 I[35] = I[36], I[36] = I[37], I[37] = I[38], I[38] = I[39], I[39] = I[40], I[40] = I[41], \
1385 I[42] = I[43], I[43] = I[44], I[44] = I[45], I[45] = I[46], I[46] = I[47], I[47] = I[48], \
1386 _p3##x = _p2##x, _p2##x = _p1##x, _p1##x = x++, ++_n1##x, ++_n2##x, ++_n3##x)
1388 #define cimg_for_in7x7(img,x0,y0,x1,y1,x,y,z,v,I) \
1389 cimg_for_in7((img).height,y0,y1,y) for (int x = (int)(x0)<0?0:(int)(x0), \
1390 _p3##x = x-3<0?0:x-3, \
1391 _p2##x = x-2<0?0:x-2, \
1392 _p1##x = x-1<0?0:x-1, \
1393 _n1##x = x+1>=(int)(img).width?(int)((img).width)-1:x+1, \
1394 _n2##x = x+2>=(int)(img).width?(int)((img).width)-1:x+2, \
1396 (I[0] = (img)(_p3##x,_p3##y,z,v)), \
1397 (I[7] = (img)(_p3##x,_p2##y,z,v)), \
1398 (I[14] = (img)(_p3##x,_p1##y,z,v)), \
1399 (I[21] = (img)(_p3##x,y,z,v)), \
1400 (I[28] = (img)(_p3##x,_n1##y,z,v)), \
1401 (I[35] = (img)(_p3##x,_n2##y,z,v)), \
1402 (I[42] = (img)(_p3##x,_n3##y,z,v)), \
1403 (I[1] = (img)(_p2##x,_p3##y,z,v)), \
1404 (I[8] = (img)(_p2##x,_p2##y,z,v)), \
1405 (I[15] = (img)(_p2##x,_p1##y,z,v)), \
1406 (I[22] = (img)(_p2##x,y,z,v)), \
1407 (I[29] = (img)(_p2##x,_n1##y,z,v)), \
1408 (I[36] = (img)(_p2##x,_n2##y,z,v)), \
1409 (I[43] = (img)(_p2##x,_n3##y,z,v)), \
1410 (I[2] = (img)(_p1##x,_p3##y,z,v)), \
1411 (I[9] = (img)(_p1##x,_p2##y,z,v)), \
1412 (I[16] = (img)(_p1##x,_p1##y,z,v)), \
1413 (I[23] = (img)(_p1##x,y,z,v)), \
1414 (I[30] = (img)(_p1##x,_n1##y,z,v)), \
1415 (I[37] = (img)(_p1##x,_n2##y,z,v)), \
1416 (I[44] = (img)(_p1##x,_n3##y,z,v)), \
1417 (I[3] = (img)(x,_p3##y,z,v)), \
1418 (I[10] = (img)(x,_p2##y,z,v)), \
1419 (I[17] = (img)(x,_p1##y,z,v)), \
1420 (I[24] = (img)(x,y,z,v)), \
1421 (I[31] = (img)(x,_n1##y,z,v)), \
1422 (I[38] = (img)(x,_n2##y,z,v)), \
1423 (I[45] = (img)(x,_n3##y,z,v)), \
1424 (I[4] = (img)(_n1##x,_p3##y,z,v)), \
1425 (I[11] = (img)(_n1##x,_p2##y,z,v)), \
1426 (I[18] = (img)(_n1##x,_p1##y,z,v)), \
1427 (I[25] = (img)(_n1##x,y,z,v)), \
1428 (I[32] = (img)(_n1##x,_n1##y,z,v)), \
1429 (I[39] = (img)(_n1##x,_n2##y,z,v)), \
1430 (I[46] = (img)(_n1##x,_n3##y,z,v)), \
1431 (I[5] = (img)(_n2##x,_p3##y,z,v)), \
1432 (I[12] = (img)(_n2##x,_p2##y,z,v)), \
1433 (I[19] = (img)(_n2##x,_p1##y,z,v)), \
1434 (I[26] = (img)(_n2##x,y,z,v)), \
1435 (I[33] = (img)(_n2##x,_n1##y,z,v)), \
1436 (I[40] = (img)(_n2##x,_n2##y,z,v)), \
1437 (I[47] = (img)(_n2##x,_n3##y,z,v)), \
1438 x+3>=(int)(img).width?(int)((img).width)-1:x+3); \
1439 x<=(int)(x1) && ((_n3##x<(int)((img).width) && ( \
1440 (I[6] = (img)(_n3##x,_p3##y,z,v)), \
1441 (I[13] = (img)(_n3##x,_p2##y,z,v)), \
1442 (I[20] = (img)(_n3##x,_p1##y,z,v)), \
1443 (I[27] = (img)(_n3##x,y,z,v)), \
1444 (I[34] = (img)(_n3##x,_n1##y,z,v)), \
1445 (I[41] = (img)(_n3##x,_n2##y,z,v)), \
1446 (I[48] = (img)(_n3##x,_n3##y,z,v)),1)) || \
1447 _n2##x==--_n3##x || _n1##x==--_n2##x || x==(_n3##x = _n2##x = --_n1##x)); \
1448 I[0] = I[1], I[1] = I[2], I[2] = I[3], I[3] = I[4], I[4] = I[5], I[5] = I[6], \
1449 I[7] = I[8], I[8] = I[9], I[9] = I[10], I[10] = I[11], I[11] = I[12], I[12] = I[13], \
1450 I[14] = I[15], I[15] = I[16], I[16] = I[17], I[17] = I[18], I[18] = I[19], I[19] = I[20], \
1451 I[21] = I[22], I[22] = I[23], I[23] = I[24], I[24] = I[25], I[25] = I[26], I[26] = I[27], \
1452 I[28] = I[29], I[29] = I[30], I[30] = I[31], I[31] = I[32], I[32] = I[33], I[33] = I[34], \
1453 I[35] = I[36], I[36] = I[37], I[37] = I[38], I[38] = I[39], I[39] = I[40], I[40] = I[41], \
1454 I[42] = I[43], I[43] = I[44], I[44] = I[45], I[45] = I[46], I[46] = I[47], I[47] = I[48], \
1455 _p3##x = _p2##x, _p2##x = _p1##x, _p1##x = x++, ++_n1##x, ++_n2##x, ++_n3##x)
1457 #define cimg_for8x8(img,x,y,z,v,I) \
1458 cimg_for8((img).height,y) for (int x = 0, \
1459 _p3##x = 0, _p2##x = 0, _p1##x = 0, \
1460 _n1##x = 1>=((img).width)?(int)((img).width)-1:1, \
1461 _n2##x = 2>=((img).width)?(int)((img).width)-1:2, \
1462 _n3##x = 3>=((img).width)?(int)((img).width)-1:3, \
1464 (I[0] = I[1] = I[2] = I[3] = (img)(0,_p3##y,z,v)), \
1465 (I[8] = I[9] = I[10] = I[11] = (img)(0,_p2##y,z,v)), \
1466 (I[16] = I[17] = I[18] = I[19] = (img)(0,_p1##y,z,v)), \
1467 (I[24] = I[25] = I[26] = I[27] = (img)(0,y,z,v)), \
1468 (I[32] = I[33] = I[34] = I[35] = (img)(0,_n1##y,z,v)), \
1469 (I[40] = I[41] = I[42] = I[43] = (img)(0,_n2##y,z,v)), \
1470 (I[48] = I[49] = I[50] = I[51] = (img)(0,_n3##y,z,v)), \
1471 (I[56] = I[57] = I[58] = I[59] = (img)(0,_n4##y,z,v)), \
1472 (I[4] = (img)(_n1##x,_p3##y,z,v)), \
1473 (I[12] = (img)(_n1##x,_p2##y,z,v)), \
1474 (I[20] = (img)(_n1##x,_p1##y,z,v)), \
1475 (I[28] = (img)(_n1##x,y,z,v)), \
1476 (I[36] = (img)(_n1##x,_n1##y,z,v)), \
1477 (I[44] = (img)(_n1##x,_n2##y,z,v)), \
1478 (I[52] = (img)(_n1##x,_n3##y,z,v)), \
1479 (I[60] = (img)(_n1##x,_n4##y,z,v)), \
1480 (I[5] = (img)(_n2##x,_p3##y,z,v)), \
1481 (I[13] = (img)(_n2##x,_p2##y,z,v)), \
1482 (I[21] = (img)(_n2##x,_p1##y,z,v)), \
1483 (I[29] = (img)(_n2##x,y,z,v)), \
1484 (I[37] = (img)(_n2##x,_n1##y,z,v)), \
1485 (I[45] = (img)(_n2##x,_n2##y,z,v)), \
1486 (I[53] = (img)(_n2##x,_n3##y,z,v)), \
1487 (I[61] = (img)(_n2##x,_n4##y,z,v)), \
1488 (I[6] = (img)(_n3##x,_p3##y,z,v)), \
1489 (I[14] = (img)(_n3##x,_p2##y,z,v)), \
1490 (I[22] = (img)(_n3##x,_p1##y,z,v)), \
1491 (I[30] = (img)(_n3##x,y,z,v)), \
1492 (I[38] = (img)(_n3##x,_n1##y,z,v)), \
1493 (I[46] = (img)(_n3##x,_n2##y,z,v)), \
1494 (I[54] = (img)(_n3##x,_n3##y,z,v)), \
1495 (I[62] = (img)(_n3##x,_n4##y,z,v)), \
1496 4>=((img).width)?(int)((img).width)-1:4); \
1497 (_n4##x<(int)((img).width) && ( \
1498 (I[7] = (img)(_n4##x,_p3##y,z,v)), \
1499 (I[15] = (img)(_n4##x,_p2##y,z,v)), \
1500 (I[23] = (img)(_n4##x,_p1##y,z,v)), \
1501 (I[31] = (img)(_n4##x,y,z,v)), \
1502 (I[39] = (img)(_n4##x,_n1##y,z,v)), \
1503 (I[47] = (img)(_n4##x,_n2##y,z,v)), \
1504 (I[55] = (img)(_n4##x,_n3##y,z,v)), \
1505 (I[63] = (img)(_n4##x,_n4##y,z,v)),1)) || \
1506 _n3##x==--_n4##x || _n2##x==--_n3##x || _n1##x==--_n2##x || x==(_n4##x = _n3##x = _n2##x = --_n1##x); \
1507 I[0] = I[1], I[1] = I[2], I[2] = I[3], I[3] = I[4], I[4] = I[5], I[5] = I[6], I[6] = I[7], \
1508 I[8] = I[9], I[9] = I[10], I[10] = I[11], I[11] = I[12], I[12] = I[13], I[13] = I[14], I[14] = I[15], \
1509 I[16] = I[17], I[17] = I[18], I[18] = I[19], I[19] = I[20], I[20] = I[21], I[21] = I[22], I[22] = I[23], \
1510 I[24] = I[25], I[25] = I[26], I[26] = I[27], I[27] = I[28], I[28] = I[29], I[29] = I[30], I[30] = I[31], \
1511 I[32] = I[33], I[33] = I[34], I[34] = I[35], I[35] = I[36], I[36] = I[37], I[37] = I[38], I[38] = I[39], \
1512 I[40] = I[41], I[41] = I[42], I[42] = I[43], I[43] = I[44], I[44] = I[45], I[45] = I[46], I[46] = I[47], \
1513 I[48] = I[49], I[49] = I[50], I[50] = I[51], I[51] = I[52], I[52] = I[53], I[53] = I[54], I[54] = I[55], \
1514 I[56] = I[57], I[57] = I[58], I[58] = I[59], I[59] = I[60], I[60] = I[61], I[61] = I[62], I[62] = I[63], \
1515 _p3##x = _p2##x, _p2##x = _p1##x, _p1##x = x++, ++_n1##x, ++_n2##x, ++_n3##x, ++_n4##x)
1517 #define cimg_for_in8x8(img,x0,y0,x1,y1,x,y,z,v,I) \
1518 cimg_for_in8((img).height,y0,y1,y) for (int x = (int)(x0)<0?0:(int)(x0), \
1519 _p3##x = x-3<0?0:x-3, \
1520 _p2##x = x-2<0?0:x-2, \
1521 _p1##x = x-1<0?0:x-1, \
1522 _n1##x = x+1>=(int)((img).width)?(int)((img).width)-1:x+1, \
1523 _n2##x = x+2>=(int)((img).width)?(int)((img).width)-1:x+2, \
1524 _n3##x = x+3>=(int)((img).width)?(int)((img).width)-1:x+3, \
1526 (I[0] = (img)(_p3##x,_p3##y,z,v)), \
1527 (I[8] = (img)(_p3##x,_p2##y,z,v)), \
1528 (I[16] = (img)(_p3##x,_p1##y,z,v)), \
1529 (I[24] = (img)(_p3##x,y,z,v)), \
1530 (I[32] = (img)(_p3##x,_n1##y,z,v)), \
1531 (I[40] = (img)(_p3##x,_n2##y,z,v)), \
1532 (I[48] = (img)(_p3##x,_n3##y,z,v)), \
1533 (I[56] = (img)(_p3##x,_n4##y,z,v)), \
1534 (I[1] = (img)(_p2##x,_p3##y,z,v)), \
1535 (I[9] = (img)(_p2##x,_p2##y,z,v)), \
1536 (I[17] = (img)(_p2##x,_p1##y,z,v)), \
1537 (I[25] = (img)(_p2##x,y,z,v)), \
1538 (I[33] = (img)(_p2##x,_n1##y,z,v)), \
1539 (I[41] = (img)(_p2##x,_n2##y,z,v)), \
1540 (I[49] = (img)(_p2##x,_n3##y,z,v)), \
1541 (I[57] = (img)(_p2##x,_n4##y,z,v)), \
1542 (I[2] = (img)(_p1##x,_p3##y,z,v)), \
1543 (I[10] = (img)(_p1##x,_p2##y,z,v)), \
1544 (I[18] = (img)(_p1##x,_p1##y,z,v)), \
1545 (I[26] = (img)(_p1##x,y,z,v)), \
1546 (I[34] = (img)(_p1##x,_n1##y,z,v)), \
1547 (I[42] = (img)(_p1##x,_n2##y,z,v)), \
1548 (I[50] = (img)(_p1##x,_n3##y,z,v)), \
1549 (I[58] = (img)(_p1##x,_n4##y,z,v)), \
1550 (I[3] = (img)(x,_p3##y,z,v)), \
1551 (I[11] = (img)(x,_p2##y,z,v)), \
1552 (I[19] = (img)(x,_p1##y,z,v)), \
1553 (I[27] = (img)(x,y,z,v)), \
1554 (I[35] = (img)(x,_n1##y,z,v)), \
1555 (I[43] = (img)(x,_n2##y,z,v)), \
1556 (I[51] = (img)(x,_n3##y,z,v)), \
1557 (I[59] = (img)(x,_n4##y,z,v)), \
1558 (I[4] = (img)(_n1##x,_p3##y,z,v)), \
1559 (I[12] = (img)(_n1##x,_p2##y,z,v)), \
1560 (I[20] = (img)(_n1##x,_p1##y,z,v)), \
1561 (I[28] = (img)(_n1##x,y,z,v)), \
1562 (I[36] = (img)(_n1##x,_n1##y,z,v)), \
1563 (I[44] = (img)(_n1##x,_n2##y,z,v)), \
1564 (I[52] = (img)(_n1##x,_n3##y,z,v)), \
1565 (I[60] = (img)(_n1##x,_n4##y,z,v)), \
1566 (I[5] = (img)(_n2##x,_p3##y,z,v)), \
1567 (I[13] = (img)(_n2##x,_p2##y,z,v)), \
1568 (I[21] = (img)(_n2##x,_p1##y,z,v)), \
1569 (I[29] = (img)(_n2##x,y,z,v)), \
1570 (I[37] = (img)(_n2##x,_n1##y,z,v)), \
1571 (I[45] = (img)(_n2##x,_n2##y,z,v)), \
1572 (I[53] = (img)(_n2##x,_n3##y,z,v)), \
1573 (I[61] = (img)(_n2##x,_n4##y,z,v)), \
1574 (I[6] = (img)(_n3##x,_p3##y,z,v)), \
1575 (I[14] = (img)(_n3##x,_p2##y,z,v)), \
1576 (I[22] = (img)(_n3##x,_p1##y,z,v)), \
1577 (I[30] = (img)(_n3##x,y,z,v)), \
1578 (I[38] = (img)(_n3##x,_n1##y,z,v)), \
1579 (I[46] = (img)(_n3##x,_n2##y,z,v)), \
1580 (I[54] = (img)(_n3##x,_n3##y,z,v)), \
1581 (I[62] = (img)(_n3##x,_n4##y,z,v)), \
1582 x+4>=(int)((img).width)?(int)((img).width)-1:x+4); \
1583 x<=(int)(x1) && ((_n4##x<(int)((img).width) && ( \
1584 (I[7] = (img)(_n4##x,_p3##y,z,v)), \
1585 (I[15] = (img)(_n4##x,_p2##y,z,v)), \
1586 (I[23] = (img)(_n4##x,_p1##y,z,v)), \
1587 (I[31] = (img)(_n4##x,y,z,v)), \
1588 (I[39] = (img)(_n4##x,_n1##y,z,v)), \
1589 (I[47] = (img)(_n4##x,_n2##y,z,v)), \
1590 (I[55] = (img)(_n4##x,_n3##y,z,v)), \
1591 (I[63] = (img)(_n4##x,_n4##y,z,v)),1)) || \
1592 _n3##x==--_n4##x || _n2##x==--_n3##x || _n1##x==--_n2##x || x==(_n4##x = _n3##x = _n2##x = --_n1##x)); \
1593 I[0] = I[1], I[1] = I[2], I[2] = I[3], I[3] = I[4], I[4] = I[5], I[5] = I[6], I[6] = I[7], \
1594 I[8] = I[9], I[9] = I[10], I[10] = I[11], I[11] = I[12], I[12] = I[13], I[13] = I[14], I[14] = I[15], \
1595 I[16] = I[17], I[17] = I[18], I[18] = I[19], I[19] = I[20], I[20] = I[21], I[21] = I[22], I[22] = I[23], \
1596 I[24] = I[25], I[25] = I[26], I[26] = I[27], I[27] = I[28], I[28] = I[29], I[29] = I[30], I[30] = I[31], \
1597 I[32] = I[33], I[33] = I[34], I[34] = I[35], I[35] = I[36], I[36] = I[37], I[37] = I[38], I[38] = I[39], \
1598 I[40] = I[41], I[41] = I[42], I[42] = I[43], I[43] = I[44], I[44] = I[45], I[45] = I[46], I[46] = I[47], \
1599 I[48] = I[49], I[49] = I[50], I[50] = I[51], I[51] = I[52], I[52] = I[53], I[53] = I[54], I[54] = I[55], \
1600 I[56] = I[57], I[57] = I[58], I[58] = I[59], I[59] = I[60], I[60] = I[61], I[61] = I[62], I[62] = I[63], \
1601 _p3##x = _p2##x, _p2##x = _p1##x, _p1##x = x++, ++_n1##x, ++_n2##x, ++_n3##x, ++_n4##x)
1603 #define cimg_for9x9(img,x,y,z,v,I) \
1604 cimg_for9((img).height,y) for (int x = 0, \
1605 _p4##x = 0, _p3##x = 0, _p2##x = 0, _p1##x = 0, \
1606 _n1##x = 1>=((img).width)?(int)((img).width)-1:1, \
1607 _n2##x = 2>=((img).width)?(int)((img).width)-1:2, \
1608 _n3##x = 3>=((img).width)?(int)((img).width)-1:3, \
1610 (I[0] = I[1] = I[2] = I[3] = I[4] = (img)(0,_p4##y,z,v)), \
1611 (I[9] = I[10] = I[11] = I[12] = I[13] = (img)(0,_p3##y,z,v)), \
1612 (I[18] = I[19] = I[20] = I[21] = I[22] = (img)(0,_p2##y,z,v)), \
1613 (I[27] = I[28] = I[29] = I[30] = I[31] = (img)(0,_p1##y,z,v)), \
1614 (I[36] = I[37] = I[38] = I[39] = I[40] = (img)(0,y,z,v)), \
1615 (I[45] = I[46] = I[47] = I[48] = I[49] = (img)(0,_n1##y,z,v)), \
1616 (I[54] = I[55] = I[56] = I[57] = I[58] = (img)(0,_n2##y,z,v)), \
1617 (I[63] = I[64] = I[65] = I[66] = I[67] = (img)(0,_n3##y,z,v)), \
1618 (I[72] = I[73] = I[74] = I[75] = I[76] = (img)(0,_n4##y,z,v)), \
1619 (I[5] = (img)(_n1##x,_p4##y,z,v)), \
1620 (I[14] = (img)(_n1##x,_p3##y,z,v)), \
1621 (I[23] = (img)(_n1##x,_p2##y,z,v)), \
1622 (I[32] = (img)(_n1##x,_p1##y,z,v)), \
1623 (I[41] = (img)(_n1##x,y,z,v)), \
1624 (I[50] = (img)(_n1##x,_n1##y,z,v)), \
1625 (I[59] = (img)(_n1##x,_n2##y,z,v)), \
1626 (I[68] = (img)(_n1##x,_n3##y,z,v)), \
1627 (I[77] = (img)(_n1##x,_n4##y,z,v)), \
1628 (I[6] = (img)(_n2##x,_p4##y,z,v)), \
1629 (I[15] = (img)(_n2##x,_p3##y,z,v)), \
1630 (I[24] = (img)(_n2##x,_p2##y,z,v)), \
1631 (I[33] = (img)(_n2##x,_p1##y,z,v)), \
1632 (I[42] = (img)(_n2##x,y,z,v)), \
1633 (I[51] = (img)(_n2##x,_n1##y,z,v)), \
1634 (I[60] = (img)(_n2##x,_n2##y,z,v)), \
1635 (I[69] = (img)(_n2##x,_n3##y,z,v)), \
1636 (I[78] = (img)(_n2##x,_n4##y,z,v)), \
1637 (I[7] = (img)(_n3##x,_p4##y,z,v)), \
1638 (I[16] = (img)(_n3##x,_p3##y,z,v)), \
1639 (I[25] = (img)(_n3##x,_p2##y,z,v)), \
1640 (I[34] = (img)(_n3##x,_p1##y,z,v)), \
1641 (I[43] = (img)(_n3##x,y,z,v)), \
1642 (I[52] = (img)(_n3##x,_n1##y,z,v)), \
1643 (I[61] = (img)(_n3##x,_n2##y,z,v)), \
1644 (I[70] = (img)(_n3##x,_n3##y,z,v)), \
1645 (I[79] = (img)(_n3##x,_n4##y,z,v)), \
1646 4>=((img).width)?(int)((img).width)-1:4); \
1647 (_n4##x<(int)((img).width) && ( \
1648 (I[8] = (img)(_n4##x,_p4##y,z,v)), \
1649 (I[17] = (img)(_n4##x,_p3##y,z,v)), \
1650 (I[26] = (img)(_n4##x,_p2##y,z,v)), \
1651 (I[35] = (img)(_n4##x,_p1##y,z,v)), \
1652 (I[44] = (img)(_n4##x,y,z,v)), \
1653 (I[53] = (img)(_n4##x,_n1##y,z,v)), \
1654 (I[62] = (img)(_n4##x,_n2##y,z,v)), \
1655 (I[71] = (img)(_n4##x,_n3##y,z,v)), \
1656 (I[80] = (img)(_n4##x,_n4##y,z,v)),1)) || \
1657 _n3##x==--_n4##x || _n2##x==--_n3##x || _n1##x==--_n2##x || x==(_n4##x = _n3##x = _n2##x = --_n1##x); \
1658 I[0] = I[1], I[1] = I[2], I[2] = I[3], I[3] = I[4], I[4] = I[5], I[5] = I[6], I[6] = I[7], I[7] = I[8], \
1659 I[9] = I[10], I[10] = I[11], I[11] = I[12], I[12] = I[13], I[13] = I[14], I[14] = I[15], I[15] = I[16], I[16] = I[17], \
1660 I[18] = I[19], I[19] = I[20], I[20] = I[21], I[21] = I[22], I[22] = I[23], I[23] = I[24], I[24] = I[25], I[25] = I[26], \
1661 I[27] = I[28], I[28] = I[29], I[29] = I[30], I[30] = I[31], I[31] = I[32], I[32] = I[33], I[33] = I[34], I[34] = I[35], \
1662 I[36] = I[37], I[37] = I[38], I[38] = I[39], I[39] = I[40], I[40] = I[41], I[41] = I[42], I[42] = I[43], I[43] = I[44], \
1663 I[45] = I[46], I[46] = I[47], I[47] = I[48], I[48] = I[49], I[49] = I[50], I[50] = I[51], I[51] = I[52], I[52] = I[53], \
1664 I[54] = I[55], I[55] = I[56], I[56] = I[57], I[57] = I[58], I[58] = I[59], I[59] = I[60], I[60] = I[61], I[61] = I[62], \
1665 I[63] = I[64], I[64] = I[65], I[65] = I[66], I[66] = I[67], I[67] = I[68], I[68] = I[69], I[69] = I[70], I[70] = I[71], \
1666 I[72] = I[73], I[73] = I[74], I[74] = I[75], I[75] = I[76], I[76] = I[77], I[77] = I[78], I[78] = I[79], I[79] = I[80], \
1667 _p4##x = _p3##x, _p3##x = _p2##x, _p2##x = _p1##x, _p1##x = x++, ++_n1##x, ++_n2##x, ++_n3##x, ++_n4##x)
1669 #define cimg_for_in9x9(img,x0,y0,x1,y1,x,y,z,v,I) \
1670 cimg_for_in9((img).height,y0,y1,y) for (int x = (int)(x0)<0?0:(int)(x0), \
1671 _p4##x = x-4<0?0:x-4, \
1672 _p3##x = x-3<0?0:x-3, \
1673 _p2##x = x-2<0?0:x-2, \
1674 _p1##x = x-1<0?0:x-1, \
1675 _n1##x = x+1>=(int)((img).width)?(int)((img).width)-1:x+1, \
1676 _n2##x = x+2>=(int)((img).width)?(int)((img).width)-1:x+2, \
1677 _n3##x = x+3>=(int)((img).width)?(int)((img).width)-1:x+3, \
1679 (I[0] = (img)(_p4##x,_p4##y,z,v)), \
1680 (I[9] = (img)(_p4##x,_p3##y,z,v)), \
1681 (I[18] = (img)(_p4##x,_p2##y,z,v)), \
1682 (I[27] = (img)(_p4##x,_p1##y,z,v)), \
1683 (I[36] = (img)(_p4##x,y,z,v)), \
1684 (I[45] = (img)(_p4##x,_n1##y,z,v)), \
1685 (I[54] = (img)(_p4##x,_n2##y,z,v)), \
1686 (I[63] = (img)(_p4##x,_n3##y,z,v)), \
1687 (I[72] = (img)(_p4##x,_n4##y,z,v)), \
1688 (I[1] = (img)(_p3##x,_p4##y,z,v)), \
1689 (I[10] = (img)(_p3##x,_p3##y,z,v)), \
1690 (I[19] = (img)(_p3##x,_p2##y,z,v)), \
1691 (I[28] = (img)(_p3##x,_p1##y,z,v)), \
1692 (I[37] = (img)(_p3##x,y,z,v)), \
1693 (I[46] = (img)(_p3##x,_n1##y,z,v)), \
1694 (I[55] = (img)(_p3##x,_n2##y,z,v)), \
1695 (I[64] = (img)(_p3##x,_n3##y,z,v)), \
1696 (I[73] = (img)(_p3##x,_n4##y,z,v)), \
1697 (I[2] = (img)(_p2##x,_p4##y,z,v)), \
1698 (I[11] = (img)(_p2##x,_p3##y,z,v)), \
1699 (I[20] = (img)(_p2##x,_p2##y,z,v)), \
1700 (I[29] = (img)(_p2##x,_p1##y,z,v)), \
1701 (I[38] = (img)(_p2##x,y,z,v)), \
1702 (I[47] = (img)(_p2##x,_n1##y,z,v)), \
1703 (I[56] = (img)(_p2##x,_n2##y,z,v)), \
1704 (I[65] = (img)(_p2##x,_n3##y,z,v)), \
1705 (I[74] = (img)(_p2##x,_n4##y,z,v)), \
1706 (I[3] = (img)(_p1##x,_p4##y,z,v)), \
1707 (I[12] = (img)(_p1##x,_p3##y,z,v)), \
1708 (I[21] = (img)(_p1##x,_p2##y,z,v)), \
1709 (I[30] = (img)(_p1##x,_p1##y,z,v)), \
1710 (I[39] = (img)(_p1##x,y,z,v)), \
1711 (I[48] = (img)(_p1##x,_n1##y,z,v)), \
1712 (I[57] = (img)(_p1##x,_n2##y,z,v)), \
1713 (I[66] = (img)(_p1##x,_n3##y,z,v)), \
1714 (I[75] = (img)(_p1##x,_n4##y,z,v)), \
1715 (I[4] = (img)(x,_p4##y,z,v)), \
1716 (I[13] = (img)(x,_p3##y,z,v)), \
1717 (I[22] = (img)(x,_p2##y,z,v)), \
1718 (I[31] = (img)(x,_p1##y,z,v)), \
1719 (I[40] = (img)(x,y,z,v)), \
1720 (I[49] = (img)(x,_n1##y,z,v)), \
1721 (I[58] = (img)(x,_n2##y,z,v)), \
1722 (I[67] = (img)(x,_n3##y,z,v)), \
1723 (I[76] = (img)(x,_n4##y,z,v)), \
1724 (I[5] = (img)(_n1##x,_p4##y,z,v)), \
1725 (I[14] = (img)(_n1##x,_p3##y,z,v)), \
1726 (I[23] = (img)(_n1##x,_p2##y,z,v)), \
1727 (I[32] = (img)(_n1##x,_p1##y,z,v)), \
1728 (I[41] = (img)(_n1##x,y,z,v)), \
1729 (I[50] = (img)(_n1##x,_n1##y,z,v)), \
1730 (I[59] = (img)(_n1##x,_n2##y,z,v)), \
1731 (I[68] = (img)(_n1##x,_n3##y,z,v)), \
1732 (I[77] = (img)(_n1##x,_n4##y,z,v)), \
1733 (I[6] = (img)(_n2##x,_p4##y,z,v)), \
1734 (I[15] = (img)(_n2##x,_p3##y,z,v)), \
1735 (I[24] = (img)(_n2##x,_p2##y,z,v)), \
1736 (I[33] = (img)(_n2##x,_p1##y,z,v)), \
1737 (I[42] = (img)(_n2##x,y,z,v)), \
1738 (I[51] = (img)(_n2##x,_n1##y,z,v)), \
1739 (I[60] = (img)(_n2##x,_n2##y,z,v)), \
1740 (I[69] = (img)(_n2##x,_n3##y,z,v)), \
1741 (I[78] = (img)(_n2##x,_n4##y,z,v)), \
1742 (I[7] = (img)(_n3##x,_p4##y,z,v)), \
1743 (I[16] = (img)(_n3##x,_p3##y,z,v)), \
1744 (I[25] = (img)(_n3##x,_p2##y,z,v)), \
1745 (I[34] = (img)(_n3##x,_p1##y,z,v)), \
1746 (I[43] = (img)(_n3##x,y,z,v)), \
1747 (I[52] = (img)(_n3##x,_n1##y,z,v)), \
1748 (I[61] = (img)(_n3##x,_n2##y,z,v)), \
1749 (I[70] = (img)(_n3##x,_n3##y,z,v)), \
1750 (I[79] = (img)(_n3##x,_n4##y,z,v)), \
1751 x+4>=(int)((img).width)?(int)((img).width)-1:x+4); \
1752 x<=(int)(x1) && ((_n4##x<(int)((img).width) && ( \
1753 (I[8] = (img)(_n4##x,_p4##y,z,v)), \
1754 (I[17] = (img)(_n4##x,_p3##y,z,v)), \
1755 (I[26] = (img)(_n4##x,_p2##y,z,v)), \
1756 (I[35] = (img)(_n4##x,_p1##y,z,v)), \
1757 (I[44] = (img)(_n4##x,y,z,v)), \
1758 (I[53] = (img)(_n4##x,_n1##y,z,v)), \
1759 (I[62] = (img)(_n4##x,_n2##y,z,v)), \
1760 (I[71] = (img)(_n4##x,_n3##y,z,v)), \
1761 (I[80] = (img)(_n4##x,_n4##y,z,v)),1)) || \
1762 _n3##x==--_n4##x || _n2##x==--_n3##x || _n1##x==--_n2##x || x==(_n4##x = _n3##x = _n2##x = --_n1##x)); \
1763 I[0] = I[1], I[1] = I[2], I[2] = I[3], I[3] = I[4], I[4] = I[5], I[5] = I[6], I[6] = I[7], I[7] = I[8], \
1764 I[9] = I[10], I[10] = I[11], I[11] = I[12], I[12] = I[13], I[13] = I[14], I[14] = I[15], I[15] = I[16], I[16] = I[17], \
1765 I[18] = I[19], I[19] = I[20], I[20] = I[21], I[21] = I[22], I[22] = I[23], I[23] = I[24], I[24] = I[25], I[25] = I[26], \
1766 I[27] = I[28], I[28] = I[29], I[29] = I[30], I[30] = I[31], I[31] = I[32], I[32] = I[33], I[33] = I[34], I[34] = I[35], \
1767 I[36] = I[37], I[37] = I[38], I[38] = I[39], I[39] = I[40], I[40] = I[41], I[41] = I[42], I[42] = I[43], I[43] = I[44], \
1768 I[45] = I[46], I[46] = I[47], I[47] = I[48], I[48] = I[49], I[49] = I[50], I[50] = I[51], I[51] = I[52], I[52] = I[53], \
1769 I[54] = I[55], I[55] = I[56], I[56] = I[57], I[57] = I[58], I[58] = I[59], I[59] = I[60], I[60] = I[61], I[61] = I[62], \
1770 I[63] = I[64], I[64] = I[65], I[65] = I[66], I[66] = I[67], I[67] = I[68], I[68] = I[69], I[69] = I[70], I[70] = I[71], \
1771 I[72] = I[73], I[73] = I[74], I[74] = I[75], I[75] = I[76], I[76] = I[77], I[77] = I[78], I[78] = I[79], I[79] = I[80], \
1772 _p4##x = _p3##x, _p3##x = _p2##x, _p2##x = _p1##x, _p1##x = x++, ++_n1##x, ++_n2##x, ++_n3##x, ++_n4##x)
1774 #define cimg_for2x2x2(img,x,y,z,v,I) \
1775 cimg_for2((img).depth,z) cimg_for2((img).height,y) for (int x = 0, \
1777 (I[0] = (img)(0,y,z,v)), \
1778 (I[2] = (img)(0,_n1##y,z,v)), \
1779 (I[4] = (img)(0,y,_n1##z,v)), \
1780 (I[6] = (img)(0,_n1##y,_n1##z,v)), \
1781 1>=(img).width?(int)((img).width)-1:1); \
1782 (_n1##x<(int)((img).width) && ( \
1783 (I[1] = (img)(_n1##x,y,z,v)), \
1784 (I[3] = (img)(_n1##x,_n1##y,z,v)), \
1785 (I[5] = (img)(_n1##x,y,_n1##z,v)), \
1786 (I[7] = (img)(_n1##x,_n1##y,_n1##z,v)),1)) || \
1788 I[0] = I[1], I[2] = I[3], I[4] = I[5], I[6] = I[7], \
1791 #define cimg_for_in2x2x2(img,x0,y0,z0,x1,y1,z1,x,y,z,v,I) \
1792 cimg_for_in2((img).depth,z0,z1,z) cimg_for_in2((img).height,y0,y1,y) for (int x = (int)(x0)<0?0:(int)(x0), \
1794 (I[0] = (img)(x,y,z,v)), \
1795 (I[2] = (img)(x,_n1##y,z,v)), \
1796 (I[4] = (img)(x,y,_n1##z,v)), \
1797 (I[6] = (img)(x,_n1##y,_n1##z,v)), \
1798 x+1>=(int)(img).width?(int)((img).width)-1:x+1); \
1799 x<=(int)(x1) && ((_n1##x<(int)((img).width) && ( \
1800 (I[1] = (img)(_n1##x,y,z,v)), \
1801 (I[3] = (img)(_n1##x,_n1##y,z,v)), \
1802 (I[5] = (img)(_n1##x,y,_n1##z,v)), \
1803 (I[7] = (img)(_n1##x,_n1##y,_n1##z,v)),1)) || \
1805 I[0] = I[1], I[2] = I[3], I[4] = I[5], I[6] = I[7], \
1808 #define cimg_for3x3x3(img,x,y,z,v,I) \
1809 cimg_for3((img).depth,z) cimg_for3((img).height,y) for (int x = 0, \
1812 (I[0] = I[1] = (img)(0,_p1##y,_p1##z,v)), \
1813 (I[3] = I[4] = (img)(0,y,_p1##z,v)), \
1814 (I[6] = I[7] = (img)(0,_n1##y,_p1##z,v)), \
1815 (I[9] = I[10] = (img)(0,_p1##y,z,v)), \
1816 (I[12] = I[13] = (img)(0,y,z,v)), \
1817 (I[15] = I[16] = (img)(0,_n1##y,z,v)), \
1818 (I[18] = I[19] = (img)(0,_p1##y,_n1##z,v)), \
1819 (I[21] = I[22] = (img)(0,y,_n1##z,v)), \
1820 (I[24] = I[25] = (img)(0,_n1##y,_n1##z,v)), \
1821 1>=(img).width?(int)((img).width)-1:1); \
1822 (_n1##x<(int)((img).width) && ( \
1823 (I[2] = (img)(_n1##x,_p1##y,_p1##z,v)), \
1824 (I[5] = (img)(_n1##x,y,_p1##z,v)), \
1825 (I[8] = (img)(_n1##x,_n1##y,_p1##z,v)), \
1826 (I[11] = (img)(_n1##x,_p1##y,z,v)), \
1827 (I[14] = (img)(_n1##x,y,z,v)), \
1828 (I[17] = (img)(_n1##x,_n1##y,z,v)), \
1829 (I[20] = (img)(_n1##x,_p1##y,_n1##z,v)), \
1830 (I[23] = (img)(_n1##x,y,_n1##z,v)), \
1831 (I[26] = (img)(_n1##x,_n1##y,_n1##z,v)),1)) || \
1833 I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], \
1834 I[9] = I[10], I[10] = I[11], I[12] = I[13], I[13] = I[14], I[15] = I[16], I[16] = I[17], \
1835 I[18] = I[19], I[19] = I[20], I[21] = I[22], I[22] = I[23], I[24] = I[25], I[25] = I[26], \
1836 _p1##x = x++, ++_n1##x)
1838 #define cimg_for_in3x3x3(img,x0,y0,z0,x1,y1,z1,x,y,z,v,I) \
1839 cimg_for_in3((img).depth,z0,z1,z) cimg_for_in3((img).height,y0,y1,y) for (int x = (int)(x0)<0?0:(int)(x0), \
1840 _p1##x = x-1<0?0:x-1, \
1842 (I[0] = (img)(_p1##x,_p1##y,_p1##z,v)), \
1843 (I[3] = (img)(_p1##x,y,_p1##z,v)), \
1844 (I[6] = (img)(_p1##x,_n1##y,_p1##z,v)), \
1845 (I[9] = (img)(_p1##x,_p1##y,z,v)), \
1846 (I[12] = (img)(_p1##x,y,z,v)), \
1847 (I[15] = (img)(_p1##x,_n1##y,z,v)), \
1848 (I[18] = (img)(_p1##x,_p1##y,_n1##z,v)), \
1849 (I[21] = (img)(_p1##x,y,_n1##z,v)), \
1850 (I[24] = (img)(_p1##x,_n1##y,_n1##z,v)), \
1851 (I[1] = (img)(x,_p1##y,_p1##z,v)), \
1852 (I[4] = (img)(x,y,_p1##z,v)), \
1853 (I[7] = (img)(x,_n1##y,_p1##z,v)), \
1854 (I[10] = (img)(x,_p1##y,z,v)), \
1855 (I[13] = (img)(x,y,z,v)), \
1856 (I[16] = (img)(x,_n1##y,z,v)), \
1857 (I[19] = (img)(x,_p1##y,_n1##z,v)), \
1858 (I[22] = (img)(x,y,_n1##z,v)), \
1859 (I[25] = (img)(x,_n1##y,_n1##z,v)), \
1860 x+1>=(int)(img).width?(int)((img).width)-1:x+1); \
1861 x<=(int)(x1) && ((_n1##x<(int)((img).width) && ( \
1862 (I[2] = (img)(_n1##x,_p1##y,_p1##z,v)), \
1863 (I[5] = (img)(_n1##x,y,_p1##z,v)), \
1864 (I[8] = (img)(_n1##x,_n1##y,_p1##z,v)), \
1865 (I[11] = (img)(_n1##x,_p1##y,z,v)), \
1866 (I[14] = (img)(_n1##x,y,z,v)), \
1867 (I[17] = (img)(_n1##x,_n1##y,z,v)), \
1868 (I[20] = (img)(_n1##x,_p1##y,_n1##z,v)), \
1869 (I[23] = (img)(_n1##x,y,_n1##z,v)), \
1870 (I[26] = (img)(_n1##x,_n1##y,_n1##z,v)),1)) || \
1872 I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], \
1873 I[9] = I[10], I[10] = I[11], I[12] = I[13], I[13] = I[14], I[15] = I[16], I[16] = I[17], \
1874 I[18] = I[19], I[19] = I[20], I[21] = I[22], I[22] = I[23], I[24] = I[25], I[25] = I[26], \
1875 _p1##x = x++, ++_n1##x)
1877 #define cimglist_for(list,l) for (int l = 0; l<(int)(list).width; ++l)
1878 #define cimglist_for_in(list,l0,l1,l) \
1879 for (int l = (int)(l0)<0?0:(int)(l0), _max##l = (unsigned int)l1<(list).width?(int)(l1):(int)(list).width-1; l<=_max##l; ++l)
1881 #define cimglist_apply(list,fn) cimglist_for(list,__##fn) (list)[__##fn].fn
1902 namespace cimg_library {
1905 template<
typename T=
float>
struct CImg;
1916 #ifdef cimg_use_vt100
1917 const char t_normal[] = { 0x1b,
'[',
'0',
';',
'0',
';',
'0',
'm', 0 };
1918 const char t_red[] = { 0x1b,
'[',
'4',
';',
'3',
'1',
';',
'5',
'9',
'm', 0 };
1919 const char t_bold[] = { 0x1b,
'[',
'1',
'm', 0 };
1920 const char t_purple[] = { 0x1b,
'[',
'0',
';',
'3',
'5',
';',
'5',
'9',
'm', 0 };
1921 const char t_green[] = { 0x1b,
'[',
'0',
';',
'3',
'2',
';',
'5',
'9',
'm', 0 };
1942 inline int dialog(
const char *title,
const char *msg,
const char *button1_txt=
"OK",
1943 const char *button2_txt=0,
const char *button3_txt=0,
1944 const char *button4_txt=0,
const char *button5_txt=0,
1945 const char *button6_txt=0,
const bool centering=
false);
1948 inline double eval(
const char *
const expression,
const double x=0,
const double y=0,
const double z=0,
const double v=0);
2021 #define _cimg_exception_err(etype,disp_flag) \
2022 std::va_list ap; va_start(ap,format); std::vsprintf(message,format,ap); va_end(ap); \
2023 switch (cimg::exception_mode()) { \
2025 case 2 : case 4 : try { cimg::dialog(etype,message,"Abort"); } catch (CImgException&) { \
2026 std::fprintf(cimg_stdout,"\n%s# %s%s :\n%s\n\n",cimg::t_red,etype,cimg::t_normal,message); \
2028 default : std::fprintf(cimg_stdout,"\n%s# %s%s :\n%s\n\n",cimg::t_red,etype,cimg::t_normal,message); \
2030 if (cimg::exception_mode()>=3) cimg_library::cimg::info();
2086 static const char*
s[] = {
"unknown",
"unknown8",
"unknown16",
"unknown24",
2087 "unknown32",
"unknown40",
"unknown48",
"unknown56",
2088 "unknown64",
"unknown72",
"unknown80",
"unknown88",
2089 "unknown96",
"unknown104",
"unknown112",
"unknown120",
2091 return s[(
sizeof(T)<17)?
sizeof(T):0];
2094 static T
min() {
return (T)-1>0?(T)0:(T)-1<<(8*
sizeof(T)-1); }
2095 static T
max() {
return (T)-1>0?(T)-1:~((T)-1<<(8*
sizeof(T)-1)); }
2097 static const char*
format(
const T val) {
static const char *
s =
"unknown";
return s; }
2101 static const char*
string() {
static const char *
const s =
"bool";
return s; }
2103 static bool min() {
return false; }
2104 static bool max() {
return true; }
2106 static const char*
format(
const bool val) {
static const char*
s[] = {
"false",
"true" };
return s[val?1:0]; }
2109 template<>
struct type<unsigned char> {
2110 static const char*
string() {
static const char *
const s =
"unsigned char";
return s; }
2112 static unsigned char min() {
return 0; }
2113 static unsigned char max() {
return (
unsigned char)~0U; }
2115 static unsigned int format(
const unsigned char val) {
return (
unsigned int)val; }
2119 static const char*
string() {
static const char *
const s =
"char";
return s; }
2121 static char min() {
return (
char)(-1L<<(8*
sizeof(char)-1)); }
2122 static char max() {
return ~((char)(-1L<<(8*
sizeof(
char)-1))); }
2124 static int format(
const char val) {
return (
int)val; }
2127 template<>
struct type<signed char> {
2128 static const char*
string() {
static const char *
const s =
"signed char";
return s; }
2130 static signed char min() {
return (
signed char)(-1L<<(8*
sizeof(
signed char)-1)); }
2131 static signed char max() {
return ~((
signed char)(-1L<<(8*
sizeof(
signed char)-1))); }
2133 static unsigned int format(
const signed char val) {
return (
int)val; }
2136 template<>
struct type<unsigned short> {
2137 static const char*
string() {
static const char *
const s =
"unsigned short";
return s; }
2139 static unsigned short min() {
return 0; }
2140 static unsigned short max() {
return (
unsigned short)~0U; }
2142 static unsigned int format(
const unsigned short val) {
return (
unsigned int)val; }
2146 static const char*
string() {
static const char *
const s =
"short";
return s; }
2148 static short min() {
return (
short)(-1L<<(8*
sizeof(short)-1)); }
2149 static short max() {
return ~((short)(-1L<<(8*
sizeof(
short)-1))); }
2151 static int format(
const short val) {
return (
int)val; }
2154 template<>
struct type<unsigned int> {
2155 static const char*
string() {
static const char *
const s =
"unsigned int";
return s; }
2157 static unsigned int min() {
return 0; }
2158 static unsigned int max() {
return (
unsigned int)~0U; }
2160 static unsigned int format(
const unsigned int val) {
return val; }
2164 static const char*
string() {
static const char *
const s =
"int";
return s; }
2166 static int min() {
return (
int)(-1L<<(8*
sizeof(int)-1)); }
2167 static int max() {
return ~((int)(-1L<<(8*
sizeof(
int)-1))); }
2169 static int format(
const int val) {
return val; }
2172 template<>
struct type<unsigned long> {
2173 static const char*
string() {
static const char *
const s =
"unsigned long";
return s; }
2175 static unsigned long min() {
return 0; }
2176 static unsigned long max() {
return (
unsigned long)~0UL; }
2177 static const char*
format() {
return "%lu"; }
2178 static unsigned long format(
const unsigned long val) {
return val; }
2182 static const char*
string() {
static const char *
const s =
"long";
return s; }
2184 static long min() {
return (
long)(-1L<<(8*
sizeof(long)-1)); }
2185 static long max() {
return ~((long)(-1L<<(8*
sizeof(
long)-1))); }
2186 static const char*
format() {
return "%ld"; }
2187 static long format(
const long val) {
return val; }
2191 static const char*
string() {
static const char *
const s =
"float";
return s; }
2193 static float min() {
return -3.4E38f; }
2194 static float max() {
return 3.4E38f; }
2196 static double format(
const float val) {
return (
double)val; }
2200 static const char*
string() {
static const char *
const s =
"double";
return s; }
2202 static double min() {
return -1.7E308; }
2203 static double max() {
return 1.7E308; }
2205 static double format(
const double val) {
return val; }
2209 template<>
struct superset<bool,unsigned char> {
typedef unsigned char type; };
2211 template<>
struct superset<bool,signed char> {
typedef signed char type; };
2212 template<>
struct superset<bool,unsigned short> {
typedef unsigned short type; };
2214 template<>
struct superset<bool,unsigned int> {
typedef unsigned int type; };
2216 template<>
struct superset<bool,unsigned long> {
typedef unsigned long type; };
2221 template<>
struct superset<unsigned char,signed char> {
typedef short type; };
2222 template<>
struct superset<unsigned char,unsigned short> {
typedef unsigned short type; };
2224 template<>
struct superset<unsigned char,unsigned int> {
typedef unsigned int type; };
2226 template<>
struct superset<unsigned char,unsigned long> {
typedef unsigned long type; };
2230 template<>
struct superset<signed char,unsigned char> {
typedef short type; };
2232 template<>
struct superset<signed char,unsigned short> {
typedef int type; };
2234 template<>
struct superset<signed char,unsigned int> {
typedef long type; };
2236 template<>
struct superset<signed char,unsigned long> {
typedef long type; };
2251 template<>
struct superset<unsigned short,signed char> {
typedef int type; };
2253 template<>
struct superset<unsigned short,unsigned int> {
typedef unsigned int type; };
2255 template<>
struct superset<unsigned short,unsigned long> {
typedef unsigned long type; };
2258 template<>
struct superset<unsigned short,double> {
typedef double type; };
2267 template<>
struct superset<unsigned int,signed char> {
typedef long type; };
2270 template<>
struct superset<unsigned int,unsigned long> {
typedef unsigned long type; };
2280 template<>
struct superset<unsigned long,signed char> {
typedef long type; };
2290 template<
typename t1,
typename t2,
typename t3>
struct superset2 {
2294 template<
typename t1,
typename t2,
typename t3,
typename t4>
struct superset3 {
2298 template<
typename t1,
typename t2>
struct last {
typedef t2
type; };
2300 #define _cimg_Tt typename cimg::superset<T,t>::type
2301 #define _cimg_Tfloat typename cimg::superset<T,float>::type
2302 #define _cimg_Ttfloat typename cimg::superset2<T,t,float>::type
2307 volatile unsigned int nb_wins;
2308 pthread_t* event_thread;
2309 CImgDisplay* wins[1024];
2311 unsigned int nb_bits;
2316 #ifdef cimg_use_xrandr
2317 XRRScreenSize *resolutions;
2319 unsigned int curr_resolution;
2320 unsigned int nb_resolutions;
2322 X11info():nb_wins(0),event_thread(0),display(0),
2323 nb_bits(0),gc(0),blue_first(
false),byte_order(
false),shm_enabled(
false) {
2324 #ifdef cimg_use_xrandr
2327 curr_resolution = nb_resolutions = 0;
2331 #if defined(cimg_module)
2333 #elif defined(cimg_main)
2334 X11info& X11attr() {
static X11info val;
return val; }
2336 inline X11info& X11attr() {
static X11info val;
return val; }
2339 #elif cimg_display==2
2342 Win32info() { wait_event = CreateEvent(0,
FALSE,
FALSE,0); }
2344 #if defined(cimg_module)
2345 Win32info& Win32attr();
2346 #elif defined(cimg_main)
2347 Win32info& Win32attr() {
static Win32info val;
return val; }
2349 inline Win32info& Win32attr() {
static Win32info val;
return val; }
2352 #elif cimg_display==3
2354 MPCriticalRegionID windowListCR;
2356 pthread_t event_thread;
2357 MPSemaphoreID sync_event;
2358 MPSemaphoreID wait_event;
2359 MPQueueID com_queue;
2360 CarbonInfo(): windowCount(0),event_thread(0),sync_event(0),com_queue(0) {
2361 if (MPCreateCriticalRegion(&windowListCR) != noErr)
2362 throw CImgDisplayException(
"MPCreateCriticalRegion failed.");
2363 if (MPCreateSemaphore(1, 0, &sync_event) != noErr)
2364 throw CImgDisplayException(
"MPCreateSemaphore failed.");
2365 if (MPCreateSemaphore(1, 0, &wait_event) != noErr)
2366 throw CImgDisplayException(
"MPCreateSemaphore failed.");
2367 if (MPCreateQueue(&com_queue) != noErr)
2368 throw CImgDisplayException(
"MPCreateQueue failed.");
2371 if (event_thread != 0) {
2372 pthread_cancel(event_thread);
2373 pthread_join(event_thread, NULL);
2376 if (MPDeleteCriticalRegion(windowListCR) != noErr)
2377 throw CImgDisplayException(
"MPDeleteCriticalRegion failed.");
2378 if (MPDeleteSemaphore(wait_event) != noErr)
2379 throw CImgDisplayException(
"MPDeleteEvent failed.");
2380 if (MPDeleteSemaphore(sync_event) != noErr)
2381 throw CImgDisplayException(
"MPDeleteEvent failed.");
2382 if (MPDeleteQueue(com_queue) != noErr)
2383 throw CImgDisplayException(
"MPDeleteQueue failed.");
2386 #if defined(cimg_module)
2387 CarbonInfo& CarbonAttr();
2388 #elif defined(cimg_main)
2389 CarbonInfo CarbonAttr() {
static CarbonInfo val;
return val; }
2391 inline CarbonInfo& CarbonAttr() {
static CarbonInfo val;
return val; }
2397 const unsigned int keyESC = XK_Escape;
2398 const unsigned int keyF1 = XK_F1;
2399 const unsigned int keyF2 = XK_F2;
2400 const unsigned int keyF3 = XK_F3;
2401 const unsigned int keyF4 = XK_F4;
2402 const unsigned int keyF5 = XK_F5;
2403 const unsigned int keyF6 = XK_F6;
2404 const unsigned int keyF7 = XK_F7;
2405 const unsigned int keyF8 = XK_F8;
2406 const unsigned int keyF9 = XK_F9;
2407 const unsigned int keyF10 = XK_F10;
2408 const unsigned int keyF11 = XK_F11;
2409 const unsigned int keyF12 = XK_F12;
2410 const unsigned int keyPAUSE = XK_Pause;
2411 const unsigned int key1 = XK_1;
2412 const unsigned int key2 = XK_2;
2413 const unsigned int key3 = XK_3;
2414 const unsigned int key4 = XK_4;
2415 const unsigned int key5 = XK_5;
2416 const unsigned int key6 = XK_6;
2417 const unsigned int key7 = XK_7;
2418 const unsigned int key8 = XK_8;
2419 const unsigned int key9 = XK_9;
2420 const unsigned int key0 = XK_0;
2422 const unsigned int keyINSERT = XK_Insert;
2423 const unsigned int keyHOME = XK_Home;
2424 const unsigned int keyPAGEUP = XK_Page_Up;
2425 const unsigned int keyTAB = XK_Tab;
2426 const unsigned int keyQ = XK_q;
2427 const unsigned int keyW = XK_w;
2428 const unsigned int keyE = XK_e;
2429 const unsigned int keyR = XK_r;
2430 const unsigned int keyT = XK_t;
2431 const unsigned int keyY = XK_y;
2432 const unsigned int keyU = XK_u;
2433 const unsigned int keyI = XK_i;
2434 const unsigned int keyO = XK_o;
2435 const unsigned int keyP = XK_p;
2436 const unsigned int keyDELETE = XK_Delete;
2437 const unsigned int keyEND = XK_End;
2440 const unsigned int keyA = XK_a;
2441 const unsigned int keyS = XK_s;
2442 const unsigned int keyD = XK_d;
2443 const unsigned int keyF = XK_f;
2444 const unsigned int keyG = XK_g;
2445 const unsigned int keyH = XK_h;
2446 const unsigned int keyJ = XK_j;
2447 const unsigned int keyK = XK_k;
2448 const unsigned int keyL = XK_l;
2449 const unsigned int keyENTER = XK_Return;
2451 const unsigned int keyZ = XK_z;
2452 const unsigned int keyX = XK_x;
2453 const unsigned int keyC = XK_c;
2454 const unsigned int keyV = XK_v;
2455 const unsigned int keyB = XK_b;
2456 const unsigned int keyN = XK_n;
2457 const unsigned int keyM = XK_m;
2462 const unsigned int keyALT = XK_Alt_L;
2463 const unsigned int keySPACE = XK_space;
2464 const unsigned int keyALTGR = XK_Alt_R;
2466 const unsigned int keyMENU = XK_Menu;
2471 const unsigned int keyPAD0 = XK_KP_0;
2472 const unsigned int keyPAD1 = XK_KP_1;
2473 const unsigned int keyPAD2 = XK_KP_2;
2474 const unsigned int keyPAD3 = XK_KP_3;
2475 const unsigned int keyPAD4 = XK_KP_4;
2476 const unsigned int keyPAD5 = XK_KP_5;
2477 const unsigned int keyPAD6 = XK_KP_6;
2478 const unsigned int keyPAD7 = XK_KP_7;
2479 const unsigned int keyPAD8 = XK_KP_8;
2480 const unsigned int keyPAD9 = XK_KP_9;
2481 const unsigned int keyPADADD = XK_KP_Add;
2482 const unsigned int keyPADSUB = XK_KP_Subtract;
2483 const unsigned int keyPADMUL = XK_KP_Multiply;
2484 const unsigned int keyPADDIV = XK_KP_Divide;
2486 #elif cimg_display==2
2488 const unsigned int keyESC = VK_ESCAPE;
2489 const unsigned int keyF1 = VK_F1;
2490 const unsigned int keyF2 = VK_F2;
2491 const unsigned int keyF3 = VK_F3;
2492 const unsigned int keyF4 = VK_F4;
2493 const unsigned int keyF5 = VK_F5;
2494 const unsigned int keyF6 = VK_F6;
2495 const unsigned int keyF7 = VK_F7;
2496 const unsigned int keyF8 = VK_F8;
2497 const unsigned int keyF9 = VK_F9;
2498 const unsigned int keyF10 = VK_F10;
2499 const unsigned int keyF11 = VK_F11;
2500 const unsigned int keyF12 = VK_F12;
2501 const unsigned int keyPAUSE = VK_PAUSE;
2502 const unsigned int key1 =
'1';
2503 const unsigned int key2 =
'2';
2504 const unsigned int key3 =
'3';
2505 const unsigned int key4 =
'4';
2506 const unsigned int key5 =
'5';
2507 const unsigned int key6 =
'6';
2508 const unsigned int key7 =
'7';
2509 const unsigned int key8 =
'8';
2510 const unsigned int key9 =
'9';
2511 const unsigned int key0 =
'0';
2513 const unsigned int keyINSERT = VK_INSERT;
2514 const unsigned int keyHOME = VK_HOME;
2515 const unsigned int keyPAGEUP = VK_PRIOR;
2516 const unsigned int keyTAB = VK_TAB;
2517 const unsigned int keyQ =
'Q';
2518 const unsigned int keyW =
'W';
2519 const unsigned int keyE =
'E';
2520 const unsigned int keyR =
'R';
2521 const unsigned int keyT =
'T';
2522 const unsigned int keyY =
'Y';
2523 const unsigned int keyU =
'U';
2524 const unsigned int keyI =
'I';
2525 const unsigned int keyO =
'O';
2526 const unsigned int keyP =
'P';
2527 const unsigned int keyDELETE = VK_DELETE;
2528 const unsigned int keyEND = VK_END;
2531 const unsigned int keyA =
'A';
2532 const unsigned int keyS =
'S';
2533 const unsigned int keyD =
'D';
2534 const unsigned int keyF =
'F';
2535 const unsigned int keyG =
'G';
2536 const unsigned int keyH =
'H';
2537 const unsigned int keyJ =
'J';
2538 const unsigned int keyK =
'K';
2539 const unsigned int keyL =
'L';
2540 const unsigned int keyENTER = VK_RETURN;
2542 const unsigned int keyZ =
'Z';
2543 const unsigned int keyX =
'X';
2544 const unsigned int keyC =
'C';
2545 const unsigned int keyV =
'V';
2546 const unsigned int keyB =
'B';
2547 const unsigned int keyN =
'N';
2548 const unsigned int keyM =
'M';
2553 const unsigned int keyALT = VK_LMENU;
2554 const unsigned int keySPACE = VK_SPACE;
2555 const unsigned int keyALTGR = VK_CONTROL;
2557 const unsigned int keyMENU = VK_APPS;
2562 const unsigned int keyPAD0 = 0x60;
2563 const unsigned int keyPAD1 = 0x61;
2564 const unsigned int keyPAD2 = 0x62;
2565 const unsigned int keyPAD3 = 0x63;
2566 const unsigned int keyPAD4 = 0x64;
2567 const unsigned int keyPAD5 = 0x65;
2568 const unsigned int keyPAD6 = 0x66;
2569 const unsigned int keyPAD7 = 0x67;
2570 const unsigned int keyPAD8 = 0x68;
2571 const unsigned int keyPAD9 = 0x69;
2573 const unsigned int keyPADSUB = VK_SUBTRACT;
2574 const unsigned int keyPADMUL = VK_MULTIPLY;
2575 const unsigned int keyPADDIV = VK_DIVIDE;
2577 #elif cimg_display==3
2579 const unsigned int keyESC = kEscapeCharCode;
2580 const unsigned int keyF1 = 2U;
2581 const unsigned int keyF2 = 3U;
2582 const unsigned int keyF3 = 4U;
2583 const unsigned int keyF4 = 5U;
2584 const unsigned int keyF5 = 6U;
2585 const unsigned int keyF6 = 7U;
2586 const unsigned int keyF7 = 8U;
2587 const unsigned int keyF8 = 9U;
2588 const unsigned int keyF9 = 10U;
2589 const unsigned int keyF10 = 11U;
2590 const unsigned int keyF11 = 12U;
2591 const unsigned int keyF12 = 13U;
2593 const unsigned int key1 =
'1';
2594 const unsigned int key2 =
'2';
2595 const unsigned int key3 =
'3';
2596 const unsigned int key4 =
'4';
2597 const unsigned int key5 =
'5';
2598 const unsigned int key6 =
'6';
2599 const unsigned int key7 =
'7';
2600 const unsigned int key8 =
'8';
2601 const unsigned int key9 =
'9';
2602 const unsigned int key0 =
'0';
2605 const unsigned int keyHOME = kHomeCharCode;
2606 const unsigned int keyPAGEUP = kPageUpCharCode;
2607 const unsigned int keyTAB = kTabCharCode;
2608 const unsigned int keyQ =
'q';
2609 const unsigned int keyW =
'w';
2610 const unsigned int keyE =
'e';
2611 const unsigned int keyR =
'r';
2612 const unsigned int keyT =
't';
2613 const unsigned int keyY =
'y';
2614 const unsigned int keyU =
'u';
2615 const unsigned int keyI =
'i';
2616 const unsigned int keyO =
'o';
2617 const unsigned int keyP =
'p';
2618 const unsigned int keyDELETE = kDeleteCharCode;
2619 const unsigned int keyEND = kEndCharCode;
2620 const unsigned int keyPAGEDOWN = kPageDownCharCode;
2622 const unsigned int keyA =
'a';
2623 const unsigned int keyS =
's';
2624 const unsigned int keyD =
'd';
2625 const unsigned int keyF =
'f';
2626 const unsigned int keyG =
'g';
2627 const unsigned int keyH =
'h';
2628 const unsigned int keyJ =
'j';
2629 const unsigned int keyK =
'k';
2630 const unsigned int keyL =
'l';
2631 const unsigned int keyENTER = kEnterCharCode;
2633 const unsigned int keyZ =
'z';
2634 const unsigned int keyX =
'x';
2635 const unsigned int keyC =
'c';
2636 const unsigned int keyV =
'v';
2637 const unsigned int keyB =
'b';
2638 const unsigned int keyN =
'n';
2639 const unsigned int keyM =
'm';
2641 const unsigned int keyARROWUP = kUpArrowCharCode;
2644 const unsigned int keyALT = 66U;
2645 const unsigned int keySPACE = kSpaceCharCode;
2648 const unsigned int keyMENU = 69U;
2653 const unsigned int keyPAD0 = 74U;
2654 const unsigned int keyPAD1 = 75U;
2655 const unsigned int keyPAD2 = 76U;
2656 const unsigned int keyPAD3 = 77U;
2657 const unsigned int keyPAD4 = 78U;
2658 const unsigned int keyPAD5 = 79U;
2659 const unsigned int keyPAD6 = 80U;
2660 const unsigned int keyPAD7 = 81U;
2661 const unsigned int keyPAD8 = 82U;
2662 const unsigned int keyPAD9 = 83U;
2765 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2766 0x0,0x0,0x0,0x0,0x0,0x0,0x90,0x0,0x7f0000,0x40000,0x0,0x0,0x4010c0a4,0x82000040,0x11848402,0x18480050,0x80430292,0x8023,0x9008000,
2767 0x40218140,0x4000040,0x21800402,0x18000051,0x1060500,0x8083,0x10000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x24002,0x4031,0x80000000,0x10000,
2768 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x81c0400,0x40020000,0x80070080,0x40440e00,0x0,0x0,0x1,0x88180000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2769 0x0,0x200000,0x0,0x0,0x80000,0x0,0x0,0x20212140,0x5000020,0x22400204,0x240000a0,0x40848500,0x4044,0x80010038,0x20424285,0xa000020,
2770 0x42428204,0x2428e0a0,0x82090a14,0x4104,0x85022014,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10240a7,0x88484040,0x40800000,0x270c3,0x87811e0e,
2771 0x7c70e000,0x78,0x3c23c1ef,0x1f3e1e89,0xf1c44819,0xa23cf0f3,0xc3cff120,0xc18307f4,0x4040400,0x20000,0x80080080,0x40200,0x0,
2772 0x40000,0x2,0x8040000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x8188,0x50603800,0xf3c00000,0x1c004003,0xc700003e,0x18180,0xc993880,0x10204081,
2773 0x2071ef9,0xf3e7cf9f,0x3e7c7911,0xe3c78f1e,0x7d1224,0x48906048,0x0,0x4000000,0x0,0x9000,0x0,0x0,0x2000,0x0,0x0,0x0,0x0,0x0,0x0,
2774 0x0,0x10240aa,0x14944080,0x23610000,0x68940,0x40831010,0x8891306,0x802044,0x44522208,0x90202088,0x40448819,0xb242890a,0x24011111,
2775 0x49448814,0x4040a00,0xe2c3c7,0x8e3f3cb9,0xc1c44216,0xee38b0f2,0xe78f9120,0xc18507e2,0x8040000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2776 0x101c207,0x88a04001,0x9c00000,0x2200a041,0x8200113a,0x8240,0x50a3110,0x2850a142,0x850c2081,0x2040204,0x8104592,0x142850a1,
2777 0x42cd1224,0x4888bc48,0x70e1c387,0xe3b3c70,0xe1c38e1c,0x38707171,0xc3870e1c,0x10791224,0x48906c41,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2778 0x10003ee,0x15140080,0x21810000,0x48840,0x40851020,0x8911306,0x31fd804,0x9c522408,0x90204088,0x4045081a,0xba42890a,0x24011111,
2779 0x49285024,0x2041b00,0x132408,0x910844c8,0x4044821b,0x7244c913,0x24041111,0x49488822,0x8040000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2780 0x28204,0x85006001,0x6a414000,0x3a004043,0xc700113a,0x8245,0x50a3a00,0x2850a142,0x850c4081,0x2040204,0x81045d2,0x142850a1,
2781 0x24951224,0x48852250,0x8102040,0x81054089,0x12244204,0x8108992,0x24489122,0x991224,0x4888b222,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2782 0x1000143,0xa988080,0x2147c01f,0x88840,0x83091c2c,0x1070f000,0xc000608,0xa48bc408,0x9e3c46f8,0x40460816,0xaa42f10b,0xc3811111,
2783 0x35102044,0x1041100,0xf22408,0x9f084488,0x40470212,0x62448912,0x6041111,0x55308846,0x8061c80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2784 0x1028704,0x8f805801,0x4be28fdf,0x220001f0,0x111a,0x60000182,0x82c5c710,0x44891224,0x489640f1,0xe3c78204,0x810e552,0x142850a1,
2785 0x18a51224,0x48822250,0x78f1e3c7,0x8f1f40f9,0xf3e7c204,0x8108912,0x24489122,0x7ea91224,0x4888a222,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2786 0x10007e2,0x85648080,0x20010000,0x88841,0x8f8232,0x20881000,0xc1fc610,0xbefa2408,0x90204288,0x40450816,0xa642810a,0x4041110a,
2787 0x36282084,0x1042080,0x1122408,0x90084488,0x40450212,0x62448912,0x184110a,0x55305082,0x8042700,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2788 0x1028207,0x82004801,0x68050040,0x1c000040,0x110a,0x60000001,0x45484d10,0x7cf9f3e7,0xcf944081,0x2040204,0x8104532,0x142850a1,
2789 0x18a51224,0x48822248,0x89122448,0x91244081,0x2040204,0x8108912,0x24489122,0xc91224,0x48852214,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x282,
2790 0x89630080,0x20010c00,0x30108842,0x810222,0x20882306,0x3001800,0x408a2208,0x90202288,0x40448814,0xa642810a,0x2041110a,0x26442104,
2791 0x840000,0x1122408,0x90084488,0x40448212,0x62448912,0x84130a,0x36485102,0x8040000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x101c208,0x4f802801,
2792 0x8028040,0x40,0x130a,0x2,0x85e897a0,0x44891224,0x489c2081,0x2040204,0x8104532,0x142850a1,0x24cd1224,0x48823c44,0x89122448,
2793 0x91244081,0x2040204,0x8108912,0x24489122,0xc93264,0xc9852214,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100028f,0x109f0080,0x20010c00,
2794 0x303071f3,0xc7011c1c,0x4071c306,0x802010,0x3907c1ef,0x1f201e89,0xf3844f90,0xa23c80f2,0x17810e04,0x228223f4,0x840000,0xfbc3c7,
2795 0x8f083c88,0x40444212,0x6238f0f2,0x7039d04,0x228423e2,0x8040000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1008780,0x2201800,0xf0014000,0x1f0,
2796 0x1d0a,0x5,0x851e140,0x83060c18,0x30671ef9,0xf3e7cf9f,0x3e7c7911,0xe3c78f1e,0x42f8e1c3,0x8702205c,0x7cf9f3e7,0xcf9b3c78,0xf1e3c204,
2797 0x8107111,0xc3870e1c,0x10f1d3a7,0x4e823c08,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x40,0x40000400,0x200000,0x0,0x2,0x0,0x0,0x0,0x0,0x18,
2798 0x0,0x4,0x44007f,0x0,0x400,0x400000,0x8010,0x0,0x6002,0x8040000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1000000,0x200800,0x0,0x0,0x100a,
2799 0x400000,0x44,0x0,0x400,0x0,0x0,0x0,0x0,0x0,0x0,0x800,0x0,0x0,0x0,0x0,0x62018,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x31,0x80000800,
2800 0x400000,0x0,0x4,0x0,0x0,0x0,0x0,0xc,0x0,0x7,0x3c0000,0x0,0x3800,0x3800000,0x8010,0x0,0x1c001,0x881c0000,0x0,0x0,0x0,0x0,0x0,0x0,
2801 0x0,0x0,0x207000,0x0,0x0,0x100a,0xc00000,0x3c,0x0,0xc00,0x0,0x0,0x0,0x0,0x0,0x0,0x1800,0x0,0x0,0x0,0x0,0x1c2070
2806 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2807 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80100c0,
2808 0x68000300,0x801,0xc00010,0x100c000,0x68100,0x100c0680,0x2,0x403000,0x1000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2809 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2810 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfc,0x0,0x0,0x0,0x0,0x0,0x4020120,
2811 0x58120480,0x402,0x1205008,0x2012050,0x58080,0x20120581,0x40000001,0x804812,0x2000000,0x0,0x300,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2812 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x140,0x80000,0x200402,0x800000,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2813 0x0,0x7010,0x7000000,0x8000200,0x20000,0xc0002000,0x8008,0x0,0x0,0x0,0x0,0x808,0x4000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2814 0x0,0x0,0x80000000,0x0,0x0,0x0,0x40000,0x0,0x0,0x0,0x0,0x480,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x70,0x80100c0,0x68000480,0x1001,
2815 0xc00010,0x1018000,0x68100,0x100c0680,0x4,0x403000,0x1020000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20140,0x28081883,0x200801,
2816 0x2a00000,0x10,0x1c0201c0,0x70040f80,0xc0f81c07,0x0,0x70,0x3e0303c0,0x3c3c0f83,0xe03c2107,0xe08810,0x18c31070,0x3c0703c0,
2817 0x783e0842,0x22222208,0x83e04010,0x1008000,0x4000200,0x20001,0x2002,0x408008,0x0,0x0,0x100000,0x0,0x1008,0x2000000,0x0,0x0,0x0,
2818 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20080,0x38000880,0x8078140f,0x81c00000,0x3e000,0xc020180,0x60080001,0xe0000002,0xc00042,0x108e2010,
2819 0xc0300c0,0x300c0303,0xf83c3e0f,0x83e0f81c,0x701c070,0x3c0c41c0,0x701c0701,0xc0001d08,0x42108421,0x8820088,0x4020120,0x58140480,
2820 0x802,0x1205008,0x3014050,0xc058080,0x20120581,0x40000002,0x804814,0x2020050,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20140,
2821 0x281e2484,0x80200801,0x1c02000,0x10,0x22060220,0x880c0801,0x82208,0x80000001,0x20008,0x41030220,0x40220802,0x402102,0x209010,
2822 0x18c31088,0x22088220,0x80080842,0x22222208,0x80204010,0x1014000,0x200,0x20001,0x2000,0x8008,0x0,0x0,0x100000,0x0,0x1008,
2823 0x2000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x40000500,0x80800010,0x40200000,0x41000,0x12020040,0x10000003,0xa0000006,
2824 0x12000c4,0x31014000,0xc0300c0,0x300c0302,0x80402008,0x2008008,0x2008020,0x220c4220,0x88220882,0x20002208,0x42108421,0x8820088,
2825 0x0,0x300,0x0,0x0,0x0,0x14000000,0x0,0x200200,0x0,0x20000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20000,0xfc282504,0x80001000,
2826 0x82a02000,0x20,0x22020020,0x8140802,0x102208,0x80801006,0x18008,0x9c848220,0x80210802,0x802102,0x20a010,0x15429104,0x22104220,
2827 0x80080842,0x22221405,0x404008,0x1022000,0x703c0,0x381e0701,0xc0783c02,0xc09008,0x1d83c070,0x3c078140,0x381c0882,0x21242208,
2828 0x81e01008,0x2000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x201e0,0x40220500,0x80800027,0x20e02800,0x9c800,0x12020040,
2829 0x20000883,0xa0200002,0x120a044,0x11064010,0x12048120,0x48120484,0x80802008,0x2008008,0x2008020,0x210a4411,0x4411044,0x10884508,
2830 0x42108421,0x503c0b0,0x1c0701c0,0x701c0707,0x70381c07,0x1c07008,0x2008020,0x20f01c0,0x701c0701,0xc0201c08,0x82208822,0x883c088,
2831 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20000,0x50281903,0x20001000,0x80802000,0x20,0x22020040,0x30240f03,0xc0101c08,0x80801018,
2832 0x1fc06010,0xa48483c0,0x80210f03,0xe0803f02,0x20c010,0x15429104,0x22104220,0x70080841,0x41540805,0x804008,0x1041000,0x8220,
2833 0x40220881,0x882202,0x40a008,0x12422088,0x22088180,0x40100882,0x21241408,0x80201008,0x2031000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2834 0x0,0x20280,0x401c0200,0x700028,0x21205000,0x92800,0xc1fc080,0x10000883,0xa0200002,0x1205049,0x12c19010,0x12048120,0x48120484,
2835 0xf0803c0f,0x3c0f008,0x2008020,0x790a4411,0x4411044,0x10504908,0x42108421,0x5022088,0x2008020,0x8020080,0x88402208,0x82208808,
2836 0x2008020,0x1e088220,0x88220882,0x20002608,0x82208822,0x8822088,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20000,0x501c0264,
2837 0xa0001000,0x8001fc00,0x7000020,0x22020080,0x83e0082,0x20202207,0x80000020,0x1020,0xa4848220,0x80210802,0x9c2102,0x20c010,
2838 0x12425104,0x3c1043c0,0x8080841,0x41540802,0x804008,0x1000000,0x78220,0x40220f81,0x882202,0x40c008,0x12422088,0x22088100,
2839 0x60100881,0x41540805,0x406008,0x1849000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20280,0xf0140200,0x880028,0x20e0a03f,0x709c800,
2840 0x201c0,0x60000881,0xa0000007,0xc0284b,0x122eb020,0x12048120,0x48120487,0x80802008,0x2008008,0x2008020,0x21094411,0x4411044,
2841 0x10204908,0x42108421,0x2022088,0x1e0781e0,0x781e0787,0xf8403e0f,0x83e0f808,0x2008020,0x22088220,0x88220882,0x21fc2a08,0x82208822,
2842 0x5022050,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20001,0xf80a0294,0x40001000,0x80002000,0x20,0x22020100,0x8040082,0x20202200,
2843 0x80000018,0x1fc06020,0xa48fc220,0x80210802,0x842102,0x20a010,0x12425104,0x20104240,0x8080841,0x41541402,0x1004008,0x1000000,
2844 0x88220,0x40220801,0x882202,0x40a008,0x12422088,0x22088100,0x18100881,0x41540805,0x801008,0x2046000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2845 0x0,0x0,0x0,0x20280,0x401c0f80,0x80880028,0x20005001,0x94800,0x20000,0x880,0xa0000000,0x5015,0x4215040,0x3f0fc3f0,0xfc3f0fc8,
2846 0x80802008,0x2008008,0x2008020,0x21094411,0x4411044,0x10505108,0x42108421,0x203c088,0x22088220,0x88220888,0x80402008,0x2008008,
2847 0x2008020,0x22088220,0x88220882,0x20002a08,0x82208822,0x5022050,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xa00a0494,0x60001000,
2848 0x80002004,0x8020,0x22020200,0x88040882,0x20402201,0x801006,0x18000,0x9f084220,0x40220802,0x442102,0x209010,0x10423088,0x20088220,
2849 0x8080840,0x80882202,0x2004008,0x1000000,0x88220,0x40220881,0x882202,0x409008,0x12422088,0x22088100,0x8100880,0x80881402,
2850 0x1001008,0x2000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20280,0x40220200,0x80700027,0x20002801,0x92800,0x1fc000,0x980,
2851 0xa0000000,0xa017,0x84417840,0x21084210,0x84210848,0x80402008,0x2008008,0x2008020,0x2208c220,0x88220882,0x20882208,0x42108421,
2852 0x2020088,0x22088220,0x88220888,0xc8402208,0x82208808,0x2008020,0x22088220,0x88220882,0x20203208,0x82208822,0x2022020,0x0,0x0,0x0,
2853 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20000,0xa03c0463,0x90000801,0x2004,0x8040,0x1c0703e0,0x70040701,0xc0401c06,0x801001,0x20020,
2854 0x400843c0,0x3c3c0f82,0x3c2107,0x1c0881e,0x10423070,0x20070210,0xf0080780,0x80882202,0x3e04004,0x1000000,0x783c0,0x381e0701,
2855 0x782202,0x408808,0x12422070,0x3c078100,0x700c0780,0x80882202,0x1e01008,0x2000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x201e0,
2856 0xf8000200,0x80080010,0x40000001,0x41000,0x0,0xe80,0xa0000000,0x21,0x8e21038,0x21084210,0x84210848,0xf83c3e0f,0x83e0f81c,
2857 0x701c070,0x3c08c1c0,0x701c0701,0xc0005c07,0x81e0781e,0x20200b0,0x1e0781e0,0x781e0787,0x30381c07,0x1c07008,0x2008020,0x1c0881c0,
2858 0x701c0701,0xc0201c07,0x81e0781e,0x203c020,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80000,0x801,0x4,0x40,0x0,0x0,0x0,0x1000,
2859 0x0,0x3c000000,0x0,0x0,0x0,0x0,0x10000,0x0,0x0,0x4004,0x1000000,0x0,0x0,0x80000,0x400000,0x0,0x20008000,0x0,0x4,0x1008,0x2000000,
2860 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x8008000f,0x80000000,0x3e000,0x0,0x800,0xa0000400,0x0,0x0,0x0,0x0,0x80000,0x0,
2861 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100000,0x0,0x0,0x0,0x0,0x2000,0x0,0x4020040,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80000,
2862 0x402,0x8,0x40,0x0,0x0,0x0,0x2000,0x0,0x0,0x0,0x0,0x0,0x0,0xc000,0x0,0x0,0x7004,0x70000fc,0x0,0x0,0x700000,0x800000,0x0,0x20008000,
2863 0x0,0x4,0x808,0x4000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x80f00000,0x0,0x0,0x0,0x800,0xa0001800,0x0,0x0,0x0,0x0,
2864 0x300000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x600000,0x0,0x0,0x0,0x0,0x0,0x0,0x4020040
2869 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2870 0x0,0x0,0x0,0x2400,0x2400,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20081834,0x1c0000,0x20081800,0x20081800,0x342008,
2871 0x18340000,0x200818,0x80000,0x0,0x180000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4200000,0x0,0x0,
2872 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x380000,0x4000,0x2000c00,0x40100840,0x70000000,0x0,0x0,0x1c,0x10700000,0x7,0x0,
2873 0x1800,0x1800,0x0,0x0,0x0,0x14,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1010242c,0x14140000,0x10102414,0x10102414,0x2c1010,0x242c1400,
2874 0x101024,0x14100038,0x0,0x240000,0x0,0x0,0x30000000,0x0,0x0,0x4000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x12,0x0,0x8100000,0x0,
2875 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10,0x80000,0x10004000,0x2001000,0x40000040,0x10000000,0x0,0x0,0x10,0x10100000,0x4,
2876 0x0,0x18000000,0x0,0x0,0x0,0x34002400,0x2400,0x0,0x0,0x0,0x3c,0x0,0x8000000,0x0,0x60607800,0x0,0x140000,0x0,0x0,0x0,0x0,0x0,
2877 0x44,0x10081834,0x240000,0x10081800,0x10081800,0x1c341008,0x18340000,0x100818,0x84000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x102812,
2878 0x8601c10,0x8100800,0x2,0x1c383e3e,0x67e1e7f,0x3e3c0000,0x38,0x1e087e1e,0x7c7f7f1e,0x417c1c42,0x4063611c,0x7e1c7e3e,0xfe414181,
2879 0x63827f10,0x40081000,0x8004000,0x2001000,0x40000040,0x10000000,0x0,0x10000000,0x10,0x10100000,0x3c000008,0x0,0x24003e00,
2880 0x3f007f00,0x0,0x0,0x2ce91800,0x1882,0x10101c,0xc2103c,0x143c3c00,0x3c00,0x18003c3c,0x10001f00,0x181c00,0x20200810,0x8080808,
2881 0x8083e1e,0x7f7f7f7f,0x7c7c7c7c,0x7c611c1c,0x1c1c1c00,0x1e414141,0x41824044,0x810242c,0x14180000,0x8102414,0x8102414,0x382c0810,
2882 0x242c1400,0x81024,0x14104014,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x102816,0x3e902010,0x10084910,0x4,0x22084343,0xa402102,0x41620000,
2883 0x44,0x33144121,0x42404021,0x41100444,0x40636122,0x43224361,0x10416381,0x22440310,0x20082800,0x4000,0x2001000,0x40000040,
2884 0x10000000,0x0,0x10000000,0x10,0x10100000,0x24000008,0x0,0x606100,0x68000300,0x8106c,0x34000000,0x4f0000,0x44,0x101020,0x441040,
2885 0x420200,0x4200,0x24000404,0x7d00,0x82200,0x20203010,0x14141414,0x14082821,0x40404040,0x10101010,0x42612222,0x22222200,0x23414141,
2886 0x41447e48,0x0,0x0,0x0,0x0,0x4000000,0x18,0x0,0x4000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10287f,0x49902010,0x10083e10,0x4,0x41080101,
2887 0x1a404002,0x41411818,0x1004004,0x21144140,0x41404040,0x41100448,0x40555141,0x41414140,0x10412281,0x14280610,0x20084400,0x1c7c1c,
2888 0x3e3c7c3a,0x5c703844,0x107f5c3c,0x7c3e3c3c,0x7e424281,0x66427e10,0x10100000,0x40100008,0x1010,0xa04000,0x48100610,0x100c3024,
2889 0x24000000,0x4f3c00,0x2c107e28,0x3820,0x42281060,0x9d1e12,0xbd00,0x24100818,0x427d00,0x82248,0x20200800,0x14141414,0x14142840,
2890 0x40404040,0x10101010,0x41514141,0x41414142,0x43414141,0x41284350,0x1c1c1c1c,0x1c1c6c1c,0x3c3c3c3c,0x70707070,0x3c5c3c3c,
2891 0x3c3c3c18,0x3e424242,0x42427c42,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x102824,0x48623010,0x10081c10,0x8,0x41080103,0x127c5e04,
2892 0x41411818,0xe7f3808,0x4f144140,0x41404040,0x41100450,0x40555141,0x41414160,0x1041225a,0x1c280410,0x1008c600,0x226622,0x66661066,
2893 0x62100848,0x10496266,0x66663242,0x10426681,0x24220260,0x100c0000,0xf8280008,0x1010,0x606000,0x48280428,0x28042014,0x48000000,
2894 0x494200,0x52280228,0x105420,0x3cee1058,0xa12236,0xa500,0x18101004,0x427d00,0x8226c,0x76767e10,0x14141414,0x14142840,0x40404040,
2895 0x10101010,0x41514141,0x41414124,0x45414141,0x41284150,0x22222222,0x22221222,0x66666666,0x10101010,0x66626666,0x66666600,
2896 0x66424242,0x42226622,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100024,0x381c4900,0x10086bfe,0x8,0x4908021c,0x22036304,0x3e630000,
2897 0x70000710,0x51227e40,0x417f7f43,0x7f100470,0x40554941,0x43417e3e,0x1041225a,0x8100810,0x10080000,0x24240,0x42421042,0x42100850,
2898 0x10494242,0x42422040,0x1042245a,0x18240410,0x10103900,0x407c003e,0x1818,0x1c3e10,0x4f7c087c,0x7c002010,0x48000000,0x4008,
2899 0x527c0410,0x105078,0x2410104c,0xa13e6c,0x7f00b900,0xfe3c3c,0x421d18,0x1c1c36,0x38383810,0x22222222,0x22144e40,0x7f7f7f7f,
2900 0x10101010,0xf1494141,0x41414118,0x49414141,0x4110435c,0x2020202,0x2021240,0x42424242,0x10101010,0x42424242,0x424242ff,0x4e424242,
2901 0x42244224,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1000fe,0xe664d00,0x10080810,0x380010,0x41080c03,0x42014108,0x633d0000,0x70000710,
2902 0x51224140,0x41404041,0x41100448,0x40494541,0x7e414203,0x1041145a,0x14101010,0x10080000,0x3e4240,0x427e1042,0x42100870,0x10494242,
2903 0x4242203c,0x1042245a,0x18241810,0x10104600,0xf8f60008,0x1010,0x600320,0x48f610f6,0xf6000000,0x187eff,0x3c04,0x5ef61810,0x105020,
2904 0x24fe0064,0x9d006c,0x138ad00,0x100000,0x420518,0x36,0xc0c0c020,0x22222222,0x22224840,0x40404040,0x10101010,0x41454141,0x41414118,
2905 0x51414141,0x41107e46,0x3e3e3e3e,0x3e3e7e40,0x7e7e7e7e,0x10101010,0x42424242,0x42424200,0x5a424242,0x42244224,0x0,0x0,0x0,
2906 0x0,0x0,0x0,0x0,0x0,0x28,0x9094500,0x10080010,0x10,0x41081801,0x7f014118,0x41010000,0xe7f3800,0x513e4140,0x41404041,0x41100444,
2907 0x40414541,0x40414101,0x10411466,0x36103010,0x8080000,0x424240,0x42401042,0x42100848,0x10494242,0x42422002,0x10423c5a,0x18142010,
2908 0x10100000,0x407c0010,0x1010,0x260140,0x487c307c,0x7c000000,0x180000,0x202,0x507c2010,0x105020,0x3c10003c,0x423e36,0x1004200,
2909 0x100000,0x420500,0x3e6c,0x41e0440,0x3e3e3e3e,0x3e3e7840,0x40404040,0x10101010,0x41454141,0x41414124,0x61414141,0x41104042,
2910 0x42424242,0x42425040,0x40404040,0x10101010,0x42424242,0x42424218,0x72424242,0x42144214,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100048,
2911 0x49096200,0x8100010,0x18001810,0x22082043,0x2432310,0x61421818,0x1004010,0x4f634121,0x42404021,0x41104444,0x40414322,0x40234143,
2912 0x10411466,0x22106010,0x8080000,0x466622,0x66621066,0x42100844,0x10494266,0x66662042,0x10461824,0x24184010,0x10100000,0x24381010,
2913 0x34001018,0xda4320,0x68386038,0x38000000,0x0,0x4204,0x50384010,0x105420,0x4210100c,0x3c0012,0x3c00,0x0,0x460500,0x48,0xc020c44,
2914 0x63636363,0x63228821,0x40404040,0x10101010,0x42432222,0x22222242,0x62414141,0x41104042,0x46464646,0x46465022,0x62626262,
2915 0x10101010,0x66426666,0x66666618,0x66464646,0x46186618,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100048,0x3e063d00,0x8100000,0x18001820,
2916 0x1c3e7f3e,0x23c1e20,0x3e3c1818,0x10,0x20417e1e,0x7c7f401e,0x417c3842,0x7f41431c,0x401e40be,0x103e0866,0x41107f10,0x4080000,
2917 0x3a5c1c,0x3a3c103a,0x427c0842,0xe49423c,0x7c3e203c,0xe3a1824,0x66087e10,0x10100000,0x3c103010,0x245a1010,0x5a3e10,0x3f107f10,
2918 0x10000000,0x0,0x3c08,0x2e107e10,0x1038fc,0x101004,0x0,0x0,0xfe0000,0x7f0500,0x0,0x14041438,0x41414141,0x41418e1e,0x7f7f7f7f,
2919 0x7c7c7c7c,0x7c431c1c,0x1c1c1c00,0xbc3e3e3e,0x3e10405c,0x3a3a3a3a,0x3a3a6e1c,0x3c3c3c3c,0x7c7c7c7c,0x3c423c3c,0x3c3c3c00,
2920 0x7c3a3a3a,0x3a087c08,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x8000000,0x4200000,0x10000020,0x0,0x0,0x10,0x0,0x30000000,0x0,
2921 0x0,0x0,0x60000,0x0,0x1c,0x4380000,0x0,0x2,0x800,0x0,0x40020000,0x0,0x8000c,0x10600000,0x2010,0x48000000,0x240000,0x0,0x0,
2922 0x0,0x0,0x0,0x1000,0x1078,0x0,0x0,0x0,0x400500,0x0,0x1e081e00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2923 0x84008,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x8000000,0x0,0x20000040,0x0,0x0,0x20,0x0,0x1e000000,0x0,0x0,0x0,0x20000,0x0,
2924 0x0,0x2000000,0x0,0x26,0x800,0x0,0x40020000,0x0,0x100000,0x10000000,0x2030,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x1000,0x0,
2925 0x0,0x0,0x400000,0x8000000,0x41e0400,0x0,0x4,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x0,0x0,0x104010,0x0,0x0,0x0,0x0,
2926 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfe,0x0,0x1c,0x7000,0x0,0x40020000,0x0,0x300000,
2927 0x0,0xe0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x0,0x0,0x0,0x400000,0x38000000,0x0,0x0,0x1c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2928 0x1c,0x0,0x0,0x0,0x0,0x0,0x304030,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2929 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2930 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2931 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2932 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 };
2936 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2937 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3600000,0x36000,0x0,0x0,0x0,0x0,0x6c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2938 0x0,0x180181c0,0xe81b0300,0x1801,0x81c06c18,0x181c06c,0xe8180,0x181c0e81,0xb0000006,0x60701b,0x1800000,0x0,0x0,0x0,0x0,0x0,
2939 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2940 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c00000,0x1c000,0x0,0x0,0x0,0x0,0x6c,0x0,0x0,0x0,0x0,
2941 0x0,0x0,0x0,0x0,0x0,0x0,0xc030360,0xb81b0480,0xc03,0x3606c0c,0x303606c,0xb80c0,0x30360b81,0xb0000003,0xc0d81b,0x3000000,0x0,
2942 0x300,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
2943 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x30000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x800,0x0,0x0,0x0,0x0,0x0,0x2200000,
2944 0x22000,0x0,0x0,0x0,0x0,0x0,0x0,0x30000,0x0,0xe0,0x38078000,0x0,0x480,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3000c080,0x480,0x3000,
2945 0xc0800030,0xc08000,0x300,0xc080000,0xc,0x302000,0xc00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20120,0x41c01,0xe020060c,
2946 0x800000,0x4,0x1e0703e0,0xf8060fc1,0xe1fe1e07,0x80000000,0x78,0x307e0,0x3c7c1fe7,0xf83c408f,0x80f10440,0x18660878,0x7e0787e0,
2947 0x78ff9024,0xa0140a0,0x27f83840,0x700e000,0x18000400,0x8000,0x70004002,0x410078,0x0,0x0,0x0,0x0,0x1808,0xc000000,0xf000000,
2948 0xe000000,0x1400,0x1e0001f,0x8007f800,0x0,0x0,0x3a3b,0x61400000,0x14202,0x20000,0x38002020,0x3c1b00,0x3e00000,0xf8,0x1c0001c0,
2949 0x78060001,0xf800000e,0x1e00020,0x8004020,0xc0300c0,0x300c0301,0xf83c7f9f,0xe7f9fe3e,0xf83e0f8,0x7c1821e0,0x781e0781,0xe0001f10,
2950 0x24090240,0xa02400f8,0x18018140,0xe81b0480,0x1801,0x81406c18,0x181406c,0x190e8180,0x18140e81,0xb0000006,0x60501b,0x184006c,
2951 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20120,0x26042202,0x200c06,0x800000,0x8,0x210d0611,0x40e0803,0x10026188,0x40000000,
2952 0x8c,0xf030418,0xc6431004,0xc64082,0x110840,0x18660884,0x41084410,0x8c081024,0xa012110,0x40082020,0x101b000,0xc000400,0x8000,
2953 0x80004002,0x410008,0x0,0x0,0x100000,0x0,0x2008,0x2000000,0x18800000,0x10000000,0x2200,0x2300024,0x800,0x0,0x0,0x2e13,0x60800000,
2954 0x8104,0x20040,0x64001040,0x80401b07,0x80100000,0x1e000,0x22000020,0x40c0003,0xc8000002,0x3300020,0x8004020,0xc0300c0,0x300c0301,
2955 0x40c64010,0x4010008,0x2008020,0x43182210,0x84210842,0x10002190,0x24090240,0x9044018c,0xc030220,0xb81b0300,0xc03,0x2206c0c,
2956 0x302206c,0x1e0b80c0,0x30220b81,0xb0000003,0xc0881b,0x304006c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20120,0x241f2202,
2957 0x200802,0x4900000,0x8,0x21010408,0x20a0802,0x44090,0x20000000,0x4,0x11878408,0x80411004,0x804082,0x111040,0x1ce50986,0x40986409,
2958 0x81022,0x12012108,0x80102020,0x1031800,0x400,0x8000,0x80004000,0x10008,0x0,0x0,0x100000,0x0,0x2008,0x2000000,0x10000000,
2959 0x10000000,0x18,0x4000044,0x1000,0x30180,0xd81b0000,0x13,0xe0000000,0x88,0x40,0x400018c0,0x80400018,0x61f00000,0x61800,0x22020020,
2960 0x4000007,0xc8000002,0x2100020,0x8038000,0x1e0781e0,0x781e0301,0x40804010,0x4010008,0x2008020,0x41142619,0x86619866,0x18002190,
2961 0x24090240,0x8887e104,0x0,0x0,0x0,0x0,0x0,0x2000000,0x0,0x0,0x0,0x40000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20120,0x2434a202,
2962 0x200802,0x3e00000,0x10,0x40810008,0x21a0804,0x44090,0x20000000,0x80040004,0x20848409,0x409004,0x1004082,0x112040,0x14a50902,
2963 0x40902409,0x81022,0x11321208,0x80202010,0x1060c00,0x7c5e0,0x781e8783,0xf07a5f0e,0x1c10808,0xfc5f078,0x5e07a170,0x7c7e1024,
2964 0xa016190,0x27f82008,0x2000000,0x20000000,0x10000000,0x80200024,0x4000044,0x2000,0x18180,0xc8320000,0x12,0xa1f00037,0x7f888,
2965 0x1e0,0x40410880,0x80600017,0xa2100000,0x5e800,0x22020040,0x38001027,0xc8000002,0x2100020,0x8004020,0x12048120,0x48120482,
2966 0x41004010,0x4010008,0x2008020,0x40942409,0x2409024,0x9044390,0x24090240,0x88841918,0x1f07c1f0,0x7c1f07c3,0x70781e07,0x81e07838,
2967 0xe0380e0,0x1f17c1e0,0x781e0781,0xe0001f90,0x24090240,0x9025e102,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20001,0xff241c41,
2968 0x1001,0x1c02000,0x10,0x40810008,0x6120f85,0xe0086190,0x20c03007,0x8007800c,0x27848419,0x409004,0x1004082,0x114040,0x14a48902,
2969 0x40902409,0x81022,0x11321205,0x602010,0x1000000,0x86610,0x84218840,0x80866182,0x411008,0x9261884,0x61086189,0x82101022,0x12012108,
2970 0x40082008,0x2000000,0x20030000,0x20000000,0x80200024,0x4000044,0x3006030,0xc018100,0x4c260000,0x12,0x26080048,0x83000850,
2971 0x20250,0x403e0500,0x8078002c,0x12302200,0x92400,0x1c0200c0,0x4001027,0xc8000002,0x3308820,0x8004020,0x12048120,0x48120482,
2972 0x41004010,0x4010008,0x2008020,0x40922409,0x2409024,0x8884690,0x24090240,0x85040920,0x21886218,0x86218860,0x88842108,0x42108408,
2973 0x2008020,0x21186210,0x84210842,0x10302190,0x24090240,0x88461084,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20000,0x4c240182,
2974 0x80001001,0x6b02000,0x20,0x4c810010,0x78220846,0x10081e10,0x20c0301c,0x1fe0e018,0x4d8487e1,0x409fe7,0xf9007f82,0x11a040,
2975 0x13248902,0x41102418,0xe0081022,0x11320c05,0x402008,0x1000000,0x2409,0x409020,0x81024082,0x412008,0x9240902,0x40902101,0x101022,
2976 0x11321208,0x40102008,0x2000000,0x7e0c8000,0xfc000003,0xf0fc0018,0x43802047,0x8c8040c8,0x32008300,0x44240000,0x0,0x4000048,
2977 0x8c801050,0x20440,0x40221dc0,0x808c0028,0x11d0667f,0x8009c400,0x1fc180,0x4001023,0xc8300002,0x1e0ccfb,0x3ec7b020,0x12048120,
2978 0x48120482,0x79007f9f,0xe7f9fe08,0x2008020,0xf0922409,0x2409024,0x8504490,0x24090240,0x85040920,0x802008,0x2008020,0x89004090,
2979 0x24090208,0x2008020,0x40902409,0x2409024,0x8304390,0x24090240,0x88440884,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20000,
2980 0x481c0606,0xc8001001,0x802000,0x20,0x4c810020,0x4220024,0x8102108,0x60000070,0x3820,0x48884419,0x409004,0x10e4082,0x112040,
2981 0x13244902,0x7e1027e0,0x3c081021,0x21320c02,0x802008,0x1000000,0x7e409,0x409020,0x81024082,0x414008,0x9240902,0x40902101,
2982 0x80101022,0x11320c08,0x40202008,0x2038800,0x200bc000,0x20000000,0x80200003,0x80f04044,0xbc080bc,0x2f000200,0x0,0x0,0x6001048,
2983 0x8bc02020,0x20441,0xf8220200,0x80820028,0x1000cc00,0x80094400,0x201e0,0x78001021,0xc830000f,0x8000663c,0xf03c0c0,0x21084210,
2984 0x84210846,0x41004010,0x4010008,0x2008020,0x40912409,0x2409024,0x8204890,0x24090240,0x82040930,0x1f87e1f8,0x7e1f87e0,0x89004090,
2985 0x24090208,0x2008020,0x40902409,0x2409024,0x8004690,0x24090240,0x88440884,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20000,
2986 0x480719c4,0x48001001,0x81fc00,0x7800020,0x40810040,0x2420024,0x8104087,0xa0000070,0x3820,0x48884409,0x409004,0x1024082,0x111040,
2987 0x13244902,0x40102410,0x2081021,0x214a1202,0x1802008,0x1000000,0x182409,0x409fe0,0x81024082,0x41a008,0x9240902,0x40902100,
2988 0xf8101021,0x214a0c04,0x80c0c008,0x1847000,0x7c1ee000,0x20000000,0x8020000c,0x8c044,0x1ee181ee,0x7b800000,0x707,0xf3ff0000,
2989 0x3e0084f,0x9ee0c020,0x20440,0x40221fc0,0xc2002c,0x13f11000,0x87892400,0x20000,0x1020,0x48000000,0x3f011c6,0x31cc6180,0x21084210,
2990 0x84210844,0x41004010,0x4010008,0x2008020,0x40912409,0x2409024,0x8505090,0x24090240,0x8204191c,0x60982609,0x82609823,0xf9007f9f,
2991 0xe7f9fe08,0x2008020,0x40902409,0x2409024,0x9fe4c90,0x24090240,0x84840848,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0xfe048224,
2992 0x28001001,0x2000,0x40,0x40810080,0x27f8024,0x8104080,0x2000001c,0x1fe0e020,0x488fc409,0x409004,0x1024082,0x110840,0x10242902,
2993 0x40102408,0x2081021,0x214a1202,0x1002004,0x1000000,0x102409,0x409000,0x81024082,0x411008,0x9240902,0x40902100,0x6101021,
2994 0x214a0c04,0x81002008,0x2000000,0x201dc000,0x20000000,0x80200000,0x98044,0x1dc101dc,0x77000000,0x700,0x0,0x180448,0x1dc10020,
2995 0x20440,0x403e0200,0x620017,0xa000cc00,0x80052800,0x20000,0x1020,0x48000000,0x6606,0x206100,0x3f0fc3f0,0xfc3f0fc7,0xc1004010,
2996 0x4010008,0x2008020,0x4090a409,0x2409024,0x8886090,0x24090240,0x8207e106,0x40902409,0x2409024,0x81004010,0x4010008,0x2008020,
2997 0x40902409,0x2409024,0x8005890,0x24090240,0x84840848,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x98048224,0x30001001,0x2000,
2998 0x40,0x21010100,0x2020024,0x8204080,0x40000007,0x80078000,0x48884408,0x80411004,0x824082,0x110840,0x10242986,0x40086409,0x2081021,
2999 0xe14a2102,0x2002004,0x1000000,0x106409,0x409000,0x81024082,0x410808,0x9240902,0x40902100,0x2101021,0x214a1202,0x82002008,
3000 0x2000000,0x300f8000,0x20000000,0x80fc001d,0xe4088044,0xf8200f8,0x3e000000,0x300,0x0,0x80c48,0xf820020,0x20640,0x40410200,
3001 0x803c0018,0x60006600,0x61800,0x0,0x1020,0x48000000,0xcc0a,0x20a100,0x21084210,0x84210844,0x40804010,0x4010008,0x2008020,
3002 0x4110a619,0x86619866,0x19046110,0x24090240,0x82040102,0x41906419,0x6419064,0x81004010,0x4010008,0x2008020,0x40902409,0x2409024,
3003 0x8307090,0x24090240,0x82840828,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20000,0x90248222,0x30000802,0x200c,0xc080,0x21010301,
3004 0x4021042,0x10202108,0xc0c03000,0x80040020,0x4d902418,0xc6431004,0xc24082,0x6210440,0x10241884,0x40084409,0x86080840,0xc0842102,
3005 0x4002002,0x1000000,0x18e610,0x84218820,0x80864082,0x410408,0x9240884,0x61086101,0x6101860,0xc0842103,0x4002008,0x2000000,
3006 0x10850180,0x20330000,0x80200013,0x26184024,0x5040050,0x14000000,0x0,0x0,0x4180848,0x85040020,0x20350,0x40000200,0x800c0007,
3007 0x80002200,0x1e000,0x0,0x1860,0x48000000,0x880a,0x40a188,0x40902409,0x2409028,0x40c64010,0x4010008,0x2008020,0x43106210,0x84210842,
3008 0x10006108,0x42108421,0x2040102,0x6398e639,0x8e6398e4,0x88842088,0x22088208,0x2008020,0x21102210,0x84210842,0x10306118,0x66198661,
3009 0x83061030,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20001,0x901f01c1,0xe8000802,0xc,0xc080,0x1e07c7f8,0xf8020f81,0xe0401e07,
3010 0x80c03000,0x20,0x279027e0,0x3c7c1fe4,0x3c408f,0x83c1027f,0x90241878,0x4007c404,0xf8080780,0xc0844082,0x7f82002,0x1000000,
3011 0xfa5e0,0x781e87c0,0x807a409f,0xc0410207,0x9240878,0x5e07a100,0xf80e0fa0,0xc0846183,0x7f82008,0x2000000,0xf020100,0x40321360,
3012 0x80200014,0xa3e0201f,0x8207f820,0x8000000,0x0,0x0,0x3e01037,0x207f820,0x201e1,0xfc000200,0x80040000,0x0,0x0,0x1fc000,0x17b0,
3013 0x48000000,0x12,0xc120f0,0x40902409,0x2409028,0x783c7f9f,0xe7f9fe3e,0xf83e0f8,0x7c1061e0,0x781e0781,0xe000be07,0x81e0781e,
3014 0x204017c,0x3e8fa3e8,0xfa3e8fa3,0x70781f07,0xc1f07c7f,0x1fc7f1fc,0x1e1021e0,0x781e0781,0xe0007e0f,0xa3e8fa3e,0x8305e030,0x0,
3015 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40000,0xc06,0xc,0x100,0x0,0x0,0x0,0x3000,0x0,0x20000000,0x0,0x0,0x0,0x0,0xc000,
3016 0x0,0x0,0x2001,0x1000000,0x0,0x0,0x20000,0x400000,0x0,0x40002000,0x0,0x1,0x2008,0x2000000,0x100,0x40240000,0x80200008,0x40000000,
3017 0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x80040000,0x0,0x0,0x0,0x1000,0x48000000,0x1f,0x181f000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3018 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1040010,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40000,0x60c,0x18,0x0,
3019 0x0,0x0,0x0,0x6000,0x0,0x10000000,0x0,0x0,0x0,0x0,0x4000,0x0,0x0,0x3800,0x7000000,0x0,0x0,0x840000,0x400000,0x0,0x40002000,
3020 0x0,0x2,0x2008,0x2000000,0x200,0x40440000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x80780000,0x0,0x0,0x0,0x1000,0x48000400,
3021 0x2,0x1e02000,0x0,0x0,0x80000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80000,0x0,0x0,0x0,0x0,0x0,0x0,0x2040020,0x0,0x0,0x0,0x0,
3022 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x0,0x4000,0x0,0xf000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3023 0x780000,0x3800000,0x0,0x40002000,0x0,0xe,0x1808,0xc000000,0x3,0x80000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80000000,
3024 0x0,0x0,0x0,0x1000,0x1c00,0x0,0x0,0x0,0x0,0x380000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x380000,0x0,0x0,0x0,0x0,0x0,0x0,0xe0400e0,
3025 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3fc,
3026 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3027 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 };
3031 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3032 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x19,0x80000000,0x198000,0x0,0x0,0x0,0x0,
3033 0x0,0x198,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc001806,0xc81980,0x60000000,0xc001806,0x1980c00,0x18060198,0xc80c,
3034 0x180600,0xc8198000,0xc001,0x80601980,0x18000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3035 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3036 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf,0x0,0xf0000,0x0,0x0,0x0,0x0,0x0,0x198,0x0,0x0,0x0,0x0,0x0,0x0,
3037 0x0,0x0,0x0,0x0,0x0,0x0,0x600300f,0x1301980,0x90000000,0x600300f,0x1980600,0x300f0198,0x13006,0x300f01,0x30198000,0x6003,
3038 0xf01980,0x30000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3039 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3040 0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x0,0x60000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7007,0x3c0000,0x3006019,
3041 0x80000000,0x90000000,0x3006019,0x80000300,0x60198000,0x3,0x601980,0x0,0x3006,0x1980000,0x60000000,0x0,0x0,0xe0000000,0x0,
3042 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3043 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x18000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6000000,
3044 0x0,0x0,0x0,0x0,0x0,0xc800019,0x80000000,0x198000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc0,0x0,0x0,0x1001,0x420000,0x0,0x0,0x90000000,
3045 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x18000c06,0xc80001,0x10000000,0x18000c06,0x1800,0xc060000,0xc818,0xc0600,0xc8000000,
3046 0x18000,0xc0600000,0xc000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6019,0x80660207,0x800f8060,0x300c004,0x0,0x6,
3047 0xe00703f,0x3f00383,0xf80f07fc,0x1f01f000,0x0,0xf8,0x607f,0x7c7e07,0xfe7fe0f8,0x6063fc1f,0x86066007,0xe7060f0,0x7f80f07f,
3048 0x81f8fff6,0x6606c03,0x70ee077f,0xe0786000,0xf0070000,0xc000060,0xc0,0x3e000,0x60006003,0x600fc00,0x0,0x0,0x0,0x0,0x0,0x3c0603,
3049 0xc0000000,0x7800000,0xf0000,0x0,0xf00001f,0x80001fe0,0x7fe000,0x0,0x0,0x0,0x168fe609,0x0,0x90e07,0x6000,0x3c000e,0x70000f8,
3050 0x1980001f,0x0,0x1f8,0xf00000f,0xf00180,0xfe000,0xe00e,0x1001,0x20060,0x6006006,0x600600,0x600fe07c,0x7fe7fe7f,0xe7fe3fc3,
3051 0xfc3fc3fc,0x7e07060f,0xf00f00,0xf00f0000,0xf360660,0x6606606e,0x76001e0,0xc00180f,0x1681981,0x10000000,0xc00180f,0x1980c00,
3052 0x180f0198,0x3801680c,0x180f01,0x68198000,0xc001,0x80f01980,0x18600198,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6019,
3053 0x8044020c,0xc01f8060,0x2004004,0x0,0xc,0x3f81f07f,0x87f80383,0xf81f87fc,0x3f83f800,0x0,0x1fc,0x780607f,0x81fe7f87,0xfe7fe1fc,
3054 0x6063fc1f,0x860c6007,0xe7061f8,0x7fc1f87f,0xc3fcfff6,0x6606c03,0x30c6067f,0xe0783000,0xf00d8000,0x6000060,0xc0,0x7e000,0x60006003,
3055 0x600fc00,0x0,0x0,0xc00,0x0,0x0,0x7c0603,0xe0000000,0xfc00000,0x1f0000,0x0,0x900003f,0xc0003fe0,0x7fe000,0x0,0x0,0x0,0x1302660f,
3056 0x0,0xf0606,0x6004,0x7e0006,0x60601f8,0x19800001,0x80000000,0x1f8,0x19800010,0x81080300,0x3f2000,0x2011,0x1001,0x1c0060,0x6006006,
3057 0x600600,0x601fe1fe,0x7fe7fe7f,0xe7fe3fc3,0xfc3fc3fc,0x7f87061f,0x81f81f81,0xf81f8000,0x3fa60660,0x66066066,0x66003f0,0x6003009,
3058 0x1301981,0x10000000,0x6003009,0x1980600,0x30090198,0x1f013006,0x300901,0x30198000,0x6003,0x901980,0x30600198,0x0,0x0,0x0,
3059 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6019,0x80cc0f8c,0xc0180060,0x6006044,0x40000000,0xc,0x3181b041,0xc41c0783,0x388018,
3060 0x71c71800,0x0,0x106,0x18c0f061,0xc38261c6,0x600384,0x60606001,0x86186007,0xe78630c,0x60e30c60,0xe7040606,0x630cc03,0x39c30c00,
3061 0xc0603000,0x3018c000,0x3000060,0xc0,0x60000,0x60000000,0x6000c00,0x0,0x0,0xc00,0x0,0x0,0x600600,0x60000000,0x18400000,0x180000,
3062 0x0,0x19800070,0x40003600,0xc000,0x0,0x0,0x0,0x25a06,0x0,0x6030c,0x4,0xe20007,0xe060180,0xf000,0x80000000,0xf0000,0x10800000,
3063 0x80080600,0x7f2000,0x2020,0x80001001,0x20000,0xf00f00f,0xf00f00,0x601b0382,0x60060060,0x6000600,0x60060060,0x61c78630,0xc30c30c3,
3064 0xc30c000,0x30e60660,0x66066063,0xc600738,0x3006019,0x80000000,0xe0000000,0x3006019,0x80000300,0x60198000,0x3e000003,0x601980,
3065 0x0,0x3006,0x1980000,0x60600000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6019,0x80cc1fcc,0xc0180060,0x6006035,0x80000000,
3066 0x18,0x71c03000,0xc00c0583,0x300018,0x60c60c00,0x0,0x6,0x3060f060,0xc30060c6,0x600300,0x60606001,0x86306007,0x9e78670e,0x60670e60,
3067 0x66000606,0x630c606,0x19830c01,0xc0601800,0x30306000,0x60,0xc0,0x60000,0x60000000,0x6000c00,0x0,0x0,0xc00,0x0,0x0,0x600600,
3068 0x60000000,0x18000000,0x300000,0x0,0x78060,0x6600,0x1c000,0x300c,0x39819c0,0x0,0x25a00,0x0,0x30c,0x4,0xc00003,0xc060180,0x30c1f,
3069 0x80000000,0x30c000,0x10800001,0x80700000,0x7f2000,0x2020,0x80001001,0x20060,0xf00f00f,0xf00f00,0xf01b0300,0x60060060,0x6000600,
3070 0x60060060,0x60c78670,0xe70e70e7,0xe70e000,0x70c60660,0x66066063,0xc7f8618,0x0,0x0,0x0,0x0,0x0,0x0,0x7000000,0x0,0x0,0x0,
3071 0x0,0x600000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6019,0x87ff3a4c,0xc0180060,0x400600e,0x600000,0x18,0x60c03000,
3072 0xc00c0d83,0x700018,0x60c60c00,0x20,0x400006,0x3060f060,0xc6006066,0x600600,0x60606001,0x86606006,0x966c6606,0x60660660,0x66000606,
3073 0x630c666,0xf019801,0x80601800,0x30603000,0x1f06f,0xf01ec0,0xf03fe1ec,0x6703e01f,0x61c0c06,0xdc6701f0,0x6f01ec0c,0xe1f87fc6,
3074 0xc60cc03,0x71c60c7f,0xc0600600,0x60000000,0x30000000,0x300000,0x40040,0x88060,0x6600,0x18000,0x300c,0x1981980,0x0,0x2421f,
3075 0x80003ce0,0x7fc198,0x601f,0xc02021,0x980600c0,0x40230,0x80000000,0x402000,0x19806003,0x80006,0xc7f2000,0x2020,0x80001001,
3076 0x420060,0xf00f00f,0xf00f00,0xf01b0600,0x60060060,0x6000600,0x60060060,0x6066c660,0x66066066,0x6606208,0x60e60660,0x66066061,
3077 0x987fc670,0x1f01f01f,0x1f01f01,0xf039c0f0,0xf00f00f,0xf03e03,0xe03e03e0,0x1f06701f,0x1f01f01,0xf01f0060,0x1e660c60,0xc60c60c6,
3078 0xc6f060c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6000,0x7ff3207,0x8c0c0000,0xc00300e,0x600000,0x30,0x60c03000,
3079 0xc01c0983,0xf0600030,0x31860c06,0x6001e0,0x78000e,0x23e1f861,0xc6006066,0x600600,0x60606001,0x86c06006,0x966c6606,0x60660660,
3080 0xe7000606,0x630c666,0xf01f803,0x600c00,0x30000000,0x3f87f,0x83f83fc3,0xf83fe3fc,0x7f83e01f,0x6380c07,0xfe7f83f8,0x7f83fc0d,
3081 0xf3fc7fc6,0xc71cc03,0x3183187f,0xc0600600,0x60000000,0xff806000,0x300000,0x40040,0x88070,0x6600,0x60030060,0x6001818,0x1883180,
3082 0x0,0x2423f,0xc0007ff0,0x607fc1f8,0x603f,0x80c01fc1,0xf80601e0,0x5f220,0x80420000,0x5f2000,0xf006006,0x80006,0xc7f2000,0x2020,
3083 0x82107c07,0xc03c0060,0x1f81f81f,0x81f81f80,0xf03b0600,0x60060060,0x6000600,0x60060060,0x6066c660,0x66066066,0x660671c,0x61660660,
3084 0x66066061,0xf860e6c0,0x3f83f83f,0x83f83f83,0xf87fe3f8,0x3f83f83f,0x83f83e03,0xe03e03e0,0x3f87f83f,0x83f83f83,0xf83f8060,
3085 0x3fc60c60,0xc60c60c3,0x187f8318,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6000,0x883200,0x300c0000,0xc003035,0x80600000,
3086 0x30,0x66c03001,0xc0f81983,0xf86f0030,0x1f071c06,0x600787,0xfe1e001c,0x6261987f,0x86006067,0xfe7fc600,0x7fe06001,0x87c06006,
3087 0xf6646606,0x60e6067f,0xc3e00606,0x61986f6,0x600f007,0x600c00,0x30000000,0x21c71,0x830831c3,0x1c06031c,0x71c06003,0x6700c06,
3088 0x6671c318,0x71831c0f,0x16040c06,0xc318606,0x1b031803,0x80600600,0x60000000,0x30009000,0x300000,0x40040,0x7003e,0x67e0,0x90070090,
3089 0x9001818,0x8c3100,0x0,0x60,0x4000e730,0x900380f0,0x6034,0x80c018c7,0xfe060338,0xb0121,0x80c60000,0x909000,0x6008,0x1080006,
3090 0xc3f2000,0x2011,0x3180060,0x60060e0,0x19819819,0x81981981,0x9833c600,0x7fe7fe7f,0xe7fe0600,0x60060060,0x60664660,0x66066066,
3091 0x66063b8,0x62660660,0x66066060,0xf06066c0,0x21c21c21,0xc21c21c2,0x1c466308,0x31c31c31,0xc31c0600,0x60060060,0x31871c31,0x83183183,
3092 0x18318000,0x71860c60,0xc60c60c3,0x18718318,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6000,0x1981a00,0xe03e0000,0xc003044,
3093 0x40600000,0x60,0x66c03001,0x80f03182,0x1c7f8030,0x3f83fc06,0x601e07,0xfe078038,0x6661987f,0x86006067,0xfe7fc61e,0x7fe06001,
3094 0x87e06006,0x66666606,0x7fc6067f,0x81f80606,0x61986f6,0x6006006,0x600600,0x30000000,0xc60,0xc60060c6,0xc06060c,0x60c06003,
3095 0x6e00c06,0x6660c60c,0x60c60c0e,0x6000c06,0xc318666,0x1f031803,0x600600,0x603c2000,0x30016800,0x1fe0000,0x1f81f8,0x1c1f,0x804067e1,
3096 0x68060168,0x16800810,0xc42300,0x0,0x60,0x20c331,0x68030060,0x6064,0x3fc1040,0xf006031c,0xa011e,0x818c7fe0,0x909000,0x7fe1f,
3097 0x80f00006,0xc0f2060,0xf80e,0x18c0780,0x780781c0,0x19819819,0x81981981,0x9833c600,0x7fe7fe7f,0xe7fe0600,0x60060060,0xfc666660,
3098 0x66066066,0x66061f0,0x66660660,0x66066060,0x606066e0,0xc00c00,0xc00c00c0,0xc066600,0x60c60c60,0xc60c0600,0x60060060,0x60c60c60,
3099 0xc60c60c6,0xc60c000,0x61c60c60,0xc60c60c3,0x1860c318,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6000,0x1980f81,0x80373000,
3100 0xc003004,0x7fe0001,0xf0000060,0x60c03003,0x183180,0xc71c060,0x3181ec00,0x7000,0xe070,0x66619860,0xc6006066,0x60061e,0x60606001,
3101 0x87606006,0x66626606,0x7f860661,0xc01c0606,0x6198696,0xf00600e,0x600600,0x30000000,0x1fc60,0xc60060c7,0xfc06060c,0x60c06003,
3102 0x7c00c06,0x6660c60c,0x60c60c0c,0x7f00c06,0xc3b8666,0xe01b007,0x3c00600,0x3c7fe000,0xff03ec00,0x1fe0000,0x40040,0xe001,0xc0806603,
3103 0xec0e03ec,0x3ec00010,0x0,0x60000000,0x7f,0x10c3f3,0xec070060,0x6064,0x3fc1040,0x6000030c,0xa0100,0x3187fe1,0xf09f1000,0x7fe00,
3104 0x6,0xc012060,0x0,0xc63c03,0xc03c0380,0x19819819,0x81981981,0x98330600,0x60060060,0x6000600,0x60060060,0xfc662660,0x66066066,
3105 0x66060e0,0x6c660660,0x66066060,0x6060e630,0x1fc1fc1f,0xc1fc1fc1,0xfc3fe600,0x7fc7fc7f,0xc7fc0600,0x60060060,0x60c60c60,0xc60c60c6,
3106 0xc60c7fe,0x62c60c60,0xc60c60c1,0xb060c1b0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6000,0xffe02c6,0x3c633000,0xc003004,
3107 0x7fe0001,0xf00000c0,0x60c03006,0xc6180,0xc60c060,0x60c00c00,0x7000,0xe060,0x66639c60,0x66006066,0x600606,0x60606001,0x86306006,
3108 0x66636606,0x60060660,0xc0060606,0x61f8696,0xf00600c,0x600300,0x30000000,0x3fc60,0xc60060c7,0xfc06060c,0x60c06003,0x7c00c06,
3109 0x6660c60c,0x60c60c0c,0x1f80c06,0xc1b0666,0xe01b00e,0x3c00600,0x3c43c000,0x3007de00,0x600000,0x40040,0x30000,0x61006607,0xde0c07de,
3110 0x7de00000,0x0,0xf07fefff,0x1f,0x8008c3f7,0xde0e0060,0x6064,0xc01047,0xfe00018c,0xb013f,0x86300061,0xf0911000,0x6000,0x6,
3111 0xc012060,0x3f,0x8063c0cc,0x3cc0c700,0x39c39c39,0xc39c39c1,0x98630600,0x60060060,0x6000600,0x60060060,0x60663660,0x66066066,
3112 0x66061f0,0x78660660,0x66066060,0x607fc618,0x3fc3fc3f,0xc3fc3fc3,0xfc7fe600,0x7fc7fc7f,0xc7fc0600,0x60060060,0x60c60c60,0xc60c60c6,
3113 0xc60c7fe,0x64c60c60,0xc60c60c1,0xb060c1b0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6000,0xffe0260,0x6661b000,0xc003000,
3114 0x600000,0xc0,0x60c0300c,0xc7fe0,0xc60c060,0x60c01c00,0x1e07,0xfe078060,0x6663fc60,0x66006066,0x600606,0x60606001,0x86386006,
3115 0x6636606,0x60060660,0xe0060606,0x60f039c,0x1b806018,0x600300,0x30000000,0x70c60,0xc60060c6,0x6060c,0x60c06003,0x7600c06,
3116 0x6660c60c,0x60c60c0c,0x1c0c06,0xc1b03fc,0xe01f01c,0xe00600,0x70000000,0x3007fc00,0x600000,0x40040,0x0,0x62006607,0xfc1807fc,
3117 0x7fc00000,0x0,0xf0000000,0x1,0xc004c307,0xfc1c0060,0x6064,0xc018c0,0x600000d8,0x5f200,0x3180060,0x50a000,0x6000,0x6,0xc012000,
3118 0x0,0xc601c0,0x4201c600,0x3fc3fc3f,0xc3fc3fc3,0xfc7f0600,0x60060060,0x6000600,0x60060060,0x60663660,0x66066066,0x66063b8,
3119 0x70660660,0x66066060,0x607f860c,0x70c70c70,0xc70c70c7,0xcc60600,0x60060060,0x6000600,0x60060060,0x60c60c60,0xc60c60c6,0xc60c000,
3120 0x68c60c60,0xc60c60c1,0xf060c1f0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3300260,0x6661e000,0xc003000,0x600000,
3121 0x180,0x71c03018,0xc7fe0,0xc60c0c0,0x60c01800,0x787,0xfe1e0060,0x6663fc60,0x630060c6,0x600306,0x60606001,0x86186006,0x661e70e,
3122 0x60070c60,0x60060606,0x60f039c,0x19806038,0x600180,0x30000000,0x60c60,0xc60060c6,0x6060c,0x60c06003,0x6700c06,0x6660c60c,
3123 0x60c60c0c,0xc0c06,0xc1b039c,0x1f00e018,0x600600,0x60000000,0x1803f800,0x600000,0x40040,0x39e00,0x63006603,0xf83803f8,0x3f800000,
3124 0x0,0x60000000,0x0,0xc00cc303,0xf8180060,0x6064,0xc01fc0,0x60060070,0x40200,0x18c0060,0x402000,0x6000,0x6,0xc012000,0x0,0x18c0140,
3125 0x2014600,0x3fc3fc3f,0xc3fc3fc3,0xfc7f0300,0x60060060,0x6000600,0x60060060,0x60c61e70,0xe70e70e7,0xe70e71c,0x60e60660,0x66066060,
3126 0x6060060c,0x60c60c60,0xc60c60c6,0xcc60600,0x60060060,0x6000600,0x60060060,0x60c60c60,0xc60c60c6,0xc60c000,0x70c60c60,0xc60c60c0,
3127 0xe060c0e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x33022e0,0x6670c000,0xc003000,0x600600,0x60180,0x31803030,
3128 0x41c0184,0x1831c0c0,0x71c23806,0x6001e0,0x780000,0x62630c60,0xe38261c6,0x600386,0x60606043,0x860c6006,0x661e30c,0x60030c60,
3129 0x740e0607,0xe0f039c,0x31c06030,0x600180,0x30000000,0x61c71,0x830831c3,0x406031c,0x60c06003,0x6300c06,0x6660c318,0x71831c0c,
3130 0x41c0c07,0x1c0e039c,0x1b00e030,0x600600,0x60000000,0x1c41b00e,0x601cc0,0x401f8,0x45240,0xe1803601,0xb03001b0,0x1b000000,
3131 0x0,0x0,0x41,0xc008e711,0xb0300060,0x6034,0x80c02020,0x60060030,0x30c00,0xc60000,0x30c000,0x0,0x7,0x1c012000,0x0,0x3180240,
3132 0x6024608,0x30c30c30,0xc30c30c3,0xc630382,0x60060060,0x6000600,0x60060060,0x61c61e30,0xc30c30c3,0xc30c208,0x70c70e70,0xe70e70e0,
3133 0x6060068c,0x61c61c61,0xc61c61c6,0x1cc62308,0x30430430,0x43040600,0x60060060,0x31860c31,0x83183183,0x18318060,0x31c71c71,
3134 0xc71c71c0,0xe07180e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6000,0x2203fc0,0x663f6000,0x6006000,0x600600,0x60300,
3135 0x3f81fe7f,0xc7f80187,0xf83f80c0,0x3f83f006,0x600020,0x400060,0x33e6067f,0xc1fe7f87,0xfe6001fe,0x6063fc7f,0x60e7fe6,0x660e3f8,
3136 0x6001f860,0x37fc0603,0xfc06030c,0x30c0607f,0xe06000c0,0x30000000,0x7fc7f,0x83f83fc3,0xfc0603fc,0x60c7fe03,0x61807c6,0x6660c3f8,
3137 0x7f83fc0c,0x7f80fc3,0xfc0e039c,0x3180607f,0xc0600600,0x60000000,0xfc0e00c,0x601986,0x66040040,0x4527f,0xc0803fe0,0xe07fe0e0,
3138 0xe000000,0x0,0x0,0x7f,0x80107ff0,0xe07fc060,0x603f,0x83fe0000,0x60060018,0xf000,0x420000,0xf0000,0x7fe00,0x7,0xfe012000,
3139 0x0,0x2100640,0xc0643f8,0x60660660,0x66066067,0xec3e1fe,0x7fe7fe7f,0xe7fe3fc3,0xfc3fc3fc,0x7f860e3f,0x83f83f83,0xf83f8000,
3140 0x5fc3fc3f,0xc3fc3fc0,0x606006fc,0x7fc7fc7f,0xc7fc7fc7,0xfcffe3f8,0x3fc3fc3f,0xc3fc7fe7,0xfe7fe7fe,0x3f860c3f,0x83f83f83,
3141 0xf83f8060,0x7f83fc3f,0xc3fc3fc0,0x607f8060,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6000,0x2201f80,0x3c1e7000,0x6006000,
3142 0x600,0x60300,0xe01fe7f,0xc3f00183,0xe01f0180,0x1f01e006,0x600000,0x60,0x3006067f,0x807c7e07,0xfe6000f8,0x6063fc3e,0x6067fe6,
3143 0x660e0f0,0x6000f060,0x3bf80601,0xf806030c,0x60e0607f,0xe06000c0,0x30000000,0x1ec6f,0xf01ec0,0xf80601ec,0x60c7fe03,0x61c03c6,
3144 0x6660c1f0,0x6f01ec0c,0x3f007c1,0xcc0e030c,0x71c0c07f,0xc0600600,0x60000000,0x7804018,0xe01186,0x66040040,0x39e3f,0x80401fe0,
3145 0x407fe040,0x4000000,0x0,0x0,0x3f,0x203ce0,0x407fc060,0x601f,0x3fe0000,0x60060018,0x0,0x0,0x0,0x7fe00,0x6,0xe6012000,0x0,
3146 0x7e0,0x1807e1f0,0x60660660,0x66066066,0x6c3e07c,0x7fe7fe7f,0xe7fe3fc3,0xfc3fc3fc,0x7e060e0f,0xf00f00,0xf00f0000,0x8f01f81f,
3147 0x81f81f80,0x60600670,0x1ec1ec1e,0xc1ec1ec1,0xec79c0f0,0xf80f80f,0x80f87fe7,0xfe7fe7fe,0x1f060c1f,0x1f01f01,0xf01f0000,0x4f01cc1c,
3148 0xc1cc1cc0,0xc06f00c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x200,0x0,0x6006000,0x600,0x600,0x0,0x0,0x0,0x0,
3149 0x600000,0x0,0x18000000,0x0,0x0,0x0,0x0,0x0,0x1800,0x0,0x0,0x0,0x600060,0x30000000,0x0,0x0,0xc,0x3,0x0,0x0,0x60000c00,0x0,
3150 0x0,0xc000,0x600600,0x60000000,0x18,0xc03100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,0x0,0x601f8,0x0,0x0,0x0,0x0,0x6,
3151 0x12000,0x2000000,0x40,0x20004000,0x0,0x0,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3152 0x0,0xc06000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x200,0x0,0x2004000,0xc00,0x0,0x0,0x0,0x0,0x0,0xc00000,
3153 0x0,0x1c000000,0x0,0x0,0x0,0x0,0x0,0xc00,0x0,0x0,0x0,0x780000,0xf0000000,0x0,0x0,0x21c,0x3,0x0,0x0,0x60000c00,0x0,0x0,0xc000,
3154 0x7c0603,0xe0000000,0x10,0xc02300,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,0x0,0x601f0,0x0,0x0,0x0,0x0,0x6,0x12000,0x1000000,
3155 0x40,0x7e004000,0x0,0x0,0x8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc06000c0,0x0,
3156 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x200,0x0,0x300c000,0xc00,0x0,0x0,0x0,0x0,0x0,0xc00000,0x0,0x7800000,0x0,
3157 0x0,0x0,0x0,0x0,0x800,0x0,0x0,0x0,0x780000,0xf0000000,0x0,0x0,0x3f8,0x3e,0x0,0x0,0x60000c00,0x0,0x0,0x38000,0x3c0603,0xc0000000,
3158 0x10,0xfc00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,0x0,0x60000,0x0,0x0,0x0,0x0,0x6,0x0,0x1000000,0x0,0x0,0x0,0x0,
3159 0x8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0x80600380,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3160 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xffc,0x0,
3161 0x0,0x1f0,0x3c,0x0,0x0,0x60000c00,0x0,0x0,0x38000,0x600,0x0,0x0,0xf000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3162 0x0,0x0,0x0,0x0,0x0,0x6,0x0,0xe000000,0x0,0x0,0x0,0x0,0x70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x70,0x0,0x0,0x0,0x0,
3163 0x0,0x0,0x0,0x3,0x80600380,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3164 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xffc,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x600,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3165 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3166 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 };
3170 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3171 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3172 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc300000,0x0,0xc300000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3173 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x70000e0,0x3c00730,0xe7001c0,0x0,0x70000e0,0x3c00e70,0x70000e0,0x3c00e70,0x730,0x70000e0,0x3c00730,
3174 0xe700000,0x700,0xe003c0,0xe7000e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3175 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3176 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3177 0x0,0x0,0x6600000,0x0,0x6600000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3178 0x0,0x0,0x18001c0,0x6600ff0,0xe7003e0,0x0,0x18001c0,0x6600e70,0x18001c0,0x6600e70,0xff0,0x18001c0,0x6600ff0,0xe700000,0x180,
3179 0x1c00660,0xe7001c0,0x0,0x0,0x0,0x380,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3180 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3181 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00000,
3182 0x0,0x3c00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c00380,
3183 0xc300ce0,0xe700630,0x0,0x1c00380,0xc300e70,0x1c00380,0xc300e70,0xce0,0x1c00380,0xc300ce0,0xe700000,0x1c0,0x3800c30,0xe700380,
3184 0x0,0x0,0x0,0x7c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3185 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3186 0x0,0x0,0x0,0x0,0xe000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1800000,0x0,0x0,0x0,
3187 0x0,0x0,0x0,0x0,0x0,0xc300000,0x0,0xc300000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x700000,0x0,0x0,0x0,0x7c007c00,0x3e000000,
3188 0x0,0x0,0x630,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe000070,0x1800000,0xc60,0x0,0xe000070,0x1800000,0xe000070,
3189 0x1800000,0x0,0xe000070,0x1800000,0x0,0xe00,0x700180,0x70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3190 0x0,0x0,0x0,0x800000,0x0,0x600600,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3191 0x0,0x0,0x3f0,0xfc0,0x0,0x7000000,0x38000000,0x1c0000,0xfc0000,0x380001c0,0xe01c00,0x7f800000,0x0,0x0,0x0,0x0,0x0,0x0,0x7c,
3192 0x1801f00,0x0,0x0,0x1c,0x0,0x0,0x3c00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7300000,0x6600000,0x0,0x6600000,0x0,0x0,0x0,0x0,0xe700000,
3193 0x0,0x0,0x0,0x0,0x0,0xe00000,0x0,0x0,0x0,0xc000c00,0x43800000,0x0,0x0,0x630,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3194 0xf80,0x70000e0,0x3c00730,0xe700c60,0x0,0x70000e0,0x3c00e70,0x70000e0,0x3c00e70,0xe000730,0x70000e0,0x3c00730,0xe700000,0x700,
3195 0xe003c0,0xe7000e0,0x38000e70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0x6300000,0x803c00,0x7c00180,
3196 0xc00300,0x1000000,0x0,0x1c,0x3c007c0,0xfc007e0,0xe01ff8,0x3f03ffc,0x7e007c0,0x0,0x0,0x7c0,0x1c0,0x7f8003f0,0x7f007ff8,0x7ff803f0,
3197 0x70381ffc,0xff0700e,0x7000783c,0x783807c0,0x7fc007c0,0x7fc00fc0,0x7fff7038,0x700ee007,0x780f780f,0x7ffc03f0,0x70000fc0,0x3c00000,
3198 0x3000000,0x38000000,0x1c0000,0x1fc0000,0x380001c0,0xe01c00,0x7f800000,0x0,0x0,0x0,0x0,0x0,0x0,0xfc,0x1801f80,0x0,0x1f80000,
3199 0x7e,0x0,0x0,0x2400000,0xfc00000,0x7ff0000,0x7ffc0000,0x0,0x0,0x0,0x0,0xf30fb0c,0x2400000,0x0,0x240780f,0x1c0,0xfc,0x780f,
3200 0x18003f0,0xe700000,0x7c00000,0x0,0xff0,0x3c00000,0x78007c0,0xc00000,0xff80000,0xf80,0x7c00000,0xc000c00,0x18001c0,0x1c001c0,
3201 0x1c001c0,0x1c003e0,0x7fe03f0,0x7ff87ff8,0x7ff87ff8,0x1ffc1ffc,0x1ffc1ffc,0x7f007838,0x7c007c0,0x7c007c0,0x7c00000,0x7c67038,
3202 0x70387038,0x7038780f,0x70001fe0,0x30000c0,0x2400f30,0xe700c60,0x0,0x30000c0,0x2400e70,0x30000c0,0x2400e70,0xf700f30,0x30000c0,
3203 0x2400f30,0xe700000,0x300,0xc00240,0xe7000c0,0x38000e70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,
3204 0x630018c,0x807e00,0xfe00180,0xc00300,0x1000000,0x0,0x38,0xff01fc0,0x3ff01ff0,0x1e01ff8,0x7f83ffc,0x1ff80ff0,0x0,0x0,0xff0,
3205 0x1f003e0,0x7fe00ff8,0x7fc07ff8,0x7ff80ff8,0x70381ffc,0xff0701c,0x7000783c,0x78381ff0,0x7fe01ff0,0x7fe01ff0,0x7fff7038,0x781ee007,
3206 0x3c1e380e,0x7ffc0380,0x380001c0,0x3c00000,0x1800000,0x38000000,0x1c0000,0x3c00000,0x380001c0,0xe01c00,0x3800000,0x0,0x0,
3207 0x0,0x7000000,0x0,0x0,0x1e0,0x18003c0,0x0,0x3fc0000,0x70,0x0,0x0,0x6600000,0x1ff00000,0x1fff0000,0x7ffc0000,0x0,0x0,0x0,0x0,
3208 0xcf0239c,0x3c00000,0x0,0x3c0380e,0x1c0,0x2001fe,0x380e,0x18007f8,0xe700000,0x8600000,0x0,0xff0,0x7e00000,0x8c00870,0x1800000,
3209 0x1ff80000,0x180,0xc600000,0xc000c00,0x38001c0,0x3e003e0,0x3e003e0,0x3e001c0,0x7fe0ff8,0x7ff87ff8,0x7ff87ff8,0x1ffc1ffc,0x1ffc1ffc,
3210 0x7fc07838,0x1ff01ff0,0x1ff01ff0,0x1ff00000,0x1fec7038,0x70387038,0x7038380e,0x70003ce0,0x1800180,0x6600cf0,0xe7007c0,0x0,
3211 0x1800180,0x6600e70,0x1800180,0x6600e70,0x7c00cf0,0x1800180,0x6600cf0,0xe700000,0x180,0x1800660,0xe700180,0x38000e70,0x0,
3212 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0x630030c,0x3f0e700,0x1e200180,0x1800180,0x21100000,0x0,
3213 0x38,0x1e7819c0,0x38781038,0x1e01c00,0xf080038,0x1c381c38,0x0,0x0,0x1878,0x7fc03e0,0x70e01e18,0x70e07000,0x70001e18,0x703801c0,
3214 0x707038,0x70007c7c,0x7c381c70,0x70701c70,0x70703830,0x1c07038,0x381ce007,0x1c1c3c1e,0x3c0380,0x380001c0,0x7e00000,0xc00000,
3215 0x38000000,0x1c0000,0x3800000,0x38000000,0x1c00,0x3800000,0x0,0x0,0x0,0x7000000,0x0,0x0,0x1c0,0x18001c0,0x0,0x70c0000,0xe0,
3216 0x0,0x0,0xc300000,0x38300000,0x3c700000,0x3c0000,0x0,0x0,0x0,0x0,0xce022f4,0x1800000,0x0,0x1803c1e,0x1c0,0x2003c2,0x3c1e,
3217 0x1800e08,0x7e0,0x300000,0x0,0x7e00000,0xe700000,0x600030,0x3000000,0x3f980000,0x180,0x18200000,0xc000c00,0x1e0001c0,0x3e003e0,
3218 0x3e003e0,0x3e003e0,0xfe01e18,0x70007000,0x70007000,0x1c001c0,0x1c001c0,0x70e07c38,0x1c701c70,0x1c701c70,0x1c700000,0x3c787038,
3219 0x70387038,0x70383c1e,0x70003870,0xc00300,0xc300ce0,0x380,0x0,0xc00300,0xc300000,0xc00300,0xc300000,0xfc00ce0,0xc00300,0xc300ce0,
3220 0x0,0xc0,0x3000c30,0x300,0x38000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0x630031c,0xff8c300,
3221 0x1c000180,0x1800180,0x39380000,0x0,0x70,0x1c3801c0,0x203c001c,0x3e01c00,0x1c000038,0x381c3838,0x0,0x0,0x1038,0xe0e03e0,0x70703c08,
3222 0x70707000,0x70003808,0x703801c0,0x707070,0x70007c7c,0x7c383838,0x70383838,0x70387010,0x1c07038,0x381c700e,0x1e3c1c1c,0x780380,
3223 0x1c0001c0,0xe700000,0x0,0x38000000,0x1c0000,0x3800000,0x38000000,0x1c00,0x3800000,0x0,0x0,0x0,0x7000000,0x0,0x0,0x1c0,0x18001c0,
3224 0x0,0xe000000,0xe0,0x0,0x1000100,0x3800,0x70100000,0x38700000,0x780000,0x1c0,0x7801ce0,0xe380000,0x0,0x2264,0x0,0x0,0x1c1c,
3225 0x0,0x200780,0x1c1c,0x1800c00,0x1818,0x7f00000,0x0,0x18180000,0xc300000,0x600070,0x0,0x7f980000,0x180,0x18300000,0xc000c00,
3226 0x3000000,0x3e003e0,0x3e003e0,0x3e003e0,0xee03c08,0x70007000,0x70007000,0x1c001c0,0x1c001c0,0x70707c38,0x38383838,0x38383838,
3227 0x38380000,0x38387038,0x70387038,0x70381c1c,0x7fc03870,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xbc00000,0x0,0x0,0x0,0x0,0x0,0x0,
3228 0x38000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0x6300318,0xe88c300,0x1c000180,0x38001c0,
3229 0xfe00180,0x0,0x70,0x1c3801c0,0x1c001c,0x6e01c00,0x1c000078,0x381c3818,0x0,0x40000,0x40000038,0x1c0607e0,0x70703800,0x70707000,
3230 0x70003800,0x703801c0,0x7070e0,0x70007c7c,0x7c383838,0x70383838,0x70387000,0x1c07038,0x381c700e,0xf780e38,0x700380,0x1c0001c0,
3231 0x1c380000,0x0,0x38000000,0x1c0000,0x3800000,0x38000000,0x1c00,0x3800000,0x0,0x0,0x0,0x7000000,0x0,0x0,0x1c0,0x18001c0,0x0,
3232 0xe000000,0xe0,0x0,0x1000100,0x4400,0x70000000,0x38700000,0x700000,0xe0,0x7001c70,0xe380000,0x0,0x2264,0x0,0x0,0xe38,0x0,
3233 0x200700,0xe38,0x1800c00,0x300c,0xc300000,0x0,0x300c0000,0xc300180,0x6003c0,0x0,0x7f980000,0x180,0x18300000,0xc000c00,0x1800000,
3234 0x7e007e0,0x7e007e0,0x7e003e0,0xee03800,0x70007000,0x70007000,0x1c001c0,0x1c001c0,0x70707c38,0x38383838,0x38383838,0x38380000,
3235 0x38387038,0x70387038,0x70380e38,0x7ff039f0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1e00000,0x0,0x0,0x0,0x40000,0x0,0x0,0x38000000,
3236 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0x6300318,0x1c80e700,0x1c000180,0x38001c0,0x3800180,
3237 0x0,0xe0,0x381c01c0,0x1c001c,0x6e01c00,0x38000070,0x381c381c,0x0,0x3c0000,0x78000078,0x38030770,0x70707800,0x70387000,0x70007000,
3238 0x703801c0,0x7071c0,0x7000745c,0x7638701c,0x7038701c,0x70387000,0x1c07038,0x1c38718e,0x7700f78,0xf00380,0xe0001c0,0x381c0000,
3239 0x7e0,0x39e003e0,0x79c03f0,0x3ffc079c,0x39e01fc0,0xfe01c1e,0x3807778,0x39e007e0,0x39e0079c,0x73c07e0,0x7ff83838,0x701ce007,
3240 0x783c701c,0x1ffc01c0,0x18001c0,0x0,0x1c000100,0xe0,0x0,0x1000100,0x4200,0x70000000,0x70700100,0xf00100,0x10000e0,0x7000c70,
3241 0xc700000,0x0,0x2204,0x7e00000,0x1e380100,0x1ffc0f78,0x0,0xf80700,0xf78,0x1800e00,0x63e6,0x18300000,0x0,0x6fe60000,0xe700180,
3242 0xc00060,0x3838,0x7f980000,0x180,0x18300000,0xc000c00,0x18001c0,0x7700770,0x7700770,0x77007f0,0xee07800,0x70007000,0x70007000,
3243 0x1c001c0,0x1c001c0,0x70387638,0x701c701c,0x701c701c,0x701c1008,0x707c7038,0x70387038,0x70380f78,0x707039c0,0x7e007e0,0x7e007e0,
3244 0x7e007e0,0x1f3c03e0,0x3f003f0,0x3f003f0,0x1fc01fc0,0x1fc01fc0,0x7f039e0,0x7e007e0,0x7e007e0,0x7e00380,0x7ce3838,0x38383838,
3245 0x3838701c,0x39e0701c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0x6307fff,0x1c807e0c,0xe000180,
3246 0x30000c0,0x3800180,0x0,0xe0,0x381c01c0,0x1c001c,0xce01fe0,0x38000070,0x381c381c,0x3800380,0xfc0000,0x7e0000f0,0x30030770,
3247 0x70707000,0x70387000,0x70007000,0x703801c0,0x707380,0x700076dc,0x7638701c,0x7038701c,0x70387800,0x1c07038,0x1c3873ce,0x7f00770,
3248 0xe00380,0xe0001c0,0x700e0000,0x1ff8,0x3ff00ff0,0xffc0ff8,0x3ffc0ffc,0x3bf01fc0,0xfe01c3c,0x3807f78,0x3bf00ff0,0x3ff00ffc,
3249 0x77e0ff0,0x7ff83838,0x3838e007,0x3c783838,0x1ffc01c0,0x18001c0,0x0,0x7ff00380,0x1e0,0x0,0x1000100,0x4200,0x78000000,0x70700380,
3250 0xe00380,0x3800060,0xe000e30,0x1c600000,0x0,0x2204,0xff00000,0x7f7c0380,0x1ffc0770,0x1c0,0x3fc0700,0x18040770,0x1800780,0x4e12,
3251 0x18300104,0x0,0x4c320000,0x7e00180,0x1c00030,0x3838,0x7f980000,0x180,0x18302080,0xc000c00,0x18001c0,0x7700770,0x7700770,
3252 0x7700770,0x1ee07000,0x70007000,0x70007000,0x1c001c0,0x1c001c0,0x70387638,0x701c701c,0x701c701c,0x701c381c,0x705c7038,0x70387038,
3253 0x70380770,0x70383b80,0x1ff81ff8,0x1ff81ff8,0x1ff81ff8,0x3fbe0ff0,0xff80ff8,0xff80ff8,0x1fc01fc0,0x1fc01fc0,0xff83bf0,0xff00ff0,
3254 0xff00ff0,0xff00380,0xffc3838,0x38383838,0x38383838,0x3ff03838,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3255 0x0,0x1c0,0x7fff,0x1c803c38,0xf000000,0x70000e0,0xfe00180,0x0,0x1c0,0x381c01c0,0x3c0078,0xce01ff0,0x39e000f0,0x1c38381c,0x3800380,
3256 0x3e07ffc,0xf8001f0,0x307b0770,0x70e07000,0x70387000,0x70007000,0x703801c0,0x707700,0x700076dc,0x7638701c,0x7038701c,0x70387e00,
3257 0x1c07038,0x1c3873ce,0x3e007f0,0x1e00380,0x70001c0,0x0,0x1038,0x3c381e18,0x1c7c1e3c,0x3801e3c,0x3c7801c0,0xe01c78,0x380739c,
3258 0x3c781c38,0x3c381c3c,0x7c21e10,0x7003838,0x3838700e,0x1ef03838,0x3c01c0,0x18001c0,0x0,0x7fe007c0,0x1c0,0x0,0x1000100,0x6400,
3259 0x7e000000,0x707007c0,0x1e007c0,0x7c00070,0xe000638,0x18600000,0x0,0x0,0x1e100000,0x73ce07c0,0x3c07f0,0x1c0,0x7240700,0x1ddc3ffe,
3260 0x1800de0,0x8c01,0x1870030c,0x0,0x8c310000,0x3c00180,0x3800030,0x3838,0x7f980000,0x180,0x183030c0,0xc000c00,0x430001c0,0x7700770,
3261 0x7700770,0x7700770,0x1ce07000,0x70007000,0x70007000,0x1c001c0,0x1c001c0,0x70387638,0x701c701c,0x701c701c,0x701c1c38,0x70dc7038,
3262 0x70387038,0x703807f0,0x70383b80,0x10381038,0x10381038,0x10381038,0x21e71e18,0x1e3c1e3c,0x1e3c1e3c,0x1c001c0,0x1c001c0,0x1e383c78,
3263 0x1c381c38,0x1c381c38,0x1c380380,0x1c383838,0x38383838,0x38383838,0x3c383838,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3264 0x0,0x0,0x0,0x0,0x0,0x1c0,0x630,0x1e8000e0,0x1f000000,0x70000e0,0x39380180,0x0,0x1c0,0x3b9c01c0,0x3c07f0,0x18e01078,0x3bf800e0,
3265 0x7e0383c,0x3800380,0x1f807ffc,0x3f001c0,0x61ff0e38,0x7fc07000,0x70387ff0,0x7ff07000,0x7ff801c0,0x707f00,0x7000729c,0x7338701c,
3266 0x7070701c,0x70703fc0,0x1c07038,0x1e7873ce,0x1c003e0,0x3c00380,0x70001c0,0x0,0x1c,0x3c381c00,0x1c3c1c1c,0x3801c3c,0x383801c0,
3267 0xe01cf0,0x380739c,0x38381c38,0x3c381c3c,0x7801c00,0x7003838,0x3838700e,0xfe03c78,0x7801c0,0x18001c0,0x0,0x1c000c20,0xff8,
3268 0x0,0x1ff01ff0,0x3818,0x3fc00100,0x707e0c20,0x3c00c20,0xc200030,0xc000618,0x18c00000,0x0,0x0,0x1c000080,0xe1ce0c20,0x7803e0,
3269 0x1c0,0xe200700,0xff83ffe,0x1801878,0x9801,0x1cf0071c,0x7ffc0000,0x8c310000,0x7ffe,0x7000030,0x3838,0x3f980380,0x180,0xc6038e0,
3270 0x7f9c7f9c,0x3e1c01c0,0xe380e38,0xe380e38,0xe380f78,0x1cfc7000,0x7ff07ff0,0x7ff07ff0,0x1c001c0,0x1c001c0,0xfe387338,0x701c701c,
3271 0x701c701c,0x701c0e70,0x719c7038,0x70387038,0x703803e0,0x70383b80,0x1c001c,0x1c001c,0x1c001c,0xe71c00,0x1c1c1c1c,0x1c1c1c1c,
3272 0x1c001c0,0x1c001c0,0x1c383838,0x1c381c38,0x1c381c38,0x1c380000,0x3c383838,0x38383838,0x38383c78,0x3c383c78,0x0,0x0,0x0,0x0,
3273 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0x630,0xf800380,0x3f830000,0x70000e0,0x31080180,0x0,0x380,0x3b9c01c0,
3274 0x7807e0,0x38e00038,0x3c3800e0,0xff01c3c,0x3800380,0x7c000000,0x7c03c0,0x61870e38,0x7fc07000,0x70387ff0,0x7ff070fc,0x7ff801c0,
3275 0x707f80,0x7000739c,0x7338701c,0x7ff0701c,0x7fe00ff0,0x1c07038,0xe7073ce,0x1c003e0,0x3800380,0x38001c0,0x0,0x1c,0x381c3800,
3276 0x381c380e,0x380381c,0x383801c0,0xe01de0,0x380739c,0x3838381c,0x381c381c,0x7001e00,0x7003838,0x1c70718e,0x7e01c70,0xf00380,
3277 0x18001e0,0x1e000000,0x1c001bb0,0xff8,0x0,0x1000100,0xe0,0xff00300,0x707e1bb0,0x3801bb0,0x1bb00010,0x8000308,0x30c00000,0x0,
3278 0x0,0x1e0000c0,0xe1ce1bb0,0xf003e0,0x1c0,0x1c203ff8,0x63003e0,0x180181c,0x9801,0xfb00e38,0x7ffc0000,0x8fc10000,0x7ffe,0xe000860,
3279 0x3838,0x1f980380,0x180,0x7c01c70,0x1f001f0,0x1f003c0,0xe380e38,0xe380e38,0xe380e38,0x1cfc7000,0x7ff07ff0,0x7ff07ff0,0x1c001c0,
3280 0x1c001c0,0xfe387338,0x701c701c,0x701c701c,0x701c07e0,0x731c7038,0x70387038,0x703803e0,0x70383980,0x1c001c,0x1c001c,0x1c001c,
3281 0xe73800,0x380e380e,0x380e380e,0x1c001c0,0x1c001c0,0x381c3838,0x381c381c,0x381c381c,0x381c0000,0x387c3838,0x38383838,0x38381c70,
3282 0x381c1c70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0xc30,0x7f00e00,0x33c30000,0x70000e0,0x1007ffe,
3283 0x0,0x380,0x3b9c01c0,0xf00078,0x30e0001c,0x3c1c01c0,0x1c381fdc,0x0,0x70000000,0x1c0380,0x63030e38,0x70707000,0x70387000,0x700070fc,
3284 0x703801c0,0x707b80,0x7000739c,0x7338701c,0x7fc0701c,0x7fc001f0,0x1c07038,0xe703e5c,0x3e001c0,0x7800380,0x38001c0,0x0,0x7fc,
3285 0x381c3800,0x381c380e,0x380381c,0x383801c0,0xe01fe0,0x380739c,0x3838381c,0x381c381c,0x7001fc0,0x7003838,0x1c70718e,0x7c01c70,
3286 0xe01f00,0x180007c,0x7f8c0000,0x7fc03fb8,0x1c0,0x0,0x1000100,0x700,0x1f00600,0x70703fb8,0x7803fb8,0x3fb80000,0x8000000,0x180,
3287 0x0,0x0,0x1fc00060,0xe1ce3fb8,0xe001c0,0x1c0,0x1c203ff8,0xc1801c0,0x180c,0x9801,0x1c70,0xc0000,0x8cc10000,0x180,0xfe007c0,
3288 0x3838,0x7980380,0xff0,0xe38,0x3e003e00,0x3e000380,0xe380e38,0xe380e38,0xe380e38,0x38e07000,0x70007000,0x70007000,0x1c001c0,
3289 0x1c001c0,0x70387338,0x701c701c,0x701c701c,0x701c03c0,0x731c7038,0x70387038,0x703801c0,0x703838e0,0x7fc07fc,0x7fc07fc,0x7fc07fc,
3290 0xe73800,0x380e380e,0x380e380e,0x1c001c0,0x1c001c0,0x381c3838,0x381c381c,0x381c381c,0x381c7ffc,0x38dc3838,0x38383838,0x38381c70,
3291 0x381c1c70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0xc60,0xf83878,0x71e30000,0x70000e0,0x1007ffe,
3292 0x7f0,0x380,0x381c01c0,0x1e0003c,0x60e0001c,0x381c01c0,0x381c079c,0x0,0x7c000000,0x7c0380,0x63031c1c,0x70307000,0x70387000,
3293 0x7000701c,0x703801c0,0x7071c0,0x7000739c,0x71b8701c,0x7000701c,0x71e00078,0x1c07038,0xe703e7c,0x7e001c0,0xf000380,0x38001c0,
3294 0x0,0x1ffc,0x381c3800,0x381c3ffe,0x380381c,0x383801c0,0xe01fc0,0x380739c,0x3838381c,0x381c381c,0x7000ff0,0x7003838,0x1ef03bdc,
3295 0x3800ee0,0x1e01f00,0x180007c,0x61fc0000,0x7fc07f3c,0x1c0,0x0,0x1000100,0x1800,0x780c00,0x70707f3c,0xf007f3c,0x7f3c0000,0x0,
3296 0x3c0,0x3ffcffff,0x0,0xff00030,0xe1fe7f3c,0x1e001c0,0x1c0,0x1c200700,0xc183ffe,0xe0c,0x9801,0x1ff038e0,0xc07f0,0x8c610000,
3297 0x180,0x0,0x3838,0x1980380,0x0,0x1ff0071c,0xe000e000,0xe0000f80,0x1c1c1c1c,0x1c1c1c1c,0x1c1c1e38,0x38e07000,0x70007000,0x70007000,
3298 0x1c001c0,0x1c001c0,0x703871b8,0x701c701c,0x701c701c,0x701c03c0,0x761c7038,0x70387038,0x703801c0,0x70703870,0x1ffc1ffc,0x1ffc1ffc,
3299 0x1ffc1ffc,0xfff3800,0x3ffe3ffe,0x3ffe3ffe,0x1c001c0,0x1c001c0,0x381c3838,0x381c381c,0x381c381c,0x381c7ffc,0x389c3838,0x38383838,
3300 0x38380ee0,0x381c0ee0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0xfffc,0xbc60fc,0x70e30000,0x70000e0,
3301 0x180,0x7f0,0x700,0x381c01c0,0x3e0001c,0x7ffc001c,0x381c03c0,0x381c001c,0x0,0x1f807ffc,0x3f00380,0x63031ffc,0x70387000,0x70387000,
3302 0x7000701c,0x703801c0,0x7071e0,0x7000701c,0x71b8701c,0x7000701c,0x70f00038,0x1c07038,0x7e03e7c,0x77001c0,0xe000380,0x1c001c0,
3303 0x0,0x3c1c,0x381c3800,0x381c3ffe,0x380381c,0x383801c0,0xe01fe0,0x380739c,0x3838381c,0x381c381c,0x70003f8,0x7003838,0xee03bdc,
3304 0x3c00ee0,0x3c00380,0x18000e0,0xf00000,0x1c007e7c,0x3c0,0x0,0x1000100,0x0,0x381800,0x70707e7c,0xe007e7c,0x7e7c0000,0x0,0x7c0,
3305 0x0,0x0,0x3f80018,0xe1fe7e7c,0x3c001c0,0x1c0,0x1c200700,0xc183ffe,0xf0c,0x8c01,0x38e0,0xc07f0,0x8c710000,0x180,0x0,0x3838,
3306 0x1980000,0x0,0x71c,0x7000f0,0x700f00,0x1ffc1ffc,0x1ffc1ffc,0x1ffc1ffc,0x3fe07000,0x70007000,0x70007000,0x1c001c0,0x1c001c0,
3307 0x703871b8,0x701c701c,0x701c701c,0x701c07e0,0x7c1c7038,0x70387038,0x703801c0,0x7ff03838,0x3c1c3c1c,0x3c1c3c1c,0x3c1c3c1c,
3308 0x3fff3800,0x3ffe3ffe,0x3ffe3ffe,0x1c001c0,0x1c001c0,0x381c3838,0x381c381c,0x381c381c,0x381c0000,0x391c3838,0x38383838,0x38380ee0,
3309 0x381c0ee0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfffc,0x9c01ce,0x70f60000,0x70000e0,0x180,
3310 0x0,0x700,0x381c01c0,0x780001c,0x7ffc001c,0x381c0380,0x381c003c,0x0,0x3e07ffc,0xf800380,0x63031ffc,0x70387000,0x70387000,
3311 0x7000701c,0x703801c0,0x7070f0,0x7000701c,0x71b8701c,0x7000701c,0x70700038,0x1c07038,0x7e03e7c,0xf7801c0,0x1e000380,0x1c001c0,
3312 0x0,0x381c,0x381c3800,0x381c3800,0x380381c,0x383801c0,0xe01fe0,0x380739c,0x3838381c,0x381c381c,0x7000078,0x7003838,0xee03a5c,
3313 0x7c00fe0,0x78001c0,0x18001c0,0x0,0x1c003ef8,0x380,0x0,0x1000100,0x810,0x383000,0x70703ef8,0x1e003ef8,0x3ef80000,0x0,0x7c0,
3314 0x0,0x0,0x78000c,0xe1c03ef8,0x78001c0,0x1c0,0x1c200700,0x63001c0,0x18003f8,0x4e12,0x1c70,0xc0000,0x4c320000,0x180,0x0,0x3838,
3315 0x1980000,0x0,0xe38,0x700118,0x701e00,0x1ffc1ffc,0x1ffc1ffc,0x1ffc1ffc,0x7fe07000,0x70007000,0x70007000,0x1c001c0,0x1c001c0,
3316 0x703871b8,0x701c701c,0x701c701c,0x701c0e70,0x7c1c7038,0x70387038,0x703801c0,0x7fc0381c,0x381c381c,0x381c381c,0x381c381c,
3317 0x78e03800,0x38003800,0x38003800,0x1c001c0,0x1c001c0,0x381c3838,0x381c381c,0x381c381c,0x381c0000,0x3b1c3838,0x38383838,0x38380fe0,
3318 0x381c0fe0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1860,0x9c0186,0x707e0000,0x30000c0,0x180,
3319 0x0,0xe00,0x183801c0,0xf00001c,0xe0001c,0x181c0380,0x381c0038,0x0,0xfc0000,0x7e000000,0x61873c1e,0x70383800,0x70707000,0x7000381c,
3320 0x703801c0,0x707070,0x7000701c,0x70f83838,0x70003838,0x70780038,0x1c07038,0x7e03c3c,0xe3801c0,0x1c000380,0xe001c0,0x0,0x381c,
3321 0x381c3800,0x381c3800,0x380381c,0x383801c0,0xe01ef0,0x380739c,0x3838381c,0x381c381c,0x7000038,0x7003838,0xfe03e7c,0xfe007c0,
3322 0x70001c0,0x18001c0,0x0,0xe001ff0,0x380,0x0,0x1000100,0x162c,0x381800,0x30701ff0,0x1c001ff0,0x1ff00000,0x0,0x3c0,0x0,0x0,
3323 0x380018,0xe1c01ff0,0x70001c0,0x1c0,0x1c200700,0xff801c0,0x18000f0,0x63e6,0xe38,0x0,0x6c3e0000,0x0,0x0,0x3838,0x1980000,0x0,
3324 0x1c70,0xf0000c,0xf01c00,0x3c1e3c1e,0x3c1e3c1e,0x3c1e3c1c,0x70e03800,0x70007000,0x70007000,0x1c001c0,0x1c001c0,0x707070f8,
3325 0x38383838,0x38383838,0x38381c38,0x38387038,0x70387038,0x703801c0,0x7000381c,0x381c381c,0x381c381c,0x381c381c,0x70e03800,
3326 0x38003800,0x38003800,0x1c001c0,0x1c001c0,0x381c3838,0x381c381c,0x381c381c,0x381c0380,0x3e1c3838,0x38383838,0x383807c0,0x381c07c0,
3327 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x18c0,0x9c0186,0x783c0000,0x38001c0,0x180,0x3800000,
3328 0x3800e00,0x1c3801c0,0x1e00003c,0xe00038,0x1c1c0780,0x381c0038,0x3800380,0x3c0000,0x78000000,0x61ff380e,0x70383808,0x70707000,
3329 0x7000381c,0x703801c0,0x40707078,0x7000701c,0x70f83838,0x70003838,0x70384038,0x1c07038,0x7e03c3c,0x1e3c01c0,0x3c000380,0xe001c0,
3330 0x0,0x383c,0x3c381c00,0x1c3c1c00,0x3801c3c,0x383801c0,0xe01c78,0x380739c,0x38381c38,0x3c381c3c,0x7000038,0x7003878,0x7c01e78,
3331 0x1ef007c0,0xf0001c0,0x18001c0,0x0,0xe000ee0,0x7800380,0xe380000,0x1001ff0,0x2242,0x40380c00,0x38700ee0,0x3c000ee0,0xee00000,
3332 0x0,0x0,0x0,0x0,0x380030,0xe1c00ee0,0xf0001c0,0x1c0,0xe200700,0xdd801c0,0x1800038,0x300c,0x71c,0x0,0x300c0000,0x0,0x0,0x3838,
3333 0x1980000,0x0,0x38e0,0xb0000c,0xb01c08,0x380e380e,0x380e380e,0x380e380e,0x70e03808,0x70007000,0x70007000,0x1c001c0,0x1c001c0,
3334 0x707070f8,0x38383838,0x38383838,0x3838381c,0x38387038,0x70387038,0x703801c0,0x7000381c,0x383c383c,0x383c383c,0x383c383c,
3335 0x70e01c00,0x1c001c00,0x1c001c00,0x1c001c0,0x1c001c0,0x1c383838,0x1c381c38,0x1c381c38,0x1c380380,0x1c383878,0x38783878,0x387807c0,
3336 0x3c3807c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0x18c0,0x10b801ce,0x3c3e0000,0x38001c0,0x180,
3337 0x3800000,0x3801c00,0x1e7801c0,0x3c002078,0xe02078,0x1c380700,0x1c3810f0,0x3800380,0x40000,0x40000380,0x307b380e,0x70701e18,
3338 0x70e07000,0x70001c1c,0x703801c0,0x60e0703c,0x7000701c,0x70f83c78,0x70003c70,0x703c70f0,0x1c03870,0x3c01c3c,0x3c1c01c0,0x78000380,
3339 0x7001c0,0x0,0x3c7c,0x3c381e18,0x1c7c1e0c,0x3801c3c,0x383801c0,0xe01c38,0x3c0739c,0x38381c38,0x3c381c3c,0x7001078,0x7803c78,
3340 0x7c01c38,0x1c780380,0x1e0001c0,0x18001c0,0x0,0x70c06c0,0x7000380,0xe300000,0x1000100,0x2142,0x70f00600,0x3c7006c0,0x780006c0,
3341 0x6c00000,0x0,0x0,0x0,0x0,0x10780060,0x73e206c0,0x1e0001c0,0x1c0,0x7240700,0x180c01c0,0x1800018,0x1818,0x30c,0x0,0x18180000,
3342 0x0,0x0,0x3c78,0x1980000,0x0,0x30c0,0x130000c,0x1301c18,0x380e380e,0x380e380e,0x380e380e,0x70e01e18,0x70007000,0x70007000,
3343 0x1c001c0,0x1c001c0,0x70e070f8,0x3c783c78,0x3c783c78,0x3c781008,0x7c783870,0x38703870,0x387001c0,0x70003a3c,0x3c7c3c7c,0x3c7c3c7c,
3344 0x3c7c3c7c,0x79f11e18,0x1e0c1e0c,0x1e0c1e0c,0x1c001c0,0x1c001c0,0x1c783838,0x1c381c38,0x1c381c38,0x1c380380,0x1c383c78,0x3c783c78,
3345 0x3c780380,0x3c380380,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0x38c0,0x1ff800fc,0x1fee0000,
3346 0x1800180,0x180,0x3800000,0x3801c00,0xff01ffc,0x3ffc3ff0,0xe03ff0,0xff00700,0x1ff81fe0,0x3800380,0x0,0x380,0x3000780f,0x7ff00ff8,
3347 0x7fc07ff8,0x70000ffc,0x70381ffc,0x7fe0701c,0x7ff8701c,0x70781ff0,0x70001ff0,0x701c7ff0,0x1c01fe0,0x3c01c38,0x380e01c0,0x7ffc0380,
3348 0x7001c0,0x0,0x1fdc,0x3ff00ff0,0xffc0ffc,0x3800fdc,0x38383ffe,0xe01c3c,0x1fc739c,0x38380ff0,0x3ff00ffc,0x7001ff0,0x3f81fb8,
3349 0x7c01c38,0x3c3c0380,0x1ffc01c0,0x18001c0,0x0,0x3fc0380,0x7000380,0xc70718c,0x1000100,0x2244,0x7ff00200,0x1fff0380,0x7ffc0380,
3350 0x3800000,0x0,0x0,0x0,0x0,0x1ff000c0,0x7f7e0380,0x1ffc01c0,0x1c0,0x3fc3ffe,0x1c0,0x1800018,0x7e0,0x104,0x0,0x7e00000,0x7ffe,
3351 0x0,0x3fde,0x1980000,0x0,0x2080,0x3300018,0x3300ff0,0x780f780f,0x780f780f,0x780f780e,0xf0fe0ff8,0x7ff87ff8,0x7ff87ff8,0x1ffc1ffc,
3352 0x1ffc1ffc,0x7fc07078,0x1ff01ff0,0x1ff01ff0,0x1ff00000,0x7ff01fe0,0x1fe01fe0,0x1fe001c0,0x70003bf8,0x1fdc1fdc,0x1fdc1fdc,
3353 0x1fdc1fdc,0x3fbf0ff0,0xffc0ffc,0xffc0ffc,0x3ffe3ffe,0x3ffe3ffe,0xff03838,0xff00ff0,0xff00ff0,0xff00000,0x3ff01fb8,0x1fb81fb8,
3354 0x1fb80380,0x3ff00380,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0x31c0,0x7e00078,0x7cf0000,0x1800180,
3355 0x0,0x3800000,0x3803800,0x3c01ffc,0x3ffc0fe0,0xe01fc0,0x3e00e00,0x7e00f80,0x3800380,0x0,0x380,0x18007007,0x7fc003f0,0x7f007ff8,
3356 0x700003f0,0x70381ffc,0x3f80701e,0x7ff8701c,0x707807c0,0x700007c0,0x701e1fc0,0x1c00fc0,0x3c01818,0x780f01c0,0x7ffc0380,0x3801c0,
3357 0x0,0xf9c,0x39e003e0,0x79c03f0,0x380079c,0x38383ffe,0xe01c1e,0x7c739c,0x383807e0,0x39e0079c,0x7000fc0,0x1f80f38,0x3801c38,
3358 0x781e0380,0x1ffc01c0,0x18001c0,0x0,0x1f80100,0xe000700,0x1c60718c,0x1000100,0x1e3c,0x1fc00100,0x7ff0100,0x7ffc0100,0x1000000,
3359 0x0,0x0,0x0,0x0,0xfc00080,0x3e3c0100,0x1ffc01c0,0x1c0,0xf83ffe,0x1c0,0x1800838,0x0,0x0,0x0,0x0,0x7ffe,0x0,0x3b9e,0x1980000,
3360 0x0,0x0,0x2300038,0x23003e0,0x70077007,0x70077007,0x70077007,0xe0fe03f0,0x7ff87ff8,0x7ff87ff8,0x1ffc1ffc,0x1ffc1ffc,0x7f007078,
3361 0x7c007c0,0x7c007c0,0x7c00000,0xc7c00fc0,0xfc00fc0,0xfc001c0,0x700039f0,0xf9c0f9c,0xf9c0f9c,0xf9c0f9c,0x1f1e03e0,0x3f003f0,
3362 0x3f003f0,0x3ffe3ffe,0x3ffe3ffe,0x7e03838,0x7e007e0,0x7e007e0,0x7e00000,0x63e00f38,0xf380f38,0xf380380,0x39e00380,0x0,0x0,
3363 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x800000,0x0,0xc00300,0x0,0x3000000,0x3800,0x0,0x0,0x0,0x0,
3364 0x0,0x300,0x0,0x0,0x1c000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe0,0x0,0x0,0x0,0x0,0x380,0x3801c0,0x0,0x0,0x0,0x0,0x1c,0x0,0xe00000,
3365 0x0,0x0,0x3800001c,0x0,0x0,0x0,0x700,0x1c0,0x18001c0,0x0,0x0,0xe000700,0x18600000,0x1000100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3366 0x0,0x0,0x0,0x0,0x0,0x200000,0x0,0x1800ff0,0x0,0x0,0x0,0x0,0x0,0x0,0x3800,0x1980000,0x1800000,0x0,0x6300070,0x6300000,0x0,
3367 0x0,0x0,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40000000,
3368 0x0,0x700,0x38000700,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x800000,0x0,0xc00300,0x0,0x7000000,
3369 0x7000,0x0,0x0,0x0,0x0,0x0,0x700,0x0,0x0,0xf040000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x78,0x0,0x0,0x0,0x0,0x3f0,0x1c0fc0,0x0,0x0,
3370 0x0,0x0,0x1c,0x0,0xe00000,0x0,0x0,0x3800001c,0x0,0x0,0x0,0x700,0x1e0,0x18003c0,0x0,0x0,0xc000700,0x18c00000,0x1000000,0x0,
3371 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x200000,0x0,0x18007e0,0x0,0x0,0x0,0x0,0x0,0x0,0x3800,0x1980000,0xc00000,
3372 0x0,0x7f800e0,0x7f80000,0x0,0x0,0x0,0x60,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x60,0x0,0x0,0x0,0x0,
3373 0x0,0x0,0x0,0x0,0x0,0x0,0x700,0x38000700,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x800000,
3374 0x0,0x600600,0x0,0x6000000,0x0,0x0,0x0,0x0,0x0,0x0,0x600,0x0,0x0,0x7fc0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x30,0x0,0x0,0x0,0x0,
3375 0x3f0,0xfc0,0x0,0x0,0x0,0x0,0x838,0x0,0x1e00000,0x0,0x0,0x3800001c,0x0,0x0,0x0,0xf00,0xfc,0x1801f80,0x0,0x0,0x8008e00,0x30c00000,
3376 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x200000,0x0,0x1800000,0x0,0x0,0x0,0x0,0x0,0x0,0x3800,0x1980000,0xc00000,
3377 0x0,0x3001c0,0x300000,0x0,0x0,0x0,0x60,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x60,0x0,0x0,0x0,0x0,0x0,
3378 0x0,0x0,0x0,0x0,0x0,0xf00,0x38000f00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x800000,0x0,
3379 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfc0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3380 0x0,0x0,0xff0,0x0,0x1fc00000,0x0,0x0,0x3800001c,0x0,0x0,0x0,0x3e00,0x7c,0x1801f00,0x0,0x0,0x800fe00,0x0,0x0,0x0,0x0,0x0,0x0,
3381 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x200000,0x0,0x1800000,0x0,0x0,0x0,0x0,0x0,0x0,0x3800,0x0,0x7c00000,0x0,0x3001fc,0x300000,
3382 0x0,0x0,0x0,0x3e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3383 0x3e00,0x38003e00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3384 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfff8,0x0,0x0,0x0,0x7e0,0x0,0x1f000000,
3385 0x0,0x0,0x3800001c,0x0,0x0,0x0,0x3c00,0x0,0x1800000,0x0,0x0,0x7800,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3386 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3800,0x0,0x7800000,0x0,0x0,0x0,0x0,0x0,0x0,0x3c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3387 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00,0x38003c00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3388 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3389 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfff8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1800000,0x0,0x0,0x0,0x0,
3390 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3391 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3392 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3393 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3394 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3395 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3396 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3397 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3398 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3399 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3400 0x0,0x0,0x0,0x0,0x0,0x0,0x0 };
3404 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3405 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3406 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c380000,0x0,0x1c380,0x0,0x0,0x0,0x0,0x0,
3407 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3800007,0x3c003,0x86000000,
3408 0x1e00000,0x3,0x80000700,0x3c00000,0x380000,0x70003c00,0x0,0xe1800e,0x1c00,0xf000e18,0x0,0x0,0x700000e0,0x780000,0x7000,0x0,
3409 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3410 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3411 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3412 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe700000,0x0,0xe700,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x38e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3413 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0000e,0x7e003,0xe60071c0,0x7f80000,0x1,0xc0000e00,0x7e0038e,0x1c0000,
3414 0xe0007e00,0x38e00000,0xf98007,0x3800,0x1f800f98,0x1c70000,0x0,0x380001c0,0xfc0071,0xc000e000,0x0,0x0,0x0,0x0,0x3e00000,0x0,
3415 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3416 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3417 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3418 0x0,0x0,0x0,0x7e00000,0x0,0x7e00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x38e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3419 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe0001c,0xe7006,0x7c0071c0,0xe180000,0x0,0xe0001c00,0xe70038e,0xe0001,0xc000e700,0x38e00000,
3420 0x19f0003,0x80007000,0x39c019f0,0x1c70000,0x0,0x1c000380,0x1ce0071,0xc001c000,0x0,0x0,0x0,0x0,0x7f00000,0x0,0x0,0x0,0x0,0x0,
3421 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3422 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3423 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00000,
3424 0x0,0x3c00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x38e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3425 0x0,0x0,0x700038,0x1c3806,0x3c0071c0,0xc0c0000,0x0,0x70003800,0x1c38038e,0x70003,0x8001c380,0x38e00000,0x18f0001,0xc000e000,
3426 0x70e018f0,0x1c70000,0x0,0xe000700,0x3870071,0xc0038000,0x0,0x0,0x0,0x0,0xe380000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3427 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3428 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3429 0xe000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x60000000,0x0,0x0,
3430 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c38,0x0,0x1,0xc3800000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c00000,0x0,0x0,0x0,
3431 0x0,0x0,0x0,0x0,0x0,0x0,0xc0c0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe000003,0x80018000,0x0,0xc180000,
3432 0xe,0x380,0x1800000,0xe00000,0x38001800,0x0,0x38,0xe00,0x6000000,0x0,0x1,0xc0000070,0x300000,0x3800,0x0,0x0,0x0,0x0,0x0,0x0,
3433 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x600,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3434 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7000000,0x0,0x0,0x0,0x0,0x0,0x0,
3435 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x78c00,0xc30,
3436 0x0,0x0,0xc3000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3800000,0x0,0x0,0x0,0xe0,0x1c000f,0xc0000000,0x0,0x0,
3437 0x0,0xc0c0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7000007,0x3c003,0xc6000000,0xc180000,0x7,0x700,
3438 0x3c00000,0x700000,0x70003c00,0x0,0xf1801c,0x1c00,0xf000f18,0x0,0x0,0xe00000e0,0x780000,0x7000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3439 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x600,0x0,0x0,0x1c007000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3440 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfe0000,0xfe000,0x0,0x3800000,0x700000,0x38,
3441 0x7,0xe000001c,0x1c00,0x1c00700,0x7fc0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf800e,0x3e0000,0x0,0x0,0x0,0x1e00000,0x0,0x1,
3442 0xf8000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7cc00,0x660,0x0,0x0,0x66000000,0x0,0x0,0x0,0x0,0x7,0x1c000000,0x0,0x0,0x0,0x3fe00000,
3443 0x0,0x0,0x7000000,0x0,0x0,0x0,0x3e0,0x7c001f,0xe0000000,0x0,0x0,0x0,0xe1c0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3444 0x0,0x0,0x0,0x1f80,0x380000e,0x7e007,0xe60071c0,0xc180000,0x3,0x80000e00,0x7e0038e,0x380000,0xe0007e00,0x38e00f00,0x1f9800e,
3445 0x3800,0x1f801f98,0x1c70000,0x0,0x700001c0,0xfc0071,0xc000e007,0x38e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3446 0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x1c7000,0x61c00600,0x1e00007e,0x70000,0x18003000,0x1800000,0x0,0x0,0x1c01f0,0x7e003f,0xc003f800,
3447 0x1e03ffc,0x7f01ff,0xfc03f000,0x7e000000,0x0,0x0,0xfc0,0x1e,0x7fe000,0x7e03fe00,0x3fff07ff,0xe007e038,0x383ffe0,0xff81c01,
3448 0xe1c000f8,0xf8f00e0,0xfc01ffc,0x3f00ff,0xc000fe07,0xfffc7007,0x1c007700,0x73c01ef,0x78ffff,0xfe0380,0xfe000,0x38000000,0x1800000,
3449 0x700000,0x38,0x1f,0xe000001c,0x1c00,0x1c00700,0x7fc0000,0x0,0x0,0x0,0x0,0x1c000000,0x0,0x0,0x0,0x3f800e,0x3f8000,0x0,0xfc0000,
3450 0x0,0x7f00000,0x0,0x1,0x98000000,0x7f00000,0x3ffe00,0xffff0,0x0,0x0,0x0,0x0,0x0,0xcf81f,0xee3807e0,0x0,0x0,0x7e03c01e,0x1c,
3451 0x0,0x1f800000,0xf0078038,0xfc007,0x1c000000,0xfe00000,0x0,0x0,0x3fe000f0,0xf,0xc001f800,0x6000000,0xffc000,0x0,0x1c0007e0,
3452 0x360,0x6c0010,0x70000700,0xf0001e,0x3c000,0x78000f00,0x7f800ff,0xf007e01f,0xff83fff0,0x7ffe0fff,0xc1fff03f,0xfe07ffc0,0xfff83fc0,
3453 0x7807007,0xe000fc00,0x1f8003f0,0x7e0000,0x1f867,0x70e00e,0x1c01c380,0x38f00787,0x3fe0,0x180000c,0x66006,0x7c0071c0,0xe380000,
3454 0x1,0x80000c00,0x660038e,0x180000,0xc0006600,0x38e0078e,0x19f0006,0x3000,0x198019f0,0x1c70000,0x0,0x30000180,0xcc0071,0xc000c007,
3455 0x38e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x1c7000,0x61800600,0x7f8001ff,0x70000,
3456 0x38003800,0x1800000,0x0,0x0,0x3807fc,0x1fe00ff,0xf00ffe00,0x3e03ffc,0xff81ff,0xfc07fc01,0xff800000,0x0,0x0,0x3fe0,0xfe001e,
3457 0x7ff801,0xff83ff80,0x3fff07ff,0xe01ff838,0x383ffe0,0xff81c03,0xc1c000f8,0xf8f80e0,0x3ff01fff,0xffc0ff,0xf003ff87,0xfffc7007,
3458 0x1e00f700,0x71c03c7,0x70ffff,0xfe01c0,0xfe000,0x7c000000,0xc00000,0x700000,0x38,0x3f,0xe000001c,0x1c00,0x1c00700,0x7fc0000,
3459 0x0,0x0,0x0,0x0,0x1c000000,0x0,0x0,0x0,0x3f800e,0x3f8000,0x0,0x3fe0000,0x0,0xff00000,0x0,0x3,0xc000000,0x1ffc0000,0xfffe00,
3460 0xffff0,0x0,0x0,0x0,0x0,0x0,0xc781f,0xee3803c0,0x0,0x0,0x3c01c01c,0x1c,0xc000,0x7fc00000,0x70070038,0x3fe007,0x1c000000,0x1ff80000,
3461 0x0,0x0,0x3fe003fc,0x1f,0xe003fc00,0xc000000,0x3ffc000,0x0,0x7c000ff0,0x60,0xc0000,0x30000700,0xf0001e,0x3c000,0x78000f00,
3462 0x3f000ff,0xf01ff81f,0xff83fff0,0x7ffe0fff,0xc1fff03f,0xfe07ffc0,0xfff83ff8,0x7c0701f,0xf803ff00,0x7fe00ffc,0x1ff8000,0x7fe67,
3463 0x70e00e,0x1c01c380,0x38700707,0x7ff0,0xc00018,0xc3006,0x3c0071c0,0x7f00000,0x0,0xc0001800,0xc30038e,0xc0001,0x8000c300,0x38e003fc,
3464 0x18f0003,0x6000,0x30c018f0,0x1c70000,0x0,0x18000300,0x1860071,0xc0018007,0x38e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3465 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x1c7000,0xe1801fc0,0x618001ff,0x70000,0x30001800,0x21840000,0x0,0x0,0x380ffe,0x1fe00ff,
3466 0xfc0fff00,0x3e03ffc,0x1ff81ff,0xfc0ffe03,0xffc00000,0x0,0x0,0x7ff0,0x3ff803f,0x7ffc03,0xffc3ffc0,0x3fff07ff,0xe03ffc38,0x383ffe0,
3467 0xff81c07,0x81c000f8,0xf8f80e0,0x7ff81fff,0x81ffe0ff,0xf80fff87,0xfffc7007,0xe00e700,0x70e0387,0x80f0ffff,0xe001c0,0xe000,
3468 0xfe000000,0xe00000,0x700000,0x38,0x3c,0x1c,0x1c00,0x1c00700,0x1c0000,0x0,0x0,0x0,0x0,0x1c000000,0x0,0x0,0x0,0x78000e,0x3c000,
3469 0x0,0x7ff0000,0x0,0xf100000,0x0,0x7,0xe000000,0x7ffc0000,0x1fffe00,0xffff0,0x0,0x0,0x0,0x0,0x0,0x3,0xf780180,0x0,0x0,0x1801e03c,
3470 0x1c,0xc000,0xffc00000,0x780f0038,0x786000,0x7f00,0x18380000,0x0,0xfe00,0x30c,0x10,0x70020e00,0x1c000000,0x7f8c000,0x0,0x6c001c38,
3471 0x60,0xc0000,0x70000700,0x1f8003f,0x7e000,0xfc001f80,0x3f000ff,0xf03ffc1f,0xff83fff0,0x7ffe0fff,0xc1fff03f,0xfe07ffc0,0xfff83ffc,
3472 0x7c0703f,0xfc07ff80,0xfff01ffe,0x3ffc000,0xffec7,0x70e00e,0x1c01c380,0x38780f07,0xf070,0xe00038,0x1c3800,0x0,0x3e00000,0x0,
3473 0xe0003800,0x1c380000,0xe0003,0x8001c380,0x3e0,0x3,0x8000e000,0x70e00000,0x0,0x0,0x1c000700,0x3870000,0x38007,0x0,0x0,0x0,
3474 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x1c7000,0xe3807ff0,0xc0c003c1,0x70000,0x70001c00,
3475 0x718e0000,0x0,0x0,0x700f1e,0x1ce00c0,0x3c0c0f80,0x7e03800,0x3e08000,0x381e0f03,0xc1e00000,0x0,0x0,0x7078,0x783c03f,0x701e07,
3476 0xc1c383e0,0x38000700,0x7c1c38,0x3801c00,0x381c0f,0x1c000fc,0x1f8f80e0,0x78781c07,0x81e1e0e0,0x780f0180,0xe007007,0xe00e380,
3477 0xe0f0783,0x80e0000e,0xe000e0,0xe001,0xef000000,0x0,0x700000,0x38,0x38,0x1c,0x0,0x700,0x1c0000,0x0,0x0,0x0,0x0,0x1c000000,
3478 0x0,0x0,0x0,0x70000e,0x1c000,0x0,0xf830000,0x0,0x1e000000,0x0,0x0,0x10000,0x780c0000,0x3e38000,0xe0,0x0,0x0,0x0,0x0,0x0,0x3,
3479 0xd580000,0x0,0x0,0xe038,0x1c,0xc000,0xf0400000,0x380e0038,0x702000,0x1ffc0,0xc0000,0x0,0x3ff80,0x606,0x0,0x30000600,0x0,
3480 0x7f8c000,0x0,0xc001818,0x60,0xc0003,0xe0000700,0x1f8003f,0x7e000,0xfc001f80,0x73801ee,0x7c1c1c,0x38000,0x70000e00,0xe0001,
3481 0xc0003800,0x700383e,0x7c0703c,0x3c078780,0xf0f01e1e,0x3c3c000,0xf0f87,0x70e00e,0x1c01c380,0x38380e07,0xe038,0x0,0x0,0x0,
3482 0x0,0x0,0x0,0x0,0x0,0x0,0xff0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3483 0x0,0x0,0x0,0x0,0x0,0x1c,0x1c7000,0xc380fff0,0xc0c00380,0x70000,0x70001c00,0x3dbc0070,0x0,0x0,0x701e0f,0xe0000,0x1e000380,
3484 0x6e03800,0x7800000,0x781c0707,0x80e00000,0x0,0x0,0x4038,0xe00c03f,0x700e07,0x4380f0,0x38000700,0x700438,0x3801c00,0x381c0e,
3485 0x1c000ec,0x1b8fc0e0,0xf03c1c03,0xc3c0f0e0,0x3c1e0000,0xe007007,0xe00e380,0xe070703,0xc1e0001e,0xe000e0,0xe001,0xc7000000,
3486 0x0,0x700000,0x38,0x38,0x1c,0x0,0x700,0x1c0000,0x0,0x0,0x0,0x0,0x1c000000,0x0,0x0,0x0,0x70000e,0x1c000,0x0,0xe010000,0x0,
3487 0x1c000000,0x10,0x20000,0x6c000,0xf0000000,0x3838000,0x1e0,0x0,0xf000f,0xf1e00,0x78f00000,0x0,0x3,0xdd80000,0x0,0x0,0xf078,
3488 0x0,0xc001,0xe0000000,0x1c1c0038,0x700000,0x3c1e0,0xc0000,0x0,0x783c0,0x606,0x0,0x30000e00,0x0,0xff8c000,0x0,0xc00300c,0x60,
3489 0xc0003,0xe0000000,0x1f8003f,0x7e000,0xfc001f80,0x73801ce,0x70041c,0x38000,0x70000e00,0xe0001,0xc0003800,0x700380f,0x7e07078,
3490 0x1e0f03c1,0xe0783c0f,0x781e000,0x1c0787,0x70e00e,0x1c01c380,0x383c1e07,0xff00e038,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x878,
3491 0x0,0x0,0x0,0x7,0x80000080,0x0,0x0,0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,
3492 0x1c7000,0xc301e630,0xc0c00380,0x70000,0xe0000e00,0xff00070,0x0,0x0,0xe01c07,0xe0000,0xe000380,0xce03800,0x7000000,0x701c0707,
3493 0x600000,0x0,0x4000010,0x38,0x1c00e07f,0x80700e0e,0x38070,0x38000700,0xe00038,0x3801c00,0x381c1c,0x1c000ec,0x1b8ec0e0,0xe01c1c01,
3494 0xc38070e0,0x1c1c0000,0xe007007,0x701c380,0xe078e01,0xc1c0003c,0xe00070,0xe003,0x83800000,0x7f,0x71f000,0x3e003e38,0x3f007ff,
3495 0xe01f1c1c,0x7801fc00,0x3fc00701,0xe01c0077,0x8f071e00,0xf801c7c,0x7c700e,0x3e01fc03,0xfff8380e,0xe007700,0x73c0787,0x387ffc,
3496 0x70000e,0x1c000,0x0,0xe000000,0x0,0x1c000000,0x10,0x20000,0xc2000,0xe0000000,0x3838000,0x3c0,0x0,0xf000f,0x78e00,0x70e00000,
3497 0x0,0x3,0xc980fe0,0x1f0,0xf8000007,0xffc07070,0x0,0x3f801,0xc0000000,0x1e3c0038,0x700000,0x70070,0x7fc0000,0x0,0xe00e0,0x606,
3498 0x1c0000,0x70007c00,0x380e,0xff8c000,0x0,0xc00300c,0x60,0xc0000,0x70000000,0x3fc007f,0x800ff001,0xfe003fc0,0x73801ce,0xe0001c,
3499 0x38000,0x70000e00,0xe0001,0xc0003800,0x7003807,0x7607070,0xe0e01c1,0xc0383807,0x700e000,0x1c0387,0x70e00e,0x1c01c380,0x381c1c07,
3500 0xffc0e0f8,0x3f8007f,0xfe001,0xfc003f80,0x7f007e3,0xe003e001,0xf8003f00,0x7e000fc,0xfe001f,0xc003f800,0x7f00003c,0x38f0007,
3501 0xc000f800,0x1f0003e0,0x7c0007,0x8003f0c3,0x80e0701c,0xe0381c0,0x70700387,0x1f01c00e,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3502 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x1c701f,0xfff1c600,0xc0c00380,0x70000,0xe0000e00,0x3c00070,0x0,0x0,0xe03c07,
3503 0x800e0000,0xe000380,0x1ce03800,0x7000000,0x701c0707,0x7003c0,0x780000,0x3c00001e,0x38,0x18006073,0x80700e0e,0x38070,0x38000700,
3504 0xe00038,0x3801c00,0x381c38,0x1c000ee,0x3b8ee0e1,0xe01e1c01,0xc78078e0,0x1c1c0000,0xe007007,0x701c387,0xe03de00,0xe3800038,
3505 0xe00070,0xe007,0x1c00000,0x1ff,0xc077f801,0xff807fb8,0xff807ff,0xe03fdc1d,0xfc01fc00,0x3fc00703,0xc01c007f,0xdf877f00,0x3fe01dfe,
3506 0xff700e,0xff07ff03,0xfff8380e,0x700f700,0x71e0f03,0x80707ffc,0x70000e,0x1c000,0x0,0x1c000008,0x0,0x1c000000,0x10,0x20000,
3507 0x82000,0xe0000000,0x7038000,0x80000380,0x2000040,0x7000e,0x38700,0xf1e00000,0x0,0x3,0xc183ff8,0x3fd,0xfc008007,0xffc038e0,
3508 0x0,0xffc01,0xc0008008,0xe380038,0x380000,0xe3e38,0x1ffc0040,0x80000000,0x1cfc70,0x606,0x1c0000,0xe0007c00,0x380e,0xff8c000,
3509 0x0,0xc00300c,0x8100060,0xc0000,0x30000700,0x39c0073,0x800e7001,0xce0039c0,0x73801ce,0xe0001c,0x38000,0x70000e00,0xe0001,
3510 0xc0003800,0x7003807,0x77070f0,0xf1e01e3,0xc03c7807,0x8f00f080,0x83c0787,0x70e00e,0x1c01c380,0x380e3807,0xffe0e1c0,0xffe01ff,
3511 0xc03ff807,0xff00ffe0,0x1ffc0ff7,0xf01ff807,0xfc00ff80,0x1ff003fe,0xfe001f,0xc003f800,0x7f0003fc,0x3bf801f,0xf003fe00,0x7fc00ff8,
3512 0x1ff0007,0x8007fd83,0x80e0701c,0xe0381c0,0x70380707,0x7f80e01c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3513 0x0,0x0,0x0,0x0,0x1c,0x1c701f,0xfff1c600,0x618081c0,0x70000,0xe0000e00,0x3c00070,0x0,0x0,0xe03803,0x800e0000,0xe000380,0x18e03800,
3514 0xf000000,0xf01c0707,0x7003c0,0x780000,0xfc00001f,0x80000078,0x301e6073,0x80700e1c,0x38038,0x38000700,0x1c00038,0x3801c00,
3515 0x381c70,0x1c000e6,0x338ee0e1,0xc00e1c01,0xc70038e0,0x1c1c0000,0xe007007,0x701c387,0xe01dc00,0xf7800078,0xe00070,0xe00e,0xe00000,
3516 0x3ff,0xe07ffc03,0xffc0fff8,0x1ffc07ff,0xe07ffc1d,0xfe01fc00,0x3fc00707,0x801c007f,0xdf877f80,0x7ff01fff,0x1fff00e,0xff07ff03,
3517 0xfff8380e,0x700e380,0xe0e0e03,0x80707ffc,0x70000e,0x1c000,0x0,0x7ffc001c,0x0,0x1c000000,0x10,0x20000,0x82000,0xe0000000,
3518 0x7038001,0xc0000780,0x70000e0,0x3800e,0x38700,0xe1c00000,0x0,0x3,0xc183ff8,0x7ff,0xfc01c007,0xffc03de0,0x0,0x1ffc01,0xc001c01c,
3519 0xf780038,0x3c0000,0xcff18,0x380c00c1,0x80000000,0x18fe30,0x30c,0x1c0001,0xc0000e00,0x380e,0xff8c000,0x0,0xc00300c,0xc180060,
3520 0xc0000,0x30000700,0x39c0073,0x800e7001,0xce0039c0,0xe1c038e,0x1c0001c,0x38000,0x70000e00,0xe0001,0xc0003800,0x7003803,0x877070e0,
3521 0x71c00e3,0x801c7003,0x8e0071c0,0x1c380fc7,0x70e00e,0x1c01c380,0x380f7807,0x1e0e380,0x1fff03ff,0xe07ffc0f,0xff81fff0,0x3ffe0fff,
3522 0xf03ffc0f,0xfe01ffc0,0x3ff807ff,0xfe001f,0xc003f800,0x7f0007fe,0x3bfc03f,0xf807ff00,0xffe01ffc,0x3ff8007,0x800fff83,0x80e0701c,
3523 0xe0381c0,0x70380707,0xffc0e01c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x1c701f,
3524 0xfff1c600,0x7f8381e0,0x70000,0xc0000600,0xff00070,0x0,0x0,0x1c03803,0x800e0000,0xe000f00,0x38e03fe0,0xe000000,0xe00e0e07,
3525 0x7003c0,0x780007,0xf0ffff87,0xf00000f0,0x307fe0f3,0xc0703c1c,0x38038,0x38000700,0x1c00038,0x3801c00,0x381ce0,0x1c000e6,0x338e70e1,
3526 0xc00e1c01,0xc70038e0,0x3c1e0000,0xe007007,0x783c38f,0x8e01fc00,0x770000f0,0xe00038,0xe01c,0x700000,0x381,0xe07c1e07,0xc0c1e0f8,
3527 0x3c1e0038,0xf07c1f,0xe001c00,0x1c0070f,0x1c0079,0xf3c7c380,0xf0781f07,0x83c1f00f,0xc10f0300,0x1c00380e,0x700e380,0xe0f1e03,
3528 0xc0f00078,0x70000e,0x1c000,0x0,0xfff8003e,0x0,0x3c000000,0x10,0x20000,0xc6000,0xf0000000,0x7038003,0xe0000f00,0xf8001f0,
3529 0x3801c,0x18300,0xe1800000,0x0,0x3,0xc187818,0x70f,0x9e03e000,0x7801dc0,0x1c,0x3cc401,0xc000efb8,0x7f7f0038,0x3f0000,0x1ce11c,
3530 0x300c01c3,0x80000000,0x38c638,0x3fc,0x1c0003,0x80000600,0x380e,0xff8c000,0x0,0xc00300c,0xe1c0060,0xc0010,0x70000700,0x79e00f3,
3531 0xc01e7803,0xcf0079e0,0xe1c038e,0x1c0001c,0x38000,0x70000e00,0xe0001,0xc0003800,0x7003803,0x873870e0,0x71c00e3,0x801c7003,
3532 0x8e0070e0,0x38381dc7,0x70e00e,0x1c01c380,0x38077007,0xf0e700,0x1c0f0381,0xe0703c0e,0x781c0f0,0x381e083e,0x787c0c1e,0xf03c1e0,
3533 0x783c0f07,0x800e0001,0xc0003800,0x7000fff,0x3e1c078,0x3c0f0781,0xe0f03c1e,0x783c000,0x1e0f03,0x80e0701c,0xe0381c0,0x70380f07,
3534 0xc1e0e03c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x1,0x8701c600,0x1e0f01e0,0x1,
3535 0xc0000700,0x3dbc0070,0x0,0x0,0x1c03803,0x800e0000,0x1e01fe00,0x70e03ff8,0xe3e0001,0xe007fc07,0x80f003c0,0x78001f,0xc0ffff81,
3536 0xfc0001e0,0x30e1e0e1,0xc07ff81c,0x38038,0x3ffe07ff,0xc1c0003f,0xff801c00,0x381de0,0x1c000e7,0x738e70e1,0xc00e1c03,0xc70038e0,
3537 0x780f8000,0xe007007,0x383838d,0x8e00f800,0x7f0000e0,0xe00038,0xe000,0x0,0x200,0xf0780e07,0x8041c078,0x380e0038,0xe03c1e,
3538 0xf001c00,0x1c0071e,0x1c0070,0xe1c783c0,0xe0381e03,0x8380f00f,0xe0000,0x1c00380e,0x381c380,0xe07bc01,0xc0e00078,0x70000e,
3539 0x1c000,0x0,0x1c000061,0x0,0x38000000,0x10,0x20000,0x7c000,0x7c000000,0x703fc06,0x10000e00,0x18400308,0x1801c,0x1c381,0xc3800000,
3540 0x0,0x0,0x7000,0xe0f,0xe061000,0x7801fc0,0x1c,0x38c001,0xc0007ff0,0x7fff0038,0x77c000,0x19c00c,0x301c0387,0x0,0x30c618,0xf0,
3541 0x1c0007,0x600,0x380e,0x7f8c007,0x80000000,0xc001818,0x70e03fc,0x387f871f,0xe0e00700,0x70e00e1,0xc01c3803,0x870070e0,0xe1c038f,
3542 0xe1c0001f,0xff03ffe0,0x7ffc0fff,0x800e0001,0xc0003800,0x7003803,0x873870e0,0x71c00e3,0x801c7003,0x8e007070,0x703839c7,0x70e00e,
3543 0x1c01c380,0x3807f007,0x70e700,0x10078200,0xf0401e08,0x3c10078,0x200f001c,0x3878041c,0x70380e0,0x701c0e03,0x800e0001,0xc0003800,
3544 0x7001e0f,0x3c1e070,0x1c0e0381,0xc070380e,0x701c000,0x1c0f03,0x80e0701c,0xe0381c0,0x701c0e07,0x80e07038,0x0,0x0,0x0,0x0,0x0,
3545 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x3,0x8600e600,0x7803f0,0x1,0xc0000700,0x718e0070,0x0,0x0,0x38038c3,
3546 0x800e0000,0x3c01f800,0x60e03ffc,0xeff8001,0xc001f003,0xc1f003c0,0x7800fe,0xffff80,0x3f8003c0,0x60c0e0e1,0xc07fe01c,0x38038,
3547 0x3ffe07ff,0xc1c07e3f,0xff801c00,0x381fe0,0x1c000e3,0x638e30e1,0xc00e1c07,0x870038ff,0xf00ff800,0xe007007,0x38381cd,0x9c007000,
3548 0x3e0001e0,0xe0001c,0xe000,0x0,0x0,0x70780f0f,0x3c078,0x70070038,0x1e03c1c,0x7001c00,0x1c0073c,0x1c0070,0xe1c701c1,0xe03c1e03,
3549 0xc780f00f,0xe0000,0x1c00380e,0x381c387,0xe03f801,0xc0e000f0,0x70000e,0x1c007,0xe0100000,0x1c0000cd,0x80000003,0xffc00000,
3550 0x3ff,0x807ff000,0xe0,0x7fc00060,0x703fc0c,0xd8001e00,0x3360066c,0x1c018,0xc181,0x83000000,0x0,0x0,0x7000,0x300e07,0xe0cd800,
3551 0xf000f80,0x1c,0x78c00f,0xff0038e0,0x3e00038,0xe1e000,0x19800c,0x383c070e,0x7fffc00,0x30fc18,0x0,0xffff80e,0x20e00,0x380e,
3552 0x7f8c007,0x80000000,0xc001c38,0x38703ff,0xf87fff0f,0xcfe00f00,0x70e00e1,0xc01c3803,0x870070e0,0x1e1e078f,0xe1c0001f,0xff03ffe0,
3553 0x7ffc0fff,0x800e0001,0xc0003800,0x700ff83,0x871870e0,0x71c00e3,0x801c7003,0x8e007038,0xe03871c7,0x70e00e,0x1c01c380,0x3803e007,
3554 0x70e700,0x38000,0x70000e00,0x1c00038,0x7001c,0x38f00038,0x3870070,0xe00e1c01,0xc00e0001,0xc0003800,0x7001c07,0x380e0f0,0x1e1e03c3,
3555 0xc078780f,0xf01e000,0x3c0f03,0x80e0701c,0xe0381c0,0x701c0e07,0x80f07038,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3556 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x3,0x8600ff00,0x1e00778,0x38000001,0xc0000700,0x21843fff,0xe0000000,0x0,0x38039e3,0x800e0000,
3557 0x7c01fe00,0xe0e0203e,0xeffc001,0xc00ffe03,0xff700000,0x7f0,0x0,0x7f00380,0x618060e1,0xc07ffc1c,0x38038,0x3ffe07ff,0xc1c07e3f,
3558 0xff801c00,0x381ff0,0x1c000e3,0x638e38e1,0xc00e1fff,0x870038ff,0xc003fe00,0xe007007,0x38381cd,0x9c00f800,0x3e0003c0,0xe0001c,
3559 0xe000,0x0,0x0,0x7070070e,0x38038,0x70070038,0x1c01c1c,0x7001c00,0x1c00778,0x1c0070,0xe1c701c1,0xc01c1c01,0xc700700e,0xfc000,
3560 0x1c00380e,0x381c3c7,0x1e01f001,0xe1e001e0,0xf0000e,0x1e01f,0xf8300000,0x1c00019c,0xc0000003,0xffc00000,0x10,0x20000,0x700,
3561 0x1ff000c0,0x703fc19,0xcc003c00,0x67300ce6,0xc038,0xc181,0x83000000,0x0,0x0,0x7e00,0x180e07,0xe19cc00,0x1e000f80,0x1c,0x70c00f,
3562 0xff007070,0x3e00038,0xe0f000,0x19800c,0x1fec0e1c,0x7fffc00,0x30f818,0x0,0xffff81f,0xf003fc00,0x380e,0x3f8c007,0x80000000,
3563 0x7f800ff0,0x1c3803f,0xe007fc00,0xff800e00,0x70e00e1,0xc01c3803,0x870070e0,0x1c0e070f,0xe1c0001f,0xff03ffe0,0x7ffc0fff,0x800e0001,
3564 0xc0003800,0x700ff83,0x871c70e0,0x71c00e3,0x801c7003,0x8e00701d,0xc038e1c7,0x70e00e,0x1c01c380,0x3803e007,0x70e3c0,0x38000,
3565 0x70000e00,0x1c00038,0x7001c,0x38e00038,0x3870070,0xe00e1c01,0xc00e0001,0xc0003800,0x7003c07,0x8380e0e0,0xe1c01c3,0x80387007,
3566 0xe00e1ff,0xfe381b83,0x80e0701c,0xe0381c0,0x701e1e07,0x707878,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3567 0x0,0x0,0x0,0x0,0x1c,0x3,0xe007fe0,0x7800e3c,0x38000001,0xc0000700,0x1803fff,0xe0000000,0x0,0x70039c3,0x800e0000,0xf8000f80,
3568 0xc0e0000e,0xf83c003,0xc01e0f01,0xff700000,0x7c0,0x0,0x1f00780,0x618061c0,0xe0701e1c,0x38038,0x38000700,0x1c07e38,0x3801c00,
3569 0x381e78,0x1c000e3,0xe38e18e1,0xc00e1fff,0x70038ff,0xe0007f80,0xe007007,0x1c701dd,0x9c00f800,0x1c000780,0xe0000e,0xe000,0x0,
3570 0x7f,0xf070070e,0x38038,0x7fff0038,0x1c01c1c,0x7001c00,0x1c007f8,0x1c0070,0xe1c701c1,0xc01c1c01,0xc700700e,0x7fc00,0x1c00380e,
3571 0x1c381c7,0x1c01f000,0xe1c001c0,0xfe0000e,0xfe1f,0xfff00000,0x7ff003fc,0xe0000003,0xffc00000,0x10,0x20000,0x3800,0x3fc0180,
3572 0x703803f,0xce007800,0xff381fe7,0x30,0x0,0xc0,0x0,0x0,0x3fe0,0xc0e07,0xfe3fce00,0x1c000700,0x1c,0x70c00f,0xff006030,0x1c00000,
3573 0xe07800,0x19800c,0xfcc1c38,0x7fffc00,0x30d818,0x0,0xffff81f,0xf001f800,0x380e,0xf8c007,0x80000000,0x7f8007e0,0xe1c3fe,0x7fc00f,
3574 0xf8001e00,0xe0701c0,0xe0381c07,0x380e070,0x1c0e070e,0x1c0001c,0x38000,0x70000e00,0xe0001,0xc0003800,0x700ff83,0x870c70e0,
3575 0x71c00e3,0x801c7003,0x8e00700f,0x8038c1c7,0x70e00e,0x1c01c380,0x3801c007,0xf0e3e0,0x3ff807f,0xf00ffe01,0xffc03ff8,0x7ff03ff,
3576 0xf8e0003f,0xff87fff0,0xfffe1fff,0xc00e0001,0xc0003800,0x7003803,0x8380e0e0,0xe1c01c3,0x80387007,0xe00e1ff,0xfe383383,0x80e0701c,
3577 0xe0381c0,0x700e1c07,0x703870,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x3,0xc000ff0,
3578 0x3c1e1c1c,0x38000001,0xc0000700,0x1803fff,0xe0000007,0xf8000000,0x7003803,0x800e0001,0xf0000381,0xc0e00007,0xf01e003,0x801c0700,
3579 0x7c700000,0x7c0,0x0,0x1f00700,0x618061c0,0xe0700e1c,0x38038,0x38000700,0x1c00e38,0x3801c00,0x381e38,0x1c000e1,0xc38e1ce1,
3580 0xc00e1ffc,0x70038e0,0xf0000780,0xe007007,0x1c701dd,0xdc01fc00,0x1c000780,0xe0000e,0xe000,0x0,0x1ff,0xf070070e,0x38038,0x7fff0038,
3581 0x1c01c1c,0x7001c00,0x1c007f8,0x1c0070,0xe1c701c1,0xc01c1c01,0xc700700e,0x3ff00,0x1c00380e,0x1c381cd,0x9c00e000,0xe1c003c0,
3582 0xf80000e,0x3e18,0x3ff00000,0xffe007fd,0xf0000000,0x38000000,0x10,0x20000,0x1c000,0x3c0300,0x703807f,0xdf007801,0xff7c3fef,
3583 0x80000000,0x0,0x3e0,0x7ffe7ff,0xff000000,0x1ff8,0x60e07,0xfe7fdf00,0x3c000700,0x1c,0x70c001,0xc0006030,0x7fff0000,0xf03800,
3584 0x19800c,0x1c38,0x1c07,0xf830cc18,0x0,0x1c0000,0x0,0x380e,0x18c007,0x80000000,0x0,0xe1cfe0,0x1fc003f,0x80003c00,0xe0701c0,
3585 0xe0381c07,0x380e070,0x1c0e070e,0x1c0001c,0x38000,0x70000e00,0xe0001,0xc0003800,0x7003803,0x870e70e0,0x71c00e3,0x801c7003,
3586 0x8e007007,0x3981c7,0x70e00e,0x1c01c380,0x3801c007,0x1e0e0f8,0xfff81ff,0xf03ffe07,0xffc0fff8,0x1fff07ff,0xf8e0003f,0xff87fff0,
3587 0xfffe1fff,0xc00e0001,0xc0003800,0x7003803,0x8380e0e0,0xe1c01c3,0x80387007,0xe00e1ff,0xfe386383,0x80e0701c,0xe0381c0,0x700e1c07,
3588 0x703870,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x7f,0xffc00678,0x707f9c1e,0x38000001,
3589 0xc0000700,0x70,0x7,0xf8000000,0xe003803,0x800e0003,0xe00001c3,0x80e00007,0xe00e007,0x80380380,0x700000,0x7f0,0x0,0x7f00700,
3590 0x618061ff,0xe070071c,0x38038,0x38000700,0x1c00e38,0x3801c00,0x381c3c,0x1c000e1,0xc38e1ce1,0xc00e1c00,0x70038e0,0x700003c0,
3591 0xe007007,0x1c701d8,0xdc03dc00,0x1c000f00,0xe00007,0xe000,0x0,0x3ff,0xf070070e,0x38038,0x7fff0038,0x1c01c1c,0x7001c00,0x1c007fc,
3592 0x1c0070,0xe1c701c1,0xc01c1c01,0xc700700e,0x3f00,0x1c00380e,0x1c381cd,0x9c01f000,0x73800780,0xfe0000e,0xfe10,0x7c00000,0x1c000ffb,
3593 0xf8000000,0x38000000,0x10,0x20000,0x20000,0x1e0700,0x70380ff,0xbf80f003,0xfefe7fdf,0xc0000000,0x0,0x3f0,0x7ffe7ff,0xff000000,
3594 0x1f8,0x30e07,0xfeffbf80,0x78000700,0x1c,0x70c001,0xc0006030,0x7fff0000,0x783800,0x1ce11c,0xe1c,0x1c07,0xf838ce38,0x0,0x1c0000,
3595 0x0,0x380e,0x18c000,0x0,0x0,0x1c38c00,0x1800030,0x7800,0xfff01ff,0xe03ffc07,0xff80fff0,0x3fff0ffe,0x1c0001c,0x38000,0x70000e00,
3596 0xe0001,0xc0003800,0x7003803,0x870e70e0,0x71c00e3,0x801c7003,0x8e00700f,0x803b81c7,0x70e00e,0x1c01c380,0x3801c007,0xffe0e03c,
3597 0x1fff83ff,0xf07ffe0f,0xffc1fff8,0x3fff0fff,0xf8e0003f,0xff87fff0,0xfffe1fff,0xc00e0001,0xc0003800,0x7003803,0x8380e0e0,0xe1c01c3,
3598 0x80387007,0xe00e000,0x38c383,0x80e0701c,0xe0381c0,0x70073807,0x701ce0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3599 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7f,0xffc0063c,0x40619c0f,0x30000001,0xc0000700,0x70,0x7,0xf8000000,0xe003803,0x800e0007,0xc00001c3,
3600 0xfffc0007,0xe00e007,0x380380,0xf00000,0xfe,0xffff80,0x3f800700,0x618063ff,0xf070071c,0x38038,0x38000700,0x1c00e38,0x3801c00,
3601 0x381c1e,0x1c000e0,0x38e0ee1,0xc00e1c00,0x70038e0,0x380001c0,0xe007007,0x1ef01d8,0xdc038e00,0x1c001e00,0xe00007,0xe000,0x0,
3602 0x7c0,0x7070070e,0x38038,0x70000038,0x1c01c1c,0x7001c00,0x1c0079e,0x1c0070,0xe1c701c1,0xc01c1c01,0xc700700e,0x780,0x1c00380e,
3603 0xe701cd,0x9c01f000,0x73800f00,0xe0000e,0xe000,0x0,0x1c0007f7,0xf0000000,0x70000000,0x10,0x20000,0x0,0xe0e00,0x703807f,0x7f01e001,
3604 0xfdfc3fbf,0x80000000,0x0,0x7f0,0x0,0x0,0x3c,0x18e07,0x7f7f00,0xf0000700,0x1c,0x70c001,0xc0007070,0x1c00000,0x3e7000,0xcff18,
3605 0x3ffc070e,0x1c07,0xf818c630,0x0,0x1c0000,0x0,0x380e,0x18c000,0x0,0x3ffc,0x3870000,0xe000fc00,0x380f000,0x1fff83ff,0xf07ffe0f,
3606 0xffc1fff8,0x3fff0ffe,0x1c0001c,0x38000,0x70000e00,0xe0001,0xc0003800,0x7003803,0x870770e0,0x71c00e3,0x801c7003,0x8e00701d,
3607 0xc03f01c7,0x70e00e,0x1c01c380,0x3801c007,0xffc0e01c,0x3e0387c0,0x70f80e1f,0x1c3e038,0x7c071e1c,0xe00038,0x70000,0xe0001c00,
3608 0xe0001,0xc0003800,0x7003803,0x8380e0e0,0xe1c01c3,0x80387007,0xe00e000,0x398383,0x80e0701c,0xe0381c0,0x70073807,0x701ce0,
3609 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7f,0xffc0061c,0xc0dc07,0xf0000001,0xc0000700,
3610 0x70,0x0,0x0,0x1c003c07,0x800e000f,0x1c3,0xfffc0007,0xe00e007,0x380380,0xe00000,0x1f,0xc0ffff81,0xfc000700,0x618063ff,0xf070070e,
3611 0x38070,0x38000700,0xe00e38,0x3801c00,0x381c0e,0x1c000e0,0x38e0ee1,0xe01e1c00,0x78078e0,0x380001c0,0xe007007,0xee01f8,0xfc078f00,
3612 0x1c001c00,0xe00003,0x8000e000,0x0,0x700,0x7070070e,0x38038,0x70000038,0x1c01c1c,0x7001c00,0x1c0070e,0x1c0070,0xe1c701c1,
3613 0xc01c1c01,0xc700700e,0x380,0x1c00380e,0xe700ed,0xb803f800,0x77800f00,0x70000e,0x1c000,0x0,0xe0003f7,0xe0000000,0x70000000,
3614 0x10,0x20000,0x1c0e0,0xe1c00,0x703803f,0x7e01c000,0xfdf81fbf,0x0,0x0,0x3f0,0x0,0x0,0x1c,0x1ce07,0x3f7e00,0xf0000700,0x1c,
3615 0x70c001,0xc00038e0,0x1c00038,0xf7000,0xe3e38,0x3ffc0387,0x1c00,0x1cc770,0x0,0x1c0000,0x0,0x380e,0x18c000,0x0,0x3ffc,0x70e0001,
3616 0xe001fe00,0x780e000,0x1fff83ff,0xf07ffe0f,0xffc1fff8,0x3fff0ffe,0xe0001c,0x38000,0x70000e00,0xe0001,0xc0003800,0x7003807,
3617 0x70770f0,0xf1e01e3,0xc03c7807,0x8f00f038,0xe03e03c7,0x70e00e,0x1c01c380,0x3801c007,0xff00e00e,0x38038700,0x70e00e1c,0x1c38038,
3618 0x70071c1c,0xe00038,0x70000,0xe0001c00,0xe0001,0xc0003800,0x7003803,0x8380e0e0,0xe1c01c3,0x80387007,0xe00e000,0x3b0383,0x80e0701c,
3619 0xe0381c0,0x70077807,0x701de0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x1c00061c,
3620 0xc0de03,0xe0000001,0xc0000700,0x70,0x0,0x0,0x1c001c07,0xe001e,0x1c3,0xfffc0007,0x600e00e,0x380380,0xe00000,0x7,0xf0ffff87,
3621 0xf0000000,0x60c0e380,0x7070070e,0x38070,0x38000700,0xe00e38,0x3801c00,0x381c0f,0x1c000e0,0x38e06e0,0xe01c1c00,0x38070e0,
3622 0x1c0001c0,0xe007007,0xee00f8,0xf80f0700,0x1c003c00,0xe00003,0x8000e000,0x0,0x700,0x70780f0f,0x3c078,0x70000038,0x1e03c1c,
3623 0x7001c00,0x1c0070f,0x1c0070,0xe1c701c1,0xe03c1e03,0xc780f00e,0x380,0x1c00380e,0xe700f8,0xf807bc00,0x3f001e00,0x70000e,0x1c000,
3624 0x0,0xe0001ff,0xc0000000,0x70000000,0x10,0x20000,0x33110,0xe0e00,0x383801f,0xfc03c000,0x7ff00ffe,0x0,0x0,0x3e0,0x0,0x0,0x1c,
3625 0x38e07,0x1ffc01,0xe0000700,0x1c,0x78c001,0xc0007ff0,0x1c00038,0x7c000,0x70070,0x1c3,0x80001c00,0xe00e0,0x0,0x1c0000,0x0,
3626 0x380e,0x18c000,0x0,0x0,0xe1c0001,0xe0010700,0x780e000,0x1c038380,0x70700e0e,0x1c1c038,0x78070e0e,0xe0001c,0x38000,0x70000e00,
3627 0xe0001,0xc0003800,0x7003807,0x7037070,0xe0e01c1,0xc0383807,0x700e070,0x701c0387,0x70e00e,0x1c01c380,0x3801c007,0xe00e,0x38038700,
3628 0x70e00e1c,0x1c38038,0x70071c1c,0xf00038,0x70000,0xe0001c00,0xe0001,0xc0003800,0x7003c07,0x8380e0f0,0x1e1e03c3,0xc078780f,
3629 0xf01e007,0x803e0783,0x80e0701c,0xe0381c0,0x7003f007,0x80f00fc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3630 0x0,0x0,0x0,0x0,0x0,0x6,0x1800061c,0xc0de01,0xc0000000,0xc0000e00,0x70,0xf0000,0x3c00,0x38001c0f,0xe003c,0x3c0,0xe0000e,0x701e00e,
3631 0x3c0780,0x1e003c0,0x780000,0xfc00001f,0x80000000,0x60e1e780,0x78700f07,0x4380f0,0x38000700,0xf00e38,0x3801c00,0xc0781c07,
3632 0x81c000e0,0x38e07e0,0xe03c1c00,0x380f0e0,0x1e0003c0,0xe00780f,0xee00f0,0x780e0780,0x1c007800,0xe00001,0xc000e000,0x0,0x700,
3633 0xf0780e07,0x8041c078,0x38020038,0xe03c1c,0x7001c00,0x1c00707,0x801c0070,0xe1c701c0,0xe0381e03,0x8380f00e,0x80380,0x1c003c1e,
3634 0x7e00f8,0xf80f1e00,0x3f003c00,0x70000e,0x1c000,0x0,0xf0100f7,0x80078000,0x700078f0,0x10,0x7ff000,0x61208,0x1e0700,0x383800f,
3635 0x78078000,0x3de007bc,0x0,0x0,0x0,0x0,0x0,0x401c,0x70e0f,0xf7803,0xc0000700,0x1c,0x38c001,0xc000efb8,0x1c00038,0x1e000,0x3c1e0,
3636 0xc1,0x80000000,0x783c0,0x0,0x0,0x0,0x3c1e,0x18c000,0x0,0x0,0xc180003,0x60000300,0xd80e010,0x3c03c780,0x78f00f1e,0x1e3c03c,
3637 0x70039c0e,0x70041c,0x38000,0x70000e00,0xe0001,0xc0003800,0x700380f,0x703f070,0x1e0e03c1,0xc078380f,0x701e0e0,0x381c0787,
3638 0x80f0f01e,0x1e03c3c0,0x7801c007,0xe00e,0x38078700,0xf0e01e1c,0x3c38078,0x700f1c1c,0x78041c,0x1038020,0x70040e00,0x800e0001,
3639 0xc0003800,0x7001c07,0x380e070,0x1c0e0381,0xc070380e,0x701c007,0x801e0703,0xc1e0783c,0xf0781e0,0xf003f007,0x80e00fc0,0x0,
3640 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0xe,0x1801867c,0xc0cf83,0xe0000000,0xe0000e00,
3641 0x70,0xf0000,0x3c00,0x38000f1e,0xe0070,0x180780,0xe0603e,0x783c01e,0x1e0f01,0x7c003c0,0x780000,0x3c00001e,0x700,0x307fe700,
3642 0x38701e07,0xc1c383e0,0x38000700,0x7c1e38,0x3801c00,0xe0f01c03,0x81c000e0,0x38e03e0,0x78781c00,0x1e1e0e0,0xe180780,0xe003c1e,
3643 0x7c00f0,0x781e03c0,0x1c007000,0xe00001,0xc000e000,0x0,0x783,0xf07c1e07,0xc0c1e0f8,0x3e0e0038,0xf07c1c,0x7001c00,0x1c00703,
3644 0xc01e0070,0xe1c701c0,0xf0781f07,0x83c1f00e,0xe0f80,0x1e003c3e,0x7e00f8,0xf80e0e00,0x3f003800,0x70000e,0x1c000,0x0,0x7830077,
3645 0xf0000,0x700078f0,0x10,0x20000,0x41208,0xc03c0380,0x3c38007,0x70070000,0x1dc003b8,0x0,0x0,0x0,0x0,0x0,0x707c,0x6070f,0x86077003,
3646 0x80000700,0x1c,0x3ec401,0xc001c01c,0x1c00038,0xf000,0x1ffc0,0x40,0x80000000,0x3ff80,0x0,0x0,0x0,0x3e3e,0x18c000,0x0,0x0,
3647 0x8100006,0x60000300,0x1980f070,0x3801c700,0x38e0071c,0xe3801c,0x70039c0e,0x7c1c1c,0x38000,0x70000e00,0xe0001,0xc0003800,
3648 0x700383e,0x701f03c,0x3c078780,0xf0f01e1e,0x3c3c1c0,0x1c3f0f03,0xc1e0783c,0xf0781e0,0xf001c007,0xe81e,0x3c1f8783,0xf0f07e1e,
3649 0xfc3c1f8,0x783f1e3e,0x187c0c1f,0x703e0e0,0x7c1c0f83,0x800e0001,0xc0003800,0x7001e0f,0x380e078,0x3c0f0781,0xe0f03c1e,0x783c007,
3650 0x801e0f03,0xc3e0787c,0xf0f81e1,0xf003f007,0xc1e00fc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3651 0x0,0x0,0x1c,0xe,0x3801fff8,0x6187ff,0xe0000000,0xe0000e00,0x70,0xf0000,0x3c00,0x38000ffe,0x1fff0ff,0xfe1fff80,0xe07ffc,0x3ffc01c,
3652 0x1fff01,0xff8003c0,0x780000,0x4000010,0x700,0x301e6700,0x387ffe03,0xffc3ffc0,0x3fff0700,0x3ffe38,0x383ffe0,0xfff01c03,0xc1fff8e0,
3653 0x38e03e0,0x7ff81c00,0x1ffe0e0,0xf1fff80,0xe003ffe,0x7c00f0,0x781c01c0,0x1c00ffff,0xe00001,0xc000e000,0x0,0x3ff,0x707ffc03,
3654 0xffc0fff8,0x1ffe0038,0x7ffc1c,0x707fff0,0x1c00701,0xc00ff070,0xe1c701c0,0x7ff01fff,0x1fff00e,0xfff00,0xff81fee,0x7e00f0,
3655 0x781e0f00,0x1e007ffc,0x70000e,0x1c000,0x0,0x3ff003e,0xf0000,0xe00070e0,0x60830010,0x20000,0x41208,0xfffc01c0,0x1fffe03,0xe00ffff0,
3656 0xf8001f0,0x0,0x0,0x0,0x0,0x0,0x7ff8,0xc07fd,0xfe03e007,0xffc00700,0x1c,0x1ffc1f,0xffc08008,0x1c00038,0x7000,0x7f00,0x0,0x0,
3657 0xfe00,0x0,0xffff800,0x0,0x3ff7,0x8018c000,0x0,0x0,0x6,0x60000700,0x19807ff0,0x3801c700,0x38e0071c,0xe3801c,0x70039c0f,0xf03ffc1f,
3658 0xff83fff0,0x7ffe0fff,0xc1fff03f,0xfe07ffc0,0xfff83ffc,0x701f03f,0xfc07ff80,0xfff01ffe,0x3ffc080,0x83fff03,0xffe07ffc,0xfff81ff,
3659 0xf001c007,0xeffc,0x1ffb83ff,0x707fee0f,0xfdc1ffb8,0x3ff70ff7,0xf83ffc0f,0xff01ffe0,0x3ffc07ff,0x83fff87f,0xff0fffe1,0xfffc0ffe,
3660 0x380e03f,0xf807ff00,0xffe01ffc,0x3ff8007,0x803ffe01,0xfee03fdc,0x7fb80ff,0x7001e007,0xffc00780,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3661 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0xc,0x3801fff0,0x7f83fe,0x70000000,0xe0000e00,0x0,0xf0000,0x3c00,0x700007fc,
3662 0x1fff0ff,0xfe1ffe00,0xe07ff8,0x1ff801c,0xffe01,0xff0003c0,0x780000,0x0,0x700,0x38000f00,0x3c7ffc01,0xff83ff80,0x3fff0700,
3663 0x1ffc38,0x383ffe0,0x7fe01c01,0xe1fff8e0,0x38e03e0,0x3ff01c00,0xffc0e0,0x71fff00,0xe001ffc,0x7c00f0,0x783c01e0,0x1c00ffff,
3664 0xe00000,0xe000e000,0x0,0x1ff,0x7077f801,0xff807fb8,0xffc0038,0x3fdc1c,0x707fff0,0x1c00701,0xe007f070,0xe1c701c0,0x3fe01dfe,
3665 0xff700e,0x7fe00,0xff80fee,0x3c0070,0x703c0780,0x1e007ffc,0x70000e,0x1c000,0x0,0x1fe001c,0xe0000,0xe000e1c0,0x71c78010,0x20000,
3666 0x21318,0xfff800c0,0xfffe01,0xc00ffff0,0x70000e0,0x0,0x0,0x0,0x0,0x0,0x3ff0,0x1803fd,0xfe01c007,0xffc00700,0x1c,0xffc1f,0xffc00000,
3667 0x1c00038,0x7000,0x0,0x0,0x0,0x0,0x0,0xffff800,0x0,0x3ff7,0x8018c000,0x0,0x0,0xc,0x60000e00,0x31803fe0,0x7801ef00,0x3de007bc,
3668 0xf7801e,0xf003fc0f,0xf01ff81f,0xff83fff0,0x7ffe0fff,0xc1fff03f,0xfe07ffc0,0xfff83ff8,0x701f01f,0xf803ff00,0x7fe00ffc,0x1ff8000,
3669 0x67fe01,0xffc03ff8,0x7ff00ff,0xe001c007,0xeff8,0xffb81ff,0x703fee07,0xfdc0ffb8,0x1ff70ff7,0xf81ff807,0xfe00ffc0,0x1ff803ff,
3670 0x3fff87f,0xff0fffe1,0xfffc07fc,0x380e01f,0xf003fe00,0x7fc00ff8,0x1ff0000,0x37fc00,0xfee01fdc,0x3fb807f,0x7001e007,0x7f800780,
3671 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0xc,0x30007fc0,0x1e00f8,0x78000000,0x70001c00,
3672 0x0,0xe0000,0x3c00,0x700001f0,0x1fff0ff,0xfe07f800,0xe01fe0,0x7e0038,0x3f800,0xfc0003c0,0x700000,0x0,0x700,0x18000e00,0x1c7ff000,
3673 0x7e03fe00,0x3fff0700,0x7f038,0x383ffe0,0x1f801c00,0xf1fff8e0,0x38e01e0,0xfc01c00,0x3f80e0,0x787fc00,0xe0007f0,0x7c00f0,0x387800f0,
3674 0x1c00ffff,0xe00000,0xe000e000,0x0,0xfc,0x7071f000,0x3f003e38,0x3f00038,0x1f1c1c,0x707fff0,0x1c00700,0xf003f070,0xe1c701c0,
3675 0x1f801c7c,0x7c700e,0x1f800,0x3f8078e,0x3c0070,0x707803c0,0x1c007ffc,0x70000e,0x1c000,0x0,0x7c0008,0x1e0000,0xe000e1c0,0x71c30010,
3676 0x20000,0x1e1f0,0x3fe00020,0x3ffe00,0x800ffff0,0x2000040,0x0,0x0,0x0,0x0,0x0,0xfc0,0x3001f0,0x78008007,0xffc00700,0x1c,0x3f81f,
3677 0xffc00000,0x1c00038,0x407000,0x0,0x0,0x0,0x0,0x0,0xffff800,0x0,0x39c7,0x18c000,0x0,0x0,0x18,0x60001c00,0x61801f80,0x7000ee00,
3678 0x1dc003b8,0x77000e,0xe001f80f,0xf007e01f,0xff83fff0,0x7ffe0fff,0xc1fff03f,0xfe07ffc0,0xfff83fc0,0x700f007,0xe000fc00,0x1f8003f0,
3679 0x7e0000,0xe1f800,0x7f000fe0,0x1fc003f,0x8001c007,0xe7f0,0x7e380fc,0x701f8e03,0xf1c07e38,0xfc703c1,0xe003f001,0xf8003f00,
3680 0x7e000fc,0x3fff87f,0xff0fffe1,0xfffc03f8,0x380e00f,0xc001f800,0x3f0007e0,0xfc0000,0x61f800,0x78e00f1c,0x1e3803c,0x7001c007,
3681 0x1f000700,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x600,0x0,0x0,0x70001c00,0x0,
3682 0x1c0000,0x0,0xe0000000,0x0,0x0,0x0,0x0,0x0,0x0,0xe00000,0x0,0x0,0xc000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c000,0x0,
3683 0x0,0x0,0x0,0x0,0xe00000,0x7000e000,0x0,0x0,0x0,0x0,0x0,0x1c00,0x0,0x1c00000,0x0,0x0,0x1c00,0x7000,0x0,0x0,0x0,0x0,0x1c000000,
3684 0x70000e,0x1c000,0x0,0x0,0x1c0000,0xe000c180,0x10,0x20000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc000,
3685 0x0,0x38,0x70e000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3800,0x18c000,0x2000,0x0,0x1f,0xf8003800,0x7fe00000,0x0,0x0,0x0,0x0,0x4000,
3686 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x400000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x400000,
3687 0x0,0x0,0x1c007,0x700,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x600,0x0,0x0,0x30001800,
3688 0x0,0x1c0000,0x0,0xe0000000,0x0,0x0,0x0,0x0,0x0,0x0,0xe00000,0x0,0x0,0xe000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1e000,
3689 0x0,0x0,0x0,0x0,0x0,0xe00000,0x7000e000,0x0,0x0,0x0,0x0,0x0,0x1c00,0x0,0x1c00000,0x0,0x0,0x1c00,0x7000,0x0,0x0,0x0,0x0,0x1c000000,
3690 0x70000e,0x1c000,0x0,0x0,0x1c0001,0xe001c380,0x10,0x20000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc000,
3691 0x0,0x38,0x7fe000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3800,0x18c000,0x3000,0x0,0x1f,0xf8007000,0x7fe00000,0x0,0x0,0x0,0x0,0x6000,
3692 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3693 0x0,0x1c007,0x700,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x600,0x0,0x0,0x38003800,
3694 0x0,0x380000,0x1,0xc0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x1c00000,0x0,0x0,0x3c18000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf000,
3695 0x0,0x0,0x0,0x0,0x0,0xfe0000,0x380fe000,0x0,0x0,0x0,0x0,0x0,0x3800,0x0,0x1c00000,0x0,0x0,0x1c00,0x7000,0x0,0x0,0x0,0x0,0x38000000,
3696 0x78000e,0x3c000,0x0,0x0,0x180001,0xc0018300,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc000,0x0,
3697 0x38,0x1f8000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3800,0x18c000,0x1800,0x0,0x0,0x6000e000,0x1800000,0x0,0x0,0x0,0x0,0x3000,0x0,
3698 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3699 0x38007,0xe00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x600,0x0,0x0,0x18003000,
3700 0x0,0x300000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1800000,0x0,0x0,0x1ff8000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4000,0x0,0x0,
3701 0x0,0x0,0x0,0xfe0000,0xfe000,0x0,0x0,0x0,0x0,0x0,0x607800,0x0,0x3c00000,0x0,0x0,0x1c00,0x7000,0x0,0x0,0x0,0x0,0x78000000,
3702 0x3f800e,0x3f8000,0x0,0x0,0x300043,0xc0018200,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc000,
3703 0x0,0x38,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3800,0x0,0x11800,0x0,0x0,0x6001ff00,0x1800000,0x0,0x0,0x0,0x0,0x23000,0x0,0x0,
3704 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x23000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x78007,
3705 0x1e00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x600,0x0,0x0,0x1c007000,0x0,0x0,
3706 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7f8000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfe0000,
3707 0xfe000,0x0,0x0,0x0,0x0,0x0,0x7ff000,0x0,0x7f800000,0x0,0x0,0x1c00,0x7000,0x0,0x0,0x0,0x3,0xf8000000,0x3f800e,0x3f8000,0x0,
3708 0x0,0x10007f,0x80000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc000,0x0,0x38,0x0,0x0,0x0,0x0,
3709 0x0,0x0,0x0,0x0,0x3800,0x0,0x1f800,0x0,0x0,0x6001ff00,0x1800000,0x0,0x0,0x0,0x0,0x3f000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3710 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3f000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3f8007,0xfe00,0x0,0x0,0x0,0x0,
3711 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3712 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7fff8,0x0,0x0,0x0,0x0,0x7fe000,0x0,
3713 0x7f000000,0x0,0x0,0x1c00,0x7000,0x0,0x0,0x0,0x3,0xf0000000,0xf800e,0x3e0000,0x0,0x0,0x7f,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3714 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3800,0x0,0x1f000,0x0,0x0,0x0,0x0,0x0,
3715 0x0,0x0,0x0,0x3e000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3e000,0x0,0x0,0x0,0x0,0x0,0x0,
3716 0x0,0x0,0x0,0x0,0x0,0x0,0x3f0007,0xfc00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3717 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3718 0x0,0x0,0x0,0x0,0x7fff8,0x0,0x0,0x0,0x0,0x1fc000,0x0,0x7e000000,0x0,0x0,0x1c00,0x7000,0x0,0x0,0x0,0x3,0xc0000000,0xe,0x0,
3719 0x0,0x0,0x3e,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3720 0x0,0x0,0x3800,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3721 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c0007,0xf000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3722 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3723 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7fff8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3724 0xe,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3725 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3726 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 };
3730 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3731 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3732 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3733 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3734 0x0,0x781e00,0x0,0x0,0x7,0x81e00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3735 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7c0000,0xf8000,0x7e00000,0x0,0x7,
3736 0xc0000000,0x0,0x7c00,0xf80,0x7e000,0x0,0x7c00000,0xf80000,0x7e000000,0x0,0x0,0x1f00,0x3e0,0x1f800,0x0,0x0,0x0,0x3,0xe0000000,
3737 0x7c00003f,0x0,0xf8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3738 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3739 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3740 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3741 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3742 0x0,0x0,0x0,0x0,0x0,0x0,0x3c3c00,0x0,0x0,0x3,0xc3c00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3e1f00,
3743 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3e0000,
3744 0x1f0000,0x7e00000,0xf838001f,0xf80001f,0xf0000000,0x0,0x3e00,0x1f00,0x7e000,0x3e1f000,0x3e00000,0x1f00000,0x7e00003e,0x1f000000,
3745 0x3e0,0xe0000f80,0x7c0,0x1f800,0x3e0e00,0x7c3e000,0x0,0x1,0xf0000000,0xf800003f,0x1f0f,0x800001f0,0x0,0x0,0x0,0x0,0x0,0x0,
3746 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3747 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3748 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3749 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3750 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1e7800,0x0,0x0,
3751 0x1,0xe7800000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3e1f00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3752 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1e0000,0x1e0000,0xff00001,0xfe38001f,0xf80003f,
3753 0xf8000000,0x0,0x1e00,0x1e00,0xff000,0x3e1f000,0x1e00000,0x1e00000,0xff00003e,0x1f000000,0x7f8,0xe0000780,0x780,0x3fc00,0x7f8e00,
3754 0x7c3e000,0x0,0x0,0xf0000000,0xf000007f,0x80001f0f,0x800001e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3755 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3756 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3757 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3758 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3759 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xef000,0x0,0x0,0x0,0xef000000,0x0,0x0,0x0,0x0,0x0,0x0,
3760 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3e1f00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3761 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf0000,0x3c0000,0x1e780003,0xfff8001f,0xf80003c,0x78000000,0x0,0xf00,0x3c00,0x1e7800,
3762 0x3e1f000,0xf00000,0x3c00001,0xe780003e,0x1f000000,0xfff,0xe00003c0,0xf00,0x79e00,0xfffe00,0x7c3e000,0x0,0x0,0x78000001,0xe00000f3,
3763 0xc0001f0f,0x800003c0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0xc0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3764 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3765 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3766 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3767 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3768 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7e000,0x0,0x0,0x0,0x7e000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3769 0x3e1f00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3770 0x0,0x78000,0x780000,0x3c3c0003,0x8ff0001f,0xf800078,0x3c000000,0x0,0x780,0x7800,0x3c3c00,0x3e1f000,0x780000,0x7800003,0xc3c0003e,
3771 0x1f000000,0xe3f,0xc00001e0,0x1e00,0xf0f00,0xe3fc00,0x7c3e000,0x0,0x0,0x3c000003,0xc00001e1,0xe0001f0f,0x80000780,0x0,0x0,
3772 0x0,0x0,0x0,0x0,0x1f,0xf0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3773 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3774 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3775 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3776 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3777 0x0,0x7e000,0x0,0x0,0x0,0x7e000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3e1f00,0x0,0x0,0x0,0x0,0x0,0x0,
3778 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfc00,0x7e000,0xfe000,0x0,0x3c000,0xf00000,0x781e0003,
3779 0x83e0001f,0xf800070,0x1c000000,0x0,0x3c0,0xf000,0x781e00,0x3e1f000,0x3c0000,0xf000007,0x81e0003e,0x1f000000,0xe0f,0x800000f0,
3780 0x3c00,0x1e0780,0xe0f800,0x7c3e000,0x0,0x0,0x1e000007,0x800003c0,0xf0001f0f,0x80000f00,0x0,0x0,0x0,0x0,0x0,0x0,0x3f,0xf8000000,
3781 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3782 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3783 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3784 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3785 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3786 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3787 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3fc00,0x1fe000,0x3ff800,0x0,0x0,0x0,0x0,0x0,0x70,0x1c000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3788 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c,0x78000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3789 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3790 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3791 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3792 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1f00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3793 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3794 0x0,0x0,0x78,0xf000000,0x0,0x0,0x780f0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7c0,
3795 0x0,0x0,0x0,0x0,0x0,0x0,0x3fc00,0x1fe000,0x3ffc00,0x0,0x0,0x0,0x0,0x0,0x70,0x1c000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3796 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1f00000,0x3e000,0x3e00000,0x0,0x78,0x3c000000,0x0,0x1f000,0x3e0,
3797 0x3e000,0x0,0x1f000000,0x3e0000,0x3e000000,0x0,0x0,0x7c00,0xf8,0xf800,0x0,0x0,0x0,0xf,0x80000000,0x1f00001f,0x0,0x3e,0x0,
3798 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3799 0x0,0x0,0x0,0x30000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3800 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf80000,
3801 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3802 0x0,0x0,0x0,0x0,0xf80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x781c0000,0x38,0xe000000,0x0,0x0,0x380e0,0x0,
3803 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf80,0x0,0x0,0x0,0x0,0x0,0x0,0x39c00,0x1ce000,0x303e00,
3804 0x0,0x0,0x0,0x0,0x0,0x78,0x3c000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4000,0x0,0x0,0x0,0x0,
3805 0x0,0x0,0xf80000,0x7c000,0x3e00000,0xf0380000,0x70,0x1c000000,0x0,0xf800,0x7c0,0x3e000,0x0,0xf800000,0x7c0000,0x3e000000,
3806 0x0,0x3c0,0xe0003e00,0x1f0,0xf800,0x3c0e00,0x0,0x0,0x7,0xc0000000,0x3e00001f,0x0,0x7c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3807 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x30000000,0xff,0x0,
3808 0xf8,0xf8000,0x1c000,0x0,0x0,0x0,0x0,0x1f,0xc0000000,0x1ff8,0xff00,0x0,0x0,0x3fe000,0x0,0x1fc00001,0xfe000000,0x0,0x0,0x0,
3809 0x0,0x7f800,0x0,0x0,0x0,0xff00000,0x0,0x0,0xff,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0xf8000000,0xfe,0x0,0x7f80,0x0,0x0,0x0,0x0,0x0,
3810 0x0,0x3f,0xf0000000,0x7fe0,0x0,0x0,0x780000,0x1,0xe0000000,0x0,0x780000,0x3,0xfe000000,0x78000,0x3c00,0xf000,0x7800003,0xffe00000,
3811 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfc0000f0,0x3f000,0x0,0x0,0x3fc00,0x0,0x0,0x1fc000,0x0,0x0,0x0,0x1fc0,
3812 0x0,0xff000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfe1c0000,0x1c,0x1c000000,0x0,0x0,0x1c1c0,0x0,0x0,0x0,0x0,0x1fe0000,
3813 0x0,0x0,0x1ff,0x1f0f8,0x0,0xff000,0x0,0x0,0x0,0x3f,0xff00000f,0x80000000,0xfe0,0x3f80,0xf00,0x0,0x0,0x0,0x1,0xf8000003,0xe0000000,
3814 0x1c00,0xe000,0xe00,0x0,0x0,0x0,0x0,0x0,0x3c,0x78000000,0xff,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7f0,0x3f80,0x1fc00,0xfe000,
3815 0x7f0000,0x0,0x1fc07000,0x0,0x0,0x0,0x0,0x0,0x3f800,0x780000,0x78000,0x7f00001,0xfc38001f,0xf800070,0x1c000000,0x0,0x7800,
3816 0x780,0x7f000,0x3e1f000,0x7800000,0x780000,0x7f00003e,0x1f0003f0,0x7f0,0xe0001e00,0x1e0,0x1fc00,0x7f0e00,0x7c3e000,0x0,0x3,
3817 0xc0000000,0x3c00003f,0x80001f0f,0x80000078,0x1e0000,0x3e1f00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3818 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x3c1e0000,0x1e078000,0x30000000,0x3ff,0xc00001e0,0xf0,
3819 0x78000,0x1c000,0x0,0x0,0x0,0x0,0x1e0007f,0xf000007e,0x1ffff,0x7ffe0,0x1f80,0x3ffff80,0xfff803,0xfffff800,0xfff80007,0xff800000,
3820 0x0,0x0,0x0,0x0,0x1ffe00,0x0,0xfe0003,0xfff80000,0x3ffe01ff,0xe00003ff,0xffe01fff,0xff0003ff,0xe01e0007,0x803ffff0,0xfff80,
3821 0x3c000fc0,0x7800001f,0x8003f07e,0x1e000f,0xfe0007ff,0xf00003ff,0x8007ffe0,0x1fff8,0x7fffffe,0xf0003c1,0xe000079e,0xf1f,0x1f3e0,
3822 0x1f01ff,0xfff8003f,0xf003c000,0x7fe0,0x3f00,0x0,0x3c0000,0x1,0xe0000000,0x0,0x780000,0xf,0xfe000000,0x78000,0x3c00,0xf000,
3823 0x7800003,0xffe00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0xfc0000f0,0x3fe00,0x0,0x0,0xfff00,0x0,0x0,0x3fe000,
3824 0x0,0x0,0x0,0x1dc0,0x0,0x3fff00,0x0,0x3ffff80,0x1f,0xffff8000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff1c07ff,0x3c0f001e,0x3c000000,
3825 0x0,0x0,0x1e3c0,0xf80007c,0x0,0x780000,0x0,0xfff8000,0x3e00,0x1f00000,0x7ff,0xc001f0f8,0x0,0x3ffc00,0x0,0x0,0x0,0x3f,0xff00003f,
3826 0xe0000000,0x3ff8,0xffe0,0x1e00,0x0,0xfffc00,0x0,0x7,0xf800000f,0xf8000000,0x1c00,0xe000,0xe00,0xf000,0x1fc000,0xfe0000,0x7f00000,
3827 0x3f800001,0xfc00003f,0xf80000ff,0xffc003ff,0xe007ffff,0xc03ffffe,0x1fffff0,0xfffff80,0x7fffe003,0xffff001f,0xfff800ff,0xffc01ffc,
3828 0xfc00,0x3c001ffc,0xffe0,0x7ff00,0x3ff800,0x1ffc000,0x0,0x7ff8f0f0,0x3c0780,0x1e03c00,0xf01e000,0x783e0001,0xf01e0000,0xffe00,
3829 0x3c0000,0xf0000,0x7700001,0xfe38001f,0xf800070,0x1c000000,0x0,0x3c00,0xf00,0x77000,0x3e1f000,0x3c00000,0xf00000,0x7700003e,
3830 0x1f0000f8,0xc0007f8,0xe0000f00,0x3c0,0x1dc00,0x7f8e00,0x7c3e000,0x0,0x1,0xe0000000,0x7800003b,0x80001f0f,0x800000f0,0x1e0000,
3831 0x3e1f00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3832 0x0,0x0,0x780000,0x3c1e0000,0x1e070000,0x300001f0,0x7ff,0xc00001e0,0x1e0,0x7c000,0x1c000,0x0,0x0,0x0,0x0,0x3c000ff,0xf80007fe,
3833 0x3ffff,0x801ffff8,0x1f80,0x3ffff80,0x3fff803,0xfffff801,0xfffc000f,0xffc00000,0x0,0x0,0x0,0x0,0x7fff80,0x0,0xfe0003,0xffff0000,
3834 0xffff01ff,0xfc0003ff,0xffe01fff,0xff000fff,0xf01e0007,0x803ffff0,0xfff80,0x3c001f80,0x7800001f,0xc007f07e,0x1e001f,0xff0007ff,
3835 0xfc0007ff,0xc007fffc,0x3fffc,0x7fffffe,0xf0003c1,0xf0000f9e,0xf0f,0x8003e1e0,0x1e01ff,0xfff8003f,0xf001e000,0x7fe0,0x3f00,
3836 0x0,0x1e0000,0x1,0xe0000000,0x0,0x780000,0x1f,0xfe000000,0x78000,0x3c00,0xf000,0x7800003,0xffe00000,0x0,0x0,0x0,0x0,0x0,0x0,
3837 0x0,0x0,0x0,0x0,0x0,0x0,0xf,0xfc0000f0,0x3ff00,0x0,0x0,0x1fff80,0x0,0x0,0xffe000,0x0,0x0,0x0,0x3de0,0x0,0x7fff80,0x0,0xfffff80,
3838 0x1f,0xffff8000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0xe7bc07ff,0x3e1f000f,0x78000000,0x0,0x0,0xf780,0x7800078,0x0,0x780000,0x180000,
3839 0x1fff8000,0x1e00,0x1e0003c,0xfff,0xc001f0f8,0x0,0x7ffe00,0x0,0x0,0x0,0x3f,0xff00007f,0xf0000000,0x3ffc,0xfff0,0x3c00,0x0,
3840 0x7fffc00,0x0,0x7,0xf800003f,0xfe000000,0x1c00,0xe000,0xe00,0xf000,0x1fc000,0xfe0000,0x7f00000,0x3f800001,0xfc00001f,0xe00001ff,
3841 0xffc00fff,0xf007ffff,0xc03ffffe,0x1fffff0,0xfffff80,0x7fffe003,0xffff001f,0xfff800ff,0xffc01fff,0xc000fc00,0x3c003ffe,0x1fff0,
3842 0xfff80,0x7ffc00,0x3ffe000,0x0,0xfffce0f0,0x3c0780,0x1e03c00,0xf01e000,0x781e0001,0xe01e0000,0x3fff00,0x1e0000,0x1e0000,0xf780003,
3843 0xcf78001f,0xf800078,0x3c000000,0x0,0x1e00,0x1e00,0xf7800,0x3e1f000,0x1e00000,0x1e00000,0xf780003e,0x1f0000fc,0x7c000f3d,
3844 0xe0000780,0x780,0x3de00,0xf3de00,0x7c3e000,0x0,0x0,0xf0000000,0xf000007b,0xc0001f0f,0x800001e0,0x1e0000,0x3e1f00,0x0,0x0,
3845 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,
3846 0x3c1e0000,0x1e0f0000,0x300007fc,0xfff,0xc00001e0,0x1e0,0x3c000,0x1c000,0x0,0x0,0x0,0x0,0x3c001ff,0xfc001ffe,0x3ffff,0xc01ffffc,
3847 0x3f80,0x3ffff80,0x7fff803,0xfffff803,0xfffe001f,0xffe00000,0x0,0x0,0x0,0x0,0xffff80,0x7f800,0xfe0003,0xffff8001,0xffff01ff,
3848 0xff0003ff,0xffe01fff,0xff001fff,0xf01e0007,0x803ffff0,0xfff80,0x3c003f00,0x7800001f,0xc007f07f,0x1e003f,0xff8007ff,0xff000fff,
3849 0xe007ffff,0x7fffc,0x7fffffe,0xf0003c0,0xf0000f1e,0xf07,0x8003c1f0,0x3e01ff,0xfff8003f,0xf001e000,0x7fe0,0x7f80,0x0,0xe0000,
3850 0x1,0xe0000000,0x0,0x780000,0x1f,0xfe000000,0x78000,0x3c00,0xf000,0x7800003,0xffe00000,0x0,0x0,0x0,0x0,0x0,0x0,0x3c000,0x0,
3851 0x0,0x0,0x0,0x0,0xf,0xfc0000f0,0x3ff00,0x0,0x0,0x3fff80,0x0,0x0,0xffe000,0x0,0x0,0x0,0x78f0,0x0,0xffff80,0x0,0x3fffff80,0x1f,
3852 0xffff8000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0xc7f80070,0x3e1f0007,0x70000000,0x0,0x0,0x7700,0x7c000f8,0x0,0x780000,0x180000,
3853 0x3fff8000,0x1f00,0x3e0003c,0x1f03,0xc001f0f8,0x0,0x703f00,0x0,0x0,0x0,0x3f,0xff0000f0,0xf8000000,0x303e,0xc0f8,0x7800,0x0,
3854 0xffffc00,0x0,0x7,0x3800003e,0x3e000000,0x1c00,0xe000,0x3c00,0xf000,0x1fc000,0xfe0000,0x7f00000,0x3f800001,0xfc00000f,0xe00001ff,
3855 0xffc01fff,0xf007ffff,0xc03ffffe,0x1fffff0,0xfffff80,0x7fffe003,0xffff001f,0xfff800ff,0xffc01fff,0xf000fe00,0x3c007fff,0x3fff8,
3856 0x1fffc0,0xfffe00,0x7fff000,0x1,0xffffc0f0,0x3c0780,0x1e03c00,0xf01e000,0x781f0003,0xe01e0000,0x3fff80,0xe0000,0x3c0000,0x1e3c0003,
3857 0x8ff0001f,0xf80003c,0x78000000,0x0,0xe00,0x3c00,0x1e3c00,0x3e1f000,0xe00000,0x3c00001,0xe3c0003e,0x1f00007f,0xf8000e3f,0xc0000380,
3858 0xf00,0x78f00,0xe3fc00,0x7c3e000,0x0,0x0,0x70000001,0xe00000f1,0xe0001f0f,0x800003c0,0x1e0000,0x3e1f00,0x0,0x0,0x0,0x0,0x0,
3859 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x3c1e0000,0x3c0f0000,
3860 0x30000ffe,0xf80,0xc00001e0,0x3c0,0x1e000,0x101c040,0x0,0x0,0x0,0x0,0x78003f0,0x7e001ffe,0x3f807,0xe01f00fe,0x3f80,0x3ffff80,
3861 0x7e01803,0xfffff007,0xe03f003f,0x3f00000,0x0,0x0,0x0,0x0,0xfc0fc0,0x3ffe00,0xfe0003,0xffffc003,0xf81f01ff,0xff8003ff,0xffe01fff,
3862 0xff003f01,0xf01e0007,0x803ffff0,0xfff80,0x3c007e00,0x7800001f,0xc007f07f,0x1e007e,0xfc007ff,0xff801f83,0xf007ffff,0x800fc07c,
3863 0x7fffffe,0xf0003c0,0xf0000f0f,0x1e07,0xc007c0f8,0x7c01ff,0xfff8003c,0xf000,0x1e0,0xffc0,0x0,0xf0000,0x1,0xe0000000,0x0,0x780000,
3864 0x3e,0x0,0x78000,0x3c00,0xf000,0x7800000,0x1e00000,0x0,0x0,0x0,0x0,0x0,0x0,0x3c000,0x0,0x0,0x0,0x0,0x0,0x1f,0x800000f0,0x1f80,
3865 0x0,0x0,0x7e0780,0x0,0x0,0x1f82000,0x0,0x0,0x0,0x7070,0x0,0x1f80f80,0x0,0x7fffff80,0x1f,0xffff8000,0x0,0x0,0x0,0x0,0x0,0x0,
3866 0x0,0x1,0xc3f80070,0x3f3f0007,0xf0000000,0x0,0x0,0x7f00,0x3e001f0,0x0,0x780000,0x180000,0x7f018000,0xf80,0x7c0003c,0x3e00,
3867 0x4001f0f8,0xfe00,0x400f00,0x0,0x0,0x0,0x7f000000,0xe0,0x38000000,0x1e,0x38,0x7800,0x0,0x1ffe1c00,0x0,0x0,0x38000078,0xf000000,
3868 0x1c00,0xe000,0x7f800,0xf000,0x1fc000,0xfe0000,0x7f00000,0x3f800001,0xfc00001f,0xf00001ff,0xffc03f81,0xf007ffff,0xc03ffffe,
3869 0x1fffff0,0xfffff80,0x7fffe003,0xffff001f,0xfff800ff,0xffc01fff,0xf800fe00,0x3c00fc1f,0x8007e0fc,0x3f07e0,0x1f83f00,0xfc1f800,
3870 0x3,0xf07fc0f0,0x3c0780,0x1e03c00,0xf01e000,0x780f8007,0xc01e0000,0x7e0fc0,0xf0000,0x3c0000,0x1c1c0003,0x87f0001f,0xf80003f,
3871 0xf8000000,0x0,0xf00,0x3c00,0x1c1c00,0x3e1f000,0xf00000,0x3c00001,0xc1c0003e,0x1f00003f,0xc0000e1f,0xc00003c0,0xf00,0x70700,
3872 0xe1fc00,0x7c3e000,0x0,0x0,0x78000001,0xe00000e0,0xe0001f0f,0x800003c0,0x1e0000,0x3e1f00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3873 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x3c1e0000,0x3c0f0001,0xff801e0f,
3874 0x1f00,0x1e0,0x3c0,0x1e000,0x3c1c1e0,0x0,0x0,0x0,0x0,0x78007c0,0x1f001f9e,0x3c001,0xf010003e,0x7780,0x3c00000,0xf800000,0xf007,
3875 0xc01f007c,0x1f80000,0x0,0x0,0x0,0x0,0xe003e0,0x7fff00,0x1ef0003,0xc007e007,0xc00301e0,0x1fc003c0,0x1e00,0x7c00,0x301e0007,
3876 0x80007800,0x780,0x3c00fc00,0x7800001f,0xe00ff07f,0x1e00f8,0x3e00780,0x1fc03e00,0xf807801f,0xc01f001c,0xf000,0xf0003c0,0xf0000f0f,
3877 0x1e03,0xc00f8078,0x780000,0xf0003c,0xf000,0x1e0,0x1f3e0,0x0,0x78000,0x1,0xe0000000,0x0,0x780000,0x3c,0x0,0x78000,0x0,0x0,
3878 0x7800000,0x1e00000,0x0,0x0,0x0,0x0,0x0,0x0,0x3c000,0x0,0x0,0x0,0x0,0x0,0x1f,0xf0,0xf80,0x0,0x0,0xf80180,0x0,0x0,0x1e00000,
3879 0x0,0x0,0x0,0xe038,0x0,0x3e00380,0x0,0xfe0f0000,0x0,0xf0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0xc0f00070,0x3b370003,0xe0000000,
3880 0x0,0x0,0x3e00,0x1e001e0,0x0,0x780000,0x180000,0x7c000000,0x780,0x780003c,0x3c00,0x0,0x7ffc0,0x780,0x0,0x0,0x3,0xffe00000,
3881 0x1c0,0x3c000000,0xe,0x38,0xf000,0x0,0x3ffe1c00,0x0,0x0,0x38000078,0xf000000,0x1c00,0xe000,0x7f000,0xf000,0x3de000,0x1ef0000,
3882 0xf780000,0x7bc00003,0xde00001e,0xf00003e7,0x80007c00,0x30078000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,
3883 0xe0001e03,0xfc00fe00,0x3c01f007,0xc00f803e,0x7c01f0,0x3e00f80,0x1f007c00,0x7,0xc01f80f0,0x3c0780,0x1e03c00,0xf01e000,0x78078007,
3884 0x801e0000,0x7803c0,0x78000,0x780000,0x380e0003,0x81e00000,0x1f,0xf0000000,0x0,0x780,0x7800,0x380e00,0x0,0x780000,0x7800003,
3885 0x80e00000,0x1ff,0x80000e07,0x800001e0,0x1e00,0xe0380,0xe07800,0x0,0x0,0x0,0x3c000003,0xc00001c0,0x70000000,0x780,0x1e0000,
3886 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3887 0x780000,0x3c1e0000,0x3c0e0007,0xfff01c07,0x1e00,0x1e0,0x780,0xf000,0x3e1c3e0,0x0,0x0,0x0,0x0,0xf0007c0,0x1f00181e,0x20000,
3888 0xf000001f,0xf780,0x3c00000,0x1f000000,0x1f00f,0x800f8078,0xf80000,0x0,0x0,0x0,0x0,0x8003e0,0x1fc0f80,0x1ef0003,0xc001e007,
3889 0x800101e0,0x7e003c0,0x1e00,0x7800,0x101e0007,0x80007800,0x780,0x3c00f800,0x7800001e,0xe00ef07f,0x801e00f0,0x1e00780,0x7c03c00,
3890 0x78078007,0xc01e0004,0xf000,0xf0003c0,0x78001e0f,0x1e03,0xe00f807c,0xf80000,0x1f0003c,0x7800,0x1e0,0x3e1f0,0x0,0x3c000,0x1,
3891 0xe0000000,0x0,0x780000,0x3c,0x0,0x78000,0x0,0x0,0x7800000,0x1e00000,0x0,0x0,0x0,0x0,0x0,0x0,0x3c000,0x0,0x0,0x0,0x0,0x0,
3892 0x1e,0xf0,0x780,0x0,0x0,0x1f00080,0x0,0x0,0x3c00000,0x0,0x0,0x0,0x1e03c,0x0,0x3c00080,0x0,0xf80f0000,0x0,0x1f0000,0x0,0x0,
3893 0x0,0x0,0x0,0x0,0x0,0x0,0x70,0x3bf70003,0xe0000000,0x0,0x0,0x3e00,0x1f003e0,0x0,0x780000,0x180000,0x78000000,0x7c0,0xf80003c,
3894 0x3c00,0x0,0x1f01f0,0x780,0x0,0x0,0xf,0x80f80000,0x1c0,0x1c000000,0xe,0x38,0x1e000,0x0,0x7ffe1c00,0x0,0x0,0x380000f0,0x7800000,
3895 0x1c00,0xe000,0x7fc00,0xf000,0x3de000,0x1ef0000,0xf780000,0x7bc00003,0xde00001e,0xf00003c7,0x80007800,0x10078000,0x3c0000,
3896 0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0x7e00ff00,0x3c01e003,0xc00f001e,0x7800f0,0x3c00780,0x1e003c00,
3897 0x7,0x800f00f0,0x3c0780,0x1e03c00,0xf01e000,0x7807c00f,0x801e0000,0xf803c0,0x3c000,0xf00000,0x780f0000,0x0,0x7,0xc0000000,
3898 0x0,0x3c0,0xf000,0x780f00,0x0,0x3c0000,0xf000007,0x80f00000,0x7ff,0xc0000000,0xf0,0x3c00,0x1e03c0,0x0,0x0,0x0,0x0,0x1e000007,
3899 0x800003c0,0x78000000,0xf00,0x1e0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3900 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x3c1e0000,0x3c1e001f,0xfff03803,0x80001e00,0x1e0,0x780,0xf000,0xf9cf80,
3901 0x0,0x0,0x0,0x0,0xf000780,0xf00001e,0x0,0xf800000f,0xe780,0x3c00000,0x1e000000,0x1e00f,0x78078,0x7c0000,0x0,0x0,0x0,0x0,0x1e0,
3902 0x3f003c0,0x1ef0003,0xc000f00f,0x800001e0,0x1f003c0,0x1e00,0xf000,0x1e0007,0x80007800,0x780,0x3c01f000,0x7800001e,0xe00ef07f,
3903 0x801e01f0,0x1e00780,0x3c07c00,0x78078003,0xc03e0000,0xf000,0xf0003c0,0x78001e0f,0x1e01,0xf01f003c,0xf00000,0x3e0003c,0x7800,
3904 0x1e0,0x7c0f8,0x0,0x0,0x1,0xe0000000,0x0,0x780000,0x3c,0x0,0x78000,0x0,0x0,0x7800000,0x1e00000,0x0,0x0,0x0,0x0,0x0,0x0,0x3c000,
3905 0x0,0x0,0x0,0x0,0x0,0x1e,0xf0,0x780,0x0,0x0,0x1e00000,0x0,0x0,0x3c00000,0x0,0x8,0x40,0x0,0x7e0000,0x7c00000,0x1,0xf00f0000,
3906 0x0,0x3e0000,0x0,0x3f,0xfc0,0xfc3f0,0xfc3f0,0x0,0x0,0x0,0x70,0x39e70000,0x0,0x0,0x0,0x0,0xf003c0,0x0,0x0,0x180000,0xf8000000,
3907 0x3c0,0xf00003c,0x3c00,0x0,0x3c0078,0x7ff80,0x0,0x0,0x1e,0x3c0000,0x1c0,0x1c000000,0xe,0xf0,0x0,0x0,0x7ffe1c00,0x0,0x0,0x380000f0,
3908 0x7800000,0x1c00,0xe000,0x3c00,0x0,0x3de000,0x1ef0000,0xf780000,0x7bc00003,0xde00001e,0xf00003c7,0x8000f800,0x78000,0x3c0000,
3909 0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0x1f00ff00,0x3c03e003,0xc01f001e,0xf800f0,0x7c00780,0x3e003c00,
3910 0xf,0x800f80f0,0x3c0780,0x1e03c00,0xf01e000,0x7803c00f,0x1fffc0,0xf001e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3911 0x0,0x0,0x307,0xe0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1e0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3912 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x3c1e0000,0x781e003f,0xfff03803,
3913 0x80001e00,0x1e0,0xf80,0xf000,0x3dde00,0x0,0x0,0x0,0x0,0xf000f00,0x780001e,0x0,0x7800000f,0x1e780,0x3c00000,0x3e000000,0x3e00f,
3914 0x780f0,0x7c0000,0x0,0x0,0x0,0x0,0x1e0,0x7c001e0,0x3ef8003,0xc000f00f,0x1e0,0xf003c0,0x1e00,0xf000,0x1e0007,0x80007800,0x780,
3915 0x3c03e000,0x7800001e,0xf01ef07b,0xc01e01e0,0xf00780,0x3e07800,0x3c078003,0xe03c0000,0xf000,0xf0003c0,0x78001e0f,0x1e00,0xf01e003e,
3916 0x1f00000,0x3c0003c,0x7800,0x1e0,0x78078,0x0,0x0,0x1,0xe0000000,0x0,0x780000,0x3c,0x0,0x78000,0x0,0x0,0x7800000,0x1e00000,
3917 0x0,0x0,0x0,0x0,0x0,0x0,0x3c000,0x0,0x0,0x0,0x0,0x0,0x1e,0xf0,0x780,0x0,0x0,0x1e00000,0x0,0x0,0x3c00000,0x0,0x18,0xc0,0x0,
3918 0xe70000,0x7800000,0x1,0xe00f0000,0x0,0x3c0000,0x0,0x3f,0xfc0,0xfc1f0,0x1f83f0,0x0,0x0,0x0,0x70,0x39e70000,0x0,0x0,0x0,0x0,
3919 0xf807c0,0x0,0x0,0x180000,0xf0000000,0x3e0,0x1f00003c,0x3e00,0x0,0x70001c,0x3fff80,0x0,0x0,0x38,0xe0000,0x1c0,0x1c000078,
3920 0x1c,0x1fe0,0x0,0x0,0xfffe1c00,0x0,0x0,0x380000f0,0x7800000,0x1c00,0xe000,0xe00,0x0,0x7df000,0x3ef8000,0x1f7c0000,0xfbe00007,
3921 0xdf00003c,0x780003c7,0x8000f000,0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0xf00f780,
3922 0x3c03c001,0xe01e000f,0xf00078,0x78003c0,0x3c001e00,0xf,0xf80f0,0x3c0780,0x1e03c00,0xf01e000,0x7803e01f,0x1ffff8,0xf001e0,
3923 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0xe0000000,0x0,0x0,0x0,0x0,0x0,0x0,0xc000,0x0,0x0,0x0,0x0,0x1e0000,
3924 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3925 0x780000,0x3c1e0000,0x781e003e,0x30703803,0x80001e00,0x1e0,0xf00,0x7800,0xff800,0x1e0000,0x0,0x0,0x0,0x1e000f00,0x780001e,
3926 0x0,0x7800000f,0x3c780,0x3c00000,0x3c000000,0x3c00f,0x780f0,0x3c0000,0x0,0x0,0x2000000,0x800000,0x1e0,0x78000e0,0x3c78003,
3927 0xc000f01e,0x1e0,0xf803c0,0x1e00,0x1e000,0x1e0007,0x80007800,0x780,0x3c07c000,0x7800001e,0x701cf07b,0xc01e01e0,0xf00780,0x1e07800,
3928 0x3c078001,0xe03c0000,0xf000,0xf0003c0,0x7c003e0f,0x1e00,0xf83e001e,0x1e00000,0x7c0003c,0x3c00,0x1e0,0xf807c,0x0,0x0,0x1fe0001,
3929 0xe1fc0000,0x7f00003,0xf8780007,0xf000003c,0x7f0,0x783f0,0x0,0x0,0x7800000,0x1e00000,0x3e0f8000,0xfc00007,0xf8000007,0xf00001fc,
3930 0xf,0xc0003fc0,0x3c000,0x0,0x0,0x0,0x0,0x0,0x1e,0xf0,0x780,0x0,0x0,0x3c00000,0x0,0x0,0x3c00000,0x0,0x18,0xc0,0x0,0x1818000,
3931 0x7800000,0x1,0xe00f0000,0x0,0x7c0000,0x0,0x1f,0x80001f80,0x7c1f8,0x1f83e0,0x0,0x0,0x0,0x70,0x38c70007,0xf8000000,0x7f03,
3932 0xf0000000,0x0,0x780780,0x0,0x0,0xfe0000,0xf0000000,0x1e0,0x1e00003c,0x3f00,0x0,0xe07f0e,0x7fff80,0x0,0x0,0x70,0x70000,0x1c0,
3933 0x1c000078,0x3c,0x1fc0,0x0,0x0,0xfffe1c00,0x0,0x0,0x380000f0,0x7800000,0x1c00,0xe000,0xe00,0x0,0x78f000,0x3c78000,0x1e3c0000,
3934 0xf1e00007,0x8f00003c,0x78000787,0x8001e000,0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,
3935 0xf80f780,0x3c03c001,0xe01e000f,0xf00078,0x78003c0,0x3c001e00,0xf,0x1f80f0,0x3c0780,0x1e03c00,0xf01e000,0x7801e01e,0x1ffffc,
3936 0xf007e0,0x3fc000,0x1fe0000,0xff00000,0x7f800003,0xfc00001f,0xe0000fc0,0xfc00007f,0xfe0,0x7f00,0x3f800,0x1fc000,0x0,0x0,0x0,
3937 0x1,0xf000001f,0x80000ff0,0x7f80,0x3fc00,0x1fe000,0xff0000,0x1f80000,0x1fc1e000,0x0,0x0,0x0,0x0,0x1e1fc0,0x0,0x0,0x0,0x0,
3938 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x3c1e0000,
3939 0x781c007c,0x30003803,0x80001f00,0x1e0,0xf00,0x7800,0x7f000,0x1e0000,0x0,0x0,0x0,0x1e000f00,0x780001e,0x0,0x7800000f,0x3c780,
3940 0x3c00000,0x3c000000,0x3c00f,0x780f0,0x3c0000,0x0,0x0,0x1e000000,0xf00000,0x3e0,0xf0000e0,0x3c78003,0xc000f01e,0x1e0,0x7803c0,
3941 0x1e00,0x1e000,0x1e0007,0x80007800,0x780,0x3c0f8000,0x7800001e,0x701cf079,0xe01e01e0,0xf00780,0x1e07800,0x3c078001,0xe03c0000,
3942 0xf000,0xf0003c0,0x3c003c0f,0x3e00,0x787c001f,0x3e00000,0xf80003c,0x3c00,0x1e0,0x1f003e,0x0,0x0,0x1fffc001,0xe7ff0000,0x3ffe000f,
3943 0xfe78003f,0xfc001fff,0xfe001ffc,0xf0078ffc,0x1ffc00,0x7ff000,0x7800f80,0x1e0000f,0x7f1fc01e,0x3ff0001f,0xfe00079f,0xfc0007ff,
3944 0x3c003c7f,0xf001fff8,0x1fffff0,0x3c003c0,0xf0000f1e,0xf1f,0x7c1f0,0x1f00ff,0xffe0001e,0xf0,0x780,0x0,0x0,0x3c00000,0x100000,
3945 0x0,0x7800000,0x0,0x18,0xc0,0x0,0x1818000,0x7800000,0x1,0xe00f0000,0x1000000,0xf80000,0x40000002,0xf,0x80001f00,0x7e0f8,0x1f07c0,
3946 0x0,0x0,0x0,0x70,0x38c7003f,0xff000000,0xff8f,0xf8000100,0xffffe,0x7c0f80,0x0,0x0,0x3ffc000,0xf0000020,0x1001f0,0x3c00003c,
3947 0x1f80,0x0,0x1c3ffc7,0x7c0780,0x0,0x0,0xe3,0xff038000,0xe0,0x38000078,0x78,0x1ff0,0x0,0x3c003c0,0xfffe1c00,0x0,0x0,0x380000f0,
3948 0x7800000,0x1c00,0xe000,0xe00,0xf000,0x78f000,0x3c78000,0x1e3c0000,0xf1e00007,0x8f00003c,0x78000787,0x8001e000,0x78000,0x3c0000,
3949 0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0x780f3c0,0x3c03c001,0xe01e000f,0xf00078,0x78003c0,0x3c001e00,
3950 0x4000200f,0x3f80f0,0x3c0780,0x1e03c00,0xf01e000,0x7801f03e,0x1ffffe,0xf01fe0,0x3fff800,0x1fffc000,0xfffe0007,0xfff0003f,
3951 0xff8001ff,0xfc003ff3,0xfe0003ff,0xe0007ff8,0x3ffc0,0x1ffe00,0xfff000,0x3ff80001,0xffc0000f,0xfe00007f,0xf000003f,0xf8003c7f,
3952 0xe0003ffc,0x1ffe0,0xfff00,0x7ff800,0x3ffc000,0x1f80000,0xfff1c03c,0x3c01e0,0x1e00f00,0xf007800,0x781f0001,0xf01e7ff0,0x7c0007c,
3953 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,
3954 0x3c1e003f,0xfffff078,0x30003803,0x80000f00,0x1e0,0x1f00,0x7800,0x7f000,0x1e0000,0x0,0x0,0x0,0x3c000f00,0x780001e,0x0,0x7800000f,
3955 0x78780,0x3c00000,0x3c000000,0x7c00f,0x780f0,0x3c0007,0xe000003f,0x0,0xfe000000,0xfe0000,0x3c0,0x1f000070,0x7c7c003,0xc000f01e,
3956 0x1e0,0x7803c0,0x1e00,0x1e000,0x1e0007,0x80007800,0x780,0x3c1f0000,0x7800001e,0x783cf079,0xe01e03c0,0xf00780,0x1e0f000,0x3c078001,
3957 0xe03c0000,0xf000,0xf0003c0,0x3c003c07,0x81f03c00,0x7c7c000f,0x87c00000,0xf00003c,0x1e00,0x1e0,0x3e001f,0x0,0x0,0x3fffe001,
3958 0xefff8000,0x7fff001f,0xff78007f,0xfe001fff,0xfe003ffe,0xf0079ffe,0x1ffc00,0x7ff000,0x7801f00,0x1e0000f,0xffbfe01e,0x7ff8003f,
3959 0xff0007bf,0xfe000fff,0xbc003cff,0xf803fffc,0x1fffff0,0x3c003c0,0x78001e1e,0xf0f,0x800f80f0,0x1e00ff,0xffe0001e,0xf0,0x780,
3960 0x0,0x0,0x3c00000,0x380000,0x0,0x7800000,0x0,0x18,0xc0,0x0,0x1008000,0x7800000,0x3,0xe00f0000,0x3800000,0xf00000,0xe0000007,
3961 0xf,0x80001f00,0x3e0f8,0x1e07c0,0x0,0x0,0x0,0x70,0x3807007f,0xff800000,0x1ffdf,0xfc000380,0xffffe,0x3e1f00,0x0,0x0,0xfffe000,
3962 0xf0000030,0x3800f8,0x7c00003c,0xfc0,0x0,0x18780c3,0xf00780,0x80100,0x0,0xc3,0xffc18000,0xf0,0x78000078,0xf0,0xf0,0x0,0x3c003c0,
3963 0xfffe1c00,0x0,0x0,0x380000f0,0x7800801,0x1c00,0xe000,0x1e00,0xf000,0xf8f800,0x7c7c000,0x3e3e0001,0xf1f0000f,0x8f80007c,0x7c000787,
3964 0x8001e000,0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0x780f3c0,0x3c078001,0xe03c000f,
3965 0x1e00078,0xf0003c0,0x78001e00,0xe000701f,0x3fc0f0,0x3c0780,0x1e03c00,0xf01e000,0x7800f87c,0x1e007f,0xf07e00,0x7fffc00,0x3fffe001,
3966 0xffff000f,0xfff8007f,0xffc003ff,0xfe007ff7,0xff0007ff,0xf000fffc,0x7ffe0,0x3fff00,0x1fff800,0x3ff80001,0xffc0000f,0xfe00007f,
3967 0xf00000ff,0xf8003cff,0xf0007ffe,0x3fff0,0x1fff80,0xfffc00,0x7ffe000,0x1f80001,0xfffb803c,0x3c01e0,0x1e00f00,0xf007800,0x780f0001,
3968 0xe01efff8,0x3c00078,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
3969 0x0,0x0,0x0,0x0,0x0,0x780000,0x3c1e003f,0xfffff078,0x30001c07,0xf80,0x1e0,0x1e00,0x3c00,0xff800,0x1e0000,0x0,0x0,0x0,0x3c001e00,
3970 0x3c0001e,0x0,0x7800001e,0x70780,0x3c00000,0x78000000,0x78007,0x800f00f0,0x3e0007,0xe000003f,0x3,0xfe000000,0xff8000,0x7c0,
3971 0x1e000070,0x783c003,0xc001f01e,0x1e0,0x7803c0,0x1e00,0x1e000,0x1e0007,0x80007800,0x780,0x3c3e0000,0x7800001e,0x3838f079,
3972 0xe01e03c0,0x780780,0x1e0f000,0x1e078001,0xe03c0000,0xf000,0xf0003c0,0x3c007c07,0x81f03c00,0x3ef80007,0x87800000,0x1f00003c,
3973 0x1e00,0x1e0,0x7c000f,0x80000000,0x0,0x3ffff001,0xffffc000,0xffff003f,0xff7800ff,0xff001fff,0xfe007ffe,0xf007bffe,0x1ffc00,
3974 0x7ff000,0x7803e00,0x1e0000f,0xffffe01e,0xfff8007f,0xff8007ff,0xff001fff,0xbc003dff,0xf807fffc,0x1fffff0,0x3c003c0,0x78001e0f,
3975 0x1e07,0xc01f00f0,0x1e00ff,0xffe0001e,0xf0,0x780,0x0,0x0,0x7c00000,0x7c0000,0x0,0x7800000,0x0,0x18,0xc0,0x0,0x1018000,0x7800000,
3976 0x3,0xc00f0000,0x7c00000,0x1f00001,0xf000000f,0x80000007,0xc0003e00,0x1e07c,0x3e0780,0x0,0x0,0x0,0x70,0x380700ff,0xff800000,
3977 0x3ffff,0xfe0007c0,0xffffe,0x1e1e00,0x0,0x780000,0x1fffe000,0xf0000078,0x7c0078,0x7800003c,0xff0,0x0,0x38e0003,0x80f00780,
3978 0x180300,0x0,0x1c3,0x81e1c000,0x7f,0xf0000078,0x1e0,0x38,0x0,0x3c003c0,0xfffe1c00,0x0,0x0,0x380000f0,0x7800c01,0x80001c00,
3979 0xe000,0x603e00,0xf000,0xf07800,0x783c000,0x3c1e0001,0xe0f0000f,0x7800078,0x3c000f87,0x8001e000,0x78000,0x3c0000,0x1e00000,
3980 0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0x780f3c0,0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0,0x78000f01,0xf000f81e,
3981 0x7bc0f0,0x3c0780,0x1e03c00,0xf01e000,0x78007878,0x1e001f,0xf0f800,0x7fffe00,0x3ffff001,0xffff800f,0xfffc007f,0xffe003ff,
3982 0xff007fff,0xff800fff,0xf001fffe,0xffff0,0x7fff80,0x3fffc00,0x3ff80001,0xffc0000f,0xfe00007f,0xf00001ff,0xfc003dff,0xf000ffff,
3983 0x7fff8,0x3fffc0,0x1fffe00,0xffff000,0x1f80003,0xffff803c,0x3c01e0,0x1e00f00,0xf007800,0x780f0001,0xe01ffffc,0x3c00078,0x0,
3984 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,
3985 0x3c1e003f,0xfffff078,0x30001e0f,0x300780,0x1e0,0x1e00,0x3c00,0x3dde00,0x1e0000,0x0,0x0,0x0,0x78001e00,0x3c0001e,0x0,0xf800003e,
3986 0xf0780,0x3dfc000,0x783f8000,0xf8007,0xc01f00f0,0x3e0007,0xe000003f,0x1f,0xfc000000,0x7ff000,0xf80,0x3e007c70,0x783c003,0xc001e03c,
3987 0x1e0,0x3c03c0,0x1e00,0x3c000,0x1e0007,0x80007800,0x780,0x3c7c0000,0x7800001e,0x3878f078,0xf01e03c0,0x780780,0x1e0f000,0x1e078001,
3988 0xe03e0000,0xf000,0xf0003c0,0x1e007807,0x83f03c00,0x3ef00007,0xcf800000,0x3e00003c,0xf00,0x1e0,0xf80007,0xc0000000,0x0,0x3e01f801,
3989 0xfe07e001,0xf80f007e,0x7f801f8,0x1f801fff,0xfe00fc0f,0xf007f83f,0x1ffc00,0x7ff000,0x7807c00,0x1e0000f,0x87e1e01f,0xe0fc00fc,
3990 0xfc007f8,0x1f803f03,0xfc003df0,0x3807e03c,0x1fffff0,0x3c003c0,0x78003e0f,0x1e03,0xe03e00f8,0x3e00ff,0xffe0001e,0xf0,0x780,
3991 0x0,0x0,0x7800000,0xfe0000,0x0,0x7800000,0x0,0x18,0xc0,0x0,0x1818000,0x7c00000,0x3,0xc00f0000,0xfe00000,0x3e00003,0xf800001f,
3992 0xc0000007,0xc0003e00,0x1e03c,0x3c0f80,0x0,0x0,0x0,0x70,0x380700fc,0x7800000,0x7c1fe,0x3e000fe0,0xffffe,0x1f3e00,0x0,0x780000,
3993 0x3f98e000,0xf000003c,0xfcf8007c,0xf800003c,0x3ffc,0x0,0x31c0001,0x80f00f80,0x380700,0x0,0x183,0x80e0c000,0x3f,0xe0000078,
3994 0x3c0,0x38,0x0,0x3c003c0,0xfffe1c00,0x0,0x0,0x38000078,0xf000e01,0xc003ffe0,0x1fff00,0x7ffc00,0xf000,0xf07800,0x783c000,0x3c1e0001,
3995 0xe0f0000f,0x7800078,0x3c000f07,0x8003c000,0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,
3996 0x3c0f1e0,0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0,0x78000f00,0xf801f01e,0xf3c0f0,0x3c0780,0x1e03c00,0xf01e000,0x78007cf8,
3997 0x1e000f,0x80f0f000,0x7c03f00,0x3e01f801,0xf00fc00f,0x807e007c,0x3f003e0,0x1f80707f,0x8f801f80,0xf003f03f,0x1f81f8,0xfc0fc0,
3998 0x7e07e00,0x3ff80001,0xffc0000f,0xfe00007f,0xf00003ff,0xfc003fc1,0xf801f81f,0x800fc0fc,0x7e07e0,0x3f03f00,0x1f81f800,0x1f80007,
3999 0xe07f003c,0x3c01e0,0x1e00f00,0xf007800,0x780f8003,0xe01fe07e,0x3e000f8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4000 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x3f,0xfffff078,0x30000ffe,0x1f007c0,0x0,0x1e00,
4001 0x3c00,0xf9cf80,0x1e0000,0x0,0x0,0x0,0x78001e00,0x3c0001e,0x0,0xf00000fc,0x1e0780,0x3fff800,0x78ffe000,0xf0003,0xe03e00f0,
4002 0x3e0007,0xe000003f,0x7f,0xe01fffff,0xf00ffc00,0x1f80,0x3c01ff70,0x783c003,0xc007e03c,0x1e0,0x3c03c0,0x1e00,0x3c000,0x1e0007,
4003 0x80007800,0x780,0x3cfc0000,0x7800001e,0x3c78f078,0xf01e03c0,0x780780,0x3e0f000,0x1e078003,0xc01f0000,0xf000,0xf0003c0,0x1e007807,
4004 0x83f83c00,0x1ff00003,0xcf000000,0x3e00003c,0xf00,0x1e0,0x0,0x0,0x0,0x20007801,0xfc03e003,0xe003007c,0x3f803e0,0x7c0003c,
4005 0xf807,0xf007e00f,0x3c00,0xf000,0x780f800,0x1e0000f,0x87e1f01f,0x803c00f8,0x7c007f0,0xf803e01,0xfc003f80,0x80f8004,0x3c000,
4006 0x3c003c0,0x3c003c0f,0x1e03,0xe03e0078,0x3c0000,0x7c0001e,0xf0,0x780,0x0,0x0,0x3ffff800,0x1ff0000,0x0,0x7800000,0x0,0x18,
4007 0xc0,0x0,0x1818000,0x3e00000,0x3,0xc00f0000,0x1ff00000,0x3e00007,0xfc00003f,0xe0000003,0xc0003c00,0xf03c,0x3c0f00,0x0,0x0,
4008 0x0,0x70,0x380701f0,0x800000,0x780fc,0x1e001ff0,0x7c,0xf3c00,0x0,0x780000,0x7e182000,0xf000001f,0xfff00ffc,0xffc0003c,0x3cfe,
4009 0x0,0x31c0001,0x80f01f80,0x780f00,0x0,0x183,0x80e0c000,0xf,0x80000078,0x780,0x38,0x0,0x3c003c0,0x7ffe1c00,0x0,0x0,0x38000078,
4010 0xf000f01,0xe003ffe0,0x1fff00,0x7ff800,0xf000,0xf07800,0x783c000,0x3c1e0001,0xe0f0000f,0x78000f8,0x3e000f07,0x8003c000,0x78000,
4011 0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0x3c0f1e0,0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0,
4012 0x78000f00,0x7c03e01e,0x1e3c0f0,0x3c0780,0x1e03c00,0xf01e000,0x78003cf0,0x1e0007,0x80f1e000,0x4000f00,0x20007801,0x3c008,
4013 0x1e0040,0xf00200,0x780403f,0x7803e00,0x3007c00f,0x803e007c,0x1f003e0,0xf801f00,0x780000,0x3c00000,0x1e000000,0xf00007f0,
4014 0x3e003f00,0x7801f00f,0x800f807c,0x7c03e0,0x3e01f00,0x1f00f800,0x1f80007,0xc03e003c,0x3c01e0,0x1e00f00,0xf007800,0x78078003,
4015 0xc01fc03e,0x1e000f0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4016 0x0,0x0,0x0,0x0,0x0,0x780000,0x0,0xf078007c,0x300007fc,0x7e00fe0,0x0,0x1e00,0x3c00,0x3e1c3e0,0x1e0000,0x0,0x0,0x0,0xf0001e00,
4017 0x3c0001e,0x1,0xf000fff8,0x1e0780,0x3fffe00,0x79fff000,0x1f0001,0xfffc00f0,0x7e0007,0xe000003f,0x3ff,0x801fffff,0xf003ff80,
4018 0x3f00,0x3c03fff0,0xf01e003,0xffffc03c,0x1e0,0x3c03ff,0xffc01fff,0xfe03c000,0x1fffff,0x80007800,0x780,0x3df80000,0x7800001e,
4019 0x1c70f078,0x781e03c0,0x780780,0x3c0f000,0x1e078007,0xc01f8000,0xf000,0xf0003c0,0x1e007807,0x83f83c00,0xfe00003,0xff000000,
4020 0x7c00003c,0x780,0x1e0,0x0,0x0,0x0,0x7c01,0xf801f007,0xc00100f8,0x1f803c0,0x3c0003c,0x1f003,0xf007c00f,0x80003c00,0xf000,
4021 0x783f000,0x1e0000f,0x3c0f01f,0x3e01f0,0x3e007e0,0x7c07c00,0xfc003f00,0xf0000,0x3c000,0x3c003c0,0x3c003c0f,0x1e01,0xf07c007c,
4022 0x7c0000,0xfc0001e,0xf0,0x780,0x0,0x0,0x3ffff000,0x3838000,0x0,0x7800000,0x0,0x18,0xc0,0x0,0xff0000,0x3f00000,0x3,0xc00fff00,
4023 0x38380000,0x7c0000e,0xe000070,0x70000001,0xe0003c00,0xf01e,0x780e00,0x0,0x0,0x0,0x0,0x1e0,0x0,0x780f8,0xf003838,0xfc,0xffc00,
4024 0x0,0x780000,0x7c180000,0xf000000f,0xffe00fff,0xffc0003c,0x783f,0x80000000,0x6380000,0xc0f83f80,0xf81f00,0x0,0x303,0x80e06000,
4025 0x0,0x78,0xf00,0x78,0x0,0x3c003c0,0x7ffe1c00,0x0,0x0,0x3800003c,0x3e000f81,0xf003ffe0,0x1fff00,0x1fc000,0xf000,0x1e03c00,
4026 0xf01e000,0x780f0003,0xc078001e,0x3c000f0,0x1e000f07,0xff83c000,0x7ffff,0x803ffffc,0x1ffffe0,0xfffff00,0xf00000,0x7800000,
4027 0x3c000001,0xe0001e00,0x3c0f0f0,0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0,0x78000f00,0x3e07c01e,0x1e3c0f0,0x3c0780,0x1e03c00,
4028 0xf01e000,0x78003ff0,0x1e0007,0x80f1e000,0xf80,0x7c00,0x3e000,0x1f0000,0xf80000,0x7c0001e,0x3c07c00,0x10078007,0x803c003c,
4029 0x1e001e0,0xf000f00,0x780000,0x3c00000,0x1e000000,0xf00007c0,0x1e003e00,0x7c03e007,0xc01f003e,0xf801f0,0x7c00f80,0x3e007c00,
4030 0xf,0x801f003c,0x3c01e0,0x1e00f00,0xf007800,0x7807c007,0xc01f801f,0x1f001f0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4031 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x0,0xe078003c,0x300001f0,0x3f801ff0,0x0,
4032 0x3c00,0x1e00,0x3c1c1e0,0x1e0000,0x0,0x0,0x0,0xf0001e0f,0x3c0001e,0x3,0xe000fff0,0x3c0780,0x3ffff00,0x7bfff800,0x1e0000,0x7ff00078,
4033 0x7e0007,0xe000003f,0x1ffc,0x1fffff,0xf0007ff0,0x7e00,0x3c07c3f0,0xf01e003,0xffff003c,0x1e0,0x3c03ff,0xffc01fff,0xfe03c000,
4034 0x1fffff,0x80007800,0x780,0x3ffc0000,0x7800001e,0x1ef0f078,0x781e03c0,0x780780,0x7c0f000,0x1e07801f,0x800ff000,0xf000,0xf0003c0,
4035 0xf00f807,0x83b83c00,0xfc00001,0xfe000000,0xf800003c,0x780,0x1e0,0x0,0x0,0x0,0x3c01,0xf000f007,0xc00000f0,0xf80780,0x3c0003c,
4036 0x1e001,0xf007c007,0x80003c00,0xf000,0x787e000,0x1e0000f,0x3c0f01f,0x1e01e0,0x1e007c0,0x3c07800,0x7c003f00,0xf0000,0x3c000,
4037 0x3c003c0,0x3e007c07,0x80003c00,0xf8f8003c,0x780000,0xf80001e,0xf0,0x780,0x0,0x0,0x7ffff000,0x601c000,0x3,0xffff0000,0x0,
4038 0xfff,0xf8007fff,0xc0000000,0x7e003c,0x1fe0000,0xc0003,0xc00fff00,0x601c0000,0xf800018,0x70000c0,0x38000001,0xe0007800,0x701e,
4039 0x701e00,0x0,0x0,0x0,0x0,0x1e0,0x6,0x700f8,0xf00601c,0xf8,0x7f800,0x0,0x780000,0xf8180000,0xf000000f,0x87c00fff,0xffc0003c,
4040 0xf01f,0xc0000000,0x6380000,0xc07ff780,0x1f03e03,0xfffffe00,0x303,0x81c06000,0x0,0x1ffff,0xfe001e00,0x180f8,0x0,0x3c003c0,
4041 0x3ffe1c00,0x3f00000,0x0,0x3800003f,0xfe0007c0,0xf8000000,0x18000000,0xc0000006,0x1f000,0x1e03c00,0xf01e000,0x780f0003,0xc078001e,
4042 0x3c000f0,0x1e001f07,0xff83c000,0x7ffff,0x803ffffc,0x1ffffe0,0xfffff00,0xf00000,0x7800000,0x3c000001,0xe000fff8,0x3c0f0f0,
4043 0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0,0x78000f00,0x1f0f801e,0x3c3c0f0,0x3c0780,0x1e03c00,0xf01e000,0x78001fe0,0x1e0007,
4044 0x80f1e000,0x780,0x3c00,0x1e000,0xf0000,0x780000,0x3c0001e,0x3c07c00,0xf0007,0x8078003c,0x3c001e0,0x1e000f00,0x780000,0x3c00000,
4045 0x1e000000,0xf0000f80,0x1f003e00,0x3c03c003,0xc01e001e,0xf000f0,0x7800780,0x3c003c00,0xf,0x3f003c,0x3c01e0,0x1e00f00,0xf007800,
4046 0x7803c007,0x801f000f,0xf001e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4047 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x1,0xe078003f,0xb0000000,0xfc003cf0,0x0,0x3c00,0x1e00,0x101c040,0x1e0000,0x0,0x0,0x1,
4048 0xe0001e1f,0x83c0001e,0x7,0xe000fff0,0x3c0780,0x3c03f80,0x7fc0fc00,0x1e0000,0xfff80078,0xfe0007,0xe000003f,0x7fe0,0x1fffff,
4049 0xf0000ffc,0xfc00,0x780f81f0,0xf01e003,0xffff003c,0x1e0,0x3c03ff,0xffc01fff,0xfe03c000,0x1fffff,0x80007800,0x780,0x3ffc0000,
4050 0x7800001e,0x1ef0f078,0x3c1e03c0,0x780780,0x1fc0f000,0x1e07ffff,0x7ff00,0xf000,0xf0003c0,0xf00f007,0xc3b87c00,0x7c00001,0xfe000000,
4051 0xf800003c,0x3c0,0x1e0,0x0,0x0,0x0,0x3c01,0xf000f007,0x800000f0,0xf80780,0x1e0003c,0x1e001,0xf0078007,0x80003c00,0xf000,0x78fc000,
4052 0x1e0000f,0x3c0f01e,0x1e01e0,0x1e007c0,0x3c07800,0x7c003e00,0xf0000,0x3c000,0x3c003c0,0x1e007807,0x80003c00,0x7df0003c,0x780000,
4053 0x1f00001e,0xf0,0x780,0x0,0x0,0x7800000,0xe7ce000,0x3,0xffff0000,0x0,0xfff,0xf8007fff,0xc0000000,0x1f0,0xffe000,0x1c0003,
4054 0xc00fff00,0xe7ce0000,0xf800039,0xf38001cf,0x9c000000,0xe0007800,0x780e,0x701c00,0x0,0x0,0x0,0x0,0x1e0,0x7,0xf0078,0xf00e7ce,
4055 0x1f0,0x7f800,0x0,0x780000,0xf0180000,0xf000000e,0x1c0001f,0xe000003c,0xf007,0xe0000000,0x6380000,0xc03fe780,0x3e07c03,0xfffffe00,
4056 0x303,0xffc06000,0x0,0x1ffff,0xfe003ffe,0x1fff0,0x0,0x3c003c0,0x1ffe1c00,0x3f00000,0x7,0xffc0001f,0xfc0003e0,0x7c000001,0xfc00000f,
4057 0xe000007f,0x1e000,0x1e03c00,0xf01e000,0x780f0003,0xc078001e,0x3c000f0,0x1e001e07,0xff83c000,0x7ffff,0x803ffffc,0x1ffffe0,
4058 0xfffff00,0xf00000,0x7800000,0x3c000001,0xe000fff8,0x3c0f078,0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0,0x78000f00,0xf9f001e,
4059 0x783c0f0,0x3c0780,0x1e03c00,0xf01e000,0x78001fe0,0x1e0007,0x80f1e000,0x780,0x3c00,0x1e000,0xf0000,0x780000,0x3c0001e,0x3c07800,
4060 0xf0003,0xc078001e,0x3c000f0,0x1e000780,0x780000,0x3c00000,0x1e000000,0xf0000f00,0xf003c00,0x3c03c003,0xc01e001e,0xf000f0,
4061 0x7800780,0x3c003c00,0xf,0x7f003c,0x3c01e0,0x1e00f00,0xf007800,0x7803c007,0x801f000f,0xf001e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4062 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x1,0xe070001f,0xf8000007,
4063 0xf0007cf8,0x7800000,0x3c00,0x1e00,0x1c000,0x1e0000,0x0,0x0,0x1,0xe0001e1f,0x83c0001e,0xf,0xc000fff8,0x780780,0x2000f80,0x7f803e00,
4064 0x3e0003,0xfffe007c,0x1fe0000,0x0,0x3ff00,0x0,0x1ff,0x8001f000,0x780f00f0,0x1f00f003,0xffffc03c,0x1e0,0x3c03ff,0xffc01fff,
4065 0xfe03c00f,0xf81fffff,0x80007800,0x780,0x3ffe0000,0x7800001e,0xee0f078,0x3c1e03c0,0x7807ff,0xff80f000,0x1e07fffe,0x3ffe0,
4066 0xf000,0xf0003c0,0xf00f003,0xc7bc7800,0xfc00000,0xfc000001,0xf000003c,0x3c0,0x1e0,0x0,0x0,0x0,0x3c01,0xe000f80f,0x800001e0,
4067 0xf80f00,0x1e0003c,0x3c000,0xf0078007,0x80003c00,0xf000,0x79f8000,0x1e0000f,0x3c0f01e,0x1e03c0,0x1f00780,0x3e0f000,0x7c003e00,
4068 0xf0000,0x3c000,0x3c003c0,0x1e007807,0x81e03c00,0x7df0003e,0xf80000,0x3e00003e,0xf0,0x7c0,0xfc000,0x80000000,0x7800000,0x1e7cf000,
4069 0x3,0xffff0000,0x0,0x18,0xc0,0x0,0xf80,0x7ffc00,0x380003,0xc00fff01,0xe7cf0000,0x1f000079,0xf3c003cf,0x9e000000,0xe0007000,
4070 0x380e,0xe01c00,0x0,0x0,0x0,0x0,0x1e0,0x3,0x800f0078,0xf01e7cf,0x3e0,0x3f000,0x0,0x780000,0xf018001f,0xfff8001e,0x1e0000f,
4071 0xc000003c,0xf003,0xe0000000,0x6380000,0xc00fc780,0x7c0f803,0xfffffe00,0x303,0xfe006000,0x0,0x1ffff,0xfe003ffe,0x1ffe0,0x0,
4072 0x3c003c0,0xffe1c00,0x3f00000,0x7,0xffc00007,0xf00001f0,0x3e00001f,0xfc0000ff,0xe00007ff,0x3e000,0x3e01e00,0x1f00f000,0xf8078007,
4073 0xc03c003e,0x1e001e0,0xf001e07,0xff83c000,0x7ffff,0x803ffffc,0x1ffffe0,0xfffff00,0xf00000,0x7800000,0x3c000001,0xe000fff8,
4074 0x3c0f078,0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0,0x78000f00,0x7fe001e,0xf03c0f0,0x3c0780,0x1e03c00,0xf01e000,0x78000fc0,
4075 0x1e0007,0x80f1f000,0x780,0x3c00,0x1e000,0xf0000,0x780000,0x3c0001e,0x3c0f800,0x1e0003,0xc0f0001e,0x78000f0,0x3c000780,0x780000,
4076 0x3c00000,0x1e000000,0xf0000f00,0xf003c00,0x3c078003,0xe03c001f,0x1e000f8,0xf0007c0,0x78003e00,0x1e,0xf7803c,0x3c01e0,0x1e00f00,
4077 0xf007800,0x7803e00f,0x801e000f,0x80f803e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4078 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x1,0xe0f0000f,0xff00001f,0x8000f87c,0x7800000,0x3c00,0x1e00,0x1c000,0x7fffff80,
4079 0x0,0x0,0x3,0xc0001e1f,0x83c0001e,0x1f,0x800000fe,0xf00780,0x7c0,0x7f001e00,0x3c0007,0xe03f003f,0x3fe0000,0x0,0x3fc00,0x0,
4080 0x7f,0x8001e000,0x781f00f0,0x1e00f003,0xc007e03c,0x1e0,0x3c03c0,0x1e00,0x3c00f,0xf81e0007,0x80007800,0x780,0x3f9f0000,0x7800001e,
4081 0xfe0f078,0x3c1e03c0,0x7807ff,0xff00f000,0x1e07fff8,0xfff8,0xf000,0xf0003c0,0xf81f003,0xc7bc7800,0xfe00000,0x78000003,0xe000003c,
4082 0x1e0,0x1e0,0x0,0x0,0x0,0x1fffc01,0xe000780f,0x1e0,0x780f00,0x1e0003c,0x3c000,0xf0078007,0x80003c00,0xf000,0x7bf0000,0x1e0000f,
4083 0x3c0f01e,0x1e03c0,0xf00780,0x1e0f000,0x3c003c00,0xf8000,0x3c000,0x3c003c0,0x1f00f807,0x81f03c00,0x3fe0001e,0xf00000,0x7c00007c,
4084 0xf0,0x3e0,0x3ff801,0x80000000,0x7800000,0x3cfcf800,0x3,0xffff0000,0x0,0x18,0xc0,0x0,0x7c00,0x1fff00,0x700003,0xc00f0003,
4085 0xcfcf8000,0x3e0000f3,0xf3e0079f,0x9f000000,0xf000,0x1000,0x0,0x0,0x0,0x0,0x0,0x1f0,0x1,0xc00f0078,0xf03cfcf,0x800007c0,0x1e000,
4086 0x0,0x780001,0xe018001f,0xfff8001c,0xe00007,0x8000003c,0xf001,0xf0000000,0x6380000,0xc0000000,0xf81f003,0xfffffe00,0x303,
4087 0x87006000,0x0,0x1ffff,0xfe003ffe,0x7f00,0x0,0x3c003c0,0x3fe1c00,0x3f00000,0x7,0xffc00000,0xf8,0x1f0001ff,0xf0000fff,0x80007ffc,
4088 0xfc000,0x3c01e00,0x1e00f000,0xf0078007,0x803c003c,0x1e001e0,0xf001e07,0x8003c000,0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,
4089 0x7800000,0x3c000001,0xe000fff8,0x3c0f078,0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0,0x78000f00,0x3fc001e,0x1e03c0f0,0x3c0780,
4090 0x1e03c00,0xf01e000,0x78000780,0x1e0007,0x80f0fc00,0x3fff80,0x1fffc00,0xfffe000,0x7fff0003,0xfff8001f,0xffc0001e,0x3c0f000,
4091 0x1e0003,0xc0f0001e,0x78000f0,0x3c000780,0x780000,0x3c00000,0x1e000000,0xf0001e00,0xf803c00,0x3c078001,0xe03c000f,0x1e00078,
4092 0xf0003c0,0x78001e07,0xfffffe1e,0x1e7803c,0x3c01e0,0x1e00f00,0xf007800,0x7801e00f,0x1e0007,0x807803c0,0x0,0x0,0x0,0x0,0x0,
4093 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x3,0xc0f00007,
4094 0xffc0007e,0xf03e,0x7800000,0x3c00,0x1e00,0x1c000,0x7fffff80,0x0,0x0,0x3,0xc0001e1f,0x83c0001e,0x3f,0x3e,0xf00780,0x3c0,0x7e001e00,
4095 0x7c000f,0x800f001f,0xffde0000,0x0,0x3e000,0x0,0xf,0x8003e000,0x781e0070,0x1e00f003,0xc001f03c,0x1e0,0x3c03c0,0x1e00,0x3c00f,
4096 0xf81e0007,0x80007800,0x780,0x3f1f0000,0x7800001e,0x7c0f078,0x1e1e03c0,0x7807ff,0xfc00f000,0x1e07fffe,0xffc,0xf000,0xf0003c0,
4097 0x781e003,0xc71c7800,0x1ff00000,0x78000003,0xe000003c,0x1e0,0x1e0,0x0,0x0,0x0,0xffffc01,0xe000780f,0x1e0,0x780fff,0xffe0003c,
4098 0x3c000,0xf0078007,0x80003c00,0xf000,0x7ff0000,0x1e0000f,0x3c0f01e,0x1e03c0,0xf00780,0x1e0f000,0x3c003c00,0x7f000,0x3c000,
4099 0x3c003c0,0xf00f007,0xc1f07c00,0x1fc0001f,0x1f00000,0xfc000ff8,0xf0,0x1ff,0xfffe07,0x80000000,0x7800000,0x7ffcfc00,0x0,0xf000000,
4100 0x0,0x18,0xc0,0x0,0x3e000,0x1ff80,0xe00003,0xc00f0007,0xffcfc000,0x3e0001ff,0xf3f00fff,0x9f800000,0x6000,0x0,0x0,0x7c000,
4101 0x0,0x0,0x0,0xfe,0x0,0xe00f007f,0xff07ffcf,0xc0000fc0,0x1e000,0x0,0x780001,0xe018001f,0xfff8001c,0xe00007,0x80000000,0xf800,
4102 0xf0000000,0x6380000,0xc0000000,0x1f03c000,0x1e00,0x303,0x83806000,0x0,0x78,0x0,0x0,0x0,0x3c003c0,0xfe1c00,0x3f00000,0x0,
4103 0x0,0x3c,0xf801fff,0xfff8,0x7ffc0,0x1f8000,0x3c01e00,0x1e00f000,0xf0078007,0x803c003c,0x1e001e0,0xf003c07,0x8003c000,0x78000,
4104 0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0x3c0f03c,0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0,
4105 0x78000f00,0x1f8001e,0x1e03c0f0,0x3c0780,0x1e03c00,0xf01e000,0x78000780,0x1e000f,0x80f0ff00,0x1ffff80,0xffffc00,0x7fffe003,
4106 0xffff001f,0xfff800ff,0xffc007ff,0xffc0f000,0x1fffff,0xc0fffffe,0x7fffff0,0x3fffff80,0x780000,0x3c00000,0x1e000000,0xf0001e00,
4107 0x7803c00,0x3c078001,0xe03c000f,0x1e00078,0xf0003c0,0x78001e07,0xfffffe1e,0x3c7803c,0x3c01e0,0x1e00f00,0xf007800,0x7801f01f,
4108 0x1e0007,0x807c07c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4109 0x0,0x0,0x0,0x0,0x780000,0x3,0xc0f00000,0xfff003f0,0x1f00f03e,0x7800000,0x3c00,0x1e00,0x1c000,0x7fffff80,0x0,0x7ff80000,0x3,
4110 0xc0001e0f,0x3c0001e,0x7e,0x1f,0x1e00780,0x3e0,0x7e000f00,0x78000f,0x7800f,0xff9e0000,0x0,0x3fc00,0x0,0x7f,0x8003c000,0x781e0070,
4111 0x3e00f803,0xc000f03c,0x1e0,0x3c03c0,0x1e00,0x3c00f,0xf81e0007,0x80007800,0x780,0x3e0f8000,0x7800001e,0x7c0f078,0x1e1e03c0,
4112 0x7807ff,0xf000f000,0x1e07807f,0xfe,0xf000,0xf0003c0,0x781e003,0xc71c7800,0x3ef00000,0x78000007,0xc000003c,0x1e0,0x1e0,0x0,
4113 0x0,0x0,0x1ffffc01,0xe000780f,0x1e0,0x780fff,0xffe0003c,0x3c000,0xf0078007,0x80003c00,0xf000,0x7ff0000,0x1e0000f,0x3c0f01e,
4114 0x1e03c0,0xf00780,0x1e0f000,0x3c003c00,0x7ff80,0x3c000,0x3c003c0,0xf00f003,0xc1f07800,0x1fc0000f,0x1e00000,0xf8000ff0,0xf0,
4115 0xff,0xffffff,0x80000000,0x3fffc000,0xfff9fe00,0x0,0xf000000,0x0,0x18,0xc0,0x0,0x1f0000,0x1fc0,0x1c00003,0xc00f000f,0xff9fe000,
4116 0x7c0003ff,0xe7f81fff,0x3fc00000,0x0,0x0,0x0,0xfe000,0x1ffffc0f,0xfffffc00,0x0,0xff,0xf0000000,0x700f007f,0xff0fff9f,0xe0000f80,
4117 0x1e000,0x0,0x780001,0xe018001f,0xfff8001c,0xe00fff,0xffc00000,0xf800,0xf0000000,0x6380000,0xc0ffff80,0x3e078000,0x1e00,0x7ff80303,
4118 0x83c06000,0x0,0x78,0x0,0x0,0x0,0x3c003c0,0xe1c00,0x3f00000,0x0,0x7f,0xff00001e,0x7c1fff0,0xfff80,0x7ffc00,0x3f0000,0x7c01f00,
4119 0x3e00f801,0xf007c00f,0x803e007c,0x1f003e0,0xf803c07,0x8003c000,0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,
4120 0xe0001e00,0x3c0f03c,0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0,0x78000f00,0x1f8001e,0x3c03c0f0,0x3c0780,0x1e03c00,0xf01e000,
4121 0x78000780,0x1e001f,0xf07f80,0x3ffff80,0x1ffffc00,0xffffe007,0xffff003f,0xfff801ff,0xffc03fff,0xffc0f000,0x1fffff,0xc0fffffe,
4122 0x7fffff0,0x3fffff80,0x780000,0x3c00000,0x1e000000,0xf0001e00,0x7803c00,0x3c078001,0xe03c000f,0x1e00078,0xf0003c0,0x78001e07,
4123 0xfffffe1e,0x787803c,0x3c01e0,0x1e00f00,0xf007800,0x7800f01e,0x1e0007,0x803c0780,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4124 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x1ff,0xffff8000,0x3ff80fc0,0x7fc1e01f,
4125 0x7800000,0x3c00,0x1e00,0x0,0x7fffff80,0x0,0x7ff80000,0x7,0x80001e00,0x3c0001e,0xfc,0xf,0x1e00780,0x1e0,0x7c000f00,0x78000f,
4126 0x78007,0xff1e0000,0x0,0x3ff00,0x0,0x1ff,0x8003c000,0x781e0070,0x3c007803,0xc000f03c,0x1e0,0x3c03c0,0x1e00,0x3c000,0x781e0007,
4127 0x80007800,0x780,0x3c07c000,0x7800001e,0x7c0f078,0xf1e03c0,0x780780,0xf000,0x1e07801f,0x3e,0xf000,0xf0003c0,0x781e003,0xcf1c7800,
4128 0x3cf80000,0x7800000f,0x8000003c,0xf0,0x1e0,0x0,0x0,0x0,0x3ffffc01,0xe000780f,0x1e0,0x780fff,0xffe0003c,0x3c000,0xf0078007,
4129 0x80003c00,0xf000,0x7ff8000,0x1e0000f,0x3c0f01e,0x1e03c0,0xf00780,0x1e0f000,0x3c003c00,0x3fff0,0x3c000,0x3c003c0,0xf81f003,
4130 0xc3b87800,0xf80000f,0x1e00001,0xf0000ff0,0xf0,0xff,0xf03fff,0x80000000,0x3fff8001,0xfff1ff00,0x0,0xf000000,0x0,0x18,0xc0,
4131 0x0,0x380000,0x7c0,0x3c00003,0xc00f001f,0xff1ff000,0xf80007ff,0xc7fc3ffe,0x3fe00000,0x0,0x0,0x0,0x1ff000,0x7ffffe1f,0xffffff00,
4132 0x0,0x7f,0xfe000000,0x780f007f,0xff1fff1f,0xf0001f00,0x1e000,0x0,0x780001,0xe0180000,0xf000001c,0xe00fff,0xffc00000,0x7c00,
4133 0xf0000000,0x31c0001,0x80ffff80,0x3e078000,0x1e00,0x7ff80183,0x81c0c000,0x0,0x78,0x0,0x0,0x0,0x3c003c0,0xe1c00,0x3f00000,
4134 0x0,0x7f,0xff00001e,0x7c7ff03,0xc03ff8fe,0x1ffc0f0,0x7e0000,0x7800f00,0x3c007801,0xe003c00f,0x1e0078,0xf003c0,0x7803c07,0x8003c000,
4135 0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0x3c0f01e,0x3c078000,0xf03c0007,0x81e0003c,
4136 0xf0001e0,0x78000f00,0x3fc001e,0x7803c0f0,0x3c0780,0x1e03c00,0xf01e000,0x78000780,0x1e007f,0xf03fe0,0x7ffff80,0x3ffffc01,
4137 0xffffe00f,0xffff007f,0xfff803ff,0xffc07fff,0xffc0f000,0x1fffff,0xc0fffffe,0x7fffff0,0x3fffff80,0x780000,0x3c00000,0x1e000000,
4138 0xf0001e00,0x7803c00,0x3c078001,0xe03c000f,0x1e00078,0xf0003c0,0x78001e07,0xfffffe1e,0x707803c,0x3c01e0,0x1e00f00,0xf007800,
4139 0x7800f01e,0x1e0007,0x803c0780,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4140 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x1ff,0xffff8000,0x30f81f00,0xffe1e00f,0x87800000,0x3c00,0x1e00,0x0,0x1e0000,0x0,0x7ff80000,
4141 0x7,0x80001e00,0x3c0001e,0x1f8,0x7,0x83c00780,0x1e0,0x7c000f00,0xf8001e,0x3c001,0xfc1e0000,0x0,0x7fe0,0x0,0xffc,0x3c000,0x781e0070,
4142 0x3ffff803,0xc000783c,0x1e0,0x3c03c0,0x1e00,0x3c000,0x781e0007,0x80007800,0x780,0x3c07c000,0x7800001e,0x380f078,0xf1e03c0,
4143 0x780780,0xf000,0x1e07800f,0x8000001e,0xf000,0xf0003c0,0x3c3c003,0xcf1e7800,0x7c780000,0x7800000f,0x8000003c,0xf0,0x1e0,0x0,
4144 0x0,0x0,0x7f003c01,0xe000780f,0x1e0,0x780fff,0xffe0003c,0x3c000,0xf0078007,0x80003c00,0xf000,0x7f7c000,0x1e0000f,0x3c0f01e,
4145 0x1e03c0,0xf00780,0x1e0f000,0x3c003c00,0xfff8,0x3c000,0x3c003c0,0x781e003,0xc3b87800,0x1fc00007,0x83e00003,0xe0000ff8,0xf0,
4146 0x1ff,0xc007fe,0x0,0x7fff8001,0xffe3ff00,0x0,0x1e000000,0x0,0x18,0xc0,0x0,0x0,0x3c0,0x7800003,0xc00f001f,0xfe3ff000,0xf80007ff,
4147 0x8ffc3ffc,0x7fe00000,0x0,0x0,0x0,0x1ff000,0x0,0x0,0x0,0x1f,0xff000000,0x3c0f007f,0xff1ffe3f,0xf0003e00,0x1e000,0x0,0x780001,
4148 0xe0180000,0xf000001e,0x1e00fff,0xffc00000,0x3f00,0xf0000000,0x31c0001,0x80ffff80,0x1f03c000,0x1e00,0x7ff80183,0x81c0c000,
4149 0x0,0x78,0x0,0x0,0x0,0x3c003c0,0xe1c00,0x0,0x0,0x7f,0xff00003c,0xf87f007,0xc03f83ff,0x81fc01f0,0x7c0000,0x7ffff00,0x3ffff801,
4150 0xffffc00f,0xfffe007f,0xfff003ff,0xff807fff,0x8003c000,0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,
4151 0xe0001e00,0x3c0f01e,0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0,0x78000f00,0x7fe001e,0xf003c0f0,0x3c0780,0x1e03c00,0xf01e000,
4152 0x78000780,0x1ffffe,0xf00ff0,0xfe00780,0x7f003c03,0xf801e01f,0xc00f00fe,0x7807f0,0x3c0ffff,0xffc0f000,0x1fffff,0xc0fffffe,
4153 0x7fffff0,0x3fffff80,0x780000,0x3c00000,0x1e000000,0xf0001e00,0x7803c00,0x3c078001,0xe03c000f,0x1e00078,0xf0003c0,0x78001e00,
4154 0x1e,0xf07803c,0x3c01e0,0x1e00f00,0xf007800,0x7800783e,0x1e0007,0x801e0f80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4155 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x1ff,0xffff8000,0x307c0801,0xe1f1e00f,0x87000000,
4156 0x3c00,0x1e00,0x0,0x1e0000,0x0,0x7ff80000,0xf,0x1e00,0x3c0001e,0x3f0,0x7,0x83fffffc,0x1e0,0x7c000f00,0xf0001e,0x3c000,0x3e0000,
4157 0x0,0x1ffc,0x1fffff,0xf0007ff0,0x3c000,0x781e0070,0x7ffffc03,0xc000781e,0x1e0,0x7803c0,0x1e00,0x3c000,0x781e0007,0x80007800,
4158 0x780,0x3c03e000,0x7800001e,0xf078,0x79e03c0,0x780780,0xf000,0x1e078007,0x8000000f,0xf000,0xf0003c0,0x3c3c001,0xee0ef000,
4159 0xf87c0000,0x7800001f,0x3c,0x78,0x1e0,0x0,0x0,0x0,0x7c003c01,0xe000780f,0x1e0,0x780f00,0x3c,0x3c000,0xf0078007,0x80003c00,
4160 0xf000,0x7e3e000,0x1e0000f,0x3c0f01e,0x1e03c0,0xf00780,0x1e0f000,0x3c003c00,0x1ffc,0x3c000,0x3c003c0,0x781e003,0xe3b8f800,
4161 0x1fc00007,0x83c00007,0xc00000fc,0xf0,0x3e0,0x8001f8,0x0,0x7800000,0xffc7fe00,0x0,0x1e000000,0x0,0x18,0xc0,0x0,0x0,0x1e0,
4162 0xf000003,0xc00f000f,0xfc7fe001,0xf00003ff,0x1ff81ff8,0xffc00000,0x0,0x0,0x0,0x1ff000,0x0,0x0,0x0,0x3,0xff800000,0x1e0f0078,
4163 0xffc7f,0xe0007c00,0x1e000,0x0,0x780001,0xe0180000,0xf000000e,0x1c00007,0x80000000,0x1f81,0xe0000000,0x38e0003,0x80000000,
4164 0xf81f000,0x1e00,0x7ff801c3,0x80e1c000,0x0,0x78,0x0,0x0,0x0,0x3c003c0,0xe1c00,0x0,0x0,0x0,0xf8,0x1f070007,0xc03803ff,0xc1c001f0,
4165 0xf80000,0xfffff00,0x7ffff803,0xffffc01f,0xfffe00ff,0xfff007ff,0xffc07fff,0x8001e000,0x78000,0x3c0000,0x1e00000,0xf000000,
4166 0xf00000,0x7800000,0x3c000001,0xe0001e00,0x780f00f,0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0,0x78000f00,0xf9f001e,0xf003c0f0,
4167 0x3c0780,0x1e03c00,0xf01e000,0x78000780,0x1ffffc,0xf003f8,0xf800780,0x7c003c03,0xe001e01f,0xf00f8,0x7807c0,0x3c0fc1e,0xf000,
4168 0x1e0000,0xf00000,0x7800000,0x3c000000,0x780000,0x3c00000,0x1e000000,0xf0001e00,0x7803c00,0x3c078001,0xe03c000f,0x1e00078,
4169 0xf0003c0,0x78001e00,0x1e,0x1e07803c,0x3c01e0,0x1e00f00,0xf007800,0x7800783c,0x1e0007,0x801e0f00,0x0,0x0,0x0,0x0,0x0,0x0,
4170 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1ff,0xffff8000,0x303c0001,
4171 0xc071e007,0xcf000000,0x3c00,0x1e00,0x0,0x1e0000,0x0,0x0,0xf,0xf00,0x780001e,0x7e0,0x7,0x83fffffc,0x1e0,0x7c000f00,0x1f0001e,
4172 0x3c000,0x3c0000,0x0,0x3ff,0x801fffff,0xf003ff80,0x3c000,0x781e0070,0x7ffffc03,0xc000781e,0x1e0,0x7803c0,0x1e00,0x1e000,0x781e0007,
4173 0x80007800,0x780,0x3c01f000,0x7800001e,0xf078,0x79e03c0,0xf00780,0xf000,0x3e078007,0xc000000f,0xf000,0xf0003c0,0x3c3c001,
4174 0xee0ef000,0xf03e0000,0x7800003e,0x3c,0x78,0x1e0,0x0,0x0,0x0,0xf8003c01,0xe000780f,0x1e0,0x780f00,0x3c,0x3c000,0xf0078007,
4175 0x80003c00,0xf000,0x7c3e000,0x1e0000f,0x3c0f01e,0x1e03c0,0xf00780,0x1e0f000,0x3c003c00,0xfc,0x3c000,0x3c003c0,0x3c3e001,0xe7b8f000,
4176 0x3fe00007,0xc7c0000f,0xc000003e,0xf0,0x7c0,0x0,0x0,0x7c00000,0x7fcffc00,0x0,0x1e000000,0x0,0x18,0xc0,0x0,0x0,0x1e0,0x1e000003,
4177 0xc00f0007,0xfcffc003,0xe00001ff,0x3ff00ff9,0xff800000,0x0,0x0,0x0,0x1ff000,0x0,0x0,0x0,0x0,0x1f800000,0xf0f0078,0x7fcff,
4178 0xc000fc00,0x1e000,0x0,0x780001,0xe0180000,0xf000000f,0x87c00007,0x80000000,0xfe3,0xe0000000,0x18780c3,0x0,0x7c0f800,0x1e00,
4179 0xc3,0x80e18000,0x0,0x78,0x0,0x0,0x0,0x3c003c0,0xe1c00,0x0,0x0,0x0,0x1f0,0x3e00000f,0xc0000303,0xe00003f0,0xf00000,0xfffff80,
4180 0x7ffffc03,0xffffe01f,0xffff00ff,0xfff807ff,0xffc07fff,0x8001e000,0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,
4181 0x3c000001,0xe0001e00,0x780f00f,0x3c078001,0xe03c000f,0x1e00078,0xf0003c0,0x78001e00,0x1f0f801f,0xe00780f0,0x3c0780,0x1e03c00,
4182 0xf01e000,0x78000780,0x1ffff8,0xf000f8,0x1f000780,0xf8003c07,0xc001e03e,0xf01f0,0x780f80,0x3c1f01e,0xf000,0x1e0000,0xf00000,
4183 0x7800000,0x3c000000,0x780000,0x3c00000,0x1e000000,0xf0001e00,0x7803c00,0x3c078001,0xe03c000f,0x1e00078,0xf0003c0,0x78001e00,
4184 0x1e,0x3c07803c,0x3c01e0,0x1e00f00,0xf007800,0x78007c7c,0x1e0007,0x801f1f00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4185 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x81c00000,0x303c0003,0x8039e003,0xef000000,
4186 0x3c00,0x1e00,0x0,0x1e0000,0x0,0x0,0x1e,0xf00,0x780001e,0xfc0,0x7,0x83fffffc,0x1e0,0x3c000f00,0x1e0001e,0x3c000,0x3c0000,
4187 0x0,0x7f,0xe01fffff,0xf00ffc00,0x3c000,0x781f00f0,0x7ffffc03,0xc000781e,0x1e0,0x7803c0,0x1e00,0x1e000,0x781e0007,0x80007800,
4188 0x780,0x3c01f000,0x7800001e,0xf078,0x7de01e0,0xf00780,0x7800,0x3c078003,0xc000000f,0xf000,0xf0003c0,0x3e7c001,0xee0ef001,
4189 0xf01e0000,0x7800003e,0x3c,0x3c,0x1e0,0x0,0x0,0x0,0xf0003c01,0xe000780f,0x1e0,0x780f00,0x3c,0x3c000,0xf0078007,0x80003c00,
4190 0xf000,0x781f000,0x1e0000f,0x3c0f01e,0x1e03c0,0xf00780,0x1e0f000,0x3c003c00,0x3e,0x3c000,0x3c003c0,0x3c3c001,0xe71cf000,0x7df00003,
4191 0xc780000f,0x8000003e,0xf0,0x780,0x0,0x0,0x3c00000,0x3fcff800,0x0,0x1e000000,0x0,0x18,0xc0,0x0,0x1f00fc,0x1e0,0x1e000001,
4192 0xe00f0003,0xfcff8003,0xe00000ff,0x3fe007f9,0xff000000,0x0,0x0,0x0,0x1ff000,0x0,0x0,0x0,0x0,0x7c00000,0xf0f0078,0x3fcff,0x8000f800,
4193 0x1e000,0x0,0x780001,0xe0180000,0xf000001f,0xffe00007,0x8000003c,0x7ff,0xc0000000,0x1c3ffc7,0x0,0x3e07c00,0x1e00,0xe3,0x80738000,
4194 0x0,0x78,0x0,0x0,0x0,0x3c003c0,0xe1c00,0x0,0x0,0x0,0x3e0,0x7c00001d,0xc0000001,0xe0000770,0x1f00000,0xfffff80,0x7ffffc03,
4195 0xffffe01f,0xffff00ff,0xfff807ff,0xffc07fff,0x8001e000,0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,
4196 0xe0001e00,0x780f00f,0x3c03c001,0xe01e000f,0xf00078,0x78003c0,0x3c001e00,0x3e07c01f,0xc00780f0,0x3c0780,0x1e03c00,0xf01e000,
4197 0x78000780,0x1fffc0,0xf0007c,0x1e000780,0xf0003c07,0x8001e03c,0xf01e0,0x780f00,0x3c1e01e,0xf000,0x1e0000,0xf00000,0x7800000,
4198 0x3c000000,0x780000,0x3c00000,0x1e000000,0xf0001e00,0x7803c00,0x3c078001,0xe03c000f,0x1e00078,0xf0003c0,0x78001e00,0x1e,0x7807803c,
4199 0x3c01e0,0x1e00f00,0xf007800,0x78003c78,0x1e0007,0x800f1e00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4200 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x83c00000,0x303c0003,0x8039e001,0xee000000,0x1e00,0x3c00,
4201 0x0,0x1e0000,0x0,0x0,0x1e,0xf00,0x780001e,0x1f80,0x7,0x83fffffc,0x1e0,0x3c000f00,0x1e0001e,0x3c000,0x3c0000,0x0,0x1f,0xfc1fffff,
4202 0xf07ff000,0x0,0x780f00f0,0x78003c03,0xc000781e,0x1e0,0xf803c0,0x1e00,0x1e000,0x781e0007,0x80007800,0x780,0x3c00f800,0x7800001e,
4203 0xf078,0x3de01e0,0xf00780,0x7800,0x3c078003,0xe000000f,0xf000,0xf0003c0,0x1e78001,0xfe0ff003,0xe01f0000,0x7800007c,0x3c,0x3c,
4204 0x1e0,0x0,0x0,0x0,0xf0007c01,0xe000f80f,0x800001e0,0xf80f00,0x3c,0x1e001,0xf0078007,0x80003c00,0xf000,0x780f800,0x1e0000f,
4205 0x3c0f01e,0x1e03c0,0x1f00780,0x3e0f000,0x7c003c00,0x1e,0x3c000,0x3c003c0,0x3c3c001,0xe71cf000,0xf8f80003,0xe780001f,0x1e,
4206 0xf0,0x780,0x0,0x0,0x3c00000,0x1ffff000,0x0,0x1e000000,0x0,0x18,0xc0,0x0,0x3bc1de,0x1e0,0xf000001,0xe00f0001,0xffff0007,0xc000007f,
4207 0xffc003ff,0xfe000000,0x0,0x0,0x0,0xfe000,0x0,0x0,0x0,0x0,0x3c00000,0x1e0f0078,0x1ffff,0x1f000,0x1e000,0x0,0x780000,0xf0180000,
4208 0xf000001f,0xfff00007,0x8000003c,0x1ff,0x80000000,0xe0ff0e,0x0,0x1f03e00,0x1e00,0x70,0x70000,0x0,0x78,0x0,0x0,0x0,0x3c003c0,
4209 0xe1c00,0x0,0x0,0x0,0x7c0,0xf8000019,0xc0000000,0xe0000670,0x1e00000,0xf000780,0x78003c03,0xc001e01e,0xf00f0,0x780780,0x3c0f807,
4210 0x8001e000,0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0xf80f007,0xbc03c001,0xe01e000f,
4211 0xf00078,0x78003c0,0x3c001e00,0x7c03e00f,0x800780f0,0x3c0780,0x1e03c00,0xf01e000,0x78000780,0x1e0000,0xf0003c,0x1e000f80,
4212 0xf0007c07,0x8003e03c,0x1f01e0,0xf80f00,0x7c1e01e,0xf800,0x1e0000,0xf00000,0x7800000,0x3c000000,0x780000,0x3c00000,0x1e000000,
4213 0xf0001e00,0x7803c00,0x3c078003,0xe03c001f,0x1e000f8,0xf0007c0,0x78003e00,0x1f8001f,0xf00f803c,0x3c01e0,0x1e00f00,0xf007800,
4214 0x78003e78,0x1e000f,0x800f9e00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4215 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf,0x3c00000,0x303c0003,0x8039f001,0xfe000000,0x1e00,0x3c00,0x0,0x1e0000,0x0,0x0,0x3c,0xf00,
4216 0x780001e,0x3f00,0x7,0x80000780,0x3e0,0x3e000f00,0x3c0001e,0x3c000,0x7c0000,0x0,0x3,0xfe000000,0xff8000,0x0,0x3c0f81f0,0xf0001e03,
4217 0xc000780f,0x1e0,0xf003c0,0x1e00,0xf000,0x781e0007,0x80007800,0x780,0x3c007c00,0x7800001e,0xf078,0x3de01e0,0xf00780,0x7800,
4218 0x3c078001,0xe000000f,0xf000,0xf0003c0,0x1e78001,0xfc07f003,0xe00f0000,0x78000078,0x3c,0x1e,0x1e0,0x0,0x0,0x0,0xf0007c01,
4219 0xf000f007,0x800000f0,0xf80780,0x3c,0x1e001,0xf0078007,0x80003c00,0xf000,0x7807c00,0x1e0000f,0x3c0f01e,0x1e01e0,0x1e007c0,
4220 0x3c07800,0x7c003c00,0x1e,0x3c000,0x3c007c0,0x1e78001,0xe71df000,0xf8f80001,0xef80003e,0x1e,0xf0,0x780,0x0,0x0,0x3c00000,
4221 0xfffe000,0x0,0x3e000000,0x0,0x18,0x7fff,0xc0000000,0x60c306,0x1e0,0x7800001,0xe00f0000,0xfffe0007,0x8000003f,0xff8001ff,
4222 0xfc000000,0x0,0x0,0x0,0x7c000,0x0,0x0,0x0,0x0,0x3c00000,0x3c0f0078,0xfffe,0x3e000,0x1e000,0x0,0x780000,0xf0180000,0xf000003c,
4223 0xfcf80007,0x8000003c,0x7f,0x0,0x70001c,0x0,0xf81f00,0x0,0x38,0xe0000,0x0,0x0,0x0,0x0,0x0,0x3c003c0,0xe1c00,0x0,0x0,0x0,0xf81,
4224 0xf0000039,0xc0000000,0xe0000e70,0x1e00000,0x1e0003c0,0xf0001e07,0x8000f03c,0x781e0,0x3c0f00,0x1e0f007,0x8000f000,0x78000,
4225 0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0xf00f007,0xbc03c001,0xe01e000f,0xf00078,0x78003c0,
4226 0x3c001e00,0xf801f00f,0x800780f0,0x3c0780,0x1e03c00,0xf01e000,0x78000780,0x1e0000,0xf0003c,0x1e000f80,0xf0007c07,0x8003e03c,
4227 0x1f01e0,0xf80f00,0x7c1e01e,0x7800,0xf0000,0x780000,0x3c00000,0x1e000000,0x780000,0x3c00000,0x1e000000,0xf0000f00,0xf003c00,
4228 0x3c03c003,0xc01e001e,0xf000f0,0x7800780,0x3c003c00,0x1f8000f,0xe00f003c,0x7c01e0,0x3e00f00,0x1f007800,0xf8001ef8,0x1f000f,
4229 0x7be00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4230 0x0,0x0,0xf,0x3c00000,0x307c0003,0x8038f000,0xfc000000,0x1e00,0x3c00,0x0,0x1e0000,0xfc0000,0x0,0x7e00003c,0x780,0xf00001e,
4231 0x7e00,0xf,0x80000780,0x3c0,0x3e001e00,0x3c0001f,0x7c000,0x780007,0xe000003f,0x0,0xfe000000,0xfe0000,0x0,0x3c07c3f0,0xf0001e03,
4232 0xc000f80f,0x800001e0,0x1f003c0,0x1e00,0xf000,0x781e0007,0x80007800,0x4000f80,0x3c003c00,0x7800001e,0xf078,0x1fe01f0,0x1f00780,
4233 0x7c00,0x7c078001,0xf000001f,0xf000,0xf0003c0,0x1e78001,0xfc07f007,0xc00f8000,0x780000f8,0x3c,0x1e,0x1e0,0x0,0x0,0x0,0xf0007c01,
4234 0xf000f007,0xc00000f0,0xf80780,0x3c,0x1f003,0xf0078007,0x80003c00,0xf000,0x7807c00,0x1e0000f,0x3c0f01e,0x1e01e0,0x1e007c0,
4235 0x3c07800,0x7c003c00,0x1e,0x3c000,0x3c007c0,0x1e78000,0xfe0fe001,0xf07c0001,0xef00007c,0x1e,0xf0,0x780,0x0,0x0,0x1e00000,
4236 0x7cfc000,0xfc00000,0x3c00000f,0xc3f00000,0x18,0x7fff,0xc0000000,0x406303,0x3e0,0x3c00001,0xf00f0000,0x7cfc000f,0x8000001f,
4237 0x3f0000f9,0xf8000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00000,0x780700f8,0x7cfc,0x7c000,0x1e000,0x0,0x780000,0xf8180000,
4238 0xf0000070,0x3c0007,0x8000003c,0x3f,0x80000000,0x3c0078,0x0,0x780f00,0x0,0x1e,0x3c0000,0x0,0x0,0x0,0x0,0x0,0x3e007c0,0xe1c00,
4239 0x0,0x0,0x0,0xf01,0xe0000071,0xc0000000,0xe0001c70,0x1e00000,0x1e0003c0,0xf0001e07,0x8000f03c,0x781e0,0x3c0f00,0x1e0f007,
4240 0x8000f800,0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0x1f00f003,0xfc03e003,0xe01f001f,
4241 0xf800f8,0x7c007c0,0x3e003e01,0xf000f80f,0xf00f0,0x3c0780,0x1e03c00,0xf01e000,0x78000780,0x1e0000,0xf0003c,0x1e000f80,0xf0007c07,
4242 0x8003e03c,0x1f01e0,0xf80f00,0x7c1e01e,0x7c00,0xf0000,0x780000,0x3c00000,0x1e000000,0x780000,0x3c00000,0x1e000000,0xf0000f00,
4243 0xf003c00,0x3c03c003,0xc01e001e,0xf000f0,0x7800780,0x3c003c00,0x1f8000f,0xc00f003c,0x7c01e0,0x3e00f00,0x1f007800,0xf8001ef0,
4244 0x1f000f,0x7bc00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4245 0x0,0x0,0x0,0x0,0x780000,0xf,0x3800040,0x30780003,0x8038f800,0x78000000,0x1e00,0x3c00,0x0,0x1e0000,0xfc0000,0x0,0x7e000078,
4246 0x780,0x1f00001e,0xfc00,0x20001f,0x780,0x80007c0,0x1f001e00,0x7c0000f,0x78000,0xf80007,0xe000003f,0x0,0x1e000000,0xf00000,
4247 0x3c000,0x3c03fff0,0xf0001e03,0xc001f007,0x800101e0,0x7e003c0,0x1e00,0x7800,0x781e0007,0x80007800,0x6000f00,0x3c003e00,0x7800001e,
4248 0xf078,0x1fe00f0,0x1e00780,0x3c00,0x78078000,0xf020001e,0xf000,0x7800780,0xff0001,0xfc07f00f,0x8007c000,0x780001f0,0x3c,0xf,
4249 0x1e0,0x0,0x0,0x0,0xf800fc01,0xf801f007,0xc00100f8,0x1f807c0,0x40003c,0xf807,0xf0078007,0x80003c00,0xf000,0x7803e00,0x1f0000f,
4250 0x3c0f01e,0x1e01f0,0x3e007e0,0x7c07c00,0xfc003c00,0x1e,0x3e000,0x3e007c0,0x1ff8000,0xfe0fe003,0xe03e0001,0xff0000fc,0x1e,
4251 0xf0,0x780,0x0,0x0,0x1f00080,0x3cf8000,0xfc00000,0x3c00001f,0x83f00000,0x18,0xc0,0x0,0xc06203,0x40003c0,0x1c00000,0xf80f0000,
4252 0x3cf8001f,0xf,0x3e000079,0xf0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00000,0x700780fc,0x3cf8,0xfc000,0x1e000,0x0,0x780000,
4253 0x7c180000,0xf0000020,0x100007,0x8000003c,0xf,0x80000000,0x1f01f0,0x0,0x380700,0x0,0xf,0x80f80000,0x0,0x0,0x0,0x0,0x0,0x3e007c0,
4254 0xe1c00,0x0,0x0,0x0,0xe01,0xc0000071,0xc0000001,0xc0001c70,0x1e00040,0x1e0003c0,0xf0001e07,0x8000f03c,0x781e0,0x3c0f00,0x1e0f007,
4255 0x80007800,0x10078000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0x7e00f003,0xfc01e003,0xc00f001e,
4256 0x7800f0,0x3c00780,0x1e003c00,0xe000700f,0x800f0078,0x7803c0,0x3c01e00,0x1e00f000,0xf0000780,0x1e0000,0xf0003c,0x1f001f80,
4257 0xf800fc07,0xc007e03e,0x3f01f0,0x1f80f80,0xfc1e01f,0x7c00,0x100f8000,0x807c0004,0x3e00020,0x1f000100,0x780000,0x3c00000,0x1e000000,
4258 0xf0000f80,0x1f003c00,0x3c03e007,0xc01f003e,0xf801f0,0x7c00f80,0x3e007c00,0x1f8000f,0x801f003e,0x7c01f0,0x3e00f80,0x1f007c00,
4259 0xf8001ff0,0x1f801f,0x7fc00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4260 0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0xf,0x7800078,0x31f80001,0xc070fc00,0xfc000000,0x1e00,0x7c00,0x0,0x1e0000,0xfc0000,0x0,0x7e000078,
4261 0x7c0,0x1f00001e,0x1f000,0x38003f,0x780,0xe000f80,0x1f803e00,0x780000f,0x800f8000,0x1f00007,0xe000003f,0x0,0x2000000,0x800000,
4262 0x3c000,0x3e01ff71,0xf0001f03,0xc007f007,0xc00301e0,0x1fc003c0,0x1e00,0x7c00,0x781e0007,0x80007800,0x7801f00,0x3c001f00,0x7800001e,
4263 0xf078,0xfe00f8,0x3e00780,0x3e00,0xf8078000,0xf838003e,0xf000,0x7c00f80,0xff0000,0xfc07e00f,0x8003c000,0x780001e0,0x3c,0xf,
4264 0x1e0,0x0,0x0,0x0,0xf801fc01,0xfc03e003,0xe003007c,0x3f803e0,0x1c0003c,0xfc0f,0xf0078007,0x80003c00,0xf000,0x7801f00,0xf8000f,
4265 0x3c0f01e,0x1e00f8,0x7c007f0,0xf803e01,0xfc003c00,0x8003e,0x1f000,0x1e00fc0,0xff0000,0xfe0fe007,0xc01f0000,0xfe0000f8,0x1e,
4266 0xf0,0x780,0x0,0x0,0xf80180,0x1cf0000,0x1f800000,0x3c00001f,0x83e00000,0x18,0xc0,0x0,0xc06203,0x70007c0,0xe00000,0x7e0f0000,
4267 0x1cf0001e,0x7,0x3c000039,0xe0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x7c00000,0xe00780fc,0x2001cf0,0xf8000,0x1e000,0x0,
4268 0x780000,0x7e182000,0xf0000000,0x7,0x8000003c,0x7,0xc0000000,0x7ffc0,0x0,0x180300,0x0,0x3,0xffe00000,0x0,0x0,0x0,0x0,0x0,
4269 0x3f00fc0,0xe1c00,0x0,0x0,0x0,0xc01,0x800000e1,0xc0000003,0xc0003870,0x1f001c0,0x3e0003e1,0xf0001f0f,0x8000f87c,0x7c3e0,0x3e1f00,
4270 0x1f1e007,0x80007c00,0x30078000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e03,0xfc00f001,0xfc01f007,
4271 0xc00f803e,0x7c01f0,0x3e00f80,0x1f007c00,0x4000201f,0xc01f007c,0xf803e0,0x7c01f00,0x3e00f801,0xf0000780,0x1e0000,0xf0007c,
4272 0x1f003f80,0xf801fc07,0xc00fe03e,0x7f01f0,0x3f80f80,0x1fc1f03f,0x803e00,0x3007c003,0x803e001c,0x1f000e0,0xf800700,0x780000,
4273 0x3c00000,0x1e000000,0xf00007c0,0x3e003c00,0x3c01f00f,0x800f807c,0x7c03e0,0x3e01f00,0x1f00f800,0x1f80007,0xc03e001e,0xfc00f0,
4274 0x7e00780,0x3f003c01,0xf8000fe0,0x1fc03e,0x3f800,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4275 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x1e,0x780007f,0xfff00001,0xe0f07f03,0xfe000000,0xf00,0x7800,0x0,
4276 0x1e0000,0xfc0000,0x0,0x7e0000f0,0x3f0,0x7e000fff,0xfc03ffff,0xf83f00fe,0x780,0xfc03f80,0xfc0fc00,0xf800007,0xe03f0018,0x7e00007,
4277 0xe000003f,0x0,0x0,0x0,0x3c000,0x1e007c71,0xe0000f03,0xffffe003,0xf01f01ff,0xff8003ff,0xffe01e00,0x3f01,0xf81e0007,0x803ffff0,
4278 0x7e03f00,0x3c000f00,0x7ffffe1e,0xf078,0xfe007e,0xfc00780,0x1f83,0xf0078000,0x783f00fe,0xf000,0x3f03f00,0xff0000,0xfc07e01f,
4279 0x3e000,0x780003ff,0xfffc003c,0x7,0x800001e0,0x0,0x0,0x0,0x7e07fc01,0xfe07e001,0xf80f007e,0x7f801f8,0xfc0003c,0x7ffe,0xf0078007,
4280 0x807ffffe,0xf000,0x7801f00,0xfff00f,0x3c0f01e,0x1e00fc,0xfc007f8,0x1f803f03,0xfc003c00,0xf80fc,0x1fff0,0x1f83fc0,0xff0000,
4281 0xfc07e007,0xc01f0000,0xfe0001ff,0xffe0001e,0xf0,0x780,0x0,0x0,0xfe0780,0xfe0000,0x1f000000,0x3c00001f,0x7c00e03,0x81c00018,
4282 0xc0,0x0,0x406203,0x7e01fc0,0x700000,0x7fffff80,0xfe0003f,0xffffc003,0xf800001f,0xc0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1f0,
4283 0x1f800001,0xc007c1fe,0x6000fe0,0x1ffffe,0x1e000,0x0,0x780000,0x3f98e03f,0xffff8000,0x7,0x8000003c,0x7,0xc0000000,0xfe00,
4284 0x0,0x80100,0x0,0x0,0x7f000000,0x0,0x1ffff,0xfe000000,0x0,0x0,0x3f83fe8,0xe1c00,0x0,0x0,0x0,0x801,0xc1,0xc0000007,0x80003070,
4285 0xfc0fc0,0x3c0001e1,0xe0000f0f,0x7878,0x3c3c0,0x1e1e00,0xf1e007,0xffc03f01,0xf007ffff,0xc03ffffe,0x1fffff0,0xfffff80,0x7fffe003,
4286 0xffff001f,0xfff800ff,0xffc01fff,0xf800f001,0xfc00fc1f,0x8007e0fc,0x3f07e0,0x1f83f00,0xfc1f800,0x1f,0xf07e003f,0x3f001f8,
4287 0x1f800fc0,0xfc007e07,0xe0000780,0x1e0000,0xf301f8,0xfc0ff80,0x7e07fc03,0xf03fe01f,0x81ff00fc,0xff807e0,0x7fc0f87f,0x81801f80,
4288 0xf003f01f,0x801f80fc,0xfc07e0,0x7e03f00,0xfffffc07,0xffffe03f,0xffff01ff,0xfff807e0,0x7e003c00,0x3c01f81f,0x800fc0fc,0x7e07e0,
4289 0x3f03f00,0x1f81f800,0x1f8000f,0xe07e001f,0x83fc00fc,0x1fe007e0,0xff003f07,0xf8000fe0,0x1fe07e,0x3f800,0x0,0x0,0x0,0x0,0x0,
4290 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x1e,0x780007f,
4291 0xffe00000,0xffe03fff,0xdf000000,0xf00,0x7800,0x0,0x0,0xfc0000,0x0,0x7e0000f0,0x1ff,0xfc000fff,0xfc03ffff,0xf83ffffc,0x780,
4292 0xfffff00,0x7fff800,0xf000007,0xffff001f,0xffe00007,0xe000003f,0x0,0x0,0x0,0x3c000,0x1e000001,0xe0000f03,0xffffc001,0xffff01ff,
4293 0xff0003ff,0xffe01e00,0x1fff,0xf81e0007,0x803ffff0,0x7fffe00,0x3c000f80,0x7ffffe1e,0xf078,0xfe003f,0xff800780,0xfff,0xf0078000,
4294 0x7c3ffffc,0xf000,0x3ffff00,0xff0000,0xf803e01e,0x1e000,0x780003ff,0xfffc003c,0x7,0x800001e0,0x0,0x0,0x0,0x7fffbc01,0xffffc000,
4295 0xffff003f,0xfff800ff,0xffc0003c,0x3ffe,0xf0078007,0x807ffffe,0xf000,0x7800f80,0x7ff00f,0x3c0f01e,0x1e007f,0xff8007ff,0xff001fff,
4296 0xbc003c00,0xffffc,0x1fff0,0x1fffbc0,0xff0000,0x7c07c00f,0x800f8000,0x7e0001ff,0xffe0001e,0xf0,0x780,0x0,0x0,0x7fff80,0x7c0000,
4297 0x1f000000,0x3c00001e,0x7c00f07,0xc1e00018,0xc0,0x0,0x60e303,0x7ffff80,0x380000,0x3fffff80,0x7c0003f,0xffffc001,0xf000000f,
4298 0x80000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1ff,0xff800003,0x8003ffff,0xfe0007c0,0x1ffffe,0x1e000,0x0,0x780000,0x1fffe03f,0xffff8000,
4299 0x7,0x8000003c,0x3,0xc0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1ffff,0xfe000000,0x0,0x0,0x3fffdf8,0xe1c00,0x0,0x0,0x0,0x0,0x1c1,
4300 0xc000000f,0x7070,0x7fffc0,0x3c0001e1,0xe0000f0f,0x7878,0x3c3c0,0x1e1e00,0xf1e007,0xffc01fff,0xf007ffff,0xc03ffffe,0x1fffff0,
4301 0xfffff80,0x7fffe003,0xffff001f,0xfff800ff,0xffc01fff,0xf000f001,0xfc007fff,0x3fff8,0x1fffc0,0xfffe00,0x7fff000,0x3b,0xfffc003f,
4302 0xfff001ff,0xff800fff,0xfc007fff,0xe0000780,0x1e0000,0xf3fff8,0xffff780,0x7fffbc03,0xfffde01f,0xffef00ff,0xff7807ff,0xfbc0ffff,
4303 0xff800fff,0xf001ffff,0x800ffffc,0x7fffe0,0x3ffff00,0xfffffc07,0xffffe03f,0xffff01ff,0xfff803ff,0xfc003c00,0x3c00ffff,0x7fff8,
4304 0x3fffc0,0x1fffe00,0xffff000,0x1f,0xfffc001f,0xffbc00ff,0xfde007ff,0xef003fff,0x780007e0,0x1ffffc,0x1f800,0x0,0x0,0x0,0x0,
4305 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x1e,0x700003f,
4306 0xffc00000,0x7fc01fff,0x9f800000,0xf80,0xf800,0x0,0x0,0xfc0000,0x0,0x7e0000f0,0xff,0xf8000fff,0xfc03ffff,0xf83ffff8,0x780,
4307 0xffffe00,0x7fff000,0xf000003,0xfffe001f,0xffc00007,0xe000003f,0x0,0x0,0x0,0x3c000,0xf000003,0xe0000f83,0xffff0000,0xffff01ff,
4308 0xfc0003ff,0xffe01e00,0xfff,0xf01e0007,0x803ffff0,0x7fffc00,0x3c0007c0,0x7ffffe1e,0xf078,0x7e003f,0xff000780,0x7ff,0xe0078000,
4309 0x3c3ffff8,0xf000,0x1fffe00,0x7e0000,0xf803e03e,0x1f000,0x780003ff,0xfffc003c,0x7,0x800001e0,0x0,0x0,0x0,0x3fff3c01,0xefff8000,
4310 0x7ffe001f,0xff78007f,0xff80003c,0x1ffc,0xf0078007,0x807ffffe,0xf000,0x78007c0,0x3ff00f,0x3c0f01e,0x1e003f,0xff0007bf,0xfe000fff,
4311 0xbc003c00,0xffff8,0xfff0,0xfff3c0,0x7e0000,0x7c07c01f,0x7c000,0x7c0001ff,0xffe0001e,0xf0,0x780,0x0,0x0,0x3fff80,0x380000,
4312 0x3e000000,0x7c00003e,0x7801f07,0xc1e00018,0xc0,0x0,0x39c1ce,0x7ffff00,0x1c0000,0xfffff80,0x380003f,0xffffc000,0xe0000007,
4313 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1ff,0xff000007,0x1ffcf,0xfe000380,0x1ffffe,0x1e000,0x0,0x780000,0xfffe03f,0xffff8000,0x7,
4314 0x8000003c,0x3,0xc0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1ffff,0xfe000000,0x0,0x0,0x3dffdf8,0xe1c00,0x0,0x0,0x0,0x0,0x381,
4315 0xc000001e,0xe070,0x7fff80,0x7c0001f3,0xe0000f9f,0x7cf8,0x3e7c0,0x1f3e00,0xfbe007,0xffc00fff,0xf007ffff,0xc03ffffe,0x1fffff0,
4316 0xfffff80,0x7fffe003,0xffff001f,0xfff800ff,0xffc01fff,0xc000f000,0xfc007ffe,0x3fff0,0x1fff80,0xfffc00,0x7ffe000,0x79,0xfff8001f,
4317 0xffe000ff,0xff0007ff,0xf8003fff,0xc0000780,0x1e0000,0xf3fff0,0x7ffe780,0x3fff3c01,0xfff9e00f,0xffcf007f,0xfe7803ff,0xf3c07ff3,
4318 0xff8007ff,0xe000ffff,0x7fff8,0x3fffc0,0x1fffe00,0xfffffc07,0xffffe03f,0xffff01ff,0xfff801ff,0xf8003c00,0x3c007ffe,0x3fff0,
4319 0x1fff80,0xfffc00,0x7ffe000,0x1d,0xfff8000f,0xff3c007f,0xf9e003ff,0xcf001ffe,0x780007c0,0x1efff8,0x1f000,0x0,0x0,0x0,0x0,
4320 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x1e,0xf000003,
4321 0xfe000000,0x1f000fff,0xfc00000,0x780,0xf000,0x0,0x0,0xf80000,0x0,0x7e0001e0,0x7f,0xf0000fff,0xfc03ffff,0xf81ffff0,0x780,
4322 0x7fff800,0x1ffe000,0x1f000000,0xfff8001f,0xff000007,0xe000003e,0x0,0x0,0x0,0x3c000,0xf800003,0xc0000783,0xfff80000,0x3ffe01ff,
4323 0xe00003ff,0xffe01e00,0x7ff,0xc01e0007,0x803ffff0,0x3fff800,0x3c0003c0,0x7ffffe1e,0xf078,0x7e000f,0xfe000780,0x3ff,0xc0078000,
4324 0x3e1fffe0,0xf000,0x7ff800,0x7e0000,0xf803e07c,0xf800,0x780003ff,0xfffc003c,0x3,0xc00001e0,0x0,0x0,0x0,0xffe3c01,0xe7ff0000,
4325 0x3ffc000f,0xfe78003f,0xfe00003c,0x7f0,0xf0078007,0x807ffffe,0xf000,0x78003e0,0xff00f,0x3c0f01e,0x1e001f,0xfe00079f,0xfc0007ff,
4326 0x3c003c00,0x7ffe0,0x1ff0,0x7fe3c0,0x7e0000,0x7c07c03e,0x3e000,0x7c0001ff,0xffe0001e,0xf0,0x780,0x0,0x0,0xfff00,0x100000,
4327 0x3e000000,0x7800003c,0xf800f07,0xc1e00018,0xc0,0x0,0x1f80fc,0x3fffc00,0xc0000,0x3ffff80,0x100003f,0xffffc000,0x40000002,
4328 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xfc000006,0xff87,0xfc000100,0x1ffffe,0x1e000,0x0,0x780000,0x3ffc03f,0xffff8000,0x7,
4329 0x8000003c,0x3,0xc0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1ffff,0xfe000000,0x0,0x0,0x3dff9f8,0xe1c00,0x0,0x0,0x0,0x0,0x3ff,
4330 0xf800003c,0xfffe,0x1ffe00,0x780000f3,0xc000079e,0x3cf0,0x1e780,0xf3c00,0x7bc007,0xffc003ff,0xe007ffff,0xc03ffffe,0x1fffff0,
4331 0xfffff80,0x7fffe003,0xffff001f,0xfff800ff,0xffc01ffc,0xf000,0xfc001ffc,0xffe0,0x7ff00,0x3ff800,0x1ffc000,0x70,0xfff00007,
4332 0xff80003f,0xfc0001ff,0xe0000fff,0x780,0x1e0000,0xf3ffe0,0x1ffc780,0xffe3c00,0x7ff1e003,0xff8f001f,0xfc7800ff,0xe3c03fe1,
4333 0xff0003ff,0xc0007ffc,0x3ffe0,0x1fff00,0xfff800,0xfffffc07,0xffffe03f,0xffff01ff,0xfff800ff,0xf0003c00,0x3c003ffc,0x1ffe0,
4334 0xfff00,0x7ff800,0x3ffc000,0x38,0xfff00007,0xfe3c003f,0xf1e001ff,0x8f000ffc,0x780007c0,0x1e7ff0,0x1f000,0x0,0x0,0x0,0x0,0x0,
4335 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x30000000,
4336 0x1fc,0x0,0x780,0xf000,0x0,0x0,0x1f80000,0x0,0x1e0,0x1f,0xc0000000,0x0,0x1ff80,0x0,0xffc000,0x7f8000,0x0,0x3fe00007,0xfc000000,
4337 0x7e,0x0,0x0,0x0,0x0,0x7c00000,0x0,0x0,0xff00000,0x0,0x0,0xfe,0x0,0x0,0x3fc000,0x0,0x0,0x0,0x3,0xf8000000,0xff,0xc0000000,
4338 0x1ff00,0x0,0x1fe000,0x0,0x0,0x0,0x0,0x3c,0x3,0xc00001e0,0x0,0x0,0x0,0x3f80000,0x1fc0000,0x7f00003,0xf8000007,0xf0000000,
4339 0x0,0xf0000000,0x0,0xf000,0x0,0x0,0x0,0x7,0xf8000787,0xf00001fc,0x3c000000,0x7f80,0x0,0x1f8000,0x0,0x0,0x0,0x7c000000,0x1e,
4340 0xf0,0x780,0x0,0x0,0x3fc00,0x0,0x3c000000,0x7800003c,0xf000601,0xc00018,0xc0,0x0,0x0,0x3fe000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4341 0x0,0x0,0x0,0x0,0x0,0x0,0xf,0xf0000000,0x7e03,0xf0000000,0x0,0x0,0x0,0x0,0xfe0000,0x0,0x0,0x3c,0x2007,0x80000000,0x0,0x0,
4342 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c7e0f0,0xe1c00,0x0,0x3800000,0x0,0x0,0x3ff,0xf8000078,0xfffe,0x7f800,0x0,0x0,0x0,0x0,
4343 0x0,0x0,0xff,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7f0,0x3f80,0x1fc00,0xfe000,0x7f0000,0x70,0x3fc00001,0xfe00000f,0xf000007f,
4344 0x800003fc,0x0,0x0,0xff00,0x7f0000,0x3f80000,0x1fc00000,0xfe000007,0xf000003f,0x80001f80,0xfc00007f,0xfe0,0x7f00,0x3f800,
4345 0x1fc000,0x0,0x0,0x0,0x3f,0xc0000000,0xff0,0x7f80,0x3fc00,0x1fe000,0xff0000,0x78,0x3fc00001,0xf800000f,0xc000007e,0x3f0,0x7c0,
4346 0x1e1fc0,0x1f000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4347 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x30000000,0x0,0x0,0x3c0,0x1e000,0x0,0x0,0x1f00000,0x0,0x3c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4348 0x0,0x0,0x7c,0x0,0x0,0x0,0x0,0x3e00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0xe0000000,0x0,0x0,0x0,
4349 0x0,0x0,0x0,0x0,0x3c,0x1,0xe00001e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf0000000,0x0,0xf000,0x0,0x0,0x0,0x0,0x780,0x0,0x3c000000,
4350 0x0,0x0,0x0,0x0,0x0,0x0,0x78000000,0x1e,0xf0,0x780,0x0,0x0,0x0,0x0,0x3c000000,0x78000078,0xf000000,0x18,0xc0,0x0,0x0,0x0,
4351 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x180000,0x0,0x0,0x3c,0x3c0f,0x80000000,
4352 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00000,0xe1c00,0x0,0x1800000,0x0,0x0,0x3ff,0xf80000f0,0xfffe,0x0,0x0,0x0,0x0,
4353 0x0,0x0,0x0,0xc,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4354 0x0,0x0,0xc,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x30,0x0,0x0,0x0,0x0,0x780,0x1e0000,0x1e000,0x0,0x0,0x0,
4355 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x30000000,
4356 0x0,0x0,0x3c0,0x1e000,0x0,0x0,0x1f00000,0x0,0x3c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7c,0x0,0x0,0x0,0x0,0x1f80000,
4357 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0xf0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c,0x1,0xe00001e0,0x0,
4358 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0xe0000000,0x0,0xf000,0x0,0x0,0x0,0x0,0x780,0x0,0x3c000000,0x0,0x0,0x0,0x0,0x0,0x0,0xf8000000,
4359 0x1f,0xf0,0xf80,0x0,0x0,0x0,0x0,0x78000000,0xf8000078,0x1e000000,0x8,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4360 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x180000,0x0,0x0,0x3c,0x3fff,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4361 0x0,0x3c00000,0xe1c00,0x0,0x1c00000,0x0,0x0,0x1,0xc00001e0,0x70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4362 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4363 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf80,0x1e0000,0x3e000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4364 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x30000000,0x0,0x0,0x1e0,0x3c000,0x0,0x0,0x1f00000,
4365 0x0,0x780,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7c,0x0,0x0,0x0,0x0,0xfe0100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4366 0x0,0x0,0x0,0x0,0xf8000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3f,0xf0000000,0xf0007fe0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0xe0000000,
4367 0x0,0xf000,0x0,0x0,0x0,0x0,0x780,0x0,0x3c000000,0x0,0x0,0x0,0x0,0x0,0x0,0xf0000000,0x1f,0x800000f0,0x1f80,0x0,0x0,0x0,0x0,
4368 0x78000000,0xf0000070,0x1c000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4369 0x0,0x0,0x0,0x0,0x180000,0x0,0x0,0x3c,0x3ffe,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00000,0xe1c00,0x0,0xe00000,
4370 0x0,0x0,0x1,0xc00003ff,0xe0000070,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4371 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4372 0x0,0x0,0x0,0xf00,0x1e0000,0x3c000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4373 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x30000000,0x0,0x0,0x1e0,0x7c000,0x0,0x0,0x1e00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4374 0x0,0x0,0x0,0x0,0x0,0x78,0x0,0x0,0x0,0x0,0x7fff80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x78000000,
4375 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3f,0xf0000000,0x7fe0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4003,0xe0000000,0x0,0x1f000,0x0,0x0,
4376 0x0,0x0,0x780,0x0,0x3c000000,0x0,0x0,0x0,0x0,0x0,0x1,0xf0000000,0xf,0xfc0000f0,0x3ff00,0x0,0x0,0x0,0x0,0x70000001,0xf00000e0,
4377 0x1c000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x180000,
4378 0x0,0x0,0x3c,0xff8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00000,0xe1c00,0x0,0xe00000,0x0,0x0,0x1,0xc00003ff,
4379 0xe0000070,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4380 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1f00,0x1e0000,
4381 0x7c000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4382 0x0,0x0,0x0,0x0,0x30000000,0x0,0x0,0xf0,0x78000,0x0,0x0,0x3e00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf8,0x0,
4383 0x0,0x0,0x0,0x1fff80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3f,
4384 0xf0000000,0x7fe0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780f,0xc0000000,0x0,0x3e000,0x0,0x0,0x0,0x0,0x780,0x0,0x3c000000,0x0,
4385 0x0,0x0,0x0,0x0,0x3,0xe0000000,0xf,0xfc0000f0,0x3ff00,0x0,0x0,0x0,0x0,0xf0000103,0xe0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4386 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x180000,0x0,0x0,0x3c,0x0,0x0,0x0,0x0,0x0,0x0,
4387 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00000,0x0,0x0,0x21e00000,0x0,0x0,0x1,0xc00003ff,0xe0000070,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10f,
4388 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10f,0x0,
4389 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3e00,0x1e0000,0xf8000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4390 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x30000000,0x0,0x0,
4391 0xf8,0xf8000,0x0,0x0,0x3c00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf0,0x0,0x0,0x0,0x0,0x1fe00,0x0,0x0,0x0,0x0,
4392 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3f,0xf0000000,0x7fe0,0x0,0x0,0x0,0x0,0x0,0x0,
4393 0x0,0x0,0x7fff,0xc0000000,0x0,0x3ffe000,0x0,0x0,0x0,0x0,0x780,0x0,0x3c000000,0x0,0x0,0x0,0x0,0x0,0x7f,0xe0000000,0x7,0xfc0000f0,
4394 0x3fe00,0x0,0x0,0x0,0x0,0x600001ff,0xe0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4395 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x180000,0x0,0x0,0x3c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00000,0x0,0x0,
4396 0x3fe00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1ff,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4397 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1ff,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4398 0x0,0x0,0x0,0x0,0x7fe00,0x1e0000,0x1ff8000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4399 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4400 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4401 0x0,0x0,0x0,0x0,0x1fffffe0,0x0,0x0,0x0,0x0,0x0,0x0,0x7fff,0x80000000,0x0,0x3ffc000,0x0,0x0,0x0,0x0,0x780,0x0,0x3c000000,0x0,
4402 0x0,0x0,0x0,0x0,0x7f,0xc0000000,0x0,0xfc0000f0,0x3f000,0x0,0x0,0x0,0x0,0x1ff,0xc0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4403 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4404 0x0,0x0,0x0,0x0,0x0,0x3c00000,0x0,0x0,0x3fc00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1fe,0x0,0x0,0x0,0x0,0x0,
4405 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1fe,0x0,0x0,0x0,0x0,0x0,0x0,
4406 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7fc00,0x1e0000,0x1ff0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4407 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4408 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4409 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1fffffe0,0x0,0x0,0x0,0x0,0x0,0x0,0x3ffe,0x0,0x0,0x3ff8000,0x0,0x0,0x0,
4410 0x0,0x780,0x0,0x3c000000,0x0,0x0,0x0,0x0,0x0,0x7f,0x80000000,0x0,0xf0,0x0,0x0,0x0,0x0,0x0,0x1ff,0x80000000,0x0,0x0,0x0,0x0,
4411 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4412 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00000,0x0,0x0,0x3f800000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1fc,0x0,
4413 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1fc,0x0,0x0,
4414 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7f800,0x1e0000,0x1fe0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4415 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4416 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4417 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1fffffe0,0x0,0x0,0x0,0x0,0x0,0x0,0x7f8,0x0,0x0,0x3fe0000,
4418 0x0,0x0,0x0,0x0,0x780,0x0,0x3c000000,0x0,0x0,0x0,0x0,0x0,0x7e,0x0,0x0,0xf0,0x0,0x0,0x0,0x0,0x0,0xfe,0x0,0x0,0x0,0x0,0x0,0x0,
4419 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4420 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4421 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4422 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7e000,0x1e0000,0x1f80000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4423 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4424 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4425 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1fffffe0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4426 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4427 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4428 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4429 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4430 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4431 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4432 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4433 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf0,0x0,0x0,0x0,
4434 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4435 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4436 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
4437 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 };
4441 177,200,200,200,3,123,123,0,36,200,200,200,1,123,123,0,2,255,255,0,1,189,189,189,1,0,0,0,34,200,200,200,
4442 1,123,123,0,4,255,255,0,1,189,189,189,1,0,0,0,1,123,123,123,32,200,200,200,1,123,123,0,5,255,255,0,1,0,0,
4443 0,2,123,123,123,30,200,200,200,1,123,123,0,6,255,255,0,1,189,189,189,1,0,0,0,2,123,123,123,29,200,200,200,
4444 1,123,123,0,7,255,255,0,1,0,0,0,2,123,123,123,28,200,200,200,1,123,123,0,8,255,255,0,1,189,189,189,1,0,0,0,
4445 2,123,123,123,27,200,200,200,1,123,123,0,9,255,255,0,1,0,0,0,2,123,123,123,26,200,200,200,1,123,123,0,10,255,
4446 255,0,1,189,189,189,1,0,0,0,2,123,123,123,25,200,200,200,1,123,123,0,3,255,255,0,1,189,189,189,3,0,0,0,1,189,
4447 189,189,3,255,255,0,1,0,0,0,2,123,123,123,24,200,200,200,1,123,123,0,4,255,255,0,5,0,0,0,3,255,255,0,1,189,
4448 189,189,1,0,0,0,2,123,123,123,23,200,200,200,1,123,123,0,4,255,255,0,5,0,0,0,4,255,255,0,1,0,0,0,2,123,123,123,
4449 22,200,200,200,1,123,123,0,5,255,255,0,5,0,0,0,4,255,255,0,1,189,189,189,1,0,0,0,2,123,123,123,21,200,200,200,
4450 1,123,123,0,5,255,255,0,5,0,0,0,5,255,255,0,1,0,0,0,2,123,123,123,20,200,200,200,1,123,123,0,6,255,255,0,5,0,0,
4451 0,5,255,255,0,1,189,189,189,1,0,0,0,2,123,123,123,19,200,200,200,1,123,123,0,6,255,255,0,1,123,123,0,3,0,0,0,1,
4452 123,123,0,6,255,255,0,1,0,0,0,2,123,123,123,18,200,200,200,1,123,123,0,7,255,255,0,1,189,189,189,3,0,0,0,1,189,
4453 189,189,6,255,255,0,1,189,189,189,1,0,0,0,2,123,123,123,17,200,200,200,1,123,123,0,8,255,255,0,3,0,0,0,8,255,255,
4454 0,1,0,0,0,2,123,123,123,16,200,200,200,1,123,123,0,9,255,255,0,1,123,123,0,1,0,0,0,1,123,123,0,8,255,255,0,1,189,
4455 189,189,1,0,0,0,2,123,123,123,15,200,200,200,1,123,123,0,9,255,255,0,1,189,189,189,1,0,0,0,1,189,189,189,9,255,255,
4456 0,1,0,0,0,2,123,123,123,14,200,200,200,1,123,123,0,11,255,255,0,1,0,0,0,10,255,255,0,1,189,189,189,1,0,0,0,2,123,
4457 123,123,13,200,200,200,1,123,123,0,23,255,255,0,1,0,0,0,2,123,123,123,12,200,200,200,1,123,123,0,11,255,255,0,1,189,
4458 189,189,2,0,0,0,1,189,189,189,9,255,255,0,1,189,189,189,1,0,0,0,2,123,123,123,11,200,200,200,1,123,123,0,11,255,255,
4459 0,4,0,0,0,10,255,255,0,1,0,0,0,2,123,123,123,10,200,200,200,1,123,123,0,12,255,255,0,4,0,0,0,10,255,255,0,1,189,189,
4460 189,1,0,0,0,2,123,123,123,9,200,200,200,1,123,123,0,12,255,255,0,1,189,189,189,2,0,0,0,1,189,189,189,11,255,255,0,1,
4461 0,0,0,2,123,123,123,9,200,200,200,1,123,123,0,27,255,255,0,1,0,0,0,3,123,123,123,8,200,200,200,1,123,123,0,26,255,
4462 255,0,1,189,189,189,1,0,0,0,3,123,123,123,9,200,200,200,1,123,123,0,24,255,255,0,1,189,189,189,1,0,0,0,4,123,123,
4463 123,10,200,200,200,1,123,123,0,24,0,0,0,5,123,123,123,12,200,200,200,27,123,123,123,14,200,200,200,25,123,123,123,86,
4464 200,200,200,91,49,124,118,124,71,32,124,95,49,56,114,52,82,121,0};
4470 inline void warn(
const char *format, ...) {
4472 char message[8192] = { 0 };
4474 va_start(ap,format);
4475 std::vsprintf(message,format,ap);
4477 #ifdef cimg_strict_warnings
4491 inline int system(
const char *
const command,
const char *
const module_name=0) {
4493 PROCESS_INFORMATION
pi;
4495 std::memset(&pi,0,
sizeof(PROCESS_INFORMATION));
4496 std::memset(&si,0,
sizeof(STARTUPINFO));
4497 GetStartupInfo(&si);
4499 si.wShowWindow = SW_HIDE;
4500 si.dwFlags |= SW_HIDE;
4501 const BOOL res = CreateProcess((LPCTSTR)module_name,(LPTSTR)command,0,0,
FALSE,0,0,0,&si,&pi);
4503 WaitForSingleObject(pi.hProcess, INFINITE);
4504 CloseHandle(pi.hThread);
4505 CloseHandle(pi.hProcess);
4510 return module_name?0:1;
4514 template<
typename T>
4521 template<
typename T>
4522 inline void swap(T& a, T& b) { T t = a; a = b; b = t; }
4525 template<
typename T1,
typename T2>
4526 inline void swap(T1& a1, T1& b1, T2& a2, T2& b2) {
4531 template<
typename T1,
typename T2,
typename T3>
4532 inline void swap(T1& a1, T1& b1, T2& a2, T2& b2, T3& a3, T3& b3) {
4537 template<
typename T1,
typename T2,
typename T3,
typename T4>
4538 inline void swap(T1& a1, T1& b1, T2& a2, T2& b2, T3& a3, T3& b3, T4& a4, T4& b4) {
4543 template<
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
4544 inline void swap(T1& a1, T1& b1, T2& a2, T2& b2, T3& a3, T3& b3, T4& a4, T4& b4, T5& a5, T5& b5) {
4549 template<
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
4550 inline void swap(T1& a1, T1& b1, T2& a2, T2& b2, T3& a3, T3& b3, T4& a4, T4& b4, T5& a5, T5& b5, T6& a6, T6& b6) {
4551 cimg::swap(a1,b1,a2,b2,a3,b3,a4,b4,a5,b5);
cimg::swap(a6,b6);
4555 template<
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7>
4556 inline void swap(T1& a1, T1& b1, T2& a2, T2& b2, T3& a3, T3& b3, T4& a4, T4& b4, T5& a5, T5& b5, T6& a6, T6& b6,
4558 cimg::swap(a1,b1,a2,b2,a3,b3,a4,b4,a5,b5,a6,b6);
cimg::swap(a7,b7);
4562 template<
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7,
typename T8>
4563 inline void swap(T1& a1, T1& b1, T2& a2, T2& b2, T3& a3, T3& b3, T4& a4, T4& b4, T5& a5, T5& b5, T6& a6, T6& b6,
4564 T7& a7, T7& b7, T8& a8, T8& b8) {
4565 cimg::swap(a1,b1,a2,b2,a3,b3,a4,b4,a5,b5,a6,b6,a7,b7);
cimg::swap(a8,b8);
4574 return ((
unsigned char*)&x)[0]?
false:
true;
4578 template<
typename T>
4580 if (size)
switch (
sizeof(T)) {
4582 case 2 : {
for (
unsigned short *ptr = (
unsigned short*)buffer+size; ptr>(
unsigned short*)buffer; ) {
4583 const unsigned short val = *(--ptr);
4584 *ptr = (
unsigned short)((val>>8)|((val<<8)));
4586 case 4 : {
for (
unsigned int *ptr = (
unsigned int*)buffer+size; ptr>(
unsigned int*)buffer; ) {
4587 const unsigned int val = *(--ptr);
4588 *ptr = (val>>24)|((val>>8)&0xff00)|((val<<8)&0xff0000)|(val<<24);
4590 default : {
for (T* ptr = buffer+size; ptr>buffer; ) {
4591 unsigned char *pb = (
unsigned char*)(--ptr), *pe = pb +
sizeof(T);
4592 for (
int i = 0;
i<(int)
sizeof(T)/2; ++
i)
swap(*(pb++),*(--pe));
4598 template<
typename T>
4607 struct timeval st_time;
4608 gettimeofday(&st_time,0);
4609 return (
unsigned long)(st_time.tv_usec/1000 + st_time.tv_sec*1000);
4611 static SYSTEMTIME st_time;
4612 GetSystemTime(&st_time);
4613 return (
unsigned long)(st_time.wMilliseconds + 1000*(st_time.wSecond + 60*(st_time.wMinute + 60*st_time.wHour)));
4624 inline void sleep(
const unsigned int milliseconds) {
4627 tv.tv_sec = milliseconds/1000;
4628 tv.tv_nsec = (milliseconds%1000)*1000000;
4631 Sleep(milliseconds);
4635 inline unsigned int _sleep(
const unsigned int milliseconds,
unsigned long& timer) {
4637 const unsigned long current_time =
cimg::time();
4638 if (current_time>=timer+milliseconds) { timer = current_time;
return 0; }
4639 const unsigned long time_diff = timer + milliseconds - current_time;
4640 timer = current_time + time_diff;
4642 return (
unsigned int)time_diff;
4650 inline unsigned int wait(
const unsigned int milliseconds) {
4651 static unsigned long timer = 0;
4653 return _sleep(milliseconds,timer);
4659 static bool first_time =
true;
4662 unsigned char *
const rand_ptr =
new unsigned char[1+
std::rand()%2048];
4670 template<
typename T>
4671 inline const T
rol(
const T a,
const unsigned int n=1) {
4672 return n?(T)((a<<
n)|(a>>((
sizeof(T)<<3)-
n))):a;
4676 template<
typename T>
4677 inline const T
ror(
const T a,
const unsigned int n=1) {
4678 return n?(T)((a>>
n)|(a<<((
sizeof(T)<<3)-
n))):a;
4686 template<
typename T>
4690 inline bool abs(
const bool a) {
4693 inline unsigned char abs(
const unsigned char a) {
4696 inline unsigned short abs(
const unsigned short a) {
4699 inline unsigned int abs(
const unsigned int a) {
4702 inline unsigned long abs(
const unsigned long a) {
4705 inline double abs(
const double a) {
4706 return std::fabs(a);
4708 inline float abs(
const float a) {
4709 return (
float)std::fabs((
double)a);
4716 template<
typename T>
4727 template<
typename t1,
typename t2>
4730 return (t1t2)(a<=b?a:b);
4734 template<
typename t1,
typename t2,
typename t3>
4741 template<
typename t1,
typename t2,
typename t3,
typename t4>
4748 template<
typename t1,
typename t2>
4751 return (t1t2)(a>=b?a:b);
4755 template<
typename t1,
typename t2,
typename t3>
4762 template<
typename t1,
typename t2,
typename t3,
typename t4>
4769 template<
typename T>
4771 return (x<0)?(T)(-1):(x==0?(T)0:(T)1);
4775 template<
typename T>
4787 template<
typename T>
4788 inline T
mod(
const T&
x,
const T& m) {
4789 const double dx = (double)x, dm = (
double)m;
4790 if (x<0) {
return (T)(dm+dx+dm*std::floor(-dx/dm)); }
4791 return (T)(dx-dm*std::floor(dx/dm));
4793 inline int mod(
const bool x,
const bool m) {
4796 inline int mod(
const char x,
const char m) {
4797 return x>=0?x%m:(x%m?m+x%m:0);
4799 inline int mod(
const short x,
const short m) {
4800 return x>=0?x%m:(x%m?m+x%m:0);
4802 inline int mod(
const int x,
const int m) {
4803 return x>=0?x%m:(x%m?m+x%m:0);
4805 inline int mod(
const long x,
const long m) {
4806 return x>=0?x%m:(x%m?m+x%m:0);
4808 inline int mod(
const unsigned char x,
const unsigned char m) {
4811 inline int mod(
const unsigned short x,
const unsigned short m) {
4814 inline int mod(
const unsigned int x,
const unsigned int m) {
4817 inline int mod(
const unsigned long x,
const unsigned long m) {
4827 template<
typename T>
4829 return a*b<=0?0:(a>0?(a<b?a:b):(a<b?b:a));
4834 static bool first_time =
true;
4835 if (first_time) {
cimg::srand(); first_time =
false; }
4851 }
while (w<=0 || w>=1.0);
4857 if (z<=1.0e-10)
return 0;
4871 inline double round(
const double x,
const double y,
const int rounding_type=0) {
4874 if (delta==0.0)
return x;
4876 backward = x - delta,
4877 forward = backward +
y;
4878 return rounding_type<0?backward:(rounding_type>0?forward:(2*delta<y?backward:forward));
4883 if (absa>absb) {
const double tmp = absb/absa;
return absa*
std::sqrt(1.0+tmp*tmp); }
4884 else {
const double tmp = absa/absb;
return (absb==0?0:absb*
std::sqrt(1.0+tmp*tmp)); }
4889 return (
char)((x<'A'||x>
'Z')?x:x-
'A'+
'a');
4897 if (
string)
for (
char *ptr =
string; *ptr; ++ptr) *ptr =
uncase(*ptr);
4905 inline float atof(
const char *
const str) {
4907 if (!str)
return 0;
else { std::sscanf(str,
"%g/%g",&x,&
y);
return x/
y; }
4915 inline int strncasecmp(
const char *
const s1,
const char *
const s2,
const int l) {
4917 if (!s1)
return s2?-1:0;
4918 const char *ns1 = s1, *ns2 = s2;
4919 int k, diff = 0;
for (k = 0; k<l && !(diff =
uncase(*ns1)-
uncase(*ns2)); ++
k) { ++ns1; ++ns2; }
4928 inline int strcasecmp(
const char *
const s1,
const char *
const s2) {
4929 if (!s1)
return s2?-1:0;
4930 const unsigned int l1 = std::strlen(s1), l2 = std::strlen(s2);
4935 inline bool strpare(
char *
const s,
const char delimiter=
' ',
const bool symmetric=
false) {
4936 if (!s)
return false;
4937 const int l = (int)std::strlen(s);
4939 if (symmetric)
for (p = 0, q = l-1; p<q && s[p]==delimiter && s[
q]==delimiter; ++p) --q;
4941 for (p = 0; p<l && s[p]==delimiter; ) ++p;
4942 for (q = l-1; q>p && s[
q]==delimiter; ) --q;
4944 const int n = q - p + 1;
4945 if (n!=l) { std::memmove(s,s+p,n); s[
n] = 0;
return true; }
4953 for (
bool need_iter =
true; need_iter; ) {
4955 need_iter |=
strpare(s,
'\'',
true);
4956 need_iter |=
strpare(s,
'\"',
true);
4957 need_iter |=
strpare(s,
'`',
true);
4963 #define cimg_strescape(ci,co) case ci: *nd = co; ++ns; break;
4964 static unsigned int val = 0;
4965 for (
char *ns = s, *nd = s; *ns || (bool)(*nd=0); ++nd)
if (*ns==
'\\')
switch (*(++ns)) {
4977 case 0 : *nd = 0;
break;
4978 case '0' :
case '1' :
case '2' :
case '3' :
case '4' :
case '5' :
case '6' :
case '7' :
4979 std::sscanf(ns,
"%o",&val);
while (*ns>=
'0' && *ns<=
'7') ++ns;
4982 std::sscanf(++ns,
"%x",&val);
while ((*ns>=
'0' && *ns<=
'7') || (*ns>=
'a' && *ns<=
'f') || (*ns>=
'A' && *ns<=
'F')) ++ns;
4985 }
else *nd = *(ns++);
4997 static char randomid[9] = { 0,0,0,0,0,0,0,0,0 };
4999 for (
unsigned int k = 0;
k<8; ++
k) {
5010 char *
const ns =
new char[MAX_PATH];
5011 if (GetShortPathNameA(s,ns,MAX_PATH)) std::strcpy(s,ns);
5017 inline const char*
temporary_path(
const char *
const user_path=0,
const bool reinit_path=
false) {
5018 #define _cimg_test_temporary_path(p) \
5019 if (!path_found) { \
5020 std::sprintf(st_path,"%s",p); \
5021 std::sprintf(tmp,"%s%c%s",st_path,cimg_file_separator,filetmp); \
5022 if ((file=std::fopen(tmp,"wb"))!=0) { std::fclose(file); std::remove(tmp); path_found = true; } \
5024 static char *st_path = 0;
5025 if (reinit_path && st_path) {
delete[] st_path; st_path = 0; }
5027 if (!st_path) st_path =
new char[1024];
5028 std::memset(st_path,0,1024);
5029 std::strncpy(st_path,user_path,1023);
5030 }
else if (!st_path) {
5031 st_path =
new char[1024];
5032 std::memset(st_path,0,1024);
5033 bool path_found =
false;
5034 char tmp[1024] = { 0 }, filetmp[512] = { 0 };
5035 std::FILE *file = 0;
5037 char *tmpPath = getenv(
"TMP");
5055 std::strcpy(tmp,filetmp);
5059 throw CImgIOException(
"cimg::temporary_path() : Unable to find a temporary path accessible for writing\n"
5060 "you have to set the macro 'cimg_temporary_path' to a valid path where you have writing access :\n"
5061 "#define cimg_temporary_path \"path\" (before including 'CImg.h')");
5068 inline const char* programfiles_path(
const char *
const user_path=0,
const bool reinit_path=
false) {
5069 static char *st_path = 0;
5070 if (reinit_path && st_path) {
delete[] st_path; st_path = 0; }
5072 if (!st_path) st_path =
new char[1024];
5073 std::memset(st_path,0,1024);
5074 std::strncpy(st_path,user_path,1023);
5075 }
else if (!st_path) {
5076 st_path =
new char[MAX_PATH];
5077 std::memset(st_path,0,MAX_PATH);
5079 #if !defined(__INTEL_COMPILER)
5080 if (!SHGetSpecialFolderPathA(0,st_path,0x0026,
false)) {
5081 const char *pfPath = getenv(
"PROGRAMFILES");
5082 if (pfPath) std::strncpy(st_path,pfPath,MAX_PATH-1);
5083 else std::strcpy(st_path,
"C:\\PROGRA~1");
5086 std::strcpy(st_path,
"C:\\PROGRA~1");
5094 inline const char*
imagemagick_path(
const char *
const user_path=0,
const bool reinit_path=
false) {
5095 static char *st_path = 0;
5096 if (reinit_path && st_path) {
delete[] st_path; st_path = 0; }
5098 if (!st_path) st_path =
new char[1024];
5099 std::memset(st_path,0,1024);
5100 std::strncpy(st_path,user_path,1023);
5101 }
else if (!st_path) {
5102 st_path =
new char[1024];
5103 std::memset(st_path,0,1024);
5104 bool path_found =
false;
5105 std::FILE *file = 0;
5107 const char *pf_path = programfiles_path();
5109 std::sprintf(st_path,
".\\convert.exe");
5112 for (
int k = 32;
k>=10 && !path_found; --
k) {
5113 std::sprintf(st_path,
"%s\\IMAGEM~1.%.2d-\\convert.exe",pf_path,
k);
5116 for (
int k = 9;
k>=0 && !path_found; --
k) {
5117 std::sprintf(st_path,
"%s\\IMAGEM~1.%d-Q\\convert.exe",pf_path,
k);
5120 for (
int k = 32;
k>=0 && !path_found; --
k) {
5121 std::sprintf(st_path,
"%s\\IMAGEM~1.%d\\convert.exe",pf_path,
k);
5124 for (
int k = 32;
k>=10 && !path_found; --
k) {
5125 std::sprintf(st_path,
"%s\\IMAGEM~1.%.2d-\\VISUA~1\\BIN\\convert.exe",pf_path,
k);
5128 for (
int k = 9;
k>=0 && !path_found; --
k) {
5129 std::sprintf(st_path,
"%s\\IMAGEM~1.%d-Q\\VISUA~1\\BIN\\convert.exe",pf_path,
k);
5132 for (
int k = 32;
k>=0 && !path_found; --
k) {
5133 std::sprintf(st_path,
"%s\\IMAGEM~1.%d\\VISUA~1\\BIN\\convert.exe",pf_path,
k);
5136 for (
int k = 32;
k>=10 && !path_found; --
k) {
5137 std::sprintf(st_path,
"C:\\IMAGEM~1.%.2d-\\convert.exe",
k);
5140 for (
int k = 9;
k>=0 && !path_found; --
k) {
5141 std::sprintf(st_path,
"C:\\IMAGEM~1.%d-Q\\convert.exe",
k);
5144 for (
int k = 32;
k>=0 && !path_found; --
k) {
5145 std::sprintf(st_path,
"C:\\IMAGEM~1.%d\\convert.exe",
k);
5148 for (
int k = 32;
k>=10 && !path_found; --
k) {
5149 std::sprintf(st_path,
"C:\\IMAGEM~1.%.2d-\\VISUA~1\\BIN\\convert.exe",
k);
5152 for (
int k = 9;
k>=0 && !path_found; --
k) {
5153 std::sprintf(st_path,
"C:\\IMAGEM~1.%d-Q\\VISUA~1\\BIN\\convert.exe",
k);
5156 for (
int k = 32;
k>=0 && !path_found; --
k) {
5157 std::sprintf(st_path,
"C:\\IMAGEM~1.%d\\VISUA~1\\BIN\\convert.exe",
k);
5160 for (
int k = 32;
k>=10 && !path_found; --
k) {
5161 std::sprintf(st_path,
"D:\\IMAGEM~1.%.2d-\\convert.exe",
k);
5164 for (
int k = 9;
k>=0 && !path_found; --
k) {
5165 std::sprintf(st_path,
"D:\\IMAGEM~1.%d-Q\\convert.exe",
k);
5168 for (
int k = 32;
k>=0 && !path_found; --
k) {
5169 std::sprintf(st_path,
"D:\\IMAGEM~1.%d\\convert.exe",
k);
5172 for (
int k = 32;
k>=10 && !path_found; --
k) {
5173 std::sprintf(st_path,
"D:\\IMAGEM~1.%.2d-\\VISUA~1\\BIN\\convert.exe",
k);
5176 for (
int k = 9;
k>=0 && !path_found; --
k) {
5177 std::sprintf(st_path,
"D:\\IMAGEM~1.%d-Q\\VISUA~1\\BIN\\convert.exe",
k);
5180 for (
int k = 32;
k>=0 && !path_found; --
k) {
5181 std::sprintf(st_path,
"D:\\IMAGEM~1.%d\\VISUA~1\\BIN\\convert.exe",
k);
5184 if (!path_found) std::strcpy(st_path,
"convert.exe");
5187 std::sprintf(st_path,
"./convert");
5190 if (!path_found) std::strcpy(st_path,
"convert");
5199 static char *st_path = 0;
5200 if (reinit_path && st_path) {
delete[] st_path; st_path = 0; }
5202 if (!st_path) st_path =
new char[1024];
5203 std::memset(st_path,0,1024);
5204 std::strncpy(st_path,user_path,1023);
5205 }
else if (!st_path) {
5206 st_path =
new char[1024];
5207 std::memset(st_path,0,1024);
5208 bool path_found =
false;
5209 std::FILE *file = 0;
5211 const char* pf_path = programfiles_path();
5213 std::sprintf(st_path,
".\\gm.exe");
5216 for (
int k = 32;
k>=10 && !path_found; --
k) {
5217 std::sprintf(st_path,
"%s\\GRAPHI~1.%.2d-\\gm.exe",pf_path,
k);
5220 for (
int k = 9;
k>=0 && !path_found; --
k) {
5221 std::sprintf(st_path,
"%s\\GRAPHI~1.%d-Q\\gm.exe",pf_path,
k);
5224 for (
int k = 32;
k>=0 && !path_found; --
k) {
5225 std::sprintf(st_path,
"%s\\GRAPHI~1.%d\\gm.exe",pf_path,
k);
5228 for (
int k = 32;
k>=10 && !path_found; --
k) {
5229 std::sprintf(st_path,
"%s\\GRAPHI~1.%.2d-\\VISUA~1\\BIN\\gm.exe",pf_path,
k);
5232 for (
int k = 9;
k>=0 && !path_found; --
k) {
5233 std::sprintf(st_path,
"%s\\GRAPHI~1.%d-Q\\VISUA~1\\BIN\\gm.exe",pf_path,
k);
5236 for (
int k = 32;
k>=0 && !path_found; --
k) {
5237 std::sprintf(st_path,
"%s\\GRAPHI~1.%d\\VISUA~1\\BIN\\gm.exe",pf_path,
k);
5240 for (
int k = 32;
k>=10 && !path_found; --
k) {
5241 std::sprintf(st_path,
"C:\\GRAPHI~1.%.2d-\\gm.exe",
k);
5244 for (
int k = 9;
k>=0 && !path_found; --
k) {
5245 std::sprintf(st_path,
"C:\\GRAPHI~1.%d-Q\\gm.exe",
k);
5248 for (
int k = 32;
k>=0 && !path_found; --
k) {
5249 std::sprintf(st_path,
"C:\\GRAPHI~1.%d\\gm.exe",
k);
5252 for (
int k = 32;
k>=10 && !path_found; --
k) {
5253 std::sprintf(st_path,
"C:\\GRAPHI~1.%.2d-\\VISUA~1\\BIN\\gm.exe",
k);
5256 for (
int k = 9;
k>=0 && !path_found; --
k) {
5257 std::sprintf(st_path,
"C:\\GRAPHI~1.%d-Q\\VISUA~1\\BIN\\gm.exe",
k);
5260 for (
int k = 32;
k>=0 && !path_found; --
k) {
5261 std::sprintf(st_path,
"C:\\GRAPHI~1.%d\\VISUA~1\\BIN\\gm.exe",
k);
5264 for (
int k = 32;
k>=10 && !path_found; --
k) {
5265 std::sprintf(st_path,
"D:\\GRAPHI~1.%.2d-\\gm.exe",
k);
5268 for (
int k = 9;
k>=0 && !path_found; --
k) {
5269 std::sprintf(st_path,
"D:\\GRAPHI~1.%d-Q\\gm.exe",
k);
5272 for (
int k = 32;
k>=0 && !path_found; --
k) {
5273 std::sprintf(st_path,
"D:\\GRAPHI~1.%d\\gm.exe",
k);
5276 for (
int k = 32;
k>=10 && !path_found; --
k) {
5277 std::sprintf(st_path,
"D:\\GRAPHI~1.%.2d-\\VISUA~1\\BIN\\gm.exe",
k);
5280 for (
int k = 9;
k>=0 && !path_found; --
k) {
5281 std::sprintf(st_path,
"D:\\GRAPHI~1.%d-Q\\VISUA~1\\BIN\\gm.exe",
k);
5284 for (
int k = 32;
k>=0 && !path_found; --
k) {
5285 std::sprintf(st_path,
"D:\\GRAPHI~1.%d\\VISUA~1\\BIN\\gm.exe",
k);
5288 if (!path_found) std::strcpy(st_path,
"gm.exe");
5291 std::sprintf(st_path,
"./gm");
5294 if (!path_found) std::strcpy(st_path,
"gm");
5302 inline const char*
medcon_path(
const char *
const user_path=0,
const bool reinit_path=
false) {
5303 static char *st_path = 0;
5304 if (reinit_path && st_path) {
delete[] st_path; st_path = 0; }
5306 if (!st_path) st_path =
new char[1024];
5307 std::memset(st_path,0,1024);
5308 std::strncpy(st_path,user_path,1023);
5309 }
else if (!st_path) {
5310 st_path =
new char[1024];
5311 std::memset(st_path,0,1024);
5312 bool path_found =
false;
5313 std::FILE *file = 0;
5315 const char* pf_path = programfiles_path();
5317 std::sprintf(st_path,
".\\medcon.bat");
5321 std::sprintf(st_path,
".\\medcon.exe");
5325 std::sprintf(st_path,
"%s\\XMedCon\\bin\\medcon.bat",pf_path);
5329 std::sprintf(st_path,
"%s\\XMedCon\\bin\\medcon.exe",pf_path);
5332 if (!path_found) std::strcpy(st_path,
"medcon.bat");
5335 std::sprintf(st_path,
"./medcon");
5338 if (!path_found) std::strcpy(st_path,
"medcon");
5346 inline const char *
ffmpeg_path(
const char *
const user_path=0,
const bool reinit_path=
false) {
5347 static char *st_path = 0;
5348 if (reinit_path && st_path) {
delete[] st_path; st_path = 0; }
5350 if (!st_path) st_path =
new char[1024];
5351 std::memset(st_path,0,1024);
5352 std::strncpy(st_path,user_path,1023);
5353 }
else if (!st_path) {
5354 st_path =
new char[1024];
5355 std::memset(st_path,0,1024);
5356 bool path_found =
false;
5357 std::FILE *file = 0;
5360 std::sprintf(st_path,
".\\ffmpeg.exe");
5363 if (!path_found) std::strcpy(st_path,
"ffmpeg.exe");
5366 std::sprintf(st_path,
"./ffmpeg");
5369 if (!path_found) std::strcpy(st_path,
"ffmpeg");
5377 inline const char *
gzip_path(
const char *
const user_path=0,
const bool reinit_path=
false) {
5378 static char *st_path = 0;
5379 if (reinit_path && st_path) {
delete[] st_path; st_path = 0; }
5381 if (!st_path) st_path =
new char[1024];
5382 std::memset(st_path,0,1024);
5383 std::strncpy(st_path,user_path,1023);
5384 }
else if (!st_path) {
5385 st_path =
new char[1024];
5386 std::memset(st_path,0,1024);
5387 bool path_found =
false;
5388 std::FILE *file = 0;
5391 std::sprintf(st_path,
".\\gzip.exe");
5394 if (!path_found) std::strcpy(st_path,
"gzip.exe");
5397 std::sprintf(st_path,
"./gzip");
5400 if (!path_found) std::strcpy(st_path,
"gzip");
5408 inline const char *
gunzip_path(
const char *
const user_path=0,
const bool reinit_path=
false) {
5409 static char *st_path = 0;
5410 if (reinit_path && st_path) {
delete[] st_path; st_path = 0; }
5412 if (!st_path) st_path =
new char[1024];
5413 std::memset(st_path,0,1024);
5414 std::strncpy(st_path,user_path,1023);
5415 }
else if (!st_path) {
5416 st_path =
new char[1024];
5417 std::memset(st_path,0,1024);
5418 bool path_found =
false;
5419 std::FILE *file = 0;
5422 std::sprintf(st_path,
".\\gunzip.exe");
5425 if (!path_found) std::strcpy(st_path,
"gunzip.exe");
5428 std::sprintf(st_path,
"./gunzip");
5431 if (!path_found) std::strcpy(st_path,
"gunzip");
5439 inline const char *
dcraw_path(
const char *
const user_path=0,
const bool reinit_path=
false) {
5440 static char *st_path = 0;
5441 if (reinit_path && st_path) {
delete[] st_path; st_path = 0; }
5443 if (!st_path) st_path =
new char[1024];
5444 std::memset(st_path,0,1024);
5445 std::strncpy(st_path,user_path,1023);
5446 }
else if (!st_path) {
5447 st_path =
new char[1024];
5448 std::memset(st_path,0,1024);
5449 bool path_found =
false;
5450 std::FILE *file = 0;
5453 std::sprintf(st_path,
".\\dcraw.exe");
5456 if (!path_found) std::strcpy(st_path,
"dcraw.exe");
5459 std::sprintf(st_path,
"./dcraw");
5462 if (!path_found) std::strcpy(st_path,
"dcraw");
5471 if (!filename) {
if (body) body[0] = 0;
return 0; }
5472 const char *p = 0;
for (
const char *np = filename; np>=filename && (p=np); np = std::strchr(np,
'.')+1) {}
5474 if (body) std::strcpy(body,filename);
5475 return filename + std::strlen(filename);
5477 const unsigned int l = p - filename - 1;
5478 if (body) { std::memcpy(body,filename,l); body[l] = 0; }
5483 inline char*
number_filename(
const char *
const filename,
const int number,
const unsigned int n,
char *
const string) {
5484 if (!filename) {
if (
string)
string[0] = 0;
return 0; }
5485 char format[1024] = { 0 }, body[1024] = { 0 };
5487 if (n>0) std::sprintf(format,
"%s_%%.%ud.%s",body,n,ext);
5488 else std::sprintf(format,
"%s_%%d.%s",body,ext);
5489 std::sprintf(
string,format,number);
5494 inline std::FILE *
fopen(
const char *
const path,
const char *
const mode) {
5497 path?path:
"(null)",mode?mode:
"(null)");
5498 if (path[0]==
'-')
return (mode[0]==
'r')?stdin:stdout;
5501 throw CImgIOException(
"cimg::fopen() : File '%s', cannot open file %s",
5502 path,mode[0]==
'r'?
"for reading.":(mode[0]==
'w'?
"for writing.":
"."),path);
5508 if (!file)
warn(
"cimg::fclose() : Cannot close (null) file");
5509 if (!file || file==stdin || file==stdout)
return 0;
5511 if (errn!=0)
warn(
"cimg::fclose() : Error %d during file closing",errn);
5516 inline const char *
file_type(std::FILE *
const file,
const char *
const filename) {
5518 *
const _pnm =
"pnm",
5519 *
const _bmp =
"bmp",
5520 *
const _gif =
"gif",
5521 *
const _jpeg =
"jpeg",
5522 *
const _off =
"off",
5523 *
const _pan =
"pan",
5524 *
const _png =
"png",
5525 *
const _tiff =
"tiff";
5526 if (!filename && !file)
throw CImgArgumentException(
"cimg::file_type() : Cannot load (null) filename.");
5527 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"rb");
5528 const char *ftype = 0, *head;
5529 char header[2048] = { 0 }, item[1024] = { 0 };
5530 const unsigned char *
const uheader = (
unsigned char*)header;
5532 const unsigned int siz = (
unsigned int)
std::fread(header,2048,1,nfile);
5535 if (header[0]==
'B' && header[1]==
'M') ftype = _bmp;
5538 if (header[0]==
'G' && header[1]==
'I' && header[2]==
'F' && header[3]==
'8' && header[5]==
'a' &&
5539 (header[4]==
'7' || header[4]==
'9')) ftype = _gif;
5542 if (uheader[0]==0xFF && uheader[1]==0xD8 && uheader[2]==0xFF) ftype = _jpeg;
5545 if (header[0]==
'O' && header[1]==
'F' && header[2]==
'F' && header[3]==
'\n') ftype = _off;
5548 if (header[0]==
'P' && header[1]==
'A' && header[2]==
'N' && header[3]==
'D' && header[4]==
'O' &&
5549 header[5]==
'R' && header[6]==
'E') ftype = _pan;
5552 if (uheader[0]==0x89 && uheader[1]==0x50 && uheader[2]==0x4E && uheader[3]==0x47 &&
5553 uheader[4]==0x0D && uheader[5]==0x0A && uheader[6]==0x1A && uheader[7]==0x0A) ftype = _png;
5557 while (head<header+siz && (err=std::sscanf(head,
"%1023[^\n]",item))!=EOF && (item[0]==
'#' || !err))
5558 head+=1+(err?std::strlen(item):0);
5559 if (std::sscanf(item,
" P%d",&err)==1) ftype = _pnm;
5562 if ((uheader[0]==0x49 && uheader[1]==0x49) || (uheader[0]==0x4D && uheader[1]==0x4D)) ftype = _tiff;
5568 template<
typename T>
5569 inline int fread(T *
const ptr,
const unsigned int nmemb, std::FILE *stream) {
5570 if (!ptr || nmemb<=0 || !stream)
5571 throw CImgArgumentException(
"cimg::fread() : Cannot read %u x %u bytes of file pointer '%p' in buffer '%p'",
5572 nmemb,
sizeof(T),stream,ptr);
5573 const unsigned long wlimitT = 63*1024*1024, wlimit = wlimitT/
sizeof(T);
5574 unsigned int toread = nmemb, alread = 0, ltoread = 0, lalread = 0;
5576 ltoread = (toread*
sizeof(T))<wlimitT?toread:wlimit;
5577 lalread = (
unsigned int)
std::fread((
void*)(ptr+alread),
sizeof(T),ltoread,stream);
5580 }
while (ltoread==lalread && toread>0);
5581 if (toread>0)
warn(
"cimg::fread() : File reading problems, only %u/%u elements read",alread,nmemb);
5586 template<
typename T>
5587 inline int fwrite(
const T *ptr,
const unsigned int nmemb, std::FILE *stream) {
5588 if (!ptr || !stream)
5589 throw CImgArgumentException(
"cimg::fwrite() : Cannot write %u x %u bytes of file pointer '%p' from buffer '%p'",
5590 nmemb,
sizeof(T),stream,ptr);
5591 if (nmemb<=0)
return 0;
5592 const unsigned long wlimitT = 63*1024*1024, wlimit = wlimitT/
sizeof(T);
5593 unsigned int towrite = nmemb, alwrite = 0, ltowrite = 0, lalwrite = 0;
5595 ltowrite = (towrite*
sizeof(T))<wlimitT?towrite:wlimit;
5596 lalwrite = (
unsigned int)
std::fwrite((
void*)(ptr+alwrite),
sizeof(T),ltowrite,stream);
5599 }
while (ltowrite==lalwrite && towrite>0);
5600 if (towrite>0)
warn(
"cimg::fwrite() : File writing problems, only %u/%u elements written",alwrite,nmemb);
5604 inline const char*
option(
const char *
const name,
const int argc,
const char *
const *
const argv,
5605 const char *defaut,
const char *
const usage=0) {
5606 static bool first =
true, visu =
false;
5607 const char *res = 0;
5612 visu |= (
cimg::option(
"--help",argc,argv,(
char*)0)!=0);
5614 if (!name && visu) {
5618 std::fprintf(
cimg_stdout,
" (%s, %s)\n\n",__DATE__,__TIME__);
5620 if (defaut) std::fprintf(
cimg_stdout,
"%s\n",defaut);
5625 while (k<argc && std::strcmp(argv[k],name)) ++
k;
5626 res = (k++==argc?defaut:(k==argc?argv[--
k]:argv[
k]));
5627 }
else res = defaut;
5628 if (visu && usage) std::fprintf(
cimg_stdout,
" %s%-16s%s %-24s %s%s%s\n",
5634 inline bool option(
const char *
const name,
const int argc,
const char *
const *
const argv,
5635 const bool defaut,
const char *
const usage=0) {
5642 inline int option(
const char *
const name,
const int argc,
const char *
const *
const argv,
5643 const int defaut,
const char *
const usage=0) {
5645 const int res = s?std::atoi(s):defaut;
5646 char tmp[256] = { 0 };
5647 std::sprintf(tmp,
"%d",res);
5652 inline char option(
const char *
const name,
const int argc,
const char *
const *
const argv,
5653 const char defaut,
const char *
const usage=0) {
5655 const char res = s?s[0]:defaut;
5656 char tmp[8] = { 0 };
5662 inline float option(
const char *
const name,
const int argc,
const char *
const *
const argv,
5663 const float defaut,
const char *
const usage=0) {
5666 char tmp[256] = { 0 };
5667 std::sprintf(tmp,
"%g",res);
5672 inline double option(
const char *
const name,
const int argc,
const char *
const *
const argv,
5673 const double defaut,
const char *
const usage=0) {
5676 char tmp[256] = { 0 };
5677 std::sprintf(tmp,
"%g",res);
5682 inline const char*
argument(
const unsigned int nb,
const int argc,
const char *
const *
const argv,
const unsigned int nb_singles=0, ...) {
5683 for (
int k = 1, pos = 0;
k<argc;) {
5684 const char *
const item = argv[
k];
5685 bool option = (*item==
'-'), single_option =
false;
5688 va_start(ap,nb_singles);
5689 for (
unsigned int i = 0;
i<nb_singles; ++
i)
if (!
cimg::strcasecmp(item,va_arg(ap,
char*))) { single_option =
true;
break; }
5692 if (option) { ++
k;
if (!single_option) ++
k; }
5693 else {
if (pos++==(
int)nb)
return item;
else ++
k; }
5703 char tmp[1024] = { 0 };
5704 std::fprintf(
cimg_stdout,
"\n %sCImg Library %u.%u.%u%s, compiled %s ( %s ) with the following flags :\n\n",
5708 std::fprintf(
cimg_stdout,
" > Operating System : %s%-13s%s %s('cimg_OS'=%d)%s\n",
5715 std::fprintf(
cimg_stdout,
" > CPU endianness : %s%s Endian%s\n",
5720 std::fprintf(
cimg_stdout,
" > Debug messages : %s%-13s%s %s('cimg_debug'=%d)%s\n",
5727 std::fprintf(
cimg_stdout,
" > Stricts warnings : %s%-13s%s %s('cimg_strict_warnings' %s)%s\n",
5729 #ifdef cimg_strict_warnings
5736 std::fprintf(
cimg_stdout,
" > Using VT100 messages : %s%-13s%s %s('cimg_use_vt100' %s)%s\n",
5738 #ifdef cimg_use_vt100
5745 std::fprintf(
cimg_stdout,
" > Display type : %s%-13s%s %s('cimg_display'=%d)%s\n",
5756 std::fprintf(
cimg_stdout,
" > Using XShm for X11 : %s%-13s%s %s('cimg_use_xshm' %s)%s\n",
5758 #ifdef cimg_use_xshm
5765 std::fprintf(
cimg_stdout,
" > Using XRand for X11 : %s%-13s%s %s('cimg_use_xrandr' %s)%s\n",
5767 #ifdef cimg_use_xrandr
5774 std::fprintf(
cimg_stdout,
" > Using OpenMP : %s%-13s%s %s('cimg_use_openmp' %s)%s\n",
5776 #ifdef cimg_use_openmp
5782 std::fprintf(
cimg_stdout,
" > Using PNG library : %s%-13s%s %s('cimg_use_png' %s)%s\n",
5790 std::fprintf(
cimg_stdout,
" > Using JPEG library : %s%-13s%s %s('cimg_use_jpeg' %s)%s\n",
5792 #ifdef cimg_use_jpeg
5799 std::fprintf(
cimg_stdout,
" > Using TIFF library : %s%-13s%s %s('cimg_use_tiff' %s)%s\n",
5801 #ifdef cimg_use_tiff
5808 std::fprintf(
cimg_stdout,
" > Using Magick++ library : %s%-13s%s %s('cimg_use_magick' %s)%s\n",
5810 #ifdef cimg_use_magick
5817 std::fprintf(
cimg_stdout,
" > Using FFTW3 library : %s%-13s%s %s('cimg_use_fftw3' %s)%s\n",
5819 #ifdef cimg_use_fftw3
5826 std::fprintf(
cimg_stdout,
" > Using LAPACK library : %s%-13s%s %s('cimg_use_lapack' %s)%s\n",
5828 #ifdef cimg_use_lapack
5836 std::fprintf(
cimg_stdout,
" > Path of ImageMagick : %s%-13s%s\n",
5842 std::fprintf(
cimg_stdout,
" > Path of GraphicsMagick : %s%-13s%s\n",
5848 std::fprintf(
cimg_stdout,
" > Path of 'medcon' : %s%-13s%s\n",
5854 std::fprintf(
cimg_stdout,
" > Temporary path : %s%-13s%s\n",
5863 #ifdef cimg_use_lapack
5864 template<
typename T>
5865 inline void getrf(
int &N, T *lapA,
int *IPIV,
int &INFO) {
5866 dgetrf_(&N,&N,lapA,&N,IPIV,&INFO);
5869 inline void getrf(
int &N,
float *lapA,
int *IPIV,
int &INFO) {
5870 sgetrf_(&N,&N,lapA,&N,IPIV,&INFO);
5873 template<
typename T>
5874 inline void getri(
int &N, T *lapA,
int *IPIV, T* WORK,
int &LWORK,
int &INFO) {
5875 dgetri_(&N,lapA,&N,IPIV,WORK,&LWORK,&INFO);
5878 inline void getri(
int &N,
float *lapA,
int *IPIV,
float* WORK,
int &LWORK,
int &INFO) {
5879 sgetri_(&N,lapA,&N,IPIV,WORK,&LWORK,&INFO);
5882 template<
typename T>
5883 inline void gesvd(
char &JOB,
int &M,
int &N, T *lapA,
int &MN,
5884 T *lapS, T *lapU, T *lapV, T *WORK,
int &LWORK,
int &INFO) {
5885 dgesvd_(&JOB,&JOB,&M,&N,lapA,&MN,lapS,lapU,&M,lapV,&N,WORK,&LWORK,&INFO);
5888 inline void gesvd(
char &JOB,
int &M,
int &N,
float *lapA,
int &MN,
5889 float *lapS,
float *lapU,
float *lapV,
float *WORK,
int &LWORK,
int &INFO) {
5890 sgesvd_(&JOB,&JOB,&M,&N,lapA,&MN,lapS,lapU,&M,lapV,&N,WORK,&LWORK,&INFO);
5893 template<
typename T>
5894 inline void getrs(
char &TRANS,
int &N, T *lapA,
int *IPIV, T *lapB,
int &INFO) {
5896 dgetrs_(&TRANS,&N,&one,lapA,&N,IPIV,lapB,&N,&INFO);
5899 inline void getrs(
char &TRANS,
int &N,
float *lapA,
int *IPIV,
float *lapB,
int &INFO) {
5901 sgetrs_(&TRANS,&N,&one,lapA,&N,IPIV,lapB,&N,&INFO);
5904 template<
typename T>
5905 inline void syev(
char &JOB,
char &UPLO,
int &N, T *lapA, T *lapW, T *WORK,
int &LWORK,
int &INFO) {
5906 dsyev_(&JOB,&UPLO,&N,lapA,&N,lapW,WORK,&LWORK,&INFO);
5909 inline void syev(
char &JOB,
char &UPLO,
int &N,
float *lapA,
float *lapW,
float *WORK,
int &LWORK,
int &INFO) {
5910 ssyev_(&JOB,&UPLO,&N,lapA,&N,lapW,WORK,&LWORK,&INFO);
5926 #define _cimg_create_ext_operators(typ) \
5927 template<typename T> \
5928 inline CImg<typename cimg::superset<T,typ>::type> operator+(const typ val, const CImg<T>& img) { \
5931 template<typename T> \
5932 inline CImg<typename cimg::superset<T,typ>::type> operator-(const typ val, const CImg<T>& img) { \
5933 typedef typename cimg::superset<T,typ>::type Tt; \
5934 return CImg<Tt>(img.width,img.height,img.depth,img.dim,val)-=img; \
5936 template<typename T> \
5937 inline CImg<typename cimg::superset<T,typ>::type> operator*(const typ val, const CImg<T>& img) { \
5940 template<typename T> \
5941 inline CImg<typename cimg::superset<T,typ>::type> operator/(const typ val, const CImg<T>& img) { \
5942 return val*img.get_invert(); \
5944 template<typename T> \
5945 inline CImg<typename cimg::superset<T,typ>::type> operator&(const typ val, const CImg<T>& img) { \
5948 template<typename T> \
5949 inline CImg<typename cimg::superset<T,typ>::type> operator|(const typ val, const CImg<T>& img) { \
5952 template<typename T> \
5953 inline CImg<typename cimg::superset<T,typ>::type> operator^(const typ val, const CImg<T>& img) { \
5970 template<typename T>
5972 return img + expression;
5975 template<
typename T>
5980 template<
typename T>
5982 return img*expression;
5985 template<
typename T>
5990 template<
typename T>
5992 return img & expression;
5995 template<
typename T>
5997 return img | expression;
6000 template<
typename T>
6002 return img ^ expression;
6005 template<
typename T>
6010 template<
typename T>
6015 template<
typename T>
6020 template<
typename T>
6025 template<
typename T>
6030 template<
typename T>
6035 template<
typename T>
6040 template<
typename T>
6045 template<
typename T>
6050 template<
typename T>
6055 template<
typename T>
6060 template<
typename T>
6065 template<
typename T>
6070 template<
typename T>
6075 template<
typename T>
6080 template<
typename T>
6085 template<
typename T>
6090 template<
typename T>
6277 #ifdef cimgdisplay_plugin
6278 #include cimgdisplay_plugin
6280 #ifdef cimgdisplay_plugin1
6281 #include cimgdisplay_plugin1
6283 #ifdef cimgdisplay_plugin2
6284 #include cimgdisplay_plugin2
6286 #ifdef cimgdisplay_plugin3
6287 #include cimgdisplay_plugin3
6289 #ifdef cimgdisplay_plugin4
6290 #include cimgdisplay_plugin4
6292 #ifdef cimgdisplay_plugin5
6293 #include cimgdisplay_plugin5
6295 #ifdef cimgdisplay_plugin6
6296 #include cimgdisplay_plugin6
6298 #ifdef cimgdisplay_plugin7
6299 #include cimgdisplay_plugin7
6301 #ifdef cimgdisplay_plugin8
6302 #include cimgdisplay_plugin8
6333 const unsigned int normalization_type=3,
6334 const bool fullscreen_flag=
false,
const bool closed_flag=
false):
6338 assign(dimw,dimh,
title,normalization_type,fullscreen_flag,closed_flag);
6348 template<
typename T>
6350 const unsigned int normalization_type=3,
6351 const bool fullscreen_flag=
false,
const bool closed_flag=
false):
6355 assign(img,
title,normalization_type,fullscreen_flag,closed_flag);
6365 template<
typename T>
6367 const unsigned int normalization_type=3,
6368 const bool fullscreen_flag=
false,
const bool closed_flag=
false):
6372 assign(list,
title,normalization_type,fullscreen_flag,closed_flag);
6394 const unsigned int normalization_type=3,
6395 const bool fullscreen_flag=
false,
const bool closed_flag=
false) {
6396 throw CImgDisplayException(
"CImgDisplay() : Display has been required but is not available (cimg_display=0)");
6397 const char* avoid_warning =
title + dimw + dimh + normalization_type + (int)fullscreen_flag + (
int)closed_flag;
6403 template<
typename T>
6405 const unsigned int normalization_type=3,
6406 const bool fullscreen_flag=
false,
const bool closed_flag=
false) {
6407 throw CImgDisplayException(
"CImgDisplay()::assign() : Display has been required but is not available (cimg_display=0)");
6408 const char* avoid_warning =
title + img.
width + normalization_type + (int)fullscreen_flag + (
int)closed_flag;
6414 template<
typename T>
6416 const unsigned int normalization_type=3,
6417 const bool fullscreen_flag=
false,
const bool closed_flag=
false) {
6418 throw CImgDisplayException(
"CImgDisplay()::assign() : Display has been required but is not available (cimg_display=0)");
6419 const char* avoid_warning =
title + list.
width + normalization_type + (int)fullscreen_flag + (
int)closed_flag;
6436 #define cimg_fitscreen(dx,dy,dz) CImgDisplay::_fitscreen(dx,dy,dz,128,-85,false),CImgDisplay::_fitscreen(dx,dy,dz,128,-85,true)
6437 static unsigned int _fitscreen(
const unsigned int dx,
const unsigned int dy=1,
const unsigned int dz=1,
6438 const int dmin=128,
const int dmax=-85,
const bool return_last=
false) {
6439 unsigned int nw = dx + (dz>1?dz:0), nh =
dy + (dz>1?dz:0);
6442 mw = dmin<0?(
unsigned int)(sw*-dmin/100):(
unsigned int)dmin,
6443 mh = dmin<0?(
unsigned int)(sh*-dmin/100):(
unsigned int)dmin,
6444 Mw = dmax<0?(
unsigned int)(sw*-dmax/100):(
unsigned int)dmax,
6445 Mh = dmax<0?(
unsigned int)(sh*-dmax/100):(
unsigned int)dmax;
6446 if (nw<mw) { nh = nh*mw/nw; nh+=(nh==0); nw = mw; }
6447 if (nh<mh) { nw = nw*mh/nh; nw+=(nw==0); nh = mh; }
6448 if (nw>Mw) { nh = nh*Mw/nw; nh+=(nh==0); nw = Mw; }
6449 if (nh>Mh) { nw = nw*Mh/nh; nw+=(nw==0); nh = Mh; }
6452 if (return_last)
return nh;
6464 template<
typename t>
6470 template<
typename t>
6481 operator bool()
const {
6499 for (
unsigned int *ptrs=(
unsigned int*)
keys+512-1; ptrs>=
keys; --ptrs)
if (*ptrs) {
if (
remove) *ptrs = 0;
return true; }
6505 for (
unsigned int *ptrs=(
unsigned int*)
keys+512-1; ptrs>=
keys; --ptrs)
if (*ptrs==key1) {
if (
remove) *ptrs = 0;
return true; }
6511 const unsigned int seq[] = {
key1, key2 };
6512 return is_key(seq,2,
remove);
6516 bool is_key(
const unsigned int key1,
const unsigned int key2,
const unsigned int key3,
const bool remove) {
6517 const unsigned int seq[] = {
key1,
key2, key3 };
6518 return is_key(seq,3,
remove);
6523 const unsigned int key4,
const bool remove) {
6525 return is_key(seq,4,
remove);
6530 const unsigned int key4,
const unsigned int key5,
const bool remove) {
6532 return is_key(seq,5,
remove);
6537 const unsigned int key4,
const unsigned int key5,
const unsigned int key6,
const bool remove) {
6539 return is_key(seq,6,
remove);
6544 const unsigned int key4,
const unsigned int key5,
const unsigned int key6,
6545 const unsigned int key7,
const bool remove) {
6547 return is_key(seq,7,
remove);
6552 const unsigned int key4,
const unsigned int key5,
const unsigned int key6,
6553 const unsigned int key7,
const unsigned int key8,
const bool remove) {
6555 return is_key(seq,8,
remove);
6560 const unsigned int key4,
const unsigned int key5,
const unsigned int key6,
6561 const unsigned int key7,
const unsigned int key8,
const unsigned int key9,
const bool remove) {
6563 return is_key(seq,9,
remove);
6567 bool is_key(
const unsigned int *
const keyseq,
const unsigned int N,
const bool remove=
true) {
6569 const unsigned int *
const ps_end = keyseq+N-1,
k = *ps_end, *
const pk_end = (
unsigned int*)
keys+1+512-N;
6570 for (
unsigned int *pk = (
unsigned int*)
keys; pk<pk_end; ) {
6573 const unsigned int *ps = ps_end, *pk2 = pk;
6574 for (
unsigned int i=1;
i<N; ++
i) res = (*(--ps)==*(pk2++));
6576 if (
remove) std::memset((
void*)(pk-1),0,
sizeof(
unsigned int)*N);
6587 #define _cimg_iskey_case(k) if (key==cimg::key##k) is_key##k = pressed;
6687 template<
typename T>
6690 unsigned int avoid_warning = img.
width;
6704 template<
typename T>
6714 template<
typename T>
6734 int avoid_warning = width | height | (int)redraw;
6741 template<
typename t,
typename T>
6742 static void _render_resize(
const T *ptrs,
const unsigned int ws,
const unsigned int hs,
6743 t *ptrd,
const unsigned int wd,
const unsigned int hd) {
6744 unsigned int *
const offx =
new unsigned int[wd], *
const offy =
new unsigned int[hd+1], *poffx, *poffy;
6747 poffx = offx; curr = 0;
for (
unsigned int x = 0;
x<wd; ++
x) { old=curr; curr+=
s; *(poffx++) = (
unsigned int)curr-(
unsigned int)old; }
6749 poffy = offy; curr = 0;
for (
unsigned int y = 0;
y<hd; ++
y) { old=curr; curr+=
s; *(poffy++) = ws*((
unsigned int)curr-(
unsigned int)old); }
6752 for (
unsigned int y = 0;
y<hd; ) {
6753 const T *ptr = ptrs;
6755 for (
unsigned int x = 0;
x<wd; ++
x) { *(ptrd++) = *ptr; ptr+=*(poffx++); }
6757 unsigned int dy=*(poffy++);
6758 for (;!dy &&
y<hd; std::memcpy(ptrd, ptrd-wd,
sizeof(t)*wd), ++
y, ptrd+=wd, dy=*(poffy++)) {}
6761 delete[] offx;
delete[] offy;
6780 bool avoid_warning = redraw;
6781 avoid_warning =
false;
6797 int avoid_warning = posx | posy;
6814 int avoid_warning = posx | posy;
6821 const char *avoid_warning = format;
6827 template<
typename T>
6829 unsigned int avoid_warning = img.
width;
6840 template<
typename T>
6849 std::memset((
void*)
buttons,0,512*
sizeof(
unsigned int));
6850 std::memset((
void*)
keys,0,512*
sizeof(
unsigned int));
6851 std::memset((
void*)
released_keys,0,512*
sizeof(
unsigned int));
6915 Atom wm_delete_window, wm_delete_protocol;
6916 Window window, background_window;
6920 #ifdef cimg_use_xshm
6921 XShmSegmentInfo *shminfo;
6926 if (!cimg::X11attr().
display) {
6927 Display *disp = XOpenDisplay((std::getenv(
"DISPLAY")?std::getenv(
"DISPLAY"):
":0.0"));
6930 res = DisplayWidth(disp,DefaultScreen(disp));
6931 XCloseDisplay(disp);
6933 #ifdef cimg_use_xrandr
6934 if (cimg::X11attr().resolutions && cimg::X11attr().curr_resolution)
6935 res = cimg::X11attr().resolutions[cimg::X11attr().curr_resolution].width;
6938 res = DisplayWidth(cimg::X11attr().
display,DefaultScreen(cimg::X11attr().
display));
6945 if (!cimg::X11attr().
display) {
6946 Display *disp = XOpenDisplay((std::getenv(
"DISPLAY") ? std::getenv(
"DISPLAY") :
":0.0"));
6948 throw CImgDisplayException(
"CImgDisplay::screen_dimy() : Cannot open X11 display.");
6949 res = DisplayHeight(disp,DefaultScreen(disp));
6950 XCloseDisplay(disp);
6952 #ifdef cimg_use_xrandr
6953 if (cimg::X11attr().resolutions && cimg::X11attr().curr_resolution)
6954 res = cimg::X11attr().resolutions[cimg::X11attr().curr_resolution].height;
6957 res = DisplayHeight(cimg::X11attr().
display,DefaultScreen(cimg::X11attr().
display));
6963 if (cimg::X11attr().
display) {
6964 XLockDisplay(cimg::X11attr().
display);
6968 XNextEvent(cimg::X11attr().
display, &event);
6969 for (
unsigned int i = 0;
i<cimg::X11attr().nb_wins; ++
i)
6970 if (!cimg::X11attr().wins[
i]->is_closed &&
event.xany.window==cimg::X11attr().wins[
i]->window) {
6971 cimg::X11attr().wins[
i]->_handle_events(&event);
6972 if (cimg::X11attr().wins[
i]->
is_event) flag =
false;
6975 XUnlockDisplay(cimg::X11attr().
display);
6979 void _handle_events(
const XEvent *
const pevent) {
6980 XEvent
event = *pevent;
6981 switch (event.type) {
6982 case ClientMessage : {
6983 if ((
int)event.xclient.message_type==(
int)wm_delete_protocol &&
6984 (
int)event.xclient.data.l[0]==(
int)wm_delete_window) {
6985 XUnmapWindow(cimg::X11attr().
display,window);
6988 if (
key) { std::memmove((
void*)(
keys+1),(
void*)
keys,512-1);
key = 0; }
6993 case ConfigureNotify : {
6994 while (XCheckWindowEvent(cimg::X11attr().
display,window,StructureNotifyMask,&event)) {}
6996 nw =
event.xconfigure.width,
6997 nh =
event.xconfigure.height;
6999 nx =
event.xconfigure.x,
7000 ny =
event.xconfigure.y;
7015 while (XCheckWindowEvent(cimg::X11attr().
display,window,ExposureMask,&event)) {}
7018 XWindowAttributes attr;
7019 XGetWindowAttributes(cimg::X11attr().
display, window, &attr);
7020 while (attr.map_state != IsViewable) XSync(cimg::X11attr().
display, False);
7021 XSetInputFocus(cimg::X11attr().
display, window, RevertToParent, CurrentTime);
7024 case ButtonPress : {
7029 switch (event.xbutton.button) {
7034 }
while (XCheckWindowEvent(cimg::X11attr().
display,window,ButtonPressMask,&event));
7036 case ButtonRelease : {
7041 switch (event.xbutton.button) {
7048 }
while (XCheckWindowEvent(cimg::X11attr().
display,window,ButtonReleaseMask,&event));
7053 XLookupString(&event.xkey,&tmp,1,&ksym,0);
7055 if (
key) std::memmove((
void*)(
keys+1),(
void*)
keys,512-1);
7056 key = (
unsigned int)ksym;
7063 XLookupString(&event.xkey,&tmp,1,&ksym,0);
7065 if (
key) { std::memmove((
void*)(
keys+1),(
void*)
keys,512-1);
key = 0; }
7071 while (XCheckWindowEvent(cimg::X11attr().
display,window,EnterWindowMask,&event)) {}
7076 case LeaveNotify : {
7077 while (XCheckWindowEvent(cimg::X11attr().
display,window,LeaveWindowMask,&event)) {}
7081 case MotionNotify : {
7082 while (XCheckWindowEvent(cimg::X11attr().
display,window,PointerMotionMask,&event)) {}
7091 static void* _events_thread(
void *arg) {
7094 pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED,0);
7095 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,0);
7097 XLockDisplay(cimg::X11attr().
display);
7098 bool event_flag = XCheckTypedEvent(cimg::X11attr().
display, ClientMessage, &event);
7099 if (!event_flag) event_flag = XCheckMaskEvent(cimg::X11attr().
display,
7100 ExposureMask|StructureNotifyMask|ButtonPressMask|
7101 KeyPressMask|PointerMotionMask|EnterWindowMask|LeaveWindowMask|
7102 ButtonReleaseMask|KeyReleaseMask,&event);
7104 for (
unsigned int i = 0;
i<cimg::X11attr().nb_wins; ++
i)
7105 if (!cimg::X11attr().wins[
i]->is_closed &&
event.xany.window==cimg::X11attr().wins[
i]->window)
7106 cimg::X11attr().wins[
i]->_handle_events(&event);
7108 XUnlockDisplay(cimg::X11attr().
display);
7109 pthread_testcancel();
7115 void _set_colormap(Colormap& colormap,
const unsigned int dim) {
7116 XColor palette[256];
7119 for (
unsigned int index = 0; index<256; ++index) {
7120 palette[index].pixel = index;
7121 palette[index].red = palette[index].green = palette[index].blue = (
unsigned short)(index<<8);
7122 palette[index].flags = DoRed | DoGreen | DoBlue;
7126 for (
unsigned int index = 0, r = 8; r<256; r+=16)
7127 for (
unsigned int g = 8; g<256; g+=16) {
7128 palette[index].pixel = index;
7129 palette[index].red = palette[index].blue = (
unsigned short)(r<<8);
7130 palette[index].green = (
unsigned short)(g<<8);
7131 palette[index++].flags = DoRed | DoGreen | DoBlue;
7135 for (
unsigned int index = 0, r = 16; r<256; r+=32)
7136 for (
unsigned int g = 16; g<256; g+=32)
7137 for (
unsigned int b = 32; b<256; b+=64) {
7138 palette[index].pixel = index;
7139 palette[index].red = (
unsigned short)(r<<8);
7140 palette[index].green = (
unsigned short)(g<<8);
7141 palette[index].blue = (
unsigned short)(b<<8);
7142 palette[index++].flags = DoRed | DoGreen | DoBlue;
7146 XStoreColors(cimg::X11attr().
display,colormap,palette,256);
7149 void _map_window() {
7150 XWindowAttributes attr;
7152 bool exposed =
false, mapped =
false;
7153 XMapRaised(cimg::X11attr().
display,window);
7154 XSync(cimg::X11attr().
display,False);
7156 XWindowEvent(cimg::X11attr().
display,window,StructureNotifyMask | ExposureMask,&event);
7157 switch (event.type) {
7158 case MapNotify : mapped =
true;
break;
7159 case Expose : exposed =
true;
break;
7162 }
while (!(exposed && mapped));
7164 XGetWindowAttributes(cimg::X11attr().
display, window, &attr);
7165 if (attr.map_state!=IsViewable) { XSync(cimg::X11attr().
display,False);
cimg::sleep(10); }
7166 }
while (attr.map_state != IsViewable);
7171 void _paint(
const bool wait_expose=
true) {
7174 static XEvent event;
7175 event.xexpose.type = Expose;
7176 event.xexpose.serial = 0;
7177 event.xexpose.send_event = True;
7178 event.xexpose.display = cimg::X11attr().display;
7179 event.xexpose.window = window;
7180 event.xexpose.x = 0;
7181 event.xexpose.y = 0;
7182 event.xexpose.width =
dimx();
7183 event.xexpose.height =
dimy();
7184 event.xexpose.count = 0;
7185 XSendEvent(cimg::X11attr().
display, window, False, 0, &event);
7187 #ifdef cimg_use_xshm
7188 if (shminfo) XShmPutImage(cimg::X11attr().
display,window,*cimg::X11attr().gc,image,0,0,0,0,
width,
height,False);
7191 XPutImage(cimg::X11attr().
display,window,*cimg::X11attr().gc,image,0,0,0,0,
width,
height);
7192 XSync(cimg::X11attr().
display, False);
7197 template<
typename T>
7198 void _resize(T foo,
const unsigned int ndimx,
const unsigned int ndimy,
const bool redraw) {
7200 #ifdef cimg_use_xshm
7202 XShmSegmentInfo *nshminfo =
new XShmSegmentInfo;
7203 XImage *nimage = XShmCreateImage(cimg::X11attr().
display,DefaultVisual(cimg::X11attr().
display,DefaultScreen(cimg::X11attr().
display)),
7204 cimg::X11attr().nb_bits,ZPixmap,0,nshminfo,ndimx,ndimy);
7209 nshminfo->shmid = shmget(IPC_PRIVATE, ndimx*ndimy*
sizeof(T), IPC_CREAT | 0777);
7210 if (nshminfo->shmid==-1) {
7211 XDestroyImage(nimage);
7215 nshminfo->shmaddr = nimage->data = (
char*)shmat(nshminfo->shmid,0,0);
7216 if (nshminfo->shmaddr==(
char*)-1) {
7217 shmctl(nshminfo->shmid,IPC_RMID,0);
7218 XDestroyImage(nimage);
7222 nshminfo->readOnly = False;
7223 cimg::X11attr().shm_enabled =
true;
7224 XErrorHandler oldXErrorHandler = XSetErrorHandler(_assign_xshm);
7225 XShmAttach(cimg::X11attr().
display, nshminfo);
7226 XSync(cimg::X11attr().
display, False);
7227 XSetErrorHandler(oldXErrorHandler);
7228 if (!cimg::X11attr().shm_enabled) {
7229 shmdt(nshminfo->shmaddr);
7230 shmctl(nshminfo->shmid,IPC_RMID,0);
7231 XDestroyImage(nimage);
7235 T *
const ndata = (T*)nimage->data;
7237 else std::memset(ndata,0,
sizeof(T)*ndimx*ndimy);
7238 XShmDetach(cimg::X11attr().
display, shminfo);
7239 XDestroyImage(image);
7240 shmdt(shminfo->shmaddr);
7241 shmctl(shminfo->shmid,IPC_RMID,0);
7245 data = (
void*)ndata;
7253 T *ndata = (T*)std::malloc(ndimx*ndimy*
sizeof(T));
7255 else std::memset(ndata,0,
sizeof(T)*ndimx*ndimy);
7256 data = (
void*)ndata;
7257 XDestroyImage(image);
7258 image = XCreateImage(cimg::X11attr().
display,DefaultVisual(cimg::X11attr().
display,DefaultScreen(cimg::X11attr().
display)),
7259 cimg::X11attr().nb_bits,ZPixmap,0,(
char*)data,ndimx,ndimy,8,0);
7263 void _init_fullscreen() {
7264 background_window = 0;
7266 #ifdef cimg_use_xrandr
7268 if (XRRQueryExtension(cimg::X11attr().
display,&foo,&foo)) {
7269 XRRRotations(cimg::X11attr().
display, DefaultScreen(cimg::X11attr().
display), &cimg::X11attr().curr_rotation);
7270 if (!cimg::X11attr().resolutions) {
7271 cimg::X11attr().resolutions = XRRSizes(cimg::X11attr().
display,DefaultScreen(cimg::X11attr().
display),&foo);
7272 cimg::X11attr().nb_resolutions = (
unsigned int)foo;
7274 if (cimg::X11attr().resolutions) {
7275 cimg::X11attr().curr_resolution = 0;
7276 for (
unsigned int i = 0;
i<cimg::X11attr().nb_resolutions; ++
i) {
7278 nw = (
unsigned int)(cimg::X11attr().resolutions[
i].width),
7279 nh = (
unsigned int)(cimg::X11attr().resolutions[
i].height);
7281 nw<=(
unsigned int)(cimg::X11attr().resolutions[cimg::X11attr().curr_resolution].width) &&
7282 nh<=(
unsigned int)(cimg::X11attr().resolutions[cimg::X11attr().curr_resolution].height))
7283 cimg::X11attr().curr_resolution =
i;
7285 if (cimg::X11attr().curr_resolution>0) {
7286 XRRScreenConfiguration *config = XRRGetScreenInfo(cimg::X11attr().
display, DefaultRootWindow(cimg::X11attr().
display));
7287 XRRSetScreenConfig(cimg::X11attr().
display, config, DefaultRootWindow(cimg::X11attr().
display),
7288 cimg::X11attr().curr_resolution, cimg::X11attr().curr_rotation, CurrentTime);
7289 XRRFreeScreenConfigInfo(config);
7290 XSync(cimg::X11attr().
display, False);
7294 if (!cimg::X11attr().resolutions)
7295 cimg::warn(
"CImgDisplay::_create_window() : Xrandr extension is not supported by the X server.");
7298 XSetWindowAttributes winattr;
7299 winattr.override_redirect = True;
7301 background_window = XCreateWindow(cimg::X11attr().
display,
7302 RootWindow(cimg::X11attr().
display,DefaultScreen(cimg::X11attr().
display)),0,0,
7303 sx,sy,0,0,InputOutput,CopyFromParent,CWOverrideRedirect,&winattr);
7304 const unsigned int bufsize = sx*sy*(cimg::X11attr().nb_bits==8?1:(cimg::X11attr().nb_bits==16?2:4));
7305 void *background_data = std::malloc(bufsize);
7306 std::memset(background_data,0,bufsize);
7307 XImage *background_image = XCreateImage(cimg::X11attr().
display,DefaultVisual(cimg::X11attr().
display,DefaultScreen(cimg::X11attr().
display)),
7308 cimg::X11attr().nb_bits,ZPixmap,0,(
char*)background_data,sx,sy,8,0);
7310 XSelectInput(cimg::X11attr().
display,background_window,StructureNotifyMask);
7311 XMapRaised(cimg::X11attr().
display,background_window);
7312 do XWindowEvent(cimg::X11attr().
display,background_window,StructureNotifyMask,&event);
7313 while (event.type!=MapNotify);
7314 #ifdef cimg_use_xshm
7315 if (shminfo) XShmPutImage(cimg::X11attr().
display,background_window,*cimg::X11attr().gc,background_image,0,0,0,0,sx,sy,False);
7318 XPutImage(cimg::X11attr().
display,background_window,*cimg::X11attr().gc,background_image,0,0,0,0,sx,sy);
7319 XWindowAttributes attr;
7320 XGetWindowAttributes(cimg::X11attr().
display, background_window, &attr);
7321 while (attr.map_state != IsViewable) XSync(cimg::X11attr().
display, False);
7322 XDestroyImage(background_image);
7327 void _desinit_fullscreen() {
7329 XUngrabKeyboard(cimg::X11attr().
display,CurrentTime);
7330 #ifdef cimg_use_xrandr
7331 if (cimg::X11attr().resolutions && cimg::X11attr().curr_resolution) {
7332 XRRScreenConfiguration *config = XRRGetScreenInfo(cimg::X11attr().
display, DefaultRootWindow(cimg::X11attr().
display));
7333 XRRSetScreenConfig(cimg::X11attr().
display, config, DefaultRootWindow(cimg::X11attr().
display),
7334 0, cimg::X11attr().curr_rotation, CurrentTime);
7335 XRRFreeScreenConfigInfo(config);
7336 XSync(cimg::X11attr().
display, False);
7337 cimg::X11attr().curr_resolution = 0;
7340 if (background_window) XDestroyWindow(cimg::X11attr().
display,background_window);
7341 background_window = 0;
7346 static int _assign_xshm(Display *dpy, XErrorEvent *error) {
7348 cimg::X11attr().shm_enabled =
false;
7352 void _assign(
const unsigned int dimw,
const unsigned int dimh,
const char *
const ptitle=0,
7353 const unsigned int normalization_type=3,
7354 const bool fullscreen_flag=
false,
const bool closed_flag=
false) {
7357 const char *
const nptitle = ptitle?ptitle:
"";
7358 const unsigned int s = std::strlen(nptitle) + 1;
7359 char *tmp_title = s?
new char[
s]:0;
7360 if (s) std::memcpy(tmp_title,nptitle,s*
sizeof(
char));
7366 if (!cimg::X11attr().
display) {
7367 static bool xinit_threads =
false;
7368 if (!xinit_threads) { XInitThreads(); xinit_threads =
true; }
7369 cimg::X11attr().nb_wins = 0;
7370 cimg::X11attr().display = XOpenDisplay((std::getenv(
"DISPLAY")?std::getenv(
"DISPLAY"):
":0.0"));
7372 throw CImgDisplayException(
"CImgDisplay::_create_window() : Cannot open X11 display");
7373 cimg::X11attr().nb_bits = DefaultDepth(cimg::X11attr().
display, DefaultScreen(cimg::X11attr().
display));
7374 if (cimg::X11attr().nb_bits!=8 && cimg::X11attr().nb_bits!=16 && cimg::X11attr().nb_bits!=24 && cimg::X11attr().nb_bits!=32)
7375 throw CImgDisplayException(
"CImgDisplay::_create_window() : %u bits mode is not supported "
7376 "(only 8, 16, 24 and 32 bits modes are supported)",cimg::X11attr().nb_bits);
7377 cimg::X11attr().gc =
new GC;
7378 *cimg::X11attr().gc = DefaultGC(cimg::X11attr().
display,DefaultScreen(cimg::X11attr().
display));
7379 Visual *visual = DefaultVisual(cimg::X11attr().
display,DefaultScreen(cimg::X11attr().
display));
7380 XVisualInfo vtemplate;
7381 vtemplate.visualid = XVisualIDFromVisual(visual);
7383 XVisualInfo *vinfo = XGetVisualInfo(cimg::X11attr().
display,VisualIDMask,&vtemplate,&nb_visuals);
7384 if (vinfo && vinfo->red_mask<vinfo->blue_mask) cimg::X11attr().blue_first =
true;
7385 cimg::X11attr().byte_order = ImageByteOrder(cimg::X11attr().
display);
7387 XLockDisplay(cimg::X11attr().
display);
7388 cimg::X11attr().event_thread =
new pthread_t;
7389 pthread_create(cimg::X11attr().event_thread,0,_events_thread,0);
7390 }
else XLockDisplay(cimg::X11attr().
display);
7406 XSetWindowAttributes winattr;
7407 winattr.override_redirect = True;
7408 window = XCreateWindow(cimg::X11attr().
display,
7409 RootWindow(cimg::X11attr().
display,DefaultScreen(cimg::X11attr().
display)),
7411 width,
height,0,0,InputOutput,CopyFromParent,CWOverrideRedirect,&winattr);
7413 window = XCreateSimpleWindow(cimg::X11attr().
display,
7414 RootWindow(cimg::X11attr().
display,DefaultScreen(cimg::X11attr().
display)),
7417 if (cimg::X11attr().nb_bits==8) {
7418 colormap = XCreateColormap(cimg::X11attr().
display,window,DefaultVisual(cimg::X11attr().
display,
7419 DefaultScreen(cimg::X11attr().
display)),AllocAll);
7420 _set_colormap(colormap,3);
7421 XSetWindowColormap(cimg::X11attr().
display,window,colormap);
7427 const unsigned int bufsize =
width*
height*(cimg::X11attr().nb_bits==8?1:(cimg::X11attr().nb_bits==16?2:4));
7428 #ifdef cimg_use_xshm
7430 if (XShmQueryExtension(cimg::X11attr().
display)) {
7431 shminfo =
new XShmSegmentInfo;
7432 image = XShmCreateImage(cimg::X11attr().
display,DefaultVisual(cimg::X11attr().
display,DefaultScreen(cimg::X11attr().
display)),
7433 cimg::X11attr().nb_bits,ZPixmap,0,shminfo,
width,
height);
7438 shminfo->shmid = shmget(IPC_PRIVATE, bufsize, IPC_CREAT | 0777);
7439 if (shminfo->shmid==-1) {
7440 XDestroyImage(image);
7444 shminfo->shmaddr = image->data = (
char*)(data = shmat(shminfo->shmid,0,0));
7445 if (shminfo->shmaddr==(
char*)-1) {
7446 shmctl(shminfo->shmid,IPC_RMID,0);
7447 XDestroyImage(image);
7451 shminfo->readOnly = False;
7452 cimg::X11attr().shm_enabled =
true;
7453 XErrorHandler oldXErrorHandler = XSetErrorHandler(_assign_xshm);
7454 XShmAttach(cimg::X11attr().
display, shminfo);
7455 XSync(cimg::X11attr().
display, False);
7456 XSetErrorHandler(oldXErrorHandler);
7457 if (!cimg::X11attr().shm_enabled) {
7458 shmdt(shminfo->shmaddr);
7459 shmctl(shminfo->shmid,IPC_RMID,0);
7460 XDestroyImage(image);
7471 data = std::malloc(bufsize);
7472 image = XCreateImage(cimg::X11attr().
display,DefaultVisual(cimg::X11attr().
display,DefaultScreen(cimg::X11attr().
display)),
7473 cimg::X11attr().nb_bits,ZPixmap,0,(
char*)data,
width,
height,8,0);
7476 wm_delete_window = XInternAtom(cimg::X11attr().
display,
"WM_DELETE_WINDOW", False);
7477 wm_delete_protocol = XInternAtom(cimg::X11attr().
display,
"WM_PROTOCOLS", False);
7478 XSetWMProtocols(cimg::X11attr().
display, window, &wm_delete_window, 1);
7479 XSelectInput(cimg::X11attr().
display,window,
7480 ExposureMask | StructureNotifyMask | ButtonPressMask | KeyPressMask | PointerMotionMask |
7481 EnterWindowMask | LeaveWindowMask | ButtonReleaseMask | KeyReleaseMask);
7482 if (
is_fullscreen) XGrabKeyboard(cimg::X11attr().
display, window, True, GrabModeAsync, GrabModeAsync, CurrentTime);
7483 cimg::X11attr().wins[cimg::X11attr().nb_wins++]=
this;
7485 XUnlockDisplay(cimg::X11attr().
display);
7490 XLockDisplay(cimg::X11attr().
display);
7494 for (i = 0; i<cimg::X11attr().nb_wins && cimg::X11attr().wins[
i]!=
this; ++
i) {}
7495 for (; i<cimg::X11attr().nb_wins-1; ++
i) cimg::X11attr().wins[
i] = cimg::X11attr().wins[i+1];
7496 --cimg::X11attr().nb_wins;
7500 XDestroyWindow(cimg::X11attr().
display,window);
7502 #ifdef cimg_use_xshm
7504 XShmDetach(cimg::X11attr().
display, shminfo);
7505 XDestroyImage(image);
7506 shmdt(shminfo->shmaddr);
7507 shmctl(shminfo->shmid,IPC_RMID,0);
7512 XDestroyImage(image);
7513 data = 0; image = 0;
7514 if (cimg::X11attr().nb_bits==8) XFreeColormap(cimg::X11attr().
display,colormap);
7516 XSync(cimg::X11attr().
display, False);
7529 XUnlockDisplay(cimg::X11attr().
display);
7552 const unsigned int normalization_type=3,
7553 const bool fullscreen_flag=
false,
const bool closed_flag=
false) {
7554 if (!dimw || !dimh)
return assign();
7555 _assign(dimw,dimh,
title,normalization_type,fullscreen_flag,closed_flag);
7557 std::memset(data,0,(cimg::X11attr().nb_bits==8?
sizeof(
unsigned char):
7558 (cimg::X11attr().nb_bits==16?
sizeof(
unsigned short):
sizeof(
unsigned int)))*
width*
height);
7562 template<
typename T>
7564 const unsigned int normalization_type=3,
7565 const bool fullscreen_flag=
false,
const bool closed_flag=
false) {
7566 if (!img)
return assign();
7568 const CImg<T>& nimg = (img.depth==1)?img:(tmp=img.get_projections2d(img.width/2,img.height/2,img.depth/2));
7569 _assign(nimg.width,nimg.height,
title,normalization_type,fullscreen_flag,closed_flag);
7574 template<
typename T>
7576 const unsigned int normalization_type=3,
7577 const bool fullscreen_flag=
false,
const bool closed_flag=
false) {
7578 if (!list)
return assign();
7580 const CImg<T> img = list>
'x', &nimg = (img.depth==1)?img:(tmp=img.get_projections2d(img.width/2,img.height/2,img.depth/2));
7581 _assign(nimg.width,nimg.height,
title,normalization_type,fullscreen_flag,closed_flag);
7587 if (!disp)
return assign();
7588 _assign(disp.width,disp.height,disp.title,disp.normalization,disp.is_fullscreen,disp.is_closed);
7589 std::memcpy(data,disp.data,(cimg::X11attr().nb_bits==8?
sizeof(
unsigned char):
7590 cimg::X11attr().nb_bits==16?
sizeof(
unsigned short):
7595 CImgDisplay&
resize(
const int nwidth,
const int nheight,
const bool redraw=
true) {
7596 if (!nwidth || !nheight || (
is_empty() && (nwidth<0 || nheight<0)))
return assign();
7599 tmpdimx = (nwidth>0)?nwidth:(-nwidth*
width/100),
7600 tmpdimy = (nheight>0)?nheight:(-nheight*
height/100),
7601 dimx = tmpdimx?tmpdimx:1,
7602 dimy = tmpdimy?tmpdimy:1;
7603 XLockDisplay(cimg::X11attr().
display);
7606 case 8 : {
unsigned char foo = 0; _resize(foo,
dimx,
dimy,redraw); }
break;
7607 case 16 : {
unsigned short foo = 0; _resize(foo,
dimx,
dimy,redraw); }
break;
7608 default : {
unsigned int foo = 0; _resize(foo,
dimx,
dimy,redraw); }
7612 XUnlockDisplay(cimg::X11attr().
display);
7614 if (redraw)
return paint();
7621 const unsigned int bufsize =
width*
height*(cimg::X11attr().nb_bits==8?1:(cimg::X11attr().nb_bits==16?2:4));
7622 void *odata = std::malloc(bufsize);
7623 std::memcpy(odata,data,bufsize);
7625 std::memcpy(data,odata,bufsize);
7627 return paint(
false);
7634 XLockDisplay(cimg::X11attr().
display);
7638 XUnlockDisplay(cimg::X11attr().
display);
7646 XLockDisplay(cimg::X11attr().
display);
7648 XUnmapWindow(cimg::X11attr().
display,window);
7651 XUnlockDisplay(cimg::X11attr().
display);
7659 XLockDisplay(cimg::X11attr().
display);
7660 XMoveWindow(cimg::X11attr().
display,window,posx,posy);
7663 XUnlockDisplay(cimg::X11attr().
display);
7669 XLockDisplay(cimg::X11attr().
display);
7670 XUndefineCursor(cimg::X11attr().
display,window);
7671 XUnlockDisplay(cimg::X11attr().
display);
7677 XLockDisplay(cimg::X11attr().
display);
7678 const char pix_data[8] = { 0 };
7680 col.red = col.green = col.blue = 0;
7681 Pixmap pix = XCreateBitmapFromData(cimg::X11attr().
display,window,pix_data,8,8);
7682 Cursor cur = XCreatePixmapCursor(cimg::X11attr().
display,pix,pix,&col,&col,0,0);
7683 XFreePixmap(cimg::X11attr().
display,pix);
7684 XDefineCursor(cimg::X11attr().
display,window,cur);
7685 XUnlockDisplay(cimg::X11attr().
display);
7691 XLockDisplay(cimg::X11attr().
display);
7693 XWarpPointer(cimg::X11attr().
display,0L,window,0,0,0,0,posx,posy);
7696 XSync(cimg::X11attr().
display, False);
7697 XUnlockDisplay(cimg::X11attr().
display);
7703 char tmp[1024] = { 0 };
7705 va_start(ap, format);
7706 std::vsprintf(tmp,format,ap);
7709 const unsigned int s = std::strlen(tmp) + 1;
7711 std::memcpy(
title,tmp,s*
sizeof(
char));
7712 XLockDisplay(cimg::X11attr().
display);
7713 XStoreName(cimg::X11attr().
display,window,tmp);
7714 XUnlockDisplay(cimg::X11attr().
display);
7718 template<
typename T>
7721 throw CImgArgumentException(
"CImgDisplay::display() : Cannot display empty image.");
7728 XLockDisplay(cimg::X11attr().
display);
7729 _paint(wait_expose);
7730 XUnlockDisplay(cimg::X11attr().
display);
7734 template<
typename T>
7738 throw CImgArgumentException(
"CImgDisplay::_render_image() : Specified input image (%u,%u,%u,%u,%p) is empty.",
7739 img.width,img.height,img.depth,img.dim,img.data);
7740 if (img.depth!=1)
return render(img.get_projections2d(img.width/2,img.height/2,img.depth/2));
7742 if (cimg::X11attr().nb_bits==8 && !flag8 && img.dim==3) {
7743 typedef typename cimg::last<T,unsigned char>::type uchar;
7745 return render(img.get_index(default_palette,
true,
false));
7750 *data2 = (img.dim>1)?img.ptr(0,0,0,1):data1,
7751 *data3 = (img.dim>2)?img.ptr(0,0,0,2):data1;
7753 if (cimg::X11attr().blue_first)
cimg::swap(data1,data3);
7754 XLockDisplay(cimg::X11attr().
display);
7758 switch (cimg::X11attr().nb_bits) {
7760 _set_colormap(colormap,img.dim);
7761 unsigned char *
const ndata = (img.width==
width && img.height==
height)?(
unsigned char*)data:
new unsigned char[img.width*img.height];
7762 unsigned char *ptrd = (
unsigned char*)ndata;
7764 case 1 :
for (
unsigned int xy = img.width*img.height; xy>0; --xy) (*ptrd++) = (
unsigned char)*(data1++);
7766 case 2 :
for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7767 const unsigned char R = (
unsigned char)*(data1++), G = (
unsigned char)*(data2++);
7768 (*ptrd++) = (R&0xf0) | (G>>4);
7770 default :
for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7771 const unsigned char R = (
unsigned char)*(data1++), G = (
unsigned char)*(data2++), B = (
unsigned char)*(data3++);
7772 (*ptrd++) = (R&0xe0) | ((G>>5)<<2) | (B>>6);
7778 unsigned short *
const ndata = (img.width==
width && img.height==
height)?(
unsigned short*)data:
new unsigned short[img.width*img.height];
7779 unsigned char *ptrd = (
unsigned char*)ndata;
7780 const unsigned int M = 248;
7783 if (cimg::X11attr().byte_order)
for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7784 const unsigned char val = (
unsigned char)*(data1++), G = val>>2;
7785 *(ptrd++) = (val&M) | (G>>3);
7786 *(ptrd++) = (G<<5) | (G>>1);
7787 }
else for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7788 const unsigned char val = (
unsigned char)*(data1++), G = val>>2;
7789 *(ptrd++) = (G<<5) | (G>>1);
7790 *(ptrd++) = (val&M) | (G>>3);
7794 if (cimg::X11attr().byte_order)
for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7795 const unsigned char G = (
unsigned char)*(data2++)>>2;
7796 *(ptrd++) = ((
unsigned char)*(data1++)&M) | (G>>3);
7798 }
else for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7799 const unsigned char G = (
unsigned char)*(data2++)>>2;
7801 *(ptrd++) = ((
unsigned char)*(data1++)&M) | (G>>3);
7805 if (cimg::X11attr().byte_order)
for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7806 const unsigned char G = (
unsigned char)*(data2++)>>2;
7807 *(ptrd++) = ((
unsigned char)*(data1++)&M) | (G>>3);
7808 *(ptrd++) = (G<<5) | ((
unsigned char)*(data3++)>>3);
7809 }
else for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7810 const unsigned char G = (
unsigned char)*(data2++)>>2;
7811 *(ptrd++) = (G<<5) | ((
unsigned char)*(data3++)>>3);
7812 *(ptrd++) = ((
unsigned char)*(data1++)&M) | (G>>3);
7818 unsigned int *
const ndata = (img.width==
width && img.height==
height)?(
unsigned int*)data:
new unsigned int[img.width*img.height];
7819 if (
sizeof(
int)==4) {
7820 unsigned int *ptrd = ndata;
7824 for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7825 const unsigned char val = (
unsigned char)*(data1++);
7826 *(ptrd++) = (val<<16) | (val<<8) | val;
7829 for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7830 const unsigned char val = (
unsigned char)*(data1++)<<8;
7831 *(ptrd++) = (val<<16) | (val<<8) | val;
7836 for (
unsigned int xy = img.width*img.height; xy>0; --xy)
7837 *(ptrd++) = ((
unsigned char)*(data1++)<<16) | ((
unsigned char)*(data2++)<<8);
7839 for (
unsigned int xy = img.width*img.height; xy>0; --xy)
7840 *(ptrd++) = ((
unsigned char)*(data2++)<<16) | ((
unsigned char)*(data1++)<<8);
7844 for (
unsigned int xy = img.width*img.height; xy>0; --xy)
7845 *(ptrd++) = ((
unsigned char)*(data1++)<<16) | ((
unsigned char)*(data2++)<<8) | (
unsigned char)*(data3++);
7847 for (
unsigned int xy = img.width*img.height; xy>0; --xy)
7848 *(ptrd++) = ((
unsigned char)*(data3++)<<24) | ((
unsigned char)*(data2++)<<16) | ((
unsigned char)*(data1++)<<8);
7851 unsigned char *ptrd = (
unsigned char*)ndata;
7854 if (cimg::X11attr().byte_order)
for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7856 *(ptrd++) = (
unsigned char)*(data1++);
7859 }
else for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7862 *(ptrd++) = (
unsigned char)*(data1++);
7867 if (cimg::X11attr().byte_order)
cimg::swap(data1,data2);
7868 for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7870 *(ptrd++) = (
unsigned char)*(data2++);
7871 *(ptrd++) = (
unsigned char)*(data1++);
7876 if (cimg::X11attr().byte_order)
for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7878 *(ptrd++) = (
unsigned char)*(data1++);
7879 *(ptrd++) = (
unsigned char)*(data2++);
7880 *(ptrd++) = (
unsigned char)*(data3++);
7881 }
else for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7882 *(ptrd++) = (
unsigned char)*(data3++);
7883 *(ptrd++) = (
unsigned char)*(data2++);
7884 *(ptrd++) = (
unsigned char)*(data1++);
7894 if (cimg::type<T>::is_float())
min = (float)img.minmax(
max);
7897 const float delta =
max-
min, mm = delta?delta:1.0f;
7898 switch (cimg::X11attr().nb_bits) {
7900 _set_colormap(colormap,img.dim);
7901 unsigned char *
const ndata = (img.width==
width && img.height==
height)?(
unsigned char*)data:
new unsigned char[img.width*img.height];
7902 unsigned char *ptrd = (
unsigned char*)ndata;
7904 case 1 :
for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7905 const unsigned char R = (
unsigned char)(255*(*(data1++)-
min)/mm);
7908 case 2 :
for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7910 R = (
unsigned char)(255*(*(data1++)-
min)/mm),
7911 G = (
unsigned char)(255*(*(data2++)-
min)/mm);
7912 (*ptrd++) = (R&0xf0) | (G>>4);
7915 for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7917 R = (
unsigned char)(255*(*(data1++)-
min)/mm),
7918 G = (
unsigned char)(255*(*(data2++)-
min)/mm),
7919 B = (
unsigned char)(255*(*(data3++)-
min)/mm);
7920 *(ptrd++) = (R&0xe0) | ((G>>5)<<2) | (B>>6);
7926 unsigned short *
const ndata = (img.width==
width && img.height==
height)?(
unsigned short*)data:
new unsigned short[img.width*img.height];
7927 unsigned char *ptrd = (
unsigned char*)ndata;
7928 const unsigned int M = 248;
7931 if (cimg::X11attr().byte_order)
for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7932 const unsigned char val = (
unsigned char)(255*(*(data1++)-
min)/mm), G = val>>2;
7933 *(ptrd++) = (val&M) | (G>>3);
7934 *(ptrd++) = (G<<5) | (val>>3);
7935 }
else for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7936 const unsigned char val = (
unsigned char)(255*(*(data1++)-
min)/mm), G = val>>2;
7937 *(ptrd++) = (G<<5) | (val>>3);
7938 *(ptrd++) = (val&M) | (G>>3);
7942 if (cimg::X11attr().byte_order)
for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7943 const unsigned char G = (
unsigned char)(255*(*(data2++)-
min)/mm)>>2;
7944 *(ptrd++) = ((
unsigned char)(255*(*(data1++)-min)/mm)&M) | (G>>3);
7946 }
else for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7947 const unsigned char G = (
unsigned char)(255*(*(data2++)-
min)/mm)>>2;
7949 *(ptrd++) = ((
unsigned char)(255*(*(data1++)-min)/mm)&M) | (G>>3);
7953 if (cimg::X11attr().byte_order)
for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7954 const unsigned char G = (
unsigned char)(255*(*(data2++)-
min)/mm)>>2;
7955 *(ptrd++) = ((
unsigned char)(255*(*(data1++)-min)/mm)&M) | (G>>3);
7956 *(ptrd++) = (G<<5) | ((
unsigned char)(255*(*(data3++)-
min)/mm)>>3);
7957 }
else for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7958 const unsigned char G = (
unsigned char)(255*(*(data2++)-
min)/mm)>>2;
7959 *(ptrd++) = (G<<5) | ((
unsigned char)(255*(*(data3++)-
min)/mm)>>3);
7960 *(ptrd++) = ((
unsigned char)(255*(*(data1++)-min)/mm)&M) | (G>>3);
7966 unsigned int *
const ndata = (img.width==
width && img.height==
height)?(
unsigned int*)data:
new unsigned int[img.width*img.height];
7967 if (
sizeof(
int)==4) {
7968 unsigned int *ptrd = ndata;
7972 for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7973 const unsigned char val = (
unsigned char)(255*(*(data1++)-
min)/mm);
7974 *(ptrd++) = (val<<16) | (val<<8) | val;
7977 for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
7978 const unsigned char val = (
unsigned char)(255*(*(data1++)-
min)/mm);
7979 *(ptrd++) = (val<<24) | (val<<16) | (val<<8);
7984 for (
unsigned int xy = img.width*img.height; xy>0; --xy)
7986 ((
unsigned char)(255*(*(data1++)-min)/mm)<<16) |
7987 ((
unsigned char)(255*(*(data2++)-
min)/mm)<<8);
7989 for (
unsigned int xy = img.width*img.height; xy>0; --xy)
7991 ((
unsigned char)(255*(*(data2++)-min)/mm)<<16) |
7992 ((
unsigned char)(255*(*(data1++)-
min)/mm)<<8);
7996 for (
unsigned int xy = img.width*img.height; xy>0; --xy)
7998 ((
unsigned char)(255*(*(data1++)-min)/mm)<<16) |
7999 ((
unsigned char)(255*(*(data2++)-
min)/mm)<<8) |
8000 (
unsigned char)(255*(*(data3++)-min)/mm);
8002 for (
unsigned int xy = img.width*img.height; xy>0; --xy)
8004 ((
unsigned char)(255*(*(data3++)-min)/mm)<<24) |
8005 ((
unsigned char)(255*(*(data2++)-
min)/mm)<<16) |
8006 ((
unsigned char)(255*(*(data1++)-min)/mm)<<8);
8009 unsigned char *ptrd = (
unsigned char*)ndata;
8012 if (cimg::X11attr().byte_order)
for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
8013 const unsigned char val = (
unsigned char)(255*(*(data1++)-
min)/mm);
8018 }
else for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
8019 const unsigned char val = (
unsigned char)(255*(*(data1++)-
min)/mm);
8027 if (cimg::X11attr().byte_order)
cimg::swap(data1,data2);
8028 for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
8030 (*ptrd++) = (
unsigned char)(255*(*(data2++)-min)/mm);
8031 (*ptrd++) = (
unsigned char)(255*(*(data1++)-min)/mm);
8036 if (cimg::X11attr().byte_order)
for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
8038 (*ptrd++) = (
unsigned char)(255*(*(data1++)-min)/mm);
8039 (*ptrd++) = (
unsigned char)(255*(*(data2++)-min)/mm);
8040 (*ptrd++) = (
unsigned char)(255*(*(data3++)-min)/mm);
8041 }
else for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
8042 (*ptrd++) = (
unsigned char)(255*(*(data3++)-min)/mm);
8043 (*ptrd++) = (
unsigned char)(255*(*(data2++)-min)/mm);
8044 (*ptrd++) = (
unsigned char)(255*(*(data1++)-min)/mm);
8053 XUnlockDisplay(cimg::X11attr().
display);
8057 template<
typename T>
8063 *data1 = img.ptr(0,0,0,0),
8064 *data2 = img.ptr(0,0,0,1),
8065 *data3 = img.ptr(0,0,0,2);
8066 if (cimg::X11attr().blue_first)
cimg::swap(data1,data3);
8067 switch (cimg::X11attr().nb_bits) {
8069 unsigned char *ptrs = (
unsigned char*)data;
8070 for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
8071 const unsigned char val = *(ptrs++);
8072 *(data1++) = val&0xe0;
8073 *(data2++) = (val&0x1c)<<3;
8074 *(data3++) = val<<6;
8078 unsigned char *ptrs = (
unsigned char*)data;
8079 if (cimg::X11attr().byte_order)
for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
8080 const unsigned char val0 = *(ptrs++), val1 = *(ptrs++);
8081 *(data1++) = val0&0xf8;
8082 *(data2++) = (val0<<5) | ((val1&0xe0)>>5);
8083 *(data3++) = val1<<3;
8084 }
else for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
8085 const unsigned short val0 = *(ptrs++), val1 = *(ptrs++);
8086 *(data1++) = val1&0xf8;
8087 *(data2++) = (val1<<5) | ((val0&0xe0)>>5);
8088 *(data3++) = val0<<3;
8092 unsigned char *ptrs = (
unsigned char*)data;
8093 if (cimg::X11attr().byte_order)
for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
8095 *(data1++) = *(ptrs++);
8096 *(data2++) = *(ptrs++);
8097 *(data3++) = *(ptrs++);
8098 }
else for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
8099 *(data3++) = *(ptrs++);
8100 *(data2++) = *(ptrs++);
8101 *(data1++) = *(ptrs++);
8112 #elif cimg_display==2
8113 CLIENTCREATESTRUCT ccs;
8118 HWND background_window;
8123 bool mouse_tracking;
8124 bool visible_cursor;
8128 mode.dmSize =
sizeof(DEVMODE);
8129 mode.dmDriverExtra = 0;
8130 EnumDisplaySettings(0,ENUM_CURRENT_SETTINGS,&mode);
8131 return mode.dmPelsWidth;
8136 mode.dmSize =
sizeof(DEVMODE);
8137 mode.dmDriverExtra = 0;
8138 EnumDisplaySettings(0,ENUM_CURRENT_SETTINGS,&mode);
8139 return mode.dmPelsHeight;
8143 WaitForSingleObject(cimg::Win32attr().wait_event,INFINITE);
8146 static LRESULT APIENTRY _handle_events(HWND window,UINT msg,WPARAM wParam,LPARAM lParam) {
8156 disp->mouse_x = disp->mouse_y = -1;
8157 disp->window_x = disp->window_y = 0;
8159 std::memmove((
void*)(disp->buttons+1),(
void*)disp->buttons,512-1);
8163 std::memmove((
void*)(disp->keys+1),(
void*)disp->keys,512-1);
8166 if (disp->released_key) { std::memmove((
void*)(disp->released_keys+1),(
void*)disp->released_keys,512-1); disp->released_key = 0; }
8167 disp->is_closed =
true;
8168 ReleaseMutex(disp->mutex);
8169 ShowWindow(disp->window,SW_HIDE);
8170 disp->is_event =
true;
8171 SetEvent(cimg::Win32attr().wait_event);
8174 while (PeekMessage(&st_msg,window,WM_SIZE,WM_SIZE,PM_REMOVE)) {}
8175 WaitForSingleObject(disp->mutex,INFINITE);
8176 const unsigned int nw = LOWORD(lParam),nh = HIWORD(lParam);
8177 if (nw && nh && (nw!=disp->width || nh!=disp->height)) {
8178 disp->window_width = nw;
8179 disp->window_height = nh;
8180 disp->mouse_x = disp->mouse_y = -1;
8181 disp->is_resized = disp->is_event =
true;
8182 SetEvent(cimg::Win32attr().wait_event);
8184 ReleaseMutex(disp->mutex);
8187 while (PeekMessage(&st_msg,window,WM_SIZE,WM_SIZE,PM_REMOVE)) {}
8188 WaitForSingleObject(disp->mutex,INFINITE);
8189 const int nx = (int)(
short)(LOWORD(lParam)), ny = (
int)(short)(HIWORD(lParam));
8190 if (nx!=disp->window_x || ny!=disp->window_y) {
8191 disp->window_x = nx;
8192 disp->window_y = ny;
8193 disp->is_moved = disp->is_event =
true;
8194 SetEvent(cimg::Win32attr().wait_event);
8196 ReleaseMutex(disp->mutex);
8202 disp->_update_iskey((
unsigned int)wParam,
true);
8203 if (disp->key) std::memmove((
void*)(disp->keys+1),(
void*)disp->keys,512-1);
8204 disp->key = (
unsigned int)wParam;
8205 if (disp->released_key) { std::memmove((
void*)(disp->released_keys+1),(
void*)disp->released_keys,512-1); disp->released_key = 0; }
8206 disp->is_event =
true;
8207 SetEvent(cimg::Win32attr().wait_event);
8209 case WM_MOUSEMOVE : {
8210 while (PeekMessage(&st_msg,window,WM_MOUSEMOVE,WM_MOUSEMOVE,PM_REMOVE)) {}
8211 disp->mouse_x = LOWORD(lParam);
8212 disp->mouse_y = HIWORD(lParam);
8213 #if (_WIN32_WINNT>=0x0400) && !defined(NOTRACKMOUSEEVENT)
8214 if (!disp->mouse_tracking) {
8215 TRACKMOUSEEVENT tme;
8216 tme.cbSize =
sizeof(TRACKMOUSEEVENT);
8217 tme.dwFlags = TME_LEAVE;
8218 tme.hwndTrack = disp->window;
8219 if (TrackMouseEvent(&tme)) disp->mouse_tracking =
true;
8222 if (disp->mouse_x<0 || disp->mouse_y<0 || disp->mouse_x>=disp->dimx() || disp->mouse_y>=disp->dimy())
8223 disp->mouse_x = disp->mouse_y = -1;
8224 disp->is_event =
true;
8225 SetEvent(cimg::Win32attr().wait_event);
8227 case WM_MOUSELEAVE : {
8228 disp->mouse_x = disp->mouse_y = -1;
8229 disp->mouse_tracking =
false;
8231 case WM_LBUTTONDOWN :
8232 std::memmove((
void*)(disp->buttons+1),(
void*)disp->buttons,512-1);
8234 disp->is_event =
true;
8235 SetEvent(cimg::Win32attr().wait_event);
8237 case WM_RBUTTONDOWN :
8238 std::memmove((
void*)(disp->buttons+1),(
void*)disp->buttons,512-1);
8240 disp->is_event =
true;
8241 SetEvent(cimg::Win32attr().wait_event);
8243 case WM_MBUTTONDOWN :
8244 std::memmove((
void*)(disp->buttons+1),(
void*)disp->buttons,512-1);
8246 disp->is_event =
true;
8247 SetEvent(cimg::Win32attr().wait_event);
8250 disp->wheel+=(int)((
short)HIWORD(wParam))/120;
8251 disp->is_event =
true;
8252 SetEvent(cimg::Win32attr().wait_event);
8254 disp->_update_iskey((
unsigned int)wParam,
false);
8255 if (disp->key) { std::memmove((
void*)(disp->keys+1),(
void*)disp->keys,512-1); disp->key = 0; }
8256 if (disp->released_key) std::memmove((
void*)(disp->released_keys+1),(
void*)disp->released_keys,512-1);
8257 disp->released_key = (
unsigned int)wParam;
8258 disp->is_event =
true;
8259 SetEvent(cimg::Win32attr().wait_event);
8262 std::memmove((
void*)(disp->buttons+1),(
void*)disp->buttons,512-1);
8264 disp->is_event =
true;
8265 SetEvent(cimg::Win32attr().wait_event);
8268 std::memmove((
void*)(disp->buttons+1),(
void*)disp->buttons,512-1);
8270 disp->is_event =
true;
8271 SetEvent(cimg::Win32attr().wait_event);
8274 std::memmove((
void*)(disp->buttons+1),(
void*)disp->buttons,512-1);
8276 disp->is_event =
true;
8277 SetEvent(cimg::Win32attr().wait_event);
8280 if (disp->visible_cursor) ShowCursor(
TRUE);
8281 else ShowCursor(
FALSE);
8284 return DefWindowProc(window,msg,wParam,lParam);
8287 static DWORD WINAPI _events_thread(
void* arg) {
8289 const char *
title = (
const char*)(((
void**)arg)[1]);
8291 delete[] (
void**)arg;
8292 disp->bmi.bmiHeader.biSize =
sizeof(BITMAPINFOHEADER);
8293 disp->bmi.bmiHeader.biWidth = disp->width;
8294 disp->bmi.bmiHeader.biHeight = -(int)disp->height;
8295 disp->bmi.bmiHeader.biPlanes = 1;
8296 disp->bmi.bmiHeader.biBitCount = 32;
8297 disp->bmi.bmiHeader.biCompression = BI_RGB;
8298 disp->bmi.bmiHeader.biSizeImage = 0;
8299 disp->bmi.bmiHeader.biXPelsPerMeter = 1;
8300 disp->bmi.bmiHeader.biYPelsPerMeter = 1;
8301 disp->bmi.bmiHeader.biClrUsed = 0;
8302 disp->bmi.bmiHeader.biClrImportant = 0;
8303 disp->data =
new unsigned int[disp->width*disp->height];
8304 if (!disp->is_fullscreen) {
8306 rect.left = rect.top = 0; rect.right = disp->width-1; rect.bottom = disp->height-1;
8307 AdjustWindowRect(&rect,WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
false);
8308 const int border1 = (rect.right-rect.left+1-disp->width)/2, border2 = rect.bottom-rect.top+1-disp->height-border1;
8309 disp->window = CreateWindowA(
"MDICLIENT",title?title:
" ",
8310 WS_OVERLAPPEDWINDOW | (disp->is_closed?0:WS_VISIBLE), CW_USEDEFAULT,CW_USEDEFAULT,
8311 disp->width + 2*border1, disp->height + border1 + border2,
8312 0,0,0,&(disp->ccs));
8313 if (!disp->is_closed) {
8314 GetWindowRect(disp->window,&rect);
8315 disp->window_x = rect.left + border1;
8316 disp->window_y = rect.top + border2;
8317 }
else disp->window_x = disp->window_y = 0;
8320 disp->window = CreateWindowA(
"MDICLIENT",title?title:
" ",
8321 WS_POPUP | (disp->is_closed?0:WS_VISIBLE), (sx-disp->width)/2, (sy-disp->height)/2,
8322 disp->width,disp->height,0,0,0,&(disp->ccs));
8323 disp->window_x = disp->window_y = 0;
8325 SetForegroundWindow(disp->window);
8326 disp->hdc = GetDC(disp->window);
8327 disp->window_width = disp->width;
8328 disp->window_height = disp->height;
8331 SetWindowLongPtr(disp->window,GWLP_USERDATA,(LONG_PTR)disp);
8332 SetWindowLongPtr(disp->window,GWLP_WNDPROC,(LONG_PTR)_handle_events);
8334 SetWindowLong(disp->window,GWL_USERDATA,(LONG)disp);
8335 SetWindowLong(disp->window,GWL_WNDPROC,(LONG)_handle_events);
8337 SetEvent(disp->created);
8338 while (GetMessage(&msg,0,0,0)) DispatchMessage(&msg);
8345 rect.left = rect.top = 0; rect.right =
width-1; rect.bottom =
height-1;
8346 AdjustWindowRect(&rect,WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
false);
8347 const int border1 = (rect.right-rect.left+1-
width)/2, border2 = rect.bottom-rect.top+1-
height-border1;
8348 GetWindowRect(window,&rect);
8355 void _init_fullscreen() {
8356 background_window = 0;
8359 unsigned int imode = 0, ibest = 0, bestbpp = 0, bw = ~0U, bh = ~0U;
8360 for (mode.dmSize =
sizeof(DEVMODE), mode.dmDriverExtra = 0; EnumDisplaySettings(0,imode,&mode); ++imode) {
8361 const unsigned int nw = mode.dmPelsWidth, nh = mode.dmPelsHeight;
8362 if (nw>=
width && nh>=
height && mode.dmBitsPerPel>=bestbpp && nw<=bw && nh<=bh) {
8363 bestbpp = mode.dmBitsPerPel;
8369 curr_mode.dmSize =
sizeof(DEVMODE); curr_mode.dmDriverExtra = 0;
8370 EnumDisplaySettings(0,ENUM_CURRENT_SETTINGS,&curr_mode);
8371 EnumDisplaySettings(0,ibest,&mode);
8372 ChangeDisplaySettings(&mode,0);
8373 }
else curr_mode.dmSize = 0;
8377 CLIENTCREATESTRUCT background_ccs;
8378 background_window = CreateWindowA(
"MDICLIENT",
"",WS_POPUP | WS_VISIBLE, 0,0,sx,sy,0,0,0,&background_ccs);
8379 SetForegroundWindow(background_window);
8381 }
else curr_mode.dmSize = 0;
8384 void _desinit_fullscreen() {
8386 if (background_window) DestroyWindow(background_window);
8387 background_window = 0;
8388 if (curr_mode.dmSize) ChangeDisplaySettings(&curr_mode,0);
8393 CImgDisplay& _assign(
const unsigned int dimw,
const unsigned int dimh,
const char *
const ptitle=0,
8394 const unsigned int normalization_type=3,
8395 const bool fullscreen_flag=
false,
const bool closed_flag=
false) {
8398 const char *
const nptitle = ptitle?ptitle:
"";
8399 const unsigned int s = std::strlen(nptitle) + 1;
8400 char *tmp_title = s?
new char[
s]:0;
8401 if (s) std::memcpy(tmp_title,nptitle,s*
sizeof(
char));
8413 visible_cursor =
true;
8414 mouse_tracking =
false;
8420 void *arg = (
void*)(
new void*[2]);
8421 ((
void**)arg)[0]=(
void*)
this;
8422 ((
void**)arg)[1]=(
void*)title;
8423 unsigned long ThreadID = 0;
8424 mutex = CreateMutex(0,
FALSE,0);
8426 thread = CreateThread(0,0,_events_thread,arg,0,&ThreadID);
8427 WaitForSingleObject(created,INFINITE);
8433 DestroyWindow(window);
8434 TerminateThread(thread,0);
8435 if (data)
delete[] data;
8436 if (title)
delete[]
title;
8448 CImgDisplay&
assign(
const unsigned int dimw,
const unsigned int dimh,
const char *title=0,
8449 const unsigned int normalization_type=3,
8450 const bool fullscreen_flag=
false,
const bool closed_flag=
false) {
8451 if (!dimw || !dimh)
return assign();
8452 _assign(dimw,dimh,title,normalization_type,fullscreen_flag,closed_flag);
8454 std::memset(data,0,
sizeof(
unsigned int)*
width*
height);
8458 template<
typename T>
8460 const unsigned int normalization_type=3,
8461 const bool fullscreen_flag=
false,
const bool closed_flag=
false) {
8462 if (!img)
return assign();
8464 const CImg<T>& nimg = (img.depth==1)?img:(tmp=img.get_projections2d(img.width/2,img.height/2,img.depth/2));
8465 _assign(nimg.width,nimg.height,title,normalization_type,fullscreen_flag,closed_flag);
8470 template<
typename T>
8472 const unsigned int normalization_type=3,
8473 const bool fullscreen_flag=
false,
const bool closed_flag=
false) {
8474 if (!list)
return assign();
8476 const CImg<T> img = list>
'x', &nimg = (img.depth==1)?img:(tmp=img.get_projections2d(img.width/2,img.height/2,img.depth/2));
8477 _assign(nimg.width,nimg.height,title,normalization_type,fullscreen_flag,closed_flag);
8483 if (!disp)
return assign();
8484 _assign(disp.width,disp.height,disp.title,disp.normalization,disp.is_fullscreen,disp.is_closed);
8485 std::memcpy(data,disp.data,
sizeof(
unsigned int)*
width*
height);
8489 CImgDisplay&
resize(
const int nwidth,
const int nheight,
const bool redraw=
true) {
8490 if (!nwidth || !nheight || (
is_empty() && (nwidth<0 || nheight<0)))
return assign();
8493 tmpdimx=(nwidth>0)?nwidth:(-nwidth*
width/100),
8494 tmpdimy=(nheight>0)?nheight:(-nheight*
height/100),
8495 dimx = tmpdimx?tmpdimx:1,
8496 dimy = tmpdimy?tmpdimy:1;
8498 RECT rect; rect.left = rect.top = 0; rect.right =
dimx-1; rect.bottom =
dimy-1;
8499 AdjustWindowRect(&rect,WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
false);
8500 const int cwidth = rect.right-rect.left+1, cheight = rect.bottom-rect.top+1;
8501 SetWindowPos(window,0,0,0,cwidth,cheight,SWP_NOMOVE | SWP_NOZORDER | SWP_NOCOPYBITS);
8504 unsigned int *ndata =
new unsigned int[
dimx*
dimy];
8506 else std::memset(ndata,0x80,
sizeof(
unsigned int)*
dimx*
dimy);
8509 bmi.bmiHeader.biWidth =
dimx;
8510 bmi.bmiHeader.biHeight = -(int)
dimy;
8517 if (redraw)
return paint();
8525 void *odata = std::malloc(bufsize);
8526 std::memcpy(odata,data,bufsize);
8528 std::memcpy(data,odata,bufsize);
8540 ShowWindow(window,SW_SHOW);
8541 _update_window_pos();
8550 ShowWindow(window,SW_HIDE);
8561 AdjustWindowRect(&rect,WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
false);
8562 const int border1 = (rect.right-rect.left+1-
width)/2, border2 = rect.bottom-rect.top+1-
height-border1;
8563 SetWindowPos(window,0,posx-border1,posy-border2,0,0,SWP_NOSIZE | SWP_NOZORDER);
8564 }
else SetWindowPos(window,0,posx,posy,0,0,SWP_NOSIZE | SWP_NOZORDER);
8573 visible_cursor =
true;
8575 SendMessage(window,WM_SETCURSOR,0,0);
8581 visible_cursor =
false;
8583 SendMessage(window,WM_SETCURSOR,0,0);
8589 _update_window_pos();
8598 char tmp[1024] = { 0 };
8600 va_start(ap, format);
8601 std::vsprintf(tmp,format,ap);
8603 if (title)
delete[]
title;
8604 const unsigned int s = std::strlen(tmp) + 1;
8605 title =
new char[
s];
8606 std::memcpy(title,tmp,s*
sizeof(
char));
8607 SetWindowTextA(window, tmp);
8611 template<
typename T>
8614 throw CImgArgumentException(
"CImgDisplay::display() : Cannot display empty image.");
8621 WaitForSingleObject(mutex,INFINITE);
8622 SetDIBitsToDevice(hdc,0,0,
width,
height,0,0,0,
height,data,&bmi,DIB_RGB_COLORS);
8623 ReleaseMutex(mutex);
8628 template<
typename T>
8632 throw CImgArgumentException(
"CImgDisplay::_render_image() : Specified input image (%u,%u,%u,%u,%p) is empty.",
8633 img.width,img.height,img.depth,img.dim,img.data);
8634 if (img.depth!=1)
return render(img.get_projections2d(img.width/2,img.height/2,img.depth/2));
8638 *data2 = (img.dim>=2)?img.ptr(0,0,0,1):data1,
8639 *data3 = (img.dim>=3)?img.ptr(0,0,0,2):data1;
8641 WaitForSingleObject(mutex,INFINITE);
8643 *
const ndata = (img.width==
width && img.height==
height)?data:
new unsigned int[img.width*img.height],
8650 for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
8651 const unsigned char val = (
unsigned char)*(data1++);
8652 *(ptrd++) = (val<<16) | (val<<8) | val;
8655 for (
unsigned int xy = img.width*img.height; xy>0; --xy)
8656 *(ptrd++) = ((
unsigned char)*(data1++)<<16) | ((
unsigned char)*(data2++)<<8);
8659 for (
unsigned int xy = img.width*img.height; xy>0; --xy)
8660 *(ptrd++) = ((
unsigned char)*(data1++)<<16) | ((
unsigned char)*(data2++)<<8) | (
unsigned char)*(data3++);
8665 if (cimg::type<T>::is_float()) min = (
float)img.minmax(
max);
8668 const float delta =
max-
min, mm = delta?delta:1.0f;
8671 for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
8672 const unsigned char val = (
unsigned char)(255*(*(data1++)-min)/mm);
8673 *(ptrd++) = (val<<16) | (val<<8) | val;
8676 for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
8678 R = (
unsigned char)(255*(*(data1++)-
min)/mm),
8679 G = (
unsigned char)(255*(*(data2++)-
min)/mm);
8680 *(ptrd++) = (R<<16) | (G<<8);
8683 for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
8685 R = (
unsigned char)(255*(*(data1++)-
min)/mm),
8686 G = (
unsigned char)(255*(*(data2++)-
min)/mm),
8687 B = (
unsigned char)(255*(*(data3++)-
min)/mm);
8688 *(ptrd++) = (R<<16) | (G<<8) | B;
8693 ReleaseMutex(mutex);
8697 template<
typename T>
8703 *data1 = img.ptr(0,0,0,0),
8704 *data2 = img.ptr(0,0,0,1),
8705 *data3 = img.ptr(0,0,0,2);
8706 unsigned int *ptrs = data;
8707 for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
8708 const unsigned int val = *(ptrs++);
8709 *(data1++) = (
unsigned char)(val>>16);
8710 *(data2++) = (
unsigned char)((val>>8)&0xFF);
8711 *(data3++) = (
unsigned char)(val&0xFF);
8719 #elif cimg_display==3
8721 WindowRef carbonWindow;
8722 MPCriticalRegionID paintCriticalRegion;
8723 CGColorSpaceRef csr;
8724 CGDataProviderRef dataProvider;
8725 CGImageRef imageRef;
8726 UInt32 lastKeyModifiers;
8730 COM_CREATEWINDOW = 0,
8740 } CImgCarbonQueryKind;
8743 struct CbSerializedQuery {
8745 CImgCarbonQueryKind kind;
8748 bool createFullScreenWindow;
8749 bool createClosedWindow;
8752 CbSerializedQuery(
CImgDisplay *s, CImgCarbonQueryKind
k):sender(s),kind(k),success(false) {}
8754 inline static CbSerializedQuery BuildReleaseWindowQuery(
CImgDisplay* sender) {
8755 return CbSerializedQuery(sender, COM_RELEASEWINDOW);
8757 inline static CbSerializedQuery BuildCreateWindowQuery(
CImgDisplay* sender,
const bool fullscreen,
const bool closed) {
8758 CbSerializedQuery
q(sender, COM_CREATEWINDOW);
8760 q.createClosedWindow = closed;
8763 inline static CbSerializedQuery BuildShowWindowQuery(
CImgDisplay* sender) {
8764 return CbSerializedQuery(sender, COM_SHOWWINDOW);
8766 inline static CbSerializedQuery BuildHideWindowQuery(
CImgDisplay* sender) {
8767 return CbSerializedQuery(sender, COM_HIDEWINDOW);
8769 inline static CbSerializedQuery BuildShowMouseQuery(
CImgDisplay* sender) {
8770 return CbSerializedQuery(sender, COM_SHOWMOUSE);
8772 inline static CbSerializedQuery BuildHideMouseQuery(
CImgDisplay* sender) {
8773 return CbSerializedQuery(sender, COM_HIDEMOUSE);
8775 inline static CbSerializedQuery BuildResizeWindowQuery(
CImgDisplay* sender,
const int x,
const int y,
bool update) {
8776 CbSerializedQuery
q(sender, COM_RESIZEWINDOW);
8781 inline static CbSerializedQuery BuildMoveWindowQuery(
CImgDisplay* sender,
const int x,
const int y) {
8782 CbSerializedQuery
q(sender, COM_MOVEWINDOW);
8786 inline static CbSerializedQuery BuildSetWindowTitleQuery(
CImgDisplay* sender,
char* c) {
8787 CbSerializedQuery
q(sender, COM_SETTITLE);
8791 inline static CbSerializedQuery BuildSetWindowPosQuery(
CImgDisplay* sender,
const int x,
const int y) {
8792 CbSerializedQuery
q(sender, COM_SETMOUSEPOS);
8802 bool _CbSendMsg(cimg::CarbonInfo& c, CbSerializedQuery m) {
8803 MPNotifyQueue(c.com_queue,&m,0,0);
8804 MPWaitOnSemaphore(c.sync_event,kDurationForever);
8811 bool _CbFreeAttachedWindow(cimg::CarbonInfo& c) {
8812 if (!_CbSendMsg(c, CbSerializedQuery::BuildReleaseWindowQuery(
this)))
8813 throw CImgDisplayException(
"Cannot release window associated with the current display.");
8815 MPEnterCriticalRegion(c.windowListCR,kDurationForever);
8817 MPExitCriticalRegion(c.windowListCR);
8818 return c.windowCount == 0;
8827 void _CbCreateAttachedWindow(cimg::CarbonInfo& c,
const char* title,
const bool fullscreen,
const bool create_closed) {
8828 if (!_CbSendMsg(c,CbSerializedQuery::BuildCreateWindowQuery(
this,fullscreen,create_closed)))
8829 throw CImgDisplayException(
"Cannot create the window associated with the current display.");
8832 MPEnterCriticalRegion(c.windowListCR,kDurationForever);
8834 MPExitCriticalRegion(c.windowListCR);
8838 void _CbFinalizeGraphics() {
8839 CGImageRelease (imageRef);
8840 CGDataProviderRelease(dataProvider);
8841 CGColorSpaceRelease(csr);
8845 void _CbInitializeGraphics() {
8846 csr = CGColorSpaceCreateDeviceRGB();
8848 throw CImgDisplayException(
"CGColorSpaceCreateDeviceRGB() failed.");
8850 dataProvider = CGDataProviderCreateWithData(0,data,
height*
width*
sizeof(
unsigned int),0);
8852 throw CImgDisplayException(
"CGDataProviderCreateWithData() failed.");
8856 kCGImageAlphaNoneSkipFirst,dataProvider,0,
false,kCGRenderingIntentDefault);
8859 kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host,dataProvider,0,
false,kCGRenderingIntentDefault);
8861 throw CImgDisplayException(
"CGImageCreate() failed.");
8866 void _CbReinitGraphics() {
8867 MPEnterCriticalRegion(paintCriticalRegion, kDurationForever);
8868 _CbFinalizeGraphics();
8869 _CbInitializeGraphics();
8870 MPExitCriticalRegion(paintCriticalRegion);
8879 static bool _CbToLocalPointFromMouseEvent(EventRef mouseEvent, WindowRef window, HIPoint* point) {
8881 if (GetWindowBounds(window,kWindowStructureRgn,&bounds)==noErr) {
8882 point->x -= bounds.left;
8883 point->y -= bounds.top;
8884 HIViewRef view = NULL;
8885 if (HIViewGetViewForMouseEvent(HIViewGetRoot(window),mouseEvent,&view)==noErr)
8886 return HIViewConvertPoint(point, NULL, view) == noErr;
8892 return CGDisplayPixelsWide(kCGDirectMainDisplay);
8896 return CGDisplayPixelsHigh(kCGDirectMainDisplay);
8899 CImgDisplay&
assign(
const unsigned int dimw,
const unsigned int dimh,
const char *title=0,
8900 const unsigned int normalization_type=3,
8901 const bool fullscreen_flag=
false,
const bool closed_flag=
false) {
8902 if (!dimw || !dimh)
return assign();
8903 _assign(dimw,dimh,title,normalization_type,fullscreen_flag,closed_flag);
8905 std::memset(data,0,
sizeof(
unsigned int)*
width*
height);
8909 template<
typename T>
8911 const unsigned int normalization_type=3,
8912 const bool fullscreen_flag=
false,
const bool closed_flag=
false) {
8913 if (!img)
return assign();
8915 const CImg<T>& nimg = (img.depth==1)?img:(tmp=img.get_projections2d(img.width/2,img.height/2,img.depth/2));
8916 _assign(nimg.width,nimg.height,title,normalization_type,fullscreen_flag,closed_flag);
8921 template<
typename T>
8923 const unsigned int normalization_type=3,
8924 const bool fullscreen_flag=
false,
const bool closed_flag=
false) {
8925 if (!list)
return assign();
8927 const CImg<T> img = list>
'x', &nimg = (img.depth==1)?img:(tmp=img.get_projections2d(img.width/2,img.height/2,img.depth/2));
8928 _assign(nimg.width,nimg.height,title,normalization_type,fullscreen_flag,closed_flag);
8934 if (!win)
return assign();
8935 _assign(win.width,win.height,win.title,win.normalization,win.is_fullscreen,win.is_closed);
8936 std::memcpy(data,win.data,
sizeof(
unsigned int)*
width*
height);
8940 template<
typename T>
8946 CImgDisplay&
resize(
const int nwidth,
const int nheight,
const bool redraw=
true) {
8947 if (!nwidth || !nheight || (
is_empty() && (nwidth<0 || nheight<0)))
return assign();
8950 tmpdimx = (nwidth>0)?nwidth:(-nwidth*
width/100),
8951 tmpdimy = (nheight>0)?nheight:(-nheight*
height/100),
8952 dimx = tmpdimx?tmpdimx:1,
8953 dimy = tmpdimy?tmpdimy:1;
8954 cimg::CarbonInfo& c = cimg::CarbonAttr();
8957 !_CbSendMsg(c,CbSerializedQuery::BuildResizeWindowQuery(
this,
dimx,
dimy,redraw)))
8958 throw CImgDisplayException(
"CImgDisplay::resize() : Cannot resize the window associated to the current display.");
8961 unsigned int *ndata =
new unsigned int[
dimx*
dimy];
8963 else std::memset(ndata,0x80,
sizeof(
unsigned int)*
dimx*
dimy);
8964 unsigned int const* old_data = data;
8967 _CbReinitGraphics();
8972 if (redraw)
return paint();
8980 cimg::CarbonInfo& c = cimg::CarbonAttr();
8982 if (!_CbSendMsg(c,CbSerializedQuery::BuildMoveWindowQuery(
this,posx,posy)))
8983 throw CImgDisplayException(
"CImgDisplay::move() : Cannot move the window associated to the current display.");
8991 cimg::CarbonInfo& c = cimg::CarbonAttr();
8993 if (!_CbSendMsg(c,CbSerializedQuery::BuildSetWindowPosQuery(
this,posx,posy)))
8994 throw CImgDisplayException(
"CImgDisplay::set_mouse() : Cannot set the mouse position to the current display.");
9001 cimg::CarbonInfo& c = cimg::CarbonAttr();
9003 if (!_CbSendMsg(c,CbSerializedQuery::BuildHideMouseQuery(
this)))
9004 throw CImgDisplayException(
"CImgDisplay::hide_mouse() : Cannot hide the mouse associated to the current display.");
9010 cimg::CarbonInfo& c = cimg::CarbonAttr();
9012 if (!_CbSendMsg(c,CbSerializedQuery::BuildShowMouseQuery(
this)))
9013 throw CImgDisplayException(
"CImgDisplay::show_mouse() : Cannot show the mouse associated to the current display.");
9018 cimg::CarbonInfo& c = cimg::CarbonAttr();
9019 MPWaitOnSemaphore(c.wait_event,kDurationForever);
9025 cimg::CarbonInfo& c = cimg::CarbonAttr();
9026 if (!_CbSendMsg(c,CbSerializedQuery::BuildShowWindowQuery(
this)))
9027 throw CImgDisplayException(
"CImgDisplay::show() : Cannot show the window associated to the current display.");
9035 cimg::CarbonInfo& c = cimg::CarbonAttr();
9037 if (!_CbSendMsg(c,CbSerializedQuery::BuildHideWindowQuery(
this)))
9038 throw CImgDisplayException(
"CImgDisplay::close() : Cannot hide the window associated to the current display.");
9045 char tmp[1024] = { 0 };
9047 va_start(ap, format);
9048 std::vsprintf(tmp,format,ap);
9050 if (title)
delete[]
title;
9051 const unsigned int s = std::strlen(tmp) + 1;
9052 title =
new char[
s];
9053 std::memcpy(title,tmp,s*
sizeof(
char));
9054 cimg::CarbonInfo& c = cimg::CarbonAttr();
9055 if (!_CbSendMsg(c,CbSerializedQuery::BuildSetWindowTitleQuery(
this,tmp)))
9056 throw CImgDisplayException(
"CImgDisplay::set_title() : Cannot set the window title associated to the current display.");
9062 MPEnterCriticalRegion(paintCriticalRegion,kDurationForever);
9063 CGrafPtr portPtr = GetWindowPort(carbonWindow);
9064 CGContextRef currentContext = 0;
9065 QDBeginCGContext(portPtr,¤tContext);
9066 CGContextSetRGBFillColor(currentContext,255,255,255,255);
9069 CGContextFlush(currentContext);
9070 QDEndCGContext(portPtr, ¤tContext);
9071 MPExitCriticalRegion(paintCriticalRegion);
9076 template<
typename T>
9080 throw CImgArgumentException(
"CImgDisplay::_render_image() : Specified input image (%u,%u,%u,%u,%p) is empty.",
9081 img.width,img.height,img.depth,img.dim,img.data);
9082 if (img.depth!=1)
return render(img.get_projections2d(img.width/2,img.height/2,img.depth/2));
9085 *data2 = (img.dim>=2)?img.ptr(0,0,0,1):data1,
9086 *data3 = (img.dim>=3)?img.ptr(0,0,0,2):data1;
9087 MPEnterCriticalRegion(paintCriticalRegion, kDurationForever);
9089 *
const ndata = (img.width==
width && img.height==
height)?data:
new unsigned int[img.width*img.height],
9093 for (
unsigned int xy = img.width*img.height; xy>0; --xy)
9094 *(ptrd++) = ((
unsigned char)*(data1++)<<16) | ((
unsigned char)*(data2++)<<8) | (
unsigned char)*(data3++);
9097 if (cimg::type<T>::is_float()) min = (
float)img.minmax(
max);
9103 const float delta =
max-
min, mm = delta?delta:1.0f;
9104 for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
9106 R = (
unsigned char)(255*(*(data1++)-min)/mm),
9107 G = (
unsigned char)(255*(*(data2++)-min)/mm),
9108 B = (
unsigned char)(255*(*(data3++)-min)/mm);
9109 *(ptrd++) = (R<<16) | (G<<8) | (B);
9116 MPExitCriticalRegion(paintCriticalRegion);
9120 template<
typename T>
9126 *data1 = img.ptr(0,0,0,0),
9127 *data2 = img.ptr(0,0,0,1),
9128 *data3 = img.ptr(0,0,0,2);
9129 unsigned int *ptrs = data;
9130 for (
unsigned int xy = img.width*img.height; xy>0; --xy) {
9131 const unsigned int val = *(ptrs++);
9132 *(data1++) = (
unsigned char)(val>>16);
9133 *(data2++) = (
unsigned char)((val>>8)&0xFF);
9134 *(data3++) = (
unsigned char)(val&0xFF);
9144 void *odata = std::malloc(bufsize);
9145 std::memcpy(odata,data,bufsize);
9147 std::memcpy(data,odata,bufsize);
9154 static OSStatus CarbonEventHandler(EventHandlerCallRef myHandler, EventRef theEvent,
void* userData) {
9155 OSStatus result = eventNotHandledErr;
9158 cimg::CarbonInfo& c = cimg::CarbonAttr();
9162 if (GetEventClass(theEvent)==kEventClassWindow)
switch (GetEventKind (theEvent)) {
9163 case kEventWindowClose :
9164 disp->mouse_x = disp->mouse_y = -1;
9165 disp->window_x = disp->window_y = 0;
9167 std::memmove((
void*)(disp->buttons+1),(
void*)disp->buttons,512-1);
9171 std::memmove((
void*)(disp->keys+1),(
void*)disp->keys,512-1);
9174 if (disp->released_key) { std::memmove((
void*)(disp->released_keys+1),(
void*)disp->released_keys,512-1); disp->released_key = 0; }
9175 disp->is_closed =
true;
9176 HideWindow(disp->carbonWindow);
9177 disp->is_event =
true;
9178 MPSignalSemaphore(c.wait_event);
9182 case kEventWindowBoundsChanging :
9183 case kEventWindowResizeStarted :
9184 case kEventWindowCollapsed :
9186 case kEventWindowZoomed :
9187 case kEventWindowExpanded :
9188 case kEventWindowResizeCompleted : {
9189 MPEnterCriticalRegion(disp->paintCriticalRegion, kDurationForever);
9191 Rect newContentRect;
9192 GetWindowBounds(disp->carbonWindow,kWindowContentRgn,&newContentRect);
9194 nw = (
unsigned int)(newContentRect.right - newContentRect.left),
9195 nh = (
unsigned int)(newContentRect.bottom - newContentRect.top);
9198 if (nw && nh && (nw!=disp->width || nh!=disp->height)) {
9199 disp->window_width = nw;
9200 disp->window_height = nh;
9201 disp->mouse_x = disp->mouse_y = -1;
9202 disp->is_resized =
true;
9204 disp->is_event =
true;
9205 MPExitCriticalRegion(disp->paintCriticalRegion);
9207 MPSignalSemaphore(c.wait_event);
9210 case kEventWindowDragStarted :
9211 case kEventWindowDragCompleted : {
9212 MPEnterCriticalRegion(disp->paintCriticalRegion, kDurationForever);
9214 Rect newContentRect ;
9215 GetWindowBounds(disp->carbonWindow,kWindowStructureRgn,&newContentRect);
9216 const int nx = (int)(newContentRect.left), ny = (int)(newContentRect.top);
9218 if (nx!=disp->window_x || ny!=disp->window_y) {
9219 disp->window_x = nx;
9220 disp->window_y = ny;
9221 disp->is_moved =
true;
9223 disp->is_event =
true;
9224 MPExitCriticalRegion(disp->paintCriticalRegion);
9226 MPSignalSemaphore(c.wait_event);
9229 case kEventWindowPaint :
9234 switch (GetEventClass(theEvent)) {
9235 case kEventClassKeyboard : {
9236 if (GetEventKind(theEvent)==kEventRawKeyModifiersChanged) {
9238 UInt32 newModifiers;
9239 if (GetEventParameter(theEvent,kEventParamKeyModifiers,typeUInt32,0,
sizeof(UInt32),0,&newModifiers)==noErr) {
9240 int newKeyCode = -1;
9241 UInt32 changed = disp->lastKeyModifiers^newModifiers;
9247 if ((changed & (optionKey | rightOptionKey))!=0) newKeyCode =
cimg::keyALTGR;
9252 if (newKeyCode != -1) {
9253 if (disp->key) std::memmove((
void*)(disp->keys+1),(
void*)disp->keys,512-1);
9254 disp->key = (int)newKeyCode;
9256 disp->lastKeyModifiers = newModifiers;
9258 disp->is_event =
true;
9259 MPSignalSemaphore(c.wait_event);
9261 if (GetEventKind(theEvent)==kEventRawKeyDown || GetEventKind(theEvent)==kEventRawKeyRepeat) {
9263 if (GetEventParameter(theEvent,kEventParamKeyMacCharCodes,typeChar,0,
sizeof(keyCode),0,&keyCode)==noErr) {
9264 disp->_update_iskey((
unsigned int)keyCode,
true);
9265 if (disp->key) std::memmove((
void*)(disp->keys+1),(
void*)disp->keys,512-1);
9266 disp->key = (
unsigned int)keyCode;
9267 if (disp->released_key) { std::memmove((
void*)(disp->released_keys+1),(
void*)disp->released_keys,512-1); disp->released_key = 0; }
9269 disp->is_event =
true;
9270 MPSignalSemaphore(c.wait_event);
9274 case kEventClassMouse :
9275 switch (GetEventKind(theEvent)) {
9276 case kEventMouseDragged :
9279 case kEventMouseMoved :
9281 if (GetEventParameter(theEvent,kEventParamMouseLocation,typeHIPoint,0,
sizeof(point),0,&point)==noErr) {
9282 if (_CbToLocalPointFromMouseEvent(theEvent,disp->carbonWindow,&point)) {
9283 disp->mouse_x = (int)point.x;
9284 disp->mouse_y = (
int)point.y;
9285 if (disp->mouse_x<0 || disp->mouse_y<0 || disp->mouse_x>=disp->dimx() || disp->mouse_y>=disp->dimy())
9286 disp->mouse_x = disp->mouse_y = -1;
9287 }
else disp->mouse_x = disp->mouse_y = -1;
9289 disp->is_event =
true;
9290 MPSignalSemaphore(c.wait_event);
9292 case kEventMouseDown :
9294 if (GetEventParameter(theEvent,kEventParamMouseButton,typeMouseButton,0,
sizeof(btn),0,&btn)==noErr) {
9295 std::memmove((
void*)(disp->buttons+1),(
void*)disp->buttons,512-1);
9296 if (btn==kEventMouseButtonPrimary) disp->button|=1U;
9299 if ((disp->lastKeyModifiers & (controlKey | rightControlKey))!=0)
9300 cimg::warn(
"CImgDisplay::CarbonEventHandler() : Will emulate right click now [Down]");
9301 if (btn==kEventMouseButtonSecondary || ((disp->lastKeyModifiers & (controlKey | rightControlKey))!=0)) disp->button|=2U;
9302 if (btn==kEventMouseButtonTertiary) disp->button|=4U;
9304 disp->is_event =
true;
9305 MPSignalSemaphore(c.wait_event);
9307 case kEventMouseWheelMoved :
9308 EventMouseWheelAxis wheelax;
9310 if (GetEventParameter(theEvent,kEventParamMouseWheelAxis,typeMouseWheelAxis,0,
sizeof(wheelax),0,&wheelax)==noErr)
9311 if (wheelax==kEventMouseWheelAxisY) {
9312 if (GetEventParameter(theEvent,kEventParamMouseWheelDelta,typeLongInteger,0,
sizeof(delta),0,&delta)==noErr)
9313 if (delta>0) disp->wheel+=delta/120;
9314 disp->is_event =
true;
9315 MPSignalSemaphore(c.wait_event);
9321 switch (GetEventClass(theEvent)) {
9322 case kEventClassKeyboard :
9323 if (GetEventKind(theEvent)==kEventRawKeyUp) {
9325 if (GetEventParameter(theEvent,kEventParamKeyCode,typeUInt32,0,
sizeof(keyCode),0,&keyCode)==noErr) {
9326 disp->_update_iskey((
unsigned int)keyCode,
false);
9327 if (disp->key) { std::memmove((
void*)(disp->keys+1),(
void*)disp->keys,512-1); disp->key = 0; }
9328 if (disp->released_key) std::memmove((
void*)(disp->released_keys+1),(
void*)disp->released_keys,512-1);
9329 disp->released_key = (int)keyCode;
9331 disp->is_event =
true;
9332 MPSignalSemaphore(c.wait_event);
9336 case kEventClassMouse :
9337 switch (GetEventKind(theEvent)) {
9338 case kEventMouseUp :
9340 if (GetEventParameter(theEvent,kEventParamMouseButton,typeMouseButton,0,
sizeof(btn),0,&btn)==noErr) {
9341 std::memmove((
void*)(disp->buttons+1),(
void*)disp->buttons,512-1);
9342 if (btn==kEventMouseButtonPrimary) disp->button&=~1U;
9344 if ((disp->lastKeyModifiers & (controlKey | rightControlKey))!=0)
9345 cimg::warn(
"CImgDisplay::CarbonEventHandler() : Will emulate right click now [Up]");
9346 if (btn==kEventMouseButtonSecondary || ((disp->lastKeyModifiers & (controlKey | rightControlKey))!=0)) disp->button&=~2U;
9347 if (btn==kEventMouseButtonTertiary) disp->button&=~2U;
9349 disp->is_event =
true;
9350 MPSignalSemaphore(c.wait_event);
9358 static void* _events_thread(
void* args) {
9360 cimg::CarbonInfo& c = cimg::CarbonAttr();
9361 pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED,0);
9362 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,0);
9363 MPSignalSemaphore(c.sync_event);
9365 EventTargetRef theTarget;
9367 CbSerializedQuery* query;
9368 theTarget = GetEventDispatcherTarget();
9372 pthread_testcancel();
9373 err = ReceiveNextEvent(0,0,kDurationImmediate,
true,&theEvent);
9375 SendEventToEventTarget (theEvent, theTarget);
9376 ReleaseEvent(theEvent);
9377 }
else if (err == eventLoopTimedOutErr) {
9378 OSStatus r =MPWaitOnQueue(c.com_queue,(
void**)&query,0,0,10*kDurationMillisecond);
9379 if (r!=noErr)
continue;
9382 switch (query->kind) {
9383 case COM_SETMOUSEPOS : {
9384 query->success = CGDisplayMoveCursorToPoint(kCGDirectMainDisplay,CGPointMake(query->sender->window_x+query->x,query->sender->window_y+query->y))
9386 if (query->success) {
9387 query->sender->mouse_x = query->x;
9388 query->sender->mouse_y = query->y;
9389 }
else cimg::warn(
"CImgDisplay::_events_thread() : CGDisplayMoveCursorToPoint failed.");
9391 case COM_SETTITLE : {
9392 CFStringRef windowTitle = CFStringCreateWithCString(0,query->c,kCFStringEncodingMacRoman);
9393 query->success = SetWindowTitleWithCFString(query->sender->carbonWindow,windowTitle)==noErr;
9394 if (!query->success)
9395 cimg::warn(
"CImgDisplay::_events_thread() : SetWindowTitleWithCFString failed.");
9396 CFRelease(windowTitle);
9398 case COM_RESIZEWINDOW : {
9399 SizeWindow(query->sender->carbonWindow,query->x,query->y,query->update);
9401 query->sender->window_width = query->x;
9402 query->sender->window_height = query->y;
9403 query->success =
true;
9405 case COM_MOVEWINDOW : {
9406 MoveWindow(query->sender->carbonWindow,query->x,query->y,
false);
9407 query->sender->window_x = query->x;
9408 query->sender->window_y = query->y;
9409 query->sender->is_moved =
false;
9410 query->success =
true;
9412 case COM_SHOWMOUSE : {
9413 query->success = CGDisplayShowCursor(kCGDirectMainDisplay)==noErr;
9414 if (!query->success)
9415 cimg::warn(
"CImgDisplay::_events_thread() : CGDisplayShowCursor failed.");
9417 case COM_HIDEMOUSE : {
9418 query->success = CGDisplayHideCursor(kCGDirectMainDisplay)==noErr;
9419 if (!query->success)
9420 cimg::warn(
"CImgDisplay::_events_thread() : CGDisplayHideCursor failed.");
9422 case COM_SHOWWINDOW : {
9423 ShowWindow(query->sender->carbonWindow);
9424 query->success =
true;
9425 query->sender->is_closed =
false;
9427 case COM_HIDEWINDOW : {
9428 HideWindow(query->sender->carbonWindow);
9429 query->sender->is_closed =
true;
9430 query->sender->window_x = query->sender->window_y = 0;
9431 query->success =
true;
9433 case COM_RELEASEWINDOW : {
9434 query->success =
true;
9435 CFRelease(query->sender->carbonWindow);
9437 case COM_CREATEWINDOW : {
9438 query->success =
true;
9439 WindowAttributes windowAttrs;
9441 if (query->createFullScreenWindow) {
9443 windowAttrs = (1L << 9);
9445 SetRect(&contentRect,0,0,CGDisplayPixelsWide(kCGDirectMainDisplay),CGDisplayPixelsHigh(kCGDirectMainDisplay));
9447 SetRect(&contentRect,0,0,query->sender->width,query->sender->height);
9449 windowAttrs = kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute | kWindowInWindowMenuAttribute | kWindowLiveResizeAttribute;
9452 if (query->createClosedWindow) query->sender->window_x = query->sender->window_y = 0;
9454 query->sender->window_x = contentRect.left;
9455 query->sender->window_y = contentRect.top;
9458 query->sender->window_width = query->sender->width;
9459 query->sender->window_height = query->sender->height;
9460 query->sender->flush();
9462 if (CreateNewWindow(kDocumentWindowClass,windowAttrs,&contentRect,&query->sender->carbonWindow)!=noErr) {
9463 query->success =
false;
9464 cimg::warn(
"CImgDisplay::_events_thread() : CreateNewWindow() failed.");
9467 if (RepositionWindow(query->sender->carbonWindow,0,kWindowCenterOnMainScreen)!=noErr) query->success =
false;
9469 if (!query->createClosedWindow) ShowWindow(query->sender->carbonWindow);
9472 EventTypeSpec eventList[] = {
9473 { kEventClassWindow, kEventWindowClose },
9474 { kEventClassWindow, kEventWindowResizeStarted },
9475 { kEventClassWindow, kEventWindowResizeCompleted },
9476 { kEventClassWindow, kEventWindowDragStarted},
9477 { kEventClassWindow, kEventWindowDragCompleted },
9478 { kEventClassWindow, kEventWindowPaint },
9479 { kEventClassWindow, kEventWindowBoundsChanging },
9480 { kEventClassWindow, kEventWindowCollapsed },
9481 { kEventClassWindow, kEventWindowExpanded },
9482 { kEventClassWindow, kEventWindowZoomed },
9483 { kEventClassKeyboard, kEventRawKeyDown },
9484 { kEventClassKeyboard, kEventRawKeyUp },
9485 { kEventClassKeyboard, kEventRawKeyRepeat },
9486 { kEventClassKeyboard, kEventRawKeyModifiersChanged },
9487 { kEventClassMouse, kEventMouseMoved },
9488 { kEventClassMouse, kEventMouseDown },
9489 { kEventClassMouse, kEventMouseUp },
9490 { kEventClassMouse, kEventMouseDragged }
9494 if (InstallWindowEventHandler(query->sender->carbonWindow,NewEventHandlerUPP(CarbonEventHandler),GetEventTypeCount(eventList),
9495 eventList,(
void*)query->sender,0)!=noErr) {
9496 query->success =
false;
9497 cimg::warn(
"CImgDisplay::_events_thread() : InstallWindowEventHandler failed.");
9501 query->sender->paint();
9504 cimg::warn(
"CImgDisplay::_events_thread() : Received unknow code %d.",query->kind);
9507 MPSignalSemaphore(c.sync_event);
9517 cimg::CarbonInfo& c = cimg::CarbonAttr();
9519 _CbFreeAttachedWindow(c);
9529 _CbFinalizeGraphics();
9532 if (data)
delete[] data;
9533 if (title)
delete[]
title;
9541 if (MPDeleteCriticalRegion(paintCriticalRegion)!=noErr)
9542 throw CImgDisplayException(
"CImgDisplay()::assign() : MPDeleteCriticalRegion failed.");
9546 CImgDisplay& _assign(
const unsigned int dimw,
const unsigned int dimh,
const char *
const ptitle=0,
9547 const unsigned int normalization_type=3,
9548 const bool fullscreen_flag=
false,
const bool closed_flag=
false) {
9549 cimg::CarbonInfo& c = cimg::CarbonAttr();
9552 const char *
const nptitle = ptitle?ptitle:
"";
9553 const unsigned int s = std::strlen(nptitle) + 1;
9554 char *tmp_title = s?
new char[
s]:0;
9555 if (s) std::memcpy(tmp_title,nptitle,s*
sizeof(
char));
9566 lastKeyModifiers = 0;
9571 if (MPCreateCriticalRegion(&paintCriticalRegion) != noErr)
9572 throw CImgDisplayException(
"CImgDisplay::_assign() : MPCreateCriticalRegion() failed.");
9575 if (c.event_thread==0) {
9577 if (pthread_create(&c.event_thread,0,_events_thread,0)!=0)
9578 throw CImgDisplayException(
"CImgDisplay::_assign() : pthread_create() failed.");
9580 MPWaitOnSemaphore(c.sync_event, kDurationForever);
9585 _CbInitializeGraphics();
9588 _CbCreateAttachedWindow(c,nptitle,fullscreen_flag,closed_flag);
9700 template<
typename T>
9802 #include cimg_plugin
9805 #include cimg_plugin1
9808 #include cimg_plugin2
9811 #include cimg_plugin3
9814 #include cimg_plugin4
9817 #include cimg_plugin5
9820 #include cimg_plugin6
9823 #include cimg_plugin7
9826 #include cimg_plugin8
9874 explicit CImg(
const unsigned int dx,
const unsigned int dy=1,
const unsigned int dz=1,
const unsigned int dv=1):
9876 const unsigned int siz = dx*
dy*dz*dv;
9893 CImg(
const unsigned int dx,
const unsigned int dy,
const unsigned int dz,
const unsigned int dv,
const T val):
9895 const unsigned int siz = dx*dy*dz*dv;
9901 CImg(
const unsigned int dx,
const unsigned int dy,
const unsigned int dz,
const unsigned int dv,
9903 #define _CImg_stdarg(img,a0,a1,N,t) { \
9904 unsigned int _siz = (unsigned int)N; \
9908 T *ptrd = (img).data; \
9909 *(ptrd++) = (T)a0; \
9911 *(ptrd++) = (T)a1; \
9912 for (; _siz; --_siz) *(ptrd++) = (T)va_arg(ap,t); \
9921 CImg(
const unsigned int dx,
const unsigned int dy,
const unsigned int dz,
const unsigned int dv,
9928 CImg(
const unsigned int dx,
const unsigned int dy,
const unsigned int dz,
const unsigned int dv,
9929 const char *
const values,
const bool repeat_values):
is_shared(false) {
9930 const unsigned int siz = dx*dy*dz*dv;
9940 template<
typename t>
9941 CImg(
const t *
const data_buffer,
const unsigned int dx,
const unsigned int dy=1,
9942 const unsigned int dz=1,
const unsigned int dv=1,
const bool shared=
false):
is_shared(false) {
9944 throw CImgArgumentException(
"CImg<%s>::CImg() : Cannot construct a shared instance image from a (%s*) buffer "
9945 "(different pixel types).",
9947 const unsigned int siz = dx*
dy*dz*dv;
9948 if (data_buffer && siz) {
9950 const t *ptrs = data_buffer + siz;
cimg_for(*
this,ptrd,T) *ptrd = (T)*(--ptrs);
9954 CImg(
const T *
const data_buffer,
const unsigned int dx,
const unsigned int dy=1,
9955 const unsigned int dz=1,
const unsigned int dv=1,
const bool shared=
false) {
9956 const unsigned int siz = dx*
dy*dz*dv;
9957 if (data_buffer && siz) {
9960 else {
data =
new T[siz]; std::memcpy(
data,data_buffer,siz*
sizeof(T)); }
9997 template<
typename t>
9999 const unsigned int siz = img.size();
10000 if (img.data && siz) {
10002 const t *ptrs = img.data + siz;
cimg_for(*
this,ptrd,T) *ptrd = (T)*(--ptrs);
10007 const unsigned int siz = img.size();
10008 if (img.data && siz) {
10011 else {
data =
new T[siz]; std::memcpy(
data,img.data,siz*
sizeof(T)); }
10029 template<
typename t>
10032 throw CImgArgumentException(
"CImg<%s>::CImg() : Cannot construct a shared instance image from a CImg<%s> instance "
10033 "(different pixel types).",
10035 const unsigned int siz = img.size();
10036 if (img.data && siz) {
10038 const t *ptrs = img.data + siz;
cimg_for(*
this,ptrd,T) *ptrd = (T)*(--ptrs);
10043 const unsigned int siz = img.size();
10044 if (img.data && siz) {
10047 else {
data =
new T[siz]; std::memcpy(
data,img.data,siz*
sizeof(T)); }
10052 template<
typename t>
10058 template<
typename t>
10061 assign(img,dimensions).fill(val);
10065 template<
typename t>
10066 CImg(
const CImg<t>& img,
const char *
const dimensions,
const char *
const values,
const bool repeat_values):
10068 assign(img,dimensions).fill(values,repeat_values);
10125 CImg<T>&
assign(
const unsigned int dx,
const unsigned int dy=1,
const unsigned int dz=1,
const unsigned int dv=1) {
10126 const unsigned int siz = dx*
dy*dz*dv;
10127 if (!siz)
return assign();
10128 const unsigned int curr_siz =
size();
10129 if (siz!=curr_siz) {
10131 throw CImgArgumentException(
"CImg<%s>::assign() : Cannot assign image (%u,%u,%u,%u) to shared instance image (%u,%u,%u,%u,%p).",
10151 CImg<T>&
assign(
const unsigned int dx,
const unsigned int dy,
const unsigned int dz,
const unsigned int dv,
const T val) {
10152 return assign(dx,dy,dz,dv).fill(val);
10156 CImg<T>&
assign(
const unsigned int dx,
const unsigned int dy,
const unsigned int dz,
const unsigned int dv,
10157 const int val0,
const int val1, ...) {
10164 CImg<T>&
assign(
const unsigned int dx,
const unsigned int dy,
const unsigned int dz,
const unsigned int dv,
10165 const double val0,
const double val1, ...) {
10172 CImg<T>&
assign(
const unsigned int dx,
const unsigned int dy,
const unsigned int dz,
const unsigned int dv,
10173 const char *
const values,
const bool repeat_values) {
10174 return assign(dx,dy,dz,dv).fill(values,repeat_values);
10178 template<
typename t>
10180 const unsigned int dz=1,
const unsigned int dv=1) {
10181 const unsigned int siz = dx*
dy*dz*dv;
10182 if (!data_buffer || !siz)
return assign();
10184 const t *ptrs = data_buffer + siz;
cimg_for(*
this,ptrd,T) *ptrd = (T)*(--ptrs);
10189 const unsigned int dz=1,
const unsigned int dv=1) {
10190 const unsigned int siz = dx*
dy*dz*dv;
10191 if (!data_buffer || !siz)
return assign();
10192 const unsigned int curr_siz =
size();
10193 if (data_buffer==
data && siz==curr_siz)
return assign(dx,
dy,dz,dv);
10196 if (
is_shared) std::memmove(
data,data_buffer,siz*
sizeof(T));
10197 else std::memcpy(
data,data_buffer,siz*
sizeof(T));
10199 T *new_data =
new T[siz];
10200 std::memcpy(new_data,data_buffer,siz*
sizeof(T));
10207 template<
typename t>
10209 const unsigned int dz,
const unsigned int dv,
const bool shared) {
10211 throw CImgArgumentException(
"CImg<%s>::assign() : Cannot assign buffer (%s*) to shared instance image (%u,%u,%u,%u,%p)"
10212 "(different pixel types).",
10214 return assign(data_buffer,dx,dy,dz,dv);
10218 const unsigned int dz,
const unsigned int dv,
const bool shared) {
10219 const unsigned int siz = dx*dy*dz*dv;
10220 if (!data_buffer || !siz)
return assign();
10225 else cimg::warn(
"CImg<%s>::assign() : Shared instance image has overlapping memory !",
10229 data =
const_cast<T*
>(data_buffer);
10245 return load(filename);
10258 template<
typename t>
10260 return assign(img.data,img.width,img.height,img.depth,img.dim);
10276 template<
typename t>
10278 return assign(img.data,img.width,img.height,img.depth,img.dim,shared);
10282 template<
typename t>
10284 if (!dimensions || !*dimensions)
return assign(img.width,img.height,img.depth,img.dim);
10285 unsigned int siz[4] = { 0,1,1,1 },
k = 0;
10286 for (
const char *s = dimensions; *s &&
k<4; ++
k) {
10287 char item[256] = { 0 };
10288 if (std::sscanf(s,
"%255[^0-9%xyzvwhdcXYZVWHDC]",item)>0) s+=std::strlen(item);
10290 unsigned int val = 0;
char sep = 0;
10291 if (std::sscanf(s,
"%u%c",&val,&sep)>0) {
10294 while (*s>=
'0' && *s<=
'9') ++
s;
if (sep==
'%') ++
s;
10296 case 'x' :
case 'w' : siz[
k] = img.width; ++
s;
break;
10297 case 'y' :
case 'h' : siz[
k] = img.height; ++
s;
break;
10298 case 'z' :
case 'd' : siz[
k] = img.depth; ++
s;
break;
10299 case 'v' :
case 'c' : siz[
k] = img.dim; ++
s;
break;
10301 throw CImgArgumentException(
"CImg<%s>::assign() : Misplaced character '%c' in input dimension string '%s'.",
10306 return assign(siz[0],siz[1],siz[2],siz[3]);
10310 template<
typename t>
10312 return assign(img,dimensions).fill(val);
10316 template<
typename t>
10317 CImg<T>&
assign(
const CImg<t>& img,
const char *
const dimensions,
const char *
const values,
const bool repeat_values) {
10318 return assign(img,dimensions).fill(values,repeat_values);
10331 template<
typename t>
10339 if (
is_shared || img.is_shared) { img.assign(*
this);
assign(); }
else { img.assign();
swap(img); }
10343 template<
typename t>
10345 const unsigned int npos = pos>list.
width?list.
width:pos;
10353 return _empty.assign();
10393 cimg::warn(
"CImg<%s>::operator[] : Pixel access requested at offset=%u "
10394 "outside the image range (%u,%u,%u,%u) (size=%u)",
10398 else return data[off];
10401 const T&
operator[](
const unsigned int off)
const {
10402 return const_cast<CImg<T>*
>(
this)->
operator[](off);
10436 T&
operator()(
const unsigned int x,
const unsigned int y=0,
const unsigned int z=0,
const unsigned int v=0) {
10437 const unsigned int off = (
unsigned int)
offset(x,
y,
z,
v);
10439 cimg::warn(
"CImg<%s>::operator() : Pixel access requested at (%u,%u,%u,%u) (offset=%u) "
10440 "outside the image range (%u,%u,%u,%u) (size=%u)",
10441 pixel_type(),x,
y,
z,
v,off,
width,
height,
depth,dim,
size());
10444 else return data[off];
10447 const T&
operator()(
const unsigned int x,
const unsigned int y=0,
const unsigned int z=0,
const unsigned int v=0)
const {
10448 return const_cast<CImg<T>*
>(
this)->
operator()(
x,
y,
z,
v);
10451 T&
operator()(
const unsigned int x,
const unsigned int y=0,
const unsigned int z=0,
const unsigned int v=0) {
10455 const T&
operator()(
const unsigned int x,
const unsigned int y=0,
const unsigned int z=0,
const unsigned int v=0)
const {
10461 operator bool()
const {
10486 fill(expression,
true);
10501 template<
typename t>
10517 template<
typename t>
10528 _cimg_math_parser mp(expression,
"operator+=");
10530 cimg_forXYZV(*
this,x,
y,
z,
v) { *ptrd = (T)(*ptrd + mp.eval(*
this,x,
y,
z,
v)); ++ptrd; }
10534 values = expression;
10542 template<
typename t>
10544 const unsigned int siz =
size(), isiz = img.size();
10547 T *ptrd =
data, *
const ptrd_end =
data + siz;
10548 if (siz>isiz)
for (
unsigned int n = siz/isiz;
n; --
n)
10549 for (
const t *ptrs = img.data, *ptrs_end = ptrs + isiz; ptrs<ptrs_end; ++ptrd) *ptrd = (T)(*ptrd + *(ptrs++));
10550 for (
const t *ptrs = img.data; ptrd<ptrd_end; ++ptrd) *ptrd = (T)(*ptrd + *(ptrs++));
10578 template<
typename t>
10589 template<
typename t>
10595 template<
typename t>
10606 _cimg_math_parser mp(expression,
"operator-=");
10608 cimg_forXYZV(*
this,x,
y,
z,
v) { *ptrd = (T)(*ptrd - mp.eval(*
this,x,
y,
z,
v)); ++ptrd; }
10612 values = expression;
10620 template<
typename t>
10622 const unsigned int siz =
size(), isiz = img.size();
10625 T *ptrd =
data, *
const ptrd_end =
data + siz;
10626 if (siz>isiz)
for (
unsigned int n = siz/isiz;
n; --
n)
10627 for (
const t *ptrs = img.data, *ptrs_end = ptrs + isiz; ptrs<ptrs_end; ++ptrd) *ptrd = (T)(*ptrd - *(ptrs++));
10628 for (
const t *ptrs = img.data; ptrd<ptrd_end; ++ptrd) *ptrd = (T)(*ptrd - *(ptrs++));
10652 template<
typename t>
10663 template<
typename t>
10669 template<
typename t>
10680 _cimg_math_parser mp(expression,
"operator*=");
10682 cimg_forXYZV(*
this,x,
y,
z,
v) { *ptrd = (T)(*ptrd * mp.eval(*
this,x,
y,
z,
v)); ++ptrd; }
10686 values = expression;
10694 template<
typename t>
10700 template<
typename t>
10711 template<
typename t>
10713 if (
width!=img.height ||
depth!=1 || dim!=1)
10714 throw CImgArgumentException(
"operator*() : can't multiply a matrix image (%u,%u,%u,%u) by a matrix image (%u,%u,%u,%u)",
10718 #ifdef cimg_use_openmp
10719 #pragma omp parallel for if (size()>=1000 && img.size()>=1000) private(val)
10726 template<
typename t>
10737 _cimg_math_parser mp(expression,
"operator/=");
10739 cimg_forXYZV(*
this,x,
y,
z,
v) { *ptrd = (T)(*ptrd / mp.eval(*
this,x,
y,
z,
v)); ++ptrd; }
10743 values = expression;
10751 template<
typename t>
10753 return (*
this*img.get_invert()).
transfer_to(*
this);
10757 template<
typename t>
10768 template<
typename t>
10770 return (*
this)*img.get_invert();
10774 template<
typename t>
10785 _cimg_math_parser mp(expression,
"operator%=");
10791 values = expression;
10799 template<
typename t>
10801 const unsigned int siz =
size(), isiz = img.size();
10804 T *ptrd =
data, *
const ptrd_end =
data + siz;
10805 if (siz>isiz)
for (
unsigned int n = siz/isiz;
n; --
n)
10806 for (
const t *ptrs = img.data, *ptrs_end = ptrs + isiz; ptrs<ptrs_end; ++ptrd) *ptrd =
cimg::mod(*ptrd,(T)*(ptrs++));
10807 for (
const t *ptrs = img.data; ptrd<ptrd_end; ++ptrd) *ptrd =
cimg::mod(*ptrd,(T)*(ptrs++));
10813 template<
typename t>
10824 template<
typename t>
10830 template<
typename t>
10841 _cimg_math_parser mp(expression,
"operator&=");
10843 cimg_forXYZV(*
this,x,
y,
z,
v) { *ptrd = (T)((
unsigned long)*ptrd & (
unsigned long)mp.eval(*
this,x,
y,
z,
v)); ++ptrd; }
10847 values = expression;
10855 template<
typename t>
10857 const unsigned int siz =
size(), isiz = img.size();
10860 T *ptrd =
data, *
const ptrd_end =
data + siz;
10861 if (siz>isiz)
for (
unsigned int n = siz/isiz;
n; --
n)
10862 for (
const t *ptrs = img.data, *ptrs_end = ptrs + isiz; ptrs<ptrs_end; ++ptrd) *ptrd = (T)((
unsigned long)*ptrd & (
unsigned long)*(ptrs++));
10863 for (
const t *ptrs = img.data; ptrd<ptrd_end; ++ptrd) *ptrd = (T)((
unsigned long)*ptrd & (
unsigned long)*(ptrs++));
10869 template<
typename t>
10871 return (+*
this)&=val;
10875 template<
typename t>
10886 _cimg_math_parser mp(expression,
"operator|=");
10888 cimg_forXYZV(*
this,x,
y,
z,
v) { *ptrd = (T)((
unsigned long)*ptrd | (
unsigned long)mp.eval(*
this,x,
y,
z,
v)); ++ptrd; }
10892 values = expression;
10900 template<
typename t>
10902 const unsigned int siz =
size(), isiz = img.size();
10905 T *ptrd =
data, *
const ptrd_end =
data + siz;
10906 if (siz>isiz)
for (
unsigned int n = siz/isiz;
n; --
n)
10907 for (
const t *ptrs = img.data, *ptrs_end = ptrs + isiz; ptrs<ptrs_end; ++ptrd) *ptrd = (T)((
unsigned long)*ptrd | (
unsigned long)*(ptrs++));
10908 for (
const t *ptrs = img.data; ptrd<ptrd_end; ++ptrd) *ptrd = (T)((
unsigned long)*ptrd | (
unsigned long)*(ptrs++));
10914 template<
typename t>
10916 return (+*
this)|=val;
10920 template<
typename t>
10931 _cimg_math_parser mp(expression,
"operator^=");
10933 cimg_forXYZV(*
this,x,
y,
z,
v) { *ptrd = (T)((
unsigned long)*ptrd ^ (
unsigned long)mp.eval(*
this,x,
y,
z,
v)); ++ptrd; }
10937 values = expression;
10945 template<
typename t>
10947 const unsigned int siz =
size(), isiz = img.size();
10950 T *ptrd =
data, *
const ptrd_end =
data + siz;
10951 if (siz>isiz)
for (
unsigned int n = siz/isiz;
n; --
n)
10952 for (
const t *ptrs = img.data, *ptrs_end = ptrs + isiz; ptrs<ptrs_end; ++ptrd) *ptrd = (T)((
unsigned long)*ptrd ^ (
unsigned long)*(ptrs++));
10953 for (
const t *ptrs = img.data; ptrd<ptrd_end; ++ptrd) *ptrd = (T)((
unsigned long)*ptrd ^ (
unsigned long)*(ptrs++));
10959 template<
typename t>
10961 return (+*
this)^=val;
10967 const T *ptrs =
end();
10968 cimg_for(res,ptrd,T) {
const unsigned long val = (
unsigned long)*(--ptrs); *ptrd = (T)~val; }
10980 return (+*
this)<<=
n;
10991 return (+*
this)>>=
n;
10995 template<
typename t>
10997 const unsigned int siz =
size();
10998 bool vequal =
true;
10999 if (siz!=img.size())
return false;
11000 t *ptrs = img.data + siz;
11001 for (T *ptrd =
data + siz; vequal && ptrd>
data; vequal = vequal && ((*(--ptrd))==(*(--ptrs)))) {}
11006 template<
typename t>
11008 return !((*this)==img);
11012 template<
typename t>
11018 template<
typename t>
11107 T *
ptr(
const unsigned int x,
const unsigned int y=0,
const unsigned int z=0,
const unsigned int v=0) {
11108 const unsigned int off = (
unsigned int)
offset(x,
y,
z,
v);
11110 cimg::warn(
"CImg<%s>::ptr() : Asked for a pointer at coordinates (%u,%u,%u,%u) (offset=%u), "
11111 "outside image range (%u,%u,%u,%u) (size=%u)",
11112 pixel_type(),x,
y,
z,
v,off,
width,
height,
depth,dim,
size());
11118 const T*
ptr(
const unsigned int x,
const unsigned int y=0,
const unsigned int z=0,
const unsigned int v=0)
const {
11119 return const_cast<CImg<T>*
>(
this)->
ptr(x,
y,
z,
v);
11122 T*
ptr(
const unsigned int x,
const unsigned int y=0,
const unsigned int z=0,
const unsigned int v=0) {
11126 const T*
ptr(
const unsigned int x,
const unsigned int y=0,
const unsigned int z=0,
const unsigned int v=0)
const {
11147 int offset(
const int x,
const int y=0,
const int z=0,
const int v=0)
const {
11188 T&
at(
const int off,
const T out_val) {
11192 T
at(
const int off,
const T out_val)
const {
11193 return (off<0 || off>=(
int)
size())?out_val:(*this)[off];
11212 const unsigned int siz = (
unsigned int)
size();
11213 return (*
this)[off<0?0:(unsigned int)off>=siz?siz-1:off];
11217 const unsigned int siz = (
unsigned int)
size();
11218 return (*
this)[off<0?0:(unsigned int)off>=siz?siz-1:off];
11222 T&
atXYZV(
const int x,
const int y,
const int z,
const int v,
const T out_val) {
11223 return (x<0 || y<0 || z<0 || v<0 || x>=
dimx() || y>=
dimy() || z>=
dimz() || v>=
dimv())?
11227 T
atXYZV(
const int x,
const int y,
const int z,
const int v,
const T out_val)
const {
11228 return (x<0 || y<0 || z<0 || v<0 || x>=
dimx() || y>=
dimy() || z>=
dimz() || v>=
dimv())?out_val:(*this)(
x,
y,
z,
v);
11239 T
atXYZV(
const int x,
const int y,
const int z,
const int v)
const {
11251 T
_atXYZV(
const int x,
const int y,
const int z,
const int v)
const {
11257 T&
atXYZ(
const int x,
const int y,
const int z,
const int v,
const T out_val) {
11258 return (x<0 || y<0 || z<0 || x>=
dimx() || y>=
dimy() || z>=
dimz())?
11262 T
atXYZ(
const int x,
const int y,
const int z,
const int v,
const T out_val)
const {
11263 return (x<0 || y<0 || z<0 || x>=
dimx() || y>=
dimy() || z>=
dimz())?out_val:(*this)(
x,
y,
z,
v);
11267 T&
atXYZ(
const int x,
const int y,
const int z,
const int v=0) {
11274 T
atXYZ(
const int x,
const int y,
const int z,
const int v=0)
const {
11281 T&
_atXYZ(
const int x,
const int y,
const int z,
const int v=0) {
11286 T
_atXYZ(
const int x,
const int y,
const int z,
const int v=0)
const {
11292 T&
atXY(
const int x,
const int y,
const int z,
const int v,
const T out_val) {
11296 T
atXY(
const int x,
const int y,
const int z,
const int v,
const T out_val)
const {
11297 return (x<0 || y<0 || x>=
dimx() || y>=
dimy())?out_val:(*this)(
x,
y,
z,
v);
11301 T&
atXY(
const int x,
const int y,
const int z=0,
const int v=0) {
11308 T
atXY(
const int x,
const int y,
const int z=0,
const int v=0)
const {
11315 T&
_atXY(
const int x,
const int y,
const int z=0,
const int v=0) {
11319 T
_atXY(
const int x,
const int y,
const int z=0,
const int v=0)
const {
11324 T&
atX(
const int x,
const int y,
const int z,
const int v,
const T out_val) {
11328 T
atX(
const int x,
const int y,
const int z,
const int v,
const T out_val)
const {
11329 return (x<0 || x>=
dimx())?out_val:(*this)(
x,
y,
z,
v);
11333 T&
atX(
const int x,
const int y=0,
const int z=0,
const int v=0) {
11340 T
atX(
const int x,
const int y=0,
const int z=0,
const int v=0)
const {
11347 T&
_atX(
const int x,
const int y=0,
const int z=0,
const int v=0) {
11351 T
_atX(
const int x,
const int y=0,
const int z=0,
const int v=0)
const {
11358 x = (int)fx-(fx>=0?0:1), nx = x+1,
11359 y = (int)fy-(fy>=0?0:1), ny = y+1,
11360 z = (int)fz-(fz>=0?0:1), nz = z+1,
11361 v = (int)fv-(fv>=0?0:1), nv = v+1;
11368 Icccc = (
Tfloat)
atXYZV(x,y,z,v,out_val), Inccc = (
Tfloat)
atXYZV(nx,y,z,v,out_val),
11369 Icncc = (
Tfloat)
atXYZV(x,ny,z,v,out_val), Inncc = (
Tfloat)
atXYZV(nx,ny,z,v,out_val),
11370 Iccnc = (
Tfloat)
atXYZV(x,y,nz,v,out_val), Incnc = (
Tfloat)
atXYZV(nx,y,nz,v,out_val),
11371 Icnnc = (
Tfloat)
atXYZV(x,ny,nz,v,out_val), Innnc = (
Tfloat)
atXYZV(nx,ny,nz,v,out_val),
11372 Icccn = (
Tfloat)
atXYZV(x,y,z,nv,out_val), Inccn = (
Tfloat)
atXYZV(nx,y,z,nv,out_val),
11373 Icncn = (
Tfloat)
atXYZV(x,ny,z,nv,out_val), Inncn = (
Tfloat)
atXYZV(nx,ny,z,nv,out_val),
11374 Iccnn = (
Tfloat)
atXYZV(x,y,nz,nv,out_val), Incnn = (
Tfloat)
atXYZV(nx,y,nz,nv,out_val),
11378 dy*(Icccc+Inncc-Icncc-Inccc +
11379 dz*(Iccnc+Innnc+Icncc+Inccc-Icnnc-Incnc-Icccc-Inncc +
11380 dv*(Iccnn+Innnn+Icncn+Inccn+Icnnc+Incnc+Icccc+Inncc-Icnnn-Incnn-Icccn-Inncn-Iccnc-Innnc-Icncc-Inccc)) +
11381 dv*(Icccn+Inncn+Icncc+Inccc-Icncn-Inccn-Icccc-Inncc)) +
11382 dz*(Icccc+Incnc-Iccnc-Inccc +
11383 dv*(Icccn+Incnn+Iccnc+Inccc-Iccnn-Inccn-Icccc-Incnc)) +
11384 dv*(Icccc+Inccn-Inccc-Icccn)) +
11386 dz*(Icccc+Icnnc-Iccnc-Icncc +
11387 dv*(Icccn+Icnnn+Iccnc+Icncc-Iccnn-Icncn-Icccc-Icnnc)) +
11388 dv*(Icccc+Icncn-Icncc-Icccn)) +
11390 dv*(Icccc+Iccnn-Iccnc-Icccn)) +
11407 nfv = fv<0?0:(fv>dim-1?dim-1:fv);
11409 x = (
unsigned int)nfx,
11410 y = (
unsigned int)nfy,
11411 z = (
unsigned int)nfz,
11412 v = (
unsigned int)nfv;
11427 Icnnc = (
Tfloat)(*this)(
x,ny,nz,
v), Innnc = (
Tfloat)(*this)(nx,ny,nz,
v),
11429 Icncn = (
Tfloat)(*this)(
x,ny,
z,nv), Inncn = (
Tfloat)(*this)(nx,ny,
z,nv),
11430 Iccnn = (
Tfloat)(*this)(
x,
y,nz,nv), Incnn = (
Tfloat)(*this)(nx,
y,nz,nv),
11431 Icnnn = (
Tfloat)(*this)(
x,ny,nz,nv), Innnn = (
Tfloat)(*this)(nx,ny,nz,nv);
11434 dy*(Icccc+Inncc-Icncc-Inccc +
11435 dz*(Iccnc+Innnc+Icncc+Inccc-Icnnc-Incnc-Icccc-Inncc +
11436 dv*(Iccnn+Innnn+Icncn+Inccn+Icnnc+Incnc+Icccc+Inncc-Icnnn-Incnn-Icccn-Inncn-Iccnc-Innnc-Icncc-Inccc)) +
11437 dv*(Icccn+Inncn+Icncc+Inccc-Icncn-Inccn-Icccc-Inncc)) +
11438 dz*(Icccc+Incnc-Iccnc-Inccc +
11439 dv*(Icccn+Incnn+Iccnc+Inccc-Iccnn-Inccn-Icccc-Incnc)) +
11440 dv*(Icccc+Inccn-Inccc-Icccn)) +
11442 dz*(Icccc+Icnnc-Iccnc-Icncc +
11443 dv*(Icccn+Icnnn+Iccnc+Icncc-Iccnn-Icncn-Icccc-Icnnc)) +
11444 dv*(Icccc+Icncn-Icncc-Icccn)) +
11446 dv*(Icccc+Iccnn-Iccnc-Icccn)) +
11453 x = (int)fx-(fx>=0?0:1), nx = x+1,
11454 y = (int)fy-(fy>=0?0:1), ny = y+1,
11455 z = (int)fz-(fz>=0?0:1), nz = z+1;
11461 Iccc = (
Tfloat)
atXYZ(x,y,z,v,out_val), Incc = (
Tfloat)
atXYZ(nx,y,z,v,out_val),
11462 Icnc = (
Tfloat)
atXYZ(x,ny,z,v,out_val), Innc = (
Tfloat)
atXYZ(nx,ny,z,v,out_val),
11463 Iccn = (
Tfloat)
atXYZ(x,y,nz,v,out_val), Incn = (
Tfloat)
atXYZ(nx,y,nz,v,out_val),
11467 dy*(Iccc+Innc-Icnc-Incc +
11468 dz*(Iccn+Innn+Icnc+Incc-Icnn-Incn-Iccc-Innc)) +
11469 dz*(Iccc+Incn-Iccn-Incc)) +
11471 dz*(Iccc+Icnn-Iccn-Icnc)) +
11489 x = (
unsigned int)nfx,
11490 y = (
unsigned int)nfy,
11491 z = (
unsigned int)nfz;
11504 Icnn = (
Tfloat)(*this)(
x,ny,nz,
v), Innn = (
Tfloat)(*this)(nx,ny,nz,
v);
11507 dy*(Iccc+Innc-Icnc-Incc +
11508 dz*(Iccn+Innn+Icnc+Incc-Icnn-Incn-Iccc-Innc)) +
11509 dz*(Iccc+Incn-Iccn-Incc)) +
11511 dz*(Iccc+Icnn-Iccn-Icnc)) +
11518 x = (int)fx-(fx>=0?0:1), nx = x+1,
11519 y = (int)fy-(fy>=0?0:1), ny = y+1;
11524 Icc = (
Tfloat)
atXY(x,y,z,v,out_val), Inc = (
Tfloat)
atXY(nx,y,z,v,out_val),
11526 return Icc + dx*(Inc-Icc + dy*(Icc+Inn-Icn-Inc)) + dy*(Icn-Icc);
11542 x = (
unsigned int)nfx,
11543 y = (
unsigned int)nfy;
11553 return Icc + dx*(Inc-Icc + dy*(Icc+Inn-Icn-Inc)) + dy*(Icn-Icc);
11559 x = (int)fx-(fx>=0?0:1), nx = x+1;
11564 return Ic + dx*(In-Ic);
11579 x = (
unsigned int)nfx;
11586 return Ic + dx*(In-Ic);
11592 x = (int)fx-(fx>=0?0:1), px = x-1, nx = x+1, ax = x+2,
11593 y = (int)fy-(fy>=0?0:1), py = y-1, ny = y+1, ay = y+2;
11595 dx = fx-
x, dx2 = dx*
dx, dx3 = dx2*
dx,
11598 Ipp = (
Tfloat)
atXY(px,py,z,v,out_val), Icp = (
Tfloat)
atXY(x,py,z,v,out_val),
11599 Inp = (
Tfloat)
atXY(nx,py,z,v,out_val), Iap = (
Tfloat)
atXY(ax,py,z,v,out_val),
11600 Ipc = (
Tfloat)
atXY(px,y,z,v,out_val), Icc = (
Tfloat)
atXY(x,y,z,v,out_val),
11601 Inc = (
Tfloat)
atXY(nx,y,z,v,out_val), Iac = (
Tfloat)
atXY(ax,y,z,v,out_val),
11602 Ipn = (
Tfloat)
atXY(px,ny,z,v,out_val), Icn = (
Tfloat)
atXY(x,ny,z,v,out_val),
11603 Inn = (
Tfloat)
atXY(nx,ny,z,v,out_val), Ian = (
Tfloat)
atXY(ax,ny,z,v,out_val),
11604 Ipa = (
Tfloat)
atXY(px,ay,z,v,out_val), Ica = (
Tfloat)
atXY(x,ay,z,v,out_val),
11605 Ina = (
Tfloat)
atXY(nx,ay,z,v,out_val), Iaa = (
Tfloat)
atXY(ax,ay,z,v,out_val),
11606 valm =
cimg::min(
cimg::min(Ipp,Icp,Inp,Iap),
cimg::min(Ipc,Icc,Inc,Iac),
cimg::min(Ipn,Icn,Inn,Ian),
cimg::min(Ipa,Ica,Ina,Iaa)),
11607 valM =
cimg::max(
cimg::max(Ipp,Icp,Inp,Iap),
cimg::max(Ipc,Icc,Inc,Iac),
cimg::max(Ipn,Icn,Inn,Ian),
cimg::max(Ipa,Ica,Ina,Iaa)),
11610 ap = 2*(Icp-Inp) + u0p + u1p,
11611 bp = 3*(Inp-Icp) - 2*u0p - u1p,
11614 ac = 2*(Icc-Inc) + u0c + u1c,
11615 bc = 3*(Inc-Icc) - 2*u0c - u1c,
11618 an = 2*(Icn-Inn) + u0n + u1n,
11619 bn = 3*(Inn-Icn) - 2*u0n - u1n,
11622 aa = 2*(Ica-Ina) + u0a + u1a,
11623 ba = 3*(Ina-Ica) - 2*u0a - u1a,
11624 valp = ap*dx3 + bp*dx2 + u0p*dx + Icp,
11625 valc = ac*dx3 + bc*dx2 + u0c*dx + Icc,
11626 valn = an*dx3 + bn*dx2 + u0n*dx + Icn,
11627 vala = aa*dx3 + ba*dx2 + u0a*dx + Ica,
11630 a = 2*(valc-valn) + u0 + u1,
11631 b = 3*(valn-valc) - 2*u0 - u1,
11632 val = a*dy*dy*dy + b*dy*dy + u0*dy + valc;
11633 return val<valm?valm:(val>valM?valM:val);
11652 dx = nfx-
x, dx2 = dx*
dx, dx3 = dx2*
dx,
11655 px = x-1<0?0:x-1, nx = dx>0?x+1:
x, ax = x+2>=
dimx()?
dimx()-1:x+2,
11656 py = y-1<0?0:y-1, ny = dy>0?y+1:
y, ay = y+2>=
dimy()?
dimy()-1:y+2;
11666 valm =
cimg::min(
cimg::min(Ipp,Icp,Inp,Iap),
cimg::min(Ipc,Icc,Inc,Iac),
cimg::min(Ipn,Icn,Inn,Ian),
cimg::min(Ipa,Ica,Ina,Iaa)),
11667 valM =
cimg::max(
cimg::max(Ipp,Icp,Inp,Iap),
cimg::max(Ipc,Icc,Inc,Iac),
cimg::max(Ipn,Icn,Inn,Ian),
cimg::max(Ipa,Ica,Ina,Iaa)),
11670 ap = 2*(Icp-Inp) + u0p + u1p,
11671 bp = 3*(Inp-Icp) - 2*u0p - u1p,
11674 ac = 2*(Icc-Inc) + u0c + u1c,
11675 bc = 3*(Inc-Icc) - 2*u0c - u1c,
11678 an = 2*(Icn-Inn) + u0n + u1n,
11679 bn = 3*(Inn-Icn) - 2*u0n - u1n,
11682 aa = 2*(Ica-Ina) + u0a + u1a,
11683 ba = 3*(Ina-Ica) - 2*u0a - u1a,
11684 valp = ap*dx3 + bp*dx2 + u0p*dx + Icp,
11685 valc = ac*dx3 + bc*dx2 + u0c*dx + Icc,
11686 valn = an*dx3 + bn*dx2 + u0n*dx + Icn,
11687 vala = aa*dx3 + ba*dx2 + u0a*dx + Ica,
11690 a = 2*(valc-valn) + u0 + u1,
11691 b = 3*(valn-valc) - 2*u0 - u1,
11692 val = a*dy*dy*dy + b*dy*dy + u0*dy + valc;
11693 return val<valm?valm:(val>valM?valM:val);
11699 x = (int)fx-(fx>=0?0:1), px = x-1, nx = x+1, ax = x+2;
11703 Ip = (
Tfloat)
atX(px,y,z,v,out_val), Ic = (
Tfloat)
atX(x,y,z,v,out_val),
11704 In = (
Tfloat)
atX(nx,y,z,v,out_val), Ia = (
Tfloat)
atX(ax,y,z,v,out_val),
11708 a = 2*(Ic-In) + u0 + u1,
11709 b = 3*(In-Ic) - 2*u0 - u1,
11710 val = a*dx*dx*dx + b*dx*dx + u0*dx + Ic;
11711 return val<valm?valm:(val>valM?valM:val);
11730 px = x-1<0?0:x-1, nx = dx>0?x+1:
x, ax = x+2>=
dimx()?
dimx()-1:x+2;
11737 a = 2*(Ic-In) + u0 + u1,
11738 b = 3*(In-Ic) - 2*u0 - u1,
11739 val = a*dx*dx*dx + b*dx*dx + u0*dx + Ic;
11740 return val<valm?valm:(val>valM?valM:val);
11745 const bool add=
false) {
11747 x = (int)fx-(fx>=0?0:1), nx = x+1,
11748 y = (int)fy-(fy>=0?0:1), ny = y+1,
11749 z = (int)fz-(fz>=0?0:1), nz = z+1;
11755 if (z>=0 && z<
dimz()) {
11756 if (y>=0 && y<
dimy()) {
11757 if (x>=0 && x<
dimx()) {
11758 const float w1 = (1-
dx)*(1-dy)*(1-dz), w2 = add?1:(1-w1);
11759 (*this)(
x,
y,
z,
v) = (T)(w1*val + w2*(*this)(
x,
y,
z,
v));
11761 if (nx>=0 && nx<
dimx()) {
11762 const float w1 = dx*(1-
dy)*(1-dz), w2 = add?1:(1-w1);
11763 (*this)(nx,
y,
z,
v) = (T)(w1*val + w2*(*this)(nx,
y,
z,
v));
11766 if (ny>=0 && ny<
dimy()) {
11767 if (x>=0 && x<
dimx()) {
11768 const float w1 = (1-
dx)*dy*(1-dz), w2 = add?1:(1-w1);
11769 (*this)(
x,ny,
z,
v) = (T)(w1*val + w2*(*this)(
x,ny,
z,
v));
11771 if (nx>=0 && nx<
dimx()) {
11772 const float w1 = dx*dy*(1-dz), w2 = add?1:(1-w1);
11773 (*this)(nx,ny,
z,
v) = (T)(w1*val + w2*(*this)(nx,ny,
z,
v));
11777 if (nz>=0 && nz<
dimz()) {
11778 if (y>=0 && y<
dimy()) {
11779 if (x>=0 && x<
dimx()) {
11780 const float w1 = (1-
dx)*(1-dy), w2 = add?1:(1-w1);
11781 (*this)(
x,
y,nz,
v) = (T)(w1*val + w2*(*this)(
x,
y,nz,
v));
11783 if (nx>=0 && nx<
dimx()) {
11784 const float w1 = dx*(1-
dy), w2 = add?1:(1-w1);
11785 (*this)(nx,
y,nz,
v) = (T)(w1*val + w2*(*this)(nx,
y,nz,
v));
11788 if (ny>=0 && ny<
dimy()) {
11789 if (x>=0 && x<
dimx()) {
11790 const float w1 = (1-
dx)*dy, w2 = add?1:(1-w1);
11791 (*this)(
x,ny,nz,
v) = (T)(w1*val + w2*(*this)(
x,ny,nz,
v));
11793 if (nx>=0 && nx<
dimx()) {
11794 const float w1 = dx*
dy, w2 = add?1:(1-w1);
11795 (*this)(nx,ny,nz,
v) = (T)(w1*val + w2*(*this)(nx,ny,nz,
v));
11805 const bool add=
false) {
11807 x = (int)fx-(fx>=0?0:1), nx = x+1,
11808 y = (int)fy-(fy>=0?0:1), ny = y+1;
11813 if (y>=0 && y<
dimy()) {
11814 if (x>=0 && x<
dimx()) {
11815 const float w1 = (1-
dx)*(1-dy), w2 = add?1:(1-w1);
11816 (*this)(
x,
y,
z,
v) = (T)(w1*val + w2*(*this)(
x,
y,
z,
v));
11818 if (nx>=0 && nx<
dimx()) {
11819 const float w1 = dx*(1-
dy), w2 = add?1:(1-w1);
11820 (*this)(nx,
y,
z,
v) = (T)(w1*val + w2*(*this)(nx,
y,
z,
v));
11823 if (ny>=0 && ny<
dimy()) {
11824 if (x>=0 && x<
dimx()) {
11825 const float w1 = (1-
dx)*dy, w2 = add?1:(1-w1);
11826 (*this)(
x,ny,
z,
v) = (T)(w1*val + w2*(*this)(
x,ny,
z,
v));
11828 if (nx>=0 && nx<
dimx()) {
11829 const float w1 = dx*
dy, w2 = add?1:(1-w1);
11830 (*this)(nx,ny,
z,
v) = (T)(w1*val + w2*(*this)(nx,ny,
z,
v));
11840 const unsigned int siz = (
unsigned int)
size();
11842 char item[256] = { 0 };
11843 const T *ptrs =
ptr();
11844 for (
unsigned int off = 0; off<siz-1; ++off) {
11846 const unsigned int l = std::strlen(item);
11852 if (max_size) { res.crop(0,max_size); res(max_size) = 0; }
11870 return (
width==dx);
11874 template<
typename t>
11890 template<
typename t>
11902 return (
depth==dz);
11906 template<
typename t>
11917 template<
typename t>
11928 template<
typename t>
11944 template<
typename t>
11955 template<
typename t>
11966 template<
typename t>
11977 template<
typename t>
11983 bool is_sameZV(
const unsigned int dz,
const unsigned int dv)
const {
11988 template<
typename t>
11994 bool is_sameXYZ(
const unsigned int dx,
const unsigned int dy,
const unsigned int dz)
const {
11999 template<
typename t>
12005 bool is_sameXYV(
const unsigned int dx,
const unsigned int dy,
const unsigned int dv)
const {
12010 template<
typename t>
12016 bool is_sameXZV(
const unsigned int dx,
const unsigned int dz,
const unsigned int dv)
const {
12021 template<
typename t>
12027 bool is_sameYZV(
const unsigned int dy,
const unsigned int dz,
const unsigned int dv)
const {
12032 template<
typename t>
12038 bool is_sameXYZV(
const unsigned int dx,
const unsigned int dy,
const unsigned int dz,
const unsigned int dv)
const {
12043 template<
typename t>
12050 return !
is_empty() && x>=0 && x<dimx() && y>=0 && y<dimy() && z>=0 && z<dimz() && v>=0 &&
v<
dimv();
12054 template<
typename t>
12057 const T *
const ppixel = &pixel;
12058 if (
is_empty() || ppixel<data || ppixel>=
data+siz)
return false;
12059 unsigned int off = (
unsigned int)(ppixel -
data);
12060 const unsigned int nv = off/whz;
12062 const unsigned int nz = off/wh;
12064 const unsigned int ny = off/
width, nx = off%
width;
12065 x = (t)nx; y = (t)ny; z = (t)nz; v = (t)nv;
12070 template<
typename t>
12073 const T *
const ppixel = &pixel;
12074 if (
is_empty() || ppixel<data || ppixel>=
data+siz)
return false;
12075 unsigned int off = ((
unsigned int)(ppixel -
data))%whz;
12076 const unsigned int nz = off/wh;
12078 const unsigned int ny = off/
width, nx = off%
width;
12079 x = (t)nx; y = (t)ny; z = (t)nz;
12084 template<
typename t>
12087 const T *
const ppixel = &pixel;
12088 if (
is_empty() || ppixel<data || ppixel>=
data+siz)
return false;
12089 unsigned int off = ((
unsigned int)(ppixel -
data))%wh;
12090 const unsigned int ny = off/
width, nx = off%
width;
12091 x = (t)nx; y = (t)ny;
12096 template<
typename t>
12098 const T *
const ppixel = &pixel;
12100 x = (t)(((
unsigned int)(ppixel -
data))%
width);
12106 const T *
const ppixel = &pixel;
12114 template<
typename t>
12116 const unsigned int csiz =
size(), isiz = img.size();
12117 return !((
void*)(
data+csiz)<=(
void*)img.data || (
void*)
data>=(
void*)(img.data+isiz));
12121 template<
typename tf>
12123 const bool throw_exception=
false,
const char *
const calling_function=0)
const {
12124 const char *
const ncall = calling_function?calling_function:
"is_object3d";
12127 if (throw_exception)
12128 throw CImgArgumentException(
"CImg<%s>::%s() : Invalid 3D object, %u primitives defined for 0 vertices.",
12135 if (throw_exception)
12136 throw CImgArgumentException(
"CImg<%s>::%s() : Invalid 3D object, image (%u,%u,%u,%u,%p) is not a set of 3D vertices.",
12141 const CImg<tf>& primitive = primitives[l];
12142 const unsigned int psiz = primitive.size();
12145 const unsigned int i0 = (
unsigned int)primitive[0];
12147 if (throw_exception)
12148 throw CImgArgumentException(
"CImg<%s>::%s() : Invalid 3D object, primitive %u = point(%u) references invalid vertice "
12155 i0 = (
unsigned int)primitive(0),
12156 i1 = (
unsigned int)primitive(1),
12157 i2 = (
unsigned int)primitive(2);
12159 if (throw_exception)
12160 throw CImgArgumentException(
"CImg<%s>::%s() : Invalid 3D object, primitive %u = sphere(%u,%u,%u) references invalid vertice "
12168 i0 = (
unsigned int)primitive(0),
12169 i1 = (
unsigned int)primitive(1);
12171 if (throw_exception)
12172 throw CImgArgumentException(
"CImg<%s>::%s() : Invalid 3D object, primitive %u = segment(%u,%u) references invalid vertice "
12180 i0 = (
unsigned int)primitive(0),
12181 i1 = (
unsigned int)primitive(1),
12182 i2 = (
unsigned int)primitive(2);
12184 if (throw_exception)
12185 throw CImgArgumentException(
"CImg<%s>::%s() : Invalid 3D object, primitive %u = triangle(%u,%u,%u) references invalid vertice "
12193 i0 = (
unsigned int)primitive(0),
12194 i1 = (
unsigned int)primitive(1),
12195 i2 = (
unsigned int)primitive(2),
12196 i3 = (
unsigned int)primitive(3);
12198 if (throw_exception)
12199 throw CImgArgumentException(
"CImg<%s>::%s() : Invalid 3D object, primitive %u = rectangle(%u,%u,%u,%u) references invalid vertice "
12204 default :
return false;
12224 #define _cimg_freturn(x) { *se = saved_char; return x; }
12225 #define _cimg_fopcode0(op) _cimg_freturn(opcode(op));
12226 #define _cimg_fopcode1(op,i1) _cimg_freturn(opcode(op,i1));
12227 #define _cimg_fopcode2(op,i1,i2) _cimg_freturn(opcode(op,i1,i2));
12228 #define _cimg_fopcode3(op,i1,i2,i3) _cimg_freturn(opcode(op,i1,i2,i3));
12229 #define _cimg_fopcode5(op,i1,i2,i3,i4,i5) _cimg_freturn(opcode(op,i1,i2,i3,i4,i5));
12233 static const char *
const funcname0 =
"cimg_math_parser";
12235 if (!expression)
return;
12236 unsigned int l0 = std::strlen(expression);
12237 expr =
new char[l0+1];
12238 std::strcpy(
expr,expression);
12240 if (!*
expr)
return;
12241 char *
d =
expr;
for (
const char *s =
expr; *s || (bool)(*d=0); ++
s)
if (*s!=
' ') *(d++) = *s;
12242 const unsigned int l = d -
expr;
12246 unsigned int *pd =
level =
new unsigned int[l];
12247 for (
const char *ps = expr; *ps && lv>=0; ++ps) *(pd++) = (
unsigned int)(*ps==
'('?lv++:*ps==
')'?--lv:lv);
12248 if (lv!=0)
throw CImgArgumentException(
"CImg<%s>::%s() : Unbalanced parenthesis, in formula '%s'.",
12252 result =
compile(expr,expr+l);
12257 unsigned int opcode(
const char op,
const unsigned int arg1=0,
const unsigned int arg2=0,
12258 const unsigned int arg3=0,
const unsigned int arg4=0,
const unsigned int arg5=0) {
12260 const unsigned int pos =
mempos++;
12266 unsigned int compile(
char *
const ss,
char *
const se) {
12267 if (!ss || se<=ss || !*ss)
throw CImgArgumentException(
"CImg<%s>::%s() : Missing item, in formula '%s'.",
12270 *
const se1 = se-1, *
const se2 = se-2, *
const se3 = se-3, *
const se4 = se-4,
12271 *
const ss1 = ss+1, *
const ss2 = ss+2, *
const ss3 = ss+3, *
const ss4 = ss+4, *
const ss5 = ss+5, *
const ss6 = ss+6;
12272 const char saved_char = *se; *se = 0;
12273 const unsigned int clevel =
level[ss-
expr], clevel1 = clevel+1;
12276 char end = 0;
double val = 0;
12277 if (std::sscanf(ss,
"%lf%c",&val,&end)==1) {
12278 const unsigned int i =
mempos++;
12282 if (ss1==se)
switch (*ss) {
12299 for (
char *s = ss1, *ns = 0; s<se3 && (ns=std::strstr(s,
"and")) && ns<se3; s=ns+3)
12301 for (
char *s = ss1, *ns = 0; s<se2 && (ns=std::strstr(s,
"&&")) && ns<se2; s=ns+2)
12303 for (
char *s = ss1, *ns = 0; s<se3 && (ns=std::strstr(s,
"xor")) && ns<se3; s=ns+3)
12305 for (
char *s = ss1, *ns = 0; s<se2 && (ns=std::strstr(s,
"or")) && ns<se2; s=ns+2)
12307 for (
char *s = ss1, *ns = 0; s<se2 && (ns=std::strstr(s,
"||")) && ns<se2; s=ns+2)
12309 for (
char *s = ss1, *ns = 0; s<se2 && (ns=std::strstr(s,
"<=")) && ns<se2; s=ns+2)
12311 for (
char *s = ss1, *ns = 0; s<se2 && (ns=std::strstr(s,
">=")) && ns<se2; s=ns+2)
12313 for (
char *s = ss1, *ns = 0; s<se2 && (ns=std::strstr(s,
"!=")) && ns<se2; s=ns+2)
12315 for (
char *s = ss1, *ns = 0; s<se2 && (ns=std::strstr(s,
"==")) && ns<se2; s=ns+2)
12317 for (
char *s = ss1, *ns = 0; s<se1 && (ns=std::strstr(s,
">")) && ns<se1; s=ns+1)
12319 for (
char *s = ss1, *ns = 0; s<se1 && (ns=std::strstr(s,
"<")) && ns<se1; s=ns+1)
12321 for (
char *s = ss1, *ns = 0; s<se1 && (ns=std::strstr(s,
"+")) && ns<se1; s=ns+1)
12323 for (
char *s = ss1, *ns = 0; s<se1 && (ns=std::strstr(s,
"-")) && ns<se1; s=ns+1) {
12324 const char ps = *(ns-1);
12325 if (ps!=
'*' && ps!=
'/' && ps!=
'%' && ps!=
'^' && ps!=
'&' && ps!=
'|' && ps!=
'^' &&
12328 for (
char *s = ss1, *ns = 0; s<se1 && (ns=std::strstr(s,
"*")) && ns<se1; s=ns+1)
12330 for (
char *s = ss1, *ns = 0; s<se1 && (ns=std::strstr(s,
"/")) && ns<se1; s=ns+1)
12338 for (
char *s = ss1, *ns = 0; s<se1 && (ns=std::strstr(s,
"%")) && ns<se1; s=ns+1)
12340 for (
char *s = ss1, *ns = 0; s<se3 && (ns=std::strstr(s,
"mod")) && ns<se3; s=ns+3)
12342 for (
char *s = ss1, *ns = 0; s<se1 && (ns=std::strstr(s,
"&")) && ns<se1; s=ns+1)
12344 for (
char *s = ss1, *ns = 0; s<se1 && (ns=std::strstr(s,
"|")) && ns<se1; s=ns+1)
12346 for (
char *s = ss1, *ns = 0; s<se1 && (ns=std::strstr(s,
"^")) && ns<se1; s=ns+1)
12369 if (!std::strncmp(ss,
"atan2(",6)) {
12370 char *s1 = ss6;
while (s1<se2 && (*s1!=
',' ||
level[s1-
expr]!=clevel1)) ++s1;
12373 if (!std::strncmp(ss,
"if(",3)) {
12374 char *s1 = ss3;
while (s1<se4 && (*s1!=
',' ||
level[s1-
expr]!=clevel1)) ++s1;
12375 char *s2 = s1+1;
while (s2<se2 && (*s2!=
',' ||
level[s2-
expr]!=clevel1)) ++s2;
12378 if (!std::strncmp(ss,
"i(",2)) {
12379 unsigned int indx = 0, indy = 1, indz = 2, indv = 3, borders = 10;
12381 char *s1 = ss2;
while (s1<se2 && (*s1!=
',' ||
level[s1-
expr]!=clevel1)) ++s1;
12382 indx =
compile(ss2,s1==se2?++s1:s1);
12384 char *s2 = s1+1;
while (s2<se2 && (*s2!=
',' ||
level[s2-
expr]!=clevel1)) ++s2;
12385 indy =
compile(s1+1,s2==se2?++s2:s2);
12387 char *s3 = s2+1;
while (s3<se2 && (*s3!=
',' ||
level[s3-
expr]!=clevel1)) ++s3;
12388 indz =
compile(s2+1,s3==se2?++s3:s3);
12390 char *s4 = s3+1;
while (s4<se2 && (*s4!=
',' ||
level[s4-
expr]!=clevel1)) ++s4;
12391 indv =
compile(s3+1,s4==se2?++s4:s4);
12392 if (s4<se1) borders =
compile(s4+1,se1);
12399 if (!std::strncmp(ss,
"min(",4) || !std::strncmp(ss,
"max(",4)) {
12403 for (
char *s = ss4; s<se; ++
s) {
12404 char *ns =
s;
while (ns<se && (*ns!=
',' ||
level[ns-
expr]!=clevel1) && (*ns!=
')' ||
level[ns-
expr]!=clevel)) ++ns;
12413 char *item =
new char[std::strlen(ss)];
12414 std::strcpy(item,ss);
12422 template<
typename t>
12423 double eval(
const CImg<t>& img,
const double x,
const double y,
const double z,
const double v) {
12424 if (!
mem)
return 0;
12426 mem[4] = img.dimx();
mem[5] = img.dimy();
mem[6] = img.dimz();
mem[7] = img.dimv();
12433 case 'I' : res = (double)img.atXYZV((
int)x,(
int)y,(
int)z,(
int)v,0);
break;
12434 case '0' : res = x/img.dimx();
break;
12435 case '1' : res = y/img.dimy();
break;
12436 case '2' : res = z/img.dimz();
break;
12437 case '3' : res = v/img.dimv();
break;
12451 case 'o' : res = -
mem[
opcode(2)];
break;
12452 case 'p' : res =
mem[
opcode(2)];
break;
12453 case 'n' : res = !
mem[
opcode(2)];
break;
12454 case '~' : res = ~(
unsigned long)
mem[
opcode(2)];
break;
12456 case '&' : res = ((
unsigned long)
mem[
opcode(2)] & (
unsigned long)
mem[
opcode(3)]);
break;
12457 case '|' : res = ((
unsigned long)
mem[
opcode(2)] | (
unsigned long)
mem[
opcode(3)]);
break;
12477 case 0 : res = (double)img.linear_atXYZ((
float)
mem[opcode(2)],
12480 v<0?0:v>=img.dimv()?img.dimv()-1:
v,0);
break;
12481 case 1 : res = (double)img.linear_atXYZ((
float)
mem[opcode(2)],
12484 v<0?0:v>=img.dimv()?img.dimv()-1:
v);
break;
12485 default : res = (double)img.linear_atXYZ((
float)
cimg::mod(
mem[opcode(2)],(
double)img.dimx()),
12488 v<0?0:v>=img.dimv()?img.dimv()-1:
v);
break;
12512 double eval(
const double x,
const double y,
const double z,
const double v) {
12514 return eval(empty,x,y,z,v);
12670 template<
typename t>
12673 t *ptrs = img.data + smin;
12674 for (T *ptrd =
data + smin; ptrd>
data; --ptrd, *ptrd = (T)std::atan2((
double)*ptrd,(double)*(--ptrs))) {}
12678 template<
typename t>
12684 template<
typename t>
12686 const unsigned int siz =
size(), isiz = img.size();
12689 T *ptrd =
data, *
const ptrd_end =
data + siz;
12690 if (siz>isiz)
for (
unsigned int n = siz/isiz;
n; --
n)
12691 for (
const t *ptrs = img.data, *ptrs_end = ptrs + isiz; ptrs<ptrs_end; ++ptrd) *ptrd = (T)(*ptrd * *(ptrs++));
12692 for (
const t *ptrs = img.data; ptrd<ptrd_end; ++ptrd) *ptrd = (T)(*ptrd * *(ptrs++));
12697 template<
typename t>
12703 template<
typename t>
12705 const unsigned int siz =
size(), isiz = img.size();
12708 T *ptrd =
data, *
const ptrd_end =
data + siz;
12709 if (siz>isiz)
for (
unsigned int n = siz/isiz;
n; --
n)
12710 for (
const t *ptrs = img.data, *ptrs_end = ptrs + isiz; ptrs<ptrs_end; ++ptrd) *ptrd = (T)(*ptrd / *(ptrs++));
12711 for (
const t *ptrs = img.data; ptrd<ptrd_end; ++ptrd) *ptrd = (T)(*ptrd / *(ptrs++));
12716 template<
typename t>
12723 if (p==0)
return fill(1);
12725 if (p==1)
return *
this;
12726 if (p==2) {
cimg_for(*
this,
ptr,T) {
const T val = *
ptr; *
ptr = val*val; }
return *
this; }
12727 if (p==3) {
cimg_for(*
this,
ptr,T) {
const T val = *
ptr; *
ptr = val*val*val; }
return *
this; }
12728 if (p==4) {
cimg_for(*
this,
ptr,T) {
const T val = *
ptr; *
ptr = val*val*val*val; }
return *
this; }
12738 template<
typename t>
12741 t *ptrs = img.data;
12743 for (T* ptrd =
data; ptrd<ptrf; ++ptrd) (*ptrd) = (T)
std::pow((
double)*ptrd,(double)(*(ptrs++)));
12747 template<
typename t>
12757 _cimg_math_parser mp(expression,
"pow");
12763 values.fill(expression,
true);
12766 values.load(expression);
12785 return (+*
this).
min(val);
12789 template<
typename t>
12792 t *ptrs = img.data;
12794 for (T* ptrd =
data; ptrd<ptrf; ++ptrd) (*ptrd) =
cimg::min((T)*(ptrs++),*ptrd);
12798 template<
typename t>
12808 _cimg_math_parser mp(expression,
"min");
12814 values.fill(expression,
true);
12817 values.load(expression);
12836 return (+*
this).
max(val);
12840 template<
typename t>
12843 t *ptrs = img.data;
12845 for (T* ptrd =
data; ptrd<ptrf; ++ptrd) (*ptrd) =
cimg::max((T)*(ptrs++),*ptrd);
12849 template<
typename t>
12859 _cimg_math_parser mp(expression,
"max");
12865 values.fill(expression,
true);
12868 values.load(expression);
12885 T min_value = *ptrmin;
12893 const T *ptrmin =
data;
12894 T min_value = *ptrmin;
12904 T max_value = *ptrmax;
12912 const T *ptrmax =
data;
12913 T max_value = *ptrmax;
12919 template<
typename t>
12924 T min_value = *ptrmin, max_value = min_value;
12926 const T val = *
ptr;
12927 if (val<min_value) { min_value = val; ptrmin =
ptr; }
12928 if (val>max_value) max_value = val;
12930 max_val = (t)max_value;
12934 template<
typename t>
12938 const T *ptrmin =
data;
12939 T min_value = *ptrmin, max_value = min_value;
12941 const T val = *
ptr;
12942 if (val<min_value) { min_value = val; ptrmin =
ptr; }
12943 if (val>max_value) max_value = val;
12945 max_val = (t)max_value;
12950 template<
typename t>
12955 T max_value = *ptrmax, min_value = max_value;
12957 const T val = *
ptr;
12958 if (val>max_value) { max_value = val; ptrmax =
ptr; }
12959 if (val<min_value) min_value = val;
12961 min_val = (t)min_value;
12965 template<
typename t>
12969 const T *ptrmax =
data;
12970 T max_value = *ptrmax, min_value = max_value;
12972 const T val = *
ptr;
12973 if (val>max_value) { max_value = val; ptrmax =
ptr; }
12974 if (val<min_value) min_value = val;
12976 min_val = (t)min_value;
12983 throw CImgInstanceException(
"CImg<%s>::kth_smallest() : Instance image (%u,%u,%u,%u,%p) is empty.",
12986 unsigned int l = 0, ir =
size() - 1;
12989 if (ir==l+1 && arr[ir]<arr[l])
cimg::swap(arr[l],arr[ir]);
12992 const unsigned int mid = (l + ir)>>1;
12994 if (arr[l]>arr[ir])
cimg::swap(arr[l],arr[ir]);
12995 if (arr[l+1]>arr[ir])
cimg::swap(arr[l+1],arr[ir]);
12996 if (arr[l]>arr[l+1])
cimg::swap(arr[l],arr[l+1]);
12997 unsigned int i = l + 1,
j = ir;
12998 const T pivot = arr[l+1];
13000 do ++
i;
while (arr[i]<pivot);
13001 do --
j;
while (arr[j]>pivot);
13007 if (j>=k) ir = j - 1;
13016 const unsigned int s =
size();
13063 template<
typename t>
13068 const unsigned int siz =
size();
13069 switch (variance_method) {
13072 const unsigned int siz2 = siz>>1;
13076 const Tfloat *ptrs = buf.ptr();
13077 for (
unsigned int j = 0;
j<siz2; ++
j) a+=*(ptrs++);
13079 variance = sig*sig;
13084 const unsigned int siz2 = siz>>1;
13085 const Tfloat med_i = buf[siz2];
13089 variance = sig*sig;
13094 variance = siz>1?(S2 - S*S/siz)/(siz - 1):0;
13100 variance = (S2 - S*S/siz)/siz;
13104 throw CImgArgumentException(
"CImg<%s>::variancemean() : Incorrect parameter 'variance_method = %d' (correct values are 0,1,2 or 3).",
13107 mean = (t)(average/siz);
13108 return variance>0?variance:0;
13112 template<
typename t>
13114 if (img.size()!=
size())
13115 throw CImgArgumentException(
"CImg<%s>::MSE() : Instance image (%u,%u,%u,%u) and given image (%u,%u,%u,%u) have different dimensions.",
13119 const t* ptr2 = img.end();
13129 template<
typename t>
13140 double eval(
const char *
const expression,
const double x=0,
const double y=0,
const double z=0,
const double v=0)
const {
13141 static _cimg_math_parser *mp = 0;
13142 if (expression) {
if (mp)
delete mp; mp =
new _cimg_math_parser(expression,
"eval"); }
13144 return mp->eval(*
this,x,
y,
z,
v);
13149 return get_stats(variance_method).transfer_to(*
this);
13154 const unsigned int siz =
size();
13155 const T *
const odata =
data;
13156 const T *pm = odata, *pM = odata;
13160 const T val = *
ptr;
13162 if (val<m) { m = val; pm =
ptr; }
13163 if (val>M) { M = val; pM =
ptr; }
13168 mean_value = S/siz,
13169 _variance_value = variance_method==0?(S2 - S*S/siz)/siz:
13170 (variance_method==1?(siz>1?(S2 - S*S/siz)/(siz - 1):0):
13172 variance_value = _variance_value>0?_variance_value:0;
13174 xm = 0, ym = 0, zm = 0, vm = 0,
13175 xM = 0, yM = 0, zM = 0, vM = 0;
13196 switch (magnitude_type) {
13200 if (tmp>res) res = tmp;
13210 throw CImgArgumentException(
"CImg<%s>::magnitude() : Incorrect parameter 'magnitude_type=%d' (correct values are -1,1 or 2).",
13229 throw CImgInstanceException(
"CImg<%s>::det() : Instance matrix (%u,%u,%u,%u,%p) is not square or is empty.",
13232 case 1 :
return (
Tfloat)((*this)(0,0));
13239 return i*a*e - a*h*f - i*b*
d + b*g*f + c*
d*h - c*g*e;
13255 template<
typename t>
13262 pixel_type(),img.width,img.height,img.depth,img.dim,img.data);
13265 for (
unsigned int off = 0; off<nb; ++off) res+=(
Tfloat)
data[off]*(
Tfloat)img[off];
13272 if (dest.height!=dim) dest.assign(1,dim);
13274 const T *ptrs =
ptr(x,
y,
z);
13275 T *ptrd = dest.data;
13276 cimg_forV(*
this,
k) { *(ptrd++) = *ptrs; ptrs+=whz; }
13290 if (dim==6)
return tensor((*
this)(x,
y,
z,0),(*
this)(x,
y,
z,1),(*
this)(x,
y,
z,2),
13291 (*
this)(x,
y,
z,3),(*
this)(x,
y,
z,4),(*
this)(x,
y,
z,5));
13292 if (dim==3)
return tensor((*
this)(x,
y,
z,0),(*
this)(x,
y,
z,1),(*
this)(x,
y,
z,2));
13297 template<
typename t>
13301 const t *ptrs = vec.data;
13302 T *ptrd =
ptr(x,
y,
z);
13303 for (
unsigned int k=
cimg::min((
unsigned int)vec.size(),
dim);
k; --
k) { *ptrd = (T)*(ptrs++); ptrd+=whz; }
13309 template<
typename t>
13315 template<
typename t>
13317 if (ten.height==2) {
13318 (*this)(
x,
y,
z,0) = (T)ten[0];
13319 (*this)(
x,
y,
z,1) = (T)ten[1];
13320 (*this)(
x,
y,
z,2) = (T)ten[3];
13323 (*this)(
x,
y,
z,0) = (T)ten[0];
13324 (*this)(
x,
y,
z,1) = (T)ten[1];
13325 (*this)(
x,
y,
z,2) = (T)ten[2];
13326 (*this)(
x,
y,
z,3) = (T)ten[4];
13327 (*this)(
x,
y,
z,4) = (T)ten[5];
13328 (*this)(
x,
y,
z,5) = (T)ten[8];
13344 const unsigned int siz =
size();
13357 unsigned int i = 11, i2 = i*
i;
13358 while (i2<siz) { i2+=2*i+1; ++
i; }
13368 return (+*
this).
matrix();
13378 const unsigned int siz =
size();
13383 res(0,0) = (*this)(0);
13384 res(1,0) = res(0,1) = (*this)(1);
13385 res(1,1) = (*this)(2);
13389 res(0,0) = (*this)(0);
13390 res(1,0) = res(0,1) = (*this)(1);
13391 res(2,0) = res(0,2) = (*this)(2);
13392 res(1,1) = (*this)(3);
13393 res(2,1) = res(1,2) = (*this)(4);
13394 res(2,2) = (*this)(5);
13411 cimg_foroff(*
this,off) res(off,off) = (*this)(off);
13427 const unsigned int siz =
size() - 1;
13431 cimg_foroff(*
this,l) *(ptr++) = (T)(a0 + delta*l/siz);
13445 cimg_forYZV(*
this,
y,
z,
v)
for (
int x=
y; x<
dimx(); ++
x)
cimg::swap((*
this)(
x,
y,
z,
v),(*
this)(
y,
x,
z,
v));
13456 template<
typename t>
13458 if (
width!=1 ||
height<3 || img.width!=1 || img.height<3)
13459 throw CImgInstanceException(
"CImg<%s>::cross() : Arguments (%u,%u,%u,%u,%p) and (%u,%u,%u,%u,%p) must be both 3d vectors.",
13460 pixel_type(),
width,
height,
depth,dim,
data,img.width,img.height,img.depth,img.dim,img.data);
13461 const T x = (*this)[0],
y = (*this)[1],
z = (*this)[2];
13462 (*this)[0] = (T)(y*img[2]-z*img[1]);
13463 (*this)[1] = (T)(z*img[0]-x*img[2]);
13464 (*this)[2] = (T)(x*img[1]-y*img[0]);
13468 template<
typename t>
13477 throw CImgInstanceException(
"CImg<%s>::invert() : Instance matrix (%u,%u,%u,%u,%p) is not square.",
13479 #ifdef cimg_use_lapack
13480 int INFO = (int)use_LU, N =
width, LWORK = 4*N, *IPIV =
new int[N];
13482 *lapA =
new Tfloat[N*N],
13483 *WORK =
new Tfloat[LWORK];
13485 cimg::getrf(N,lapA,IPIV,INFO);
13487 cimg::warn(
"CImg<%s>::invert() : LAPACK library function dgetrf_() returned error code %d.",
13490 cimg::getri(N,lapA,IPIV,WORK,LWORK,INFO);
13492 cimg::warn(
"CImg<%s>::invert() : LAPACK library function dgetri_() returned Error code %d",
13495 if (!INFO)
cimg_forXY(*
this,
k,l) (*this)(
k,l) = (T)(lapA[k*N+l]);
else fill(0);
13496 delete[] IPIV;
delete[] lapA;
delete[] WORK;
13498 const double dete =
width>3?-1.0:
det();
13499 if (dete!=0.0 &&
width==2) {
13503 data[0] = (T)(d/dete);
data[1] = (T)(-c/dete);
13504 data[2] = (T)(-b/dete);
data[3] = (T)(a/dete);
13505 }
else if (dete!=0.0 &&
width==3) {
13510 data[0] = (T)((i*e-f*h)/dete),
data[1] = (T)((g*f-i*
d)/dete),
data[2] = (T)((d*h-g*e)/dete);
13511 data[3] = (T)((h*c-i*b)/dete),
data[4] = (T)((i*a-c*g)/dete),
data[5] = (T)((g*b-a*h)/dete);
13512 data[6] = (T)((b*f-e*c)/dete),
data[7] = (T)((d*c-a*f)/dete),
data[8] = (T)((a*e-d*b)/dete);
13521 col._solve(
A,indx);
13554 return V*U.transpose();
13558 template<
typename t>
13560 if (
width!=1 ||
depth!=1 || dim!=1 ||
height!=A.height || A.depth!=1 || A.dim!=1)
13562 "size of given matrix A is (%u,%u,%u,%u).",
13566 if (A.width==A.height) {
13567 #ifdef cimg_use_lapack
13569 int INFO, N =
height, LWORK = 4*N, one = 1, *IPIV =
new int[N];
13571 *lapA =
new Ttfloat[N*N],
13572 *lapB =
new Ttfloat[N],
13573 *WORK =
new Ttfloat[LWORK];
13575 cimg_forY(*
this,i) lapB[
i] = (Ttfloat)((*
this)(
i));
13576 cimg::getrf(N,lapA,IPIV,INFO);
13578 cimg::warn(
"CImg<%s>::solve() : LAPACK library function dgetrf_() returned error code %d.",
13581 cimg::getrs(TRANS,N,lapA,IPIV,lapB,INFO);
13583 cimg::warn(
"CImg<%s>::solve() : LAPACK library function dgetrs_() returned Error code %d",
13586 if (!INFO)
cimg_forY(*
this,i) (*this)(
i) = (T)(lapB[
i]);
else fill(0);
13587 delete[] IPIV;
delete[] lapA;
delete[] lapB;
delete[] WORK;
13595 }
else assign(A.get_pseudoinvert()*(*this));
13599 template<
typename t>
13604 template<
typename t,
typename ti>
13607 const int N =
size();
13610 for (
int i = 0; i<N; ++
i) {
13611 const int ip = (int)indx[i];
13612 Ttfloat sum = (*this)(ip);
13613 (*this)(ip) = (*
this)(
i);
13614 if (ii>=0)
for (
int j = ii;
j<=i-1; ++
j) sum-=
A(
j,i)*(*this)(
j);
13615 else if (sum!=0) ii=
i;
13616 (*this)(
i) = (T)
sum;
13618 for (
int i = N-1; i>=0; --
i) {
13620 for (
int j = i+1;
j<N; ++
j) sum-=
A(
j,i)*(*this)(
j);
13621 (*this)(
i) = (T)(sum/
A(i,i));
13628 template<
typename t>
13630 const int siz = (int)
size();
13631 if ((
int)a.size()!=siz || (int)b.size()!=siz || (int)c.size()!=siz)
13635 const T *ptra = a.data, *ptrb = b.data, *ptrc = c.data;
13636 T *ptrnc = nc.data, *ptrd =
data;
13637 const Ttfloat valb0 = (Ttfloat)*(ptrb++);
13638 *ptrnc = *(ptrc++)/valb0;
13639 Ttfloat vald = (Ttfloat)(*(ptrd++)/=valb0);
13640 for (
int i = 1; i<siz; ++
i) {
13642 vala = (
Tfloat)*(ptra++),
13643 id = 1/(*(ptrb++) - *(ptrnc++)*vala);
13644 *ptrnc = *(ptrc++)*
id;
13645 vald = ((*ptrd-=vala*vald)*=
id);
13649 for (
int i = siz-2; i>=0; --
i) vald = (*(--ptrd)-=*(--ptrnc)*vald);
13653 template<
typename t>
13659 template<
typename t>
13661 if (
is_empty()) { val.assign(); vec.assign(); }
13669 case 1 : { val[0]=(t)(*
this)[0]; vec[0]=(t)1; }
break;
13671 const double a = (*this)[0], b = (*this)[1], c = (*this)[2],
d = (*this)[3], e = a+
d;
13672 double f = e*e-4*(a*d-b*c);
13674 cimg::warn(
"CImg<%s>::eigen() : Complex eigenvalues",
13677 const double l1 = 0.5*(e-f), l2 = 0.5*(e+f);
13678 const double theta1 = std::atan2(l2-a,b), theta2 = std::atan2(l1-a,b);
13687 throw CImgInstanceException(
"CImg<%s>::eigen() : Eigenvalues computation of general matrices is limited"
13688 "to 2x2 matrices (given is %ux%u)",
13697 eigen(res[0],res[1]);
13702 template<
typename t>
13704 if (
is_empty()) { val.assign(); vec.assign(); }
13706 #ifdef cimg_use_lapack
13707 char JOB =
'V', UPLO =
'U';
13708 int N =
width, LWORK = 4*N, INFO;
13710 *lapA =
new Tfloat[N*N],
13712 *WORK =
new Tfloat[LWORK];
13714 cimg::syev(JOB,UPLO,N,lapA,lapW,WORK,LWORK,INFO);
13716 cimg::warn(
"CImg<%s>::symmetric_eigen() : LAPACK library function dsyev_() returned error code %d.",
13721 cimg_forY(val,i) val(i) = (T)lapW[N-1-i];
13723 }
else { val.fill(0); vec.fill(0); }
13724 delete[] lapA;
delete[] lapW;
delete[] WORK;
13729 val.assign(1,
width);
13733 SVD(vec,val,V,
false);
13734 bool ambiguous =
false;
13737 if (val[p]>eig) eig = (float)val[p];
13740 if (
cimg::abs(scal)<0.9f) ambiguous =
true;
13741 if (scal<0) val[p] = -val[p];
13745 SVD(vec,val,V,
false,40,eig);
13750 val.sort(permutations,
false);
13752 cimg_forX(permutations,x) tmp(x) = vec(permutations(x),
k);
13753 std::memcpy(vec.ptr(0,
k),tmp.data,
sizeof(t)*
width);
13767 template<
typename t>
13769 if (
is_empty()) permutations.assign();
13771 if (permutations.size()!=
size()) permutations.assign(
size());
13772 cimg_foroff(permutations,off) permutations[off] = (t)off;
13778 template<
typename t>
13780 return (+*
this).
sort(permutations,increasing);
13786 return sort(foo,increasing);
13790 return (+*
this).
sort(increasing);
13793 template<
typename t>
13796 const int mid = (min+
max)/2;
13798 if ((*
this)[
min]>(*this)[mid]) {
13800 if ((*
this)[mid]>(*
this)[max]) {
13802 if ((*
this)[min]>(*
this)[mid]) {
13805 if ((*
this)[min]<(*
this)[mid]) {
13807 if ((*
this)[mid]<(*
this)[max]) {
13809 if ((*
this)[min]<(*
this)[mid]) {
13813 const T pivot = (*this)[mid];
13817 while ((*
this)[i]<pivot) ++
i;
13818 while ((*
this)[j]>pivot) --
j;
13821 cimg::swap(permutations[i++],permutations[j--]);
13826 while ((*
this)[i]>pivot) ++
i;
13827 while ((*
this)[j]<pivot) --
j;
13830 cimg::swap(permutations[i++],permutations[j--]);
13834 if (min<j)
_quicksort(min,j,permutations,increasing);
13835 if (i<max)
_quicksort(i,max,permutations,increasing);
13842 template<
typename t>
13844 const unsigned int max_iter=40,
const float lambda=0)
const {
13845 if (
is_empty()) { U.assign(); S.assign(); V.assign(); }
13849 const unsigned int delta =
cimg::min(U.width,U.height);
13850 for (
unsigned int i = 0; i<delta; ++
i) U(i,i) = (t)(U(i,i) + lambda);
13855 t anorm = 0, c, f, g = 0, h,
s, scale = 0;
13859 l = i+1; rv1[
i] = scale*g; g = s = scale = 0;
13863 for (
int k = i;
k<
dimy(); ++
k) { U(i,
k)/=scale; s+= U(i,
k)*U(i,
k); }
13864 f = U(i,i); g = (t)((f>=0?-1:1)*
std::sqrt(s)); h=f*g-
s; U(i,i) = f-g;
13865 for (
int j = l;
j<
dimx(); ++
j) {
13867 for (
int k=i;
k<
dimy(); ++
k) s+= U(i,
k)*U(
j,
k);
13869 for (
int k = i;
k<
dimy(); ++
k) U(
j,
k)+= f*U(i,
k);
13871 for (
int k = i;
k<
dimy(); ++
k) U(i,
k)*= scale;
13880 for (
int k = l;
k<
dimx(); ++
k) { U(
k,i)/= scale; s+= U(
k,i)*U(
k,i); }
13881 f = U(l,i); g = (t)((f>=0?-1:1)*
std::sqrt(s)); h = f*g-
s; U(l,i) = f-g;
13882 for (
int k = l;
k<
dimx(); ++
k) rv1[
k]=U(
k,i)/h;
13883 for (
int j = l;
j<
dimy(); ++
j) {
13885 for (
int k = l;
k<
dimx(); ++
k) s+= U(
k,
j)*U(
k,i);
13886 for (
int k = l;
k<
dimx(); ++
k) U(
k,
j)+= s*rv1[
k];
13888 for (
int k = l;
k<
dimx(); ++
k) U(
k,i)*= scale;
13894 for (
int i =
dimx()-1; i>=0; --
i) {
13897 for (
int j = l;
j<
dimx(); ++
j) V(i,
j) =(U(
j,i)/U(l,i))/g;
13898 for (
int j = l;
j<
dimx(); ++
j) {
13900 for (
int k = l;
k<
dimx(); ++
k) s+= U(
k,i)*V(
j,
k);
13901 for (
int k = l;
k<
dimx(); ++
k) V(
j,
k)+= s*V(i,
k);
13904 for (
int j = l;
j<
dimx(); ++
j) V(
j,i) = V(i,
j) = (t)0.0;
13906 V(i,i) = (t)1.0; g = rv1[
i]; l =
i;
13912 for (
int j = l;
j<
dimx(); ++
j) U(
j,i) = 0;
13915 for (
int j = l;
j<
dimx(); ++
j) {
13916 s = 0;
for (
int k = l;
k<
dimy(); ++
k) s+= U(i,
k)*U(
j,
k);
13918 for (
int k = i;
k<
dimy(); ++
k) U(
j,
k)+= f*U(i,
k);
13920 for (
int j = i;
j<
dimy(); ++
j) U(i,
j)*= g;
13921 }
else for (
int j = i;
j<
dimy(); ++
j) U(i,
j) = 0;
13925 for (
int k =
dimx()-1;
k>=0; --
k) {
13926 for (
unsigned int its = 0; its<max_iter; ++its) {
13928 for (l =
k; l>=1; --l) {
13930 if ((
cimg::abs(rv1[l])+anorm)==anorm) { flag =
false;
break; }
13931 if ((
cimg::abs(S[nm])+anorm)==anorm)
break;
13935 for (
int i = l; i<=
k; ++
i) {
13936 f = s*rv1[
i]; rv1[
i] = c*rv1[
i];
13937 if ((
cimg::abs(f)+anorm)==anorm)
break;
13945 t x = S[l],
y = S[nm];
13946 g = rv1[nm]; h = rv1[
k];
13947 f = ((y-
z)*(y+z)+(g-h)*(g+h))/(2*h*y);
13949 f = ((x-
z)*(x+z)+h*((y/(f+ (f>=0?g:-g)))-h))/x;
13951 for (
int j = l;
j<=nm; ++
j) {
13953 g = rv1[
i]; h = s*g; g = c*g;
13956 rv1[
j] =
z; c = f/
z; s = h/
z;
13957 f = x*c+g*
s; g = g*c-x*
s; h = y*
s; y*=c;
13958 cimg_forX(U,jj) {
const t x = V(
j,jj), z = V(i,jj); V(
j,jj) = x*c+z*
s; V(i,jj) = z*c-x*
s; }
13960 if (z) { z = 1/
z; c = f*
z; s = h*
z; }
13961 f = c*g+s*
y; x = c*y-s*g;
13962 cimg_forY(U,jj) {
const t y = U(
j,jj); z = U(i,jj); U(
j,jj) = y*c+z*
s; U(i,jj) = z*c-y*
s; }
13964 rv1[l] = 0; rv1[
k]=f; S[
k]=
x;
13971 S.sort(permutations,
false);
13973 cimg_forX(permutations,x) tmp(x) = U(permutations(x),
k);
13974 std::memcpy(U.ptr(0,
k),tmp.data,
sizeof(t)*
width);
13977 cimg_forX(permutations,x) tmp(x) = V(permutations(x),
k);
13978 std::memcpy(V.ptr(0,
k),tmp.data,
sizeof(t)*
width);
13986 const unsigned int max_iter=40,
const float lambda=0)
const {
13988 SVD(res[0],res[1],res[2],sorting,max_iter,lambda);
13993 template<
typename t>
13995 const int N =
dimx();
14004 if (tmp>vmax) vmax = tmp;
14006 if (vmax==0) { indx.fill(0);
return fill(0); }
14010 for (
int i = 0; i<
j; ++
i) {
14012 for (
int k = 0;
k<
i; ++
k) sum-=(*
this)(
k,
i)*(*
this)(
j,
k);
14013 (*this)(
j,
i) = (T)
sum;
14016 for (
int i = j; i<
dimx(); ++
i) {
14018 for (
int k = 0;
k<
j; ++
k) sum-=(*
this)(
k,
i)*(*
this)(
j,
k);
14019 (*this)(
j,
i) = (T)
sum;
14021 if (tmp>=vmax) { vmax=tmp; imax=
i; }
14029 if ((*
this)(
j,
j)==0) (*this)(
j,
j) = (T)1e-20;
14032 for (
int i=j+1; i<N; ++
i) (*
this)(
j,
i) = (T)((*this)(
j,
i)*tmp);
14047 template<
typename tf,
typename t>
14049 const unsigned int starting_node,
const unsigned int ending_node,
14053 dist(starting_node) = 0;
14054 previous.assign(1,nb_nodes,1,1,(t)-1);
14055 previous(starting_node) = (t)starting_node;
14059 unsigned int sizeQ = nb_nodes;
14062 const unsigned int umin = Q(0);
14063 if (umin==ending_node) sizeQ = 0;
14065 const T dmin =
dist(umin);
14067 for (
unsigned int q=1;
q<sizeQ; ++
q) {
14068 const unsigned int v = Q(
q);
14071 const T alt = dmin +
d;
14074 previous(v) = (t)umin;
14075 const T distpos =
dist(Q(
q));
14076 for (
unsigned int pos =
q, par = 0; pos && distpos<
dist(Q(par=(pos+1)/2-1)); pos=par)
cimg::swap(Q(pos),Q(par));
14082 const T distpos =
dist(Q(0));
14083 for (
unsigned int pos = 0, left = 0, right = 0;
14084 ((right=2*(pos+1),(left=right-1))<sizeQ && distpos>
dist(Q(left))) || (right<sizeQ && distpos>
dist(Q(right)));) {
14087 else {
cimg::swap(Q(pos),Q(right)); pos = right; }
14088 }
else {
cimg::swap(Q(pos),Q(left)); pos = left; }
14096 template<
typename tf,
typename t>
14098 const unsigned int starting_node,
const unsigned int ending_node=~0U) {
14100 return dijkstra(distance,nb_nodes,starting_node,ending_node,foo);
14110 template<
typename t>
14112 return get_dijkstra(starting_node,ending_node,previous).transfer_to(*
this);
14115 template<
typename t>
14118 throw CImgInstanceException(
"CImg<%s>::dijkstra() : Instance image (%u,%u,%u,%u,%p) is not a graph adjacency matrix",
14120 return dijkstra(*
this,
width,starting_node,ending_node,previous);
14125 return get_dijkstra(starting_node,ending_node).transfer_to(*
this);
14135 static CImg<T> r(1,1); r[0] = a0;
14142 *(ptr++) = a0; *(ptr++) = a1;
14149 *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2;
14156 *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14161 static CImg<T> vector(
const T& a0,
const T& a1,
const T& a2,
const T& a3,
const T& a4) {
14163 *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3; *(ptr++) = a4;
14168 static CImg<T> vector(
const T& a0,
const T& a1,
const T& a2,
const T& a3,
const T& a4,
const T& a5) {
14170 *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3; *(ptr++) = a4; *(ptr++) = a5;
14176 const T& a4,
const T& a5,
const T& a6) {
14178 *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14179 *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6;
14185 const T& a4,
const T& a5,
const T& a6,
const T& a7) {
14187 *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14188 *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7;
14194 const T& a4,
const T& a5,
const T& a6,
const T& a7,
14197 *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14198 *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7;
14205 const T& a4,
const T& a5,
const T& a6,
const T& a7,
14206 const T& a8,
const T& a9) {
14208 *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14209 *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7;
14210 *(ptr++) = a8; *(ptr++) = a9;
14216 const T& a4,
const T& a5,
const T& a6,
const T& a7,
14217 const T& a8,
const T& a9,
const T& a10) {
14219 *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14220 *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7;
14221 *(ptr++) = a8; *(ptr++) = a9; *(ptr++) = a10;
14227 const T& a4,
const T& a5,
const T& a6,
const T& a7,
14228 const T& a8,
const T& a9,
const T& a10,
const T& a11) {
14230 *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14231 *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7;
14232 *(ptr++) = a8; *(ptr++) = a9; *(ptr++) = a10; *(ptr++) = a11;
14238 const T& a4,
const T& a5,
const T& a6,
const T& a7,
14239 const T& a8,
const T& a9,
const T& a10,
const T& a11,
14242 *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14243 *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7;
14244 *(ptr++) = a8; *(ptr++) = a9; *(ptr++) = a10; *(ptr++) = a11;
14251 const T& a4,
const T& a5,
const T& a6,
const T& a7,
14252 const T& a8,
const T& a9,
const T& a10,
const T& a11,
14253 const T& a12,
const T& a13) {
14255 *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14256 *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7;
14257 *(ptr++) = a8; *(ptr++) = a9; *(ptr++) = a10; *(ptr++) = a11;
14258 *(ptr++) = a12; *(ptr++) = a13;
14264 const T& a4,
const T& a5,
const T& a6,
const T& a7,
14265 const T& a8,
const T& a9,
const T& a10,
const T& a11,
14266 const T& a12,
const T& a13,
const T& a14) {
14268 *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14269 *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7;
14270 *(ptr++) = a8; *(ptr++) = a9; *(ptr++) = a10; *(ptr++) = a11;
14271 *(ptr++) = a12; *(ptr++) = a13; *(ptr++) = a14;
14277 const T& a4,
const T& a5,
const T& a6,
const T& a7,
14278 const T& a8,
const T& a9,
const T& a10,
const T& a11,
14279 const T& a12,
const T& a13,
const T& a14,
const T& a15) {
14281 *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14282 *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7;
14283 *(ptr++) = a8; *(ptr++) = a9; *(ptr++) = a10; *(ptr++) = a11;
14284 *(ptr++) = a12; *(ptr++) = a13; *(ptr++) = a14; *(ptr++) = a15;
14295 const T& a2,
const T& a3) {
14297 *(ptr++) = a0; *(ptr++) = a1;
14298 *(ptr++) = a2; *(ptr++) = a3;
14304 const T& a3,
const T& a4,
const T& a5,
14305 const T& a6,
const T& a7,
const T& a8) {
14307 *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2;
14308 *(ptr++) = a3; *(ptr++) = a4; *(ptr++) = a5;
14309 *(ptr++) = a6; *(ptr++) = a7; *(ptr++) = a8;
14315 const T& a4,
const T& a5,
const T& a6,
const T& a7,
14316 const T& a8,
const T& a9,
const T& a10,
const T& a11,
14317 const T& a12,
const T& a13,
const T& a14,
const T& a15) {
14319 *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14320 *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7;
14321 *(ptr++) = a8; *(ptr++) = a9; *(ptr++) = a10; *(ptr++) = a11;
14322 *(ptr++) = a12; *(ptr++) = a13; *(ptr++) = a14; *(ptr++) = a15;
14327 static CImg<T> matrix(
const T& a0,
const T& a1,
const T& a2,
const T& a3,
const T& a4,
14328 const T& a5,
const T& a6,
const T& a7,
const T& a8,
const T& a9,
14329 const T& a10,
const T& a11,
const T& a12,
const T& a13,
const T& a14,
14330 const T& a15,
const T& a16,
const T& a17,
const T& a18,
const T& a19,
14331 const T& a20,
const T& a21,
const T& a22,
const T& a23,
const T& a24) {
14333 *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3; *(ptr++) = a4;
14334 *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7; *(ptr++) = a8; *(ptr++) = a9;
14335 *(ptr++) = a10; *(ptr++) = a11; *(ptr++) = a12; *(ptr++) = a13; *(ptr++) = a14;
14336 *(ptr++) = a15; *(ptr++) = a16; *(ptr++) = a17; *(ptr++) = a18; *(ptr++) = a19;
14337 *(ptr++) = a20; *(ptr++) = a21; *(ptr++) = a22; *(ptr++) = a23; *(ptr++) = a24;
14348 return matrix(a1,a2,a2,a3);
14352 static CImg<T> tensor(
const T& a1,
const T& a2,
const T& a3,
const T& a4,
const T& a5,
const T& a6) {
14353 return matrix(a1,a2,a3,a2,a4,a5,a3,a5,a6);
14363 return matrix(a0,0,0,a1);
14368 return matrix(a0,0,0,0,a1,0,0,0,a2);
14373 return matrix(a0,0,0,0,0,a1,0,0,0,0,a2,0,0,0,0,a3);
14378 return matrix(a0,0,0,0,0,0,a1,0,0,0,0,0,a2,0,0,0,0,0,a3,0,0,0,0,0,a4);
14397 if (!quaternion_data) {
14399 nx = norm>0?x/norm:0,
14400 ny = norm>0?y/norm:0,
14401 nz = norm>0?z/norm:1,
14410 const float norm = (float)
std::sqrt(x*x + y*y + z*z + w*w);
14412 else { X = Y = Z = 0; W = 1; }
14414 const float xx = X*X, xy = X*Y, xz = X*Z, xw = X*W, yy = Y*Y, yz = Y*Z, yw = Y*W, zz = Z*Z, zw = Z*W;
14415 return CImg<T>::matrix((T)(1-2*(yy+zz)), (T)(2*(xy+zw)), (T)(2*(xz-yw)),
14416 (T)(2*(xy-zw)), (T)(1-2*(xx+zz)), (T)(2*(yz+xw)),
14417 (T)(2*(xz+yw)), (T)(2*(yz-xw)), (T)(1-2*(xx+yy)));
14435 else std::memset(
data,(
int)val,
size()*
sizeof(T));
14446 T *
ptr, *ptr_end =
end()-1;
14447 for (ptr =
data; ptr<ptr_end; ) { *(ptr++) = val0; *(ptr++) = val1; }
14448 if (ptr!=ptr_end+1) *(ptr++) = val0;
14459 T *
ptr, *ptr_end =
end()-2;
14460 for (ptr =
data; ptr<ptr_end; ) { *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; }
14462 switch (ptr_end-ptr) {
14463 case 2 : *(--ptr_end) = val1;
14464 case 1 : *(--ptr_end) = val0;
14476 T *
ptr, *ptr_end =
end()-3;
14477 for (ptr =
data; ptr<ptr_end; ) { *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; }
14479 switch (ptr_end-ptr) {
14480 case 3 : *(--ptr_end) = val2;
14481 case 2 : *(--ptr_end) = val1;
14482 case 1 : *(--ptr_end) = val0;
14492 CImg<T>&
fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4) {
14494 T *
ptr, *ptr_end =
end()-4;
14495 for (ptr =
data; ptr<ptr_end; ) { *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; }
14497 switch (ptr_end-ptr) {
14498 case 4 : *(--ptr_end) = val3;
14499 case 3 : *(--ptr_end) = val2;
14500 case 2 : *(--ptr_end) = val1;
14501 case 1 : *(--ptr_end) = val0;
14506 CImg<T> get_fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4)
const {
14511 CImg<T>&
fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4,
const T val5) {
14513 T *
ptr, *ptr_end =
end()-5;
14514 for (ptr =
data; ptr<ptr_end; ) {
14515 *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5;
14518 switch (ptr_end-ptr) {
14519 case 5 : *(--ptr_end) = val4;
14520 case 4 : *(--ptr_end) = val3;
14521 case 3 : *(--ptr_end) = val2;
14522 case 2 : *(--ptr_end) = val1;
14523 case 1 : *(--ptr_end) = val0;
14528 CImg<T> get_fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4,
const T val5)
const {
14533 CImg<T>&
fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4,
const T val5,
const T val6) {
14535 T *
ptr, *ptr_end =
end()-6;
14536 for (ptr =
data; ptr<ptr_end; ) {
14537 *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5; *(ptr++) = val6;
14540 switch (ptr_end-ptr) {
14541 case 6 : *(--ptr_end) = val5;
14542 case 5 : *(--ptr_end) = val4;
14543 case 4 : *(--ptr_end) = val3;
14544 case 3 : *(--ptr_end) = val2;
14545 case 2 : *(--ptr_end) = val1;
14546 case 1 : *(--ptr_end) = val0;
14551 CImg<T> get_fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4,
const T val5,
const T val6)
const {
14556 CImg<T>&
fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4,
const T val5,
const T val6,
14559 T *
ptr, *ptr_end =
end()-7;
14560 for (ptr =
data; ptr<ptr_end; ) {
14561 *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3;
14562 *(ptr++) = val4; *(ptr++) = val5; *(ptr++) = val6; *(ptr++) = val7;
14565 switch (ptr_end-ptr) {
14566 case 7 : *(--ptr_end) = val6;
14567 case 6 : *(--ptr_end) = val5;
14568 case 5 : *(--ptr_end) = val4;
14569 case 4 : *(--ptr_end) = val3;
14570 case 3 : *(--ptr_end) = val2;
14571 case 2 : *(--ptr_end) = val1;
14572 case 1 : *(--ptr_end) = val0;
14577 CImg<T> get_fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4,
const T val5,
const T val6,
14578 const T val7)
const {
14579 return CImg<T>(
width,
height,
depth,
dim).
fill(val0,val1,val2,val3,val4,val5,val6,val7);
14583 CImg<T>&
fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4,
const T val5,
const T val6,
14584 const T val7,
const T val8) {
14586 T *
ptr, *ptr_end =
end()-8;
14587 for (ptr =
data; ptr<ptr_end; ) {
14588 *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2;
14589 *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5;
14590 *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8;
14593 switch (ptr_end-ptr) {
14594 case 8 : *(--ptr_end) = val7;
14595 case 7 : *(--ptr_end) = val6;
14596 case 6 : *(--ptr_end) = val5;
14597 case 5 : *(--ptr_end) = val4;
14598 case 4 : *(--ptr_end) = val3;
14599 case 3 : *(--ptr_end) = val2;
14600 case 2 : *(--ptr_end) = val1;
14601 case 1 : *(--ptr_end) = val0;
14606 CImg<T> get_fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4,
const T val5,
const T val6,
14607 const T val7,
const T val8)
const {
14608 return CImg<T>(
width,
height,
depth,
dim).
fill(val0,val1,val2,val3,val4,val5,val6,val7,val8);
14612 CImg<T>&
fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4,
const T val5,
const T val6,
14613 const T val7,
const T val8,
const T val9) {
14615 T *
ptr, *ptr_end =
end()-9;
14616 for (ptr =
data; ptr<ptr_end; ) {
14617 *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4;
14618 *(ptr++) = val5; *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8; *(ptr++) = val9;
14621 switch (ptr_end-ptr) {
14622 case 9 : *(--ptr_end) = val8;
14623 case 8 : *(--ptr_end) = val7;
14624 case 7 : *(--ptr_end) = val6;
14625 case 6 : *(--ptr_end) = val5;
14626 case 5 : *(--ptr_end) = val4;
14627 case 4 : *(--ptr_end) = val3;
14628 case 3 : *(--ptr_end) = val2;
14629 case 2 : *(--ptr_end) = val1;
14630 case 1 : *(--ptr_end) = val0;
14635 CImg<T> get_fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4,
const T val5,
const T val6,
14636 const T val7,
const T val8,
const T val9)
const {
14637 return CImg<T>(
width,
height,
depth,
dim).
fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9);
14641 CImg<T>&
fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4,
const T val5,
const T val6,
14642 const T val7,
const T val8,
const T val9,
const T val10) {
14644 T *
ptr, *ptr_end =
end()-10;
14645 for (ptr =
data; ptr<ptr_end; ) {
14646 *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4;
14647 *(ptr++) = val5; *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8; *(ptr++) = val9;
14651 switch (ptr_end-ptr) {
14652 case 10 : *(--ptr_end) = val9;
14653 case 9 : *(--ptr_end) = val8;
14654 case 8 : *(--ptr_end) = val7;
14655 case 7 : *(--ptr_end) = val6;
14656 case 6 : *(--ptr_end) = val5;
14657 case 5 : *(--ptr_end) = val4;
14658 case 4 : *(--ptr_end) = val3;
14659 case 3 : *(--ptr_end) = val2;
14660 case 2 : *(--ptr_end) = val1;
14661 case 1 : *(--ptr_end) = val0;
14666 CImg<T> get_fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4,
const T val5,
const T val6,
14667 const T val7,
const T val8,
const T val9,
const T val10)
const {
14668 return CImg<T>(
width,
height,
depth,
dim).
fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10);
14672 CImg<T>&
fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4,
const T val5,
const T val6,
14673 const T val7,
const T val8,
const T val9,
const T val10,
const T val11) {
14675 T *
ptr, *ptr_end =
end()-11;
14676 for (ptr =
data; ptr<ptr_end; ) {
14677 *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5;
14678 *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8; *(ptr++) = val9; *(ptr++) = val10; *(ptr++) = val11;
14681 switch (ptr_end-ptr) {
14682 case 11 : *(--ptr_end) = val10;
14683 case 10 : *(--ptr_end) = val9;
14684 case 9 : *(--ptr_end) = val8;
14685 case 8 : *(--ptr_end) = val7;
14686 case 7 : *(--ptr_end) = val6;
14687 case 6 : *(--ptr_end) = val5;
14688 case 5 : *(--ptr_end) = val4;
14689 case 4 : *(--ptr_end) = val3;
14690 case 3 : *(--ptr_end) = val2;
14691 case 2 : *(--ptr_end) = val1;
14692 case 1 : *(--ptr_end) = val0;
14697 CImg<T> get_fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4,
const T val5,
const T val6,
14698 const T val7,
const T val8,
const T val9,
const T val10,
const T val11)
const {
14699 return CImg<T>(
width,
height,
depth,
dim).
fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11);
14703 CImg<T>&
fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4,
const T val5,
const T val6,
14704 const T val7,
const T val8,
const T val9,
const T val10,
const T val11,
const T val12) {
14706 T *
ptr, *ptr_end =
end()-12;
14707 for (ptr =
data; ptr<ptr_end; ) {
14708 *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5;
14709 *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8; *(ptr++) = val9; *(ptr++) = val10; *(ptr++) = val11;
14713 switch (ptr_end-ptr) {
14714 case 12 : *(--ptr_end) = val11;
14715 case 11 : *(--ptr_end) = val10;
14716 case 10 : *(--ptr_end) = val9;
14717 case 9 : *(--ptr_end) = val8;
14718 case 8 : *(--ptr_end) = val7;
14719 case 7 : *(--ptr_end) = val6;
14720 case 6 : *(--ptr_end) = val5;
14721 case 5 : *(--ptr_end) = val4;
14722 case 4 : *(--ptr_end) = val3;
14723 case 3 : *(--ptr_end) = val2;
14724 case 2 : *(--ptr_end) = val1;
14725 case 1 : *(--ptr_end) = val0;
14730 CImg<T> get_fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4,
const T val5,
const T val6,
14731 const T val7,
const T val8,
const T val9,
const T val10,
const T val11,
const T val12)
const {
14732 return CImg<T>(
width,
height,
depth,
dim).
fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12);
14736 CImg<T>&
fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4,
const T val5,
const T val6,
14737 const T val7,
const T val8,
const T val9,
const T val10,
const T val11,
const T val12,
14740 T *
ptr, *ptr_end =
end()-13;
14741 for (ptr =
data; ptr<ptr_end; ) {
14742 *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5;
14743 *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8; *(ptr++) = val9; *(ptr++) = val10; *(ptr++) = val11;
14744 *(ptr++) = val12; *(ptr++) = val13;
14747 switch (ptr_end-ptr) {
14748 case 13 : *(--ptr_end) = val12;
14749 case 12 : *(--ptr_end) = val11;
14750 case 11 : *(--ptr_end) = val10;
14751 case 10 : *(--ptr_end) = val9;
14752 case 9 : *(--ptr_end) = val8;
14753 case 8 : *(--ptr_end) = val7;
14754 case 7 : *(--ptr_end) = val6;
14755 case 6 : *(--ptr_end) = val5;
14756 case 5 : *(--ptr_end) = val4;
14757 case 4 : *(--ptr_end) = val3;
14758 case 3 : *(--ptr_end) = val2;
14759 case 2 : *(--ptr_end) = val1;
14760 case 1 : *(--ptr_end) = val0;
14765 CImg<T> get_fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4,
const T val5,
const T val6,
14766 const T val7,
const T val8,
const T val9,
const T val10,
const T val11,
const T val12,
14767 const T val13)
const {
14768 return CImg<T>(
width,
height,
depth,
dim).
fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12,
14773 CImg<T>&
fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4,
const T val5,
const T val6,
14774 const T val7,
const T val8,
const T val9,
const T val10,
const T val11,
const T val12,
14775 const T val13,
const T val14) {
14777 T *
ptr, *ptr_end =
end()-14;
14778 for (ptr =
data; ptr<ptr_end; ) {
14779 *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5;
14780 *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8; *(ptr++) = val9; *(ptr++) = val10; *(ptr++) = val11;
14781 *(ptr++) = val12; *(ptr++) = val13; *(ptr++) = val14;
14784 switch (ptr_end-ptr) {
14785 case 14 : *(--ptr_end) = val13;
14786 case 13 : *(--ptr_end) = val12;
14787 case 12 : *(--ptr_end) = val11;
14788 case 11 : *(--ptr_end) = val10;
14789 case 10 : *(--ptr_end) = val9;
14790 case 9 : *(--ptr_end) = val8;
14791 case 8 : *(--ptr_end) = val7;
14792 case 7 : *(--ptr_end) = val6;
14793 case 6 : *(--ptr_end) = val5;
14794 case 5 : *(--ptr_end) = val4;
14795 case 4 : *(--ptr_end) = val3;
14796 case 3 : *(--ptr_end) = val2;
14797 case 2 : *(--ptr_end) = val1;
14798 case 1 : *(--ptr_end) = val0;
14803 CImg<T> get_fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4,
const T val5,
const T val6,
14804 const T val7,
const T val8,
const T val9,
const T val10,
const T val11,
const T val12,
14805 const T val13,
const T val14)
const {
14806 return CImg<T>(
width,
height,
depth,
dim).
fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12,
14811 CImg<T>&
fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4,
const T val5,
const T val6,
14812 const T val7,
const T val8,
const T val9,
const T val10,
const T val11,
const T val12,
14813 const T val13,
const T val14,
const T val15) {
14815 T *
ptr, *ptr_end =
end()-15;
14816 for (ptr =
data; ptr<ptr_end; ) {
14817 *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5;
14818 *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8; *(ptr++) = val9; *(ptr++) = val10; *(ptr++) = val11;
14819 *(ptr++) = val12; *(ptr++) = val13; *(ptr++) = val14; *(ptr++) = val15;
14822 switch (ptr_end-ptr) {
14823 case 15 : *(--ptr_end) = val14;
14824 case 14 : *(--ptr_end) = val13;
14825 case 13 : *(--ptr_end) = val12;
14826 case 12 : *(--ptr_end) = val11;
14827 case 11 : *(--ptr_end) = val10;
14828 case 10 : *(--ptr_end) = val9;
14829 case 9 : *(--ptr_end) = val8;
14830 case 8 : *(--ptr_end) = val7;
14831 case 7 : *(--ptr_end) = val6;
14832 case 6 : *(--ptr_end) = val5;
14833 case 5 : *(--ptr_end) = val4;
14834 case 4 : *(--ptr_end) = val3;
14835 case 3 : *(--ptr_end) = val2;
14836 case 2 : *(--ptr_end) = val1;
14837 case 1 : *(--ptr_end) = val0;
14842 CImg<T> get_fill(
const T val0,
const T val1,
const T val2,
const T val3,
const T val4,
const T val5,
const T val6,
14843 const T val7,
const T val8,
const T val9,
const T val10,
const T val11,
const T val12,
14844 const T val13,
const T val14,
const T val15)
const {
14845 return CImg<T>(
width,
height,
depth,
dim).
fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12,
14846 val13,val14,val15);
14851 if (
is_empty() || !expression || !*expression)
return *
this;
14855 _cimg_math_parser mp(expression,
"fill");
14856 const CImg<T> _base = std::strstr(expression,
"i(")?+*
this:
CImg<T>(), &base = _base?_base:*
this;
14858 cimg_forXYZV(*
this,x,
y,
z,
v) *(ptrd++) = (T)mp.eval(base,(
double)x,(
double)
y,(
double)
z,(
double)
v);
14860 char item[16384] = { 0 }, sep = 0;
const char *nexpression = expression;
14861 unsigned int nb = 0;
const unsigned int siz =
size();
14863 for (
double val = 0; *nexpression && nb<siz; ++nb) {
14864 const int err = std::sscanf(nexpression,
"%4095[ \n\t0-9.e+-]%c",item,&sep);
14865 if (err>0 && std::sscanf(item,
"%lf",&val)==1) {
14866 nexpression += std::strlen(item) + (err>1?1:0);
14867 *(ptrd++) = (T)val;
14873 if (repeat_flag && nb)
for (T *ptrs =
data, *
const ptr_end =
data + siz; ptrd<ptr_end; ++ptrs) *(ptrd++) = *ptrs;
14880 return (+*
this).
fill(values,repeat_values);
14884 template<
typename t>
14886 if (
is_empty() || !values)
return *
this;
14887 T *ptrd =
data, *ptrd_end = ptrd +
size();
14888 for (t *ptrs = values.data, *ptrs_end = ptrs + values.size(); ptrs<ptrs_end && ptrd<ptrd_end; ++ptrs) *(ptrd++) = (T)*ptrs;
14889 if (repeat_values && ptrd<ptrd_end)
for (T *ptrs =
data; ptrd<ptrd_end; ++ptrs) *(ptrd++) = *ptrs;
14893 template<
typename t>
14899 CImg<T>&
fillX(
const unsigned int y,
const unsigned int z,
const unsigned int v,
const int a0, ...) {
14900 #define _cimg_fill1(x,y,z,v,off,siz,t) { \
14901 va_list ap; va_start(ap,a0); T *ptrd = ptr(x,y,z,v); *ptrd = (T)a0; \
14902 for (unsigned int k = 1; k<siz; ++k) { ptrd+=off; *ptrd = (T)va_arg(ap,t); } \
14908 CImg<T>&
fillX(
const unsigned int y,
const unsigned int z,
const unsigned int v,
const double a0, ...) {
14914 CImg<T>&
fillY(
const unsigned int x,
const unsigned int z,
const unsigned int v,
const int a0, ...) {
14919 CImg<T>&
fillY(
const unsigned int x,
const unsigned int z,
const unsigned int v,
const double a0, ...) {
14925 CImg<T>&
fillZ(
const unsigned int x,
const unsigned int y,
const unsigned int v,
const int a0, ...) {
14931 CImg<T>&
fillZ(
const unsigned int x,
const unsigned int y,
const unsigned int v,
const double a0, ...) {
14938 CImg<T>&
fillV(
const unsigned int x,
const unsigned int y,
const unsigned int z,
const int a0, ...) {
14944 CImg<T>&
fillV(
const unsigned int x,
const unsigned int y,
const unsigned int z,
const double a0, ...) {
14962 const float delta = (float)val_max - (
float)val_min;
14968 return (+*
this).
rand(val_min,val_max);
14982 return (+*
this).
round(x,rounding_type);
15004 if (nsigma==0 && noise_type!=3)
return *
this;
15006 if (nsigma<0) nsigma = -nsigma*(M-m)/100.0;
15007 switch (noise_type) {
15011 if (val>max) val =
max;
15012 if (val<min) val =
min;
15019 if (val>max) val =
max;
15020 if (val<min) val =
min;
15025 if (nsigma<0) nsigma = -nsigma;
15035 const double sqrt2 = (double)
std::sqrt(2.0);
15038 val0 = (double)*
ptr/sqrt2,
15042 if (val>max) val =
max;
15043 if (val<min) val =
min;
15049 "(should be {0=Gaussian, 1=Uniform, 2=Salt&Pepper, 3=Poisson}).",
pixel_type(),noise_type);
15056 return (+*
this).
noise(sigma,noise_type);
15075 const T a = value_min<value_max?value_min:value_max, b = value_min<value_max?value_max:value_min;
15078 if (m==M)
return fill(0);
15128 return get_norm(norm_type).transfer_to(*
this);
15133 if (dim==1)
return get_abs();
15135 switch (norm_type) {
15140 if (tmp>n) n=tmp; res(x,y,z) =
n;
15174 const T a = value_min<value_max?value_min:value_max, b = value_min<value_max?value_max:value_min;
15180 return (+*
this).
cut(value_min,value_max);
15205 const unsigned int val = (
unsigned int)((*
ptr-m)*nb_levels/range);
15206 *
ptr = (T)(m +
cimg::min(val,nb_levels-1)*range/nb_levels);
15208 const unsigned int val = (
unsigned int)((*
ptr-m)*nb_levels/range);
15216 return (+*
this).
quantize(n,keep_range);
15234 CImg<T>&
threshold(
const T value,
const bool soft_threshold=
false,
const bool strict_threshold=
false) {
15236 if (strict_threshold) {
15237 if (soft_threshold)
cimg_for(*
this,
ptr,T) {
const T
v = *
ptr; *
ptr = v>value?(T)(v-value):v<-(float)value?(T)(v+value):(T)0; }
15240 if (soft_threshold)
cimg_for(*
this,
ptr,T) {
const T
v = *
ptr; *
ptr = v>=value?(T)(v-value):v<=-(float)value?(T)(v+value):(T)0; }
15247 return (+*
this).
threshold(value,soft_threshold,strict_threshold);
15270 return get_histogram(nb_levels,value_min,value_max).transfer_to(*
this);
15278 T vmin = value_min, vmax = value_max;
15280 if (vmin>=vmax && vmin==0) vmin =
minmax(vmax);
15282 const T val = *
ptr;
15283 if (val>=vmin && val<=vmax) ++res[val==vmax?nb_levels-1:(int)((val-vmin)*nb_levels/(vmax-vmin))];
15284 }
else res[0]+=
size();
15305 CImg<T>&
equalize(
const unsigned int nb_levels,
const T value_min=(T)0,
const T value_max=(T)0) {
15307 T vmin = value_min, vmax = value_max;
15308 if (vmin==vmax && vmin==0) vmin =
minmax(vmax);
15312 cimg_forX(hist,pos) { cumul+=hist[pos]; hist[pos] = cumul; }
15314 const int pos = (
unsigned int)((*
ptr-vmin)*(nb_levels-1)/(vmax-vmin));
15315 if (pos>=0 && pos<(
int)nb_levels) *
ptr = (T)(vmin + (vmax-vmin)*hist[pos]/
size());
15322 return (+*
this).
equalize(nblevels,val_min,val_max);
15342 template<
typename t>
15344 return get_index(palette,dithering,map_indexes).transfer_to(*
this);
15347 template<
typename t>
15352 if (palette.dim!=dim)
15353 throw CImgArgumentException(
"CImg<%s>::index() : Palette (%u,%u,%u,%u,%p) and instance image (%u,%u,%u,%u,%p) "
15355 palette.width,palette.height,palette.depth,palette.dim,palette.data,
15357 const unsigned int whz =
width*
height*
depth, pwhz = palette.width*palette.height*palette.depth;
15359 tuint *ptrd = res.data;
15362 if (valm==valM && valm>=0 && valM<=255) { valm = 0; valM = 255; }
15364 Tfloat *cache_current = cache.ptr(1,0,0,0), *cache_next = cache.ptr(1,1,0,0);
15365 const unsigned int cwhz = cache.width*cache.height*cache.depth;
15370 Tfloat *ptrc0 = cache_next;
const T *ptrs0 =
ptr(0,
y+1,
z,0);
15373 Tfloat *ptrs0 = cache_current, *ptrsn0 = cache_next;
15375 const Tfloat _val0 = (
Tfloat)*ptrs0, val0 = _val0<valm?valm:_val0>valM?valM:_val0;
15377 for (
const t *ptrp0 = palette.data, *ptrp_end = ptrp0 + pwhz; ptrp0<ptrp_end; ) {
15379 if (dist<distmin) { ptrmin0 = ptrp0 - 1; distmin =
dist; }
15381 const Tfloat err0 = ((*(ptrs0++)=val0) - (
Tfloat)*ptrmin0)/16;
15382 *ptrs0 += 7*err0; *(ptrsn0-1) += 3*err0; *(ptrsn0++) += 5*err0; *ptrsn0 += err0;
15383 if (map_indexes) *(ptrd++) = (tuint)*ptrmin0;
else *(ptrd++) = (tuint)(ptrmin0 - palette.data);
15389 tuint *ptrd1 = ptrd + whz;
15392 Tfloat *ptrc0 = cache_next, *ptrc1 = ptrc0 + cwhz;
15393 const T *ptrs0 =
ptr(0,
y+1,
z,0), *ptrs1 = ptrs0 + whz;
15397 *ptrs0 = cache_current, *ptrs1 = ptrs0 + cwhz,
15398 *ptrsn0 = cache_next, *ptrsn1 = ptrsn0 + cwhz;
15401 _val0 = (
Tfloat)*ptrs0, val0 = _val0<valm?valm:_val0>valM?valM:_val0,
15402 _val1 = (
Tfloat)*ptrs1, val1 = _val1<valm?valm:_val1>valM?valM:_val1;
15404 for (
const t *ptrp0 = palette.data, *ptrp1 = ptrp0 + pwhz, *ptrp_end = ptrp1; ptrp0<ptrp_end; ) {
15406 pval0 = (
Tfloat)*(ptrp0++) - val0, pval1 = (
Tfloat)*(ptrp1++) - val1,
15407 dist = pval0*pval0 + pval1*pval1;
15408 if (dist<distmin) { ptrmin0 = ptrp0 - 1; distmin =
dist; }
15410 const t *
const ptrmin1 = ptrmin0 + pwhz;
15412 err0 = ((*(ptrs0++)=val0) - (
Tfloat)*ptrmin0)/16,
15413 err1 = ((*(ptrs1++)=val1) - (
Tfloat)*ptrmin1)/16;
15414 *ptrs0 += 7*err0; *ptrs1 += 7*err1;
15415 *(ptrsn0-1) += 3*err0; *(ptrsn1-1) += 3*err1;
15416 *(ptrsn0++) += 5*err0; *(ptrsn1++) += 5*err1;
15417 *ptrsn0 += err0; *ptrsn1 += err1;
15418 if (map_indexes) { *(ptrd++) = (tuint)*ptrmin0; *(ptrd1++) = (tuint)*ptrmin1; }
15419 else *(ptrd++) = (tuint)(ptrmin0 - palette.data);
15425 tuint *ptrd1 = ptrd + whz, *ptrd2 = ptrd1 + whz;
15428 Tfloat *ptrc0 = cache_next, *ptrc1 = ptrc0 + cwhz, *ptrc2 = ptrc1 + cwhz;
15429 const T *ptrs0 =
ptr(0,
y+1,
z,0), *ptrs1 = ptrs0 + whz, *ptrs2 = ptrs1 + whz;
15433 *ptrs0 = cache_current, *ptrs1 = ptrs0 + cwhz, *ptrs2 = ptrs1 + cwhz,
15434 *ptrsn0 = cache_next, *ptrsn1 = ptrsn0 + cwhz, *ptrsn2 = ptrsn1 + cwhz;
15437 _val0 = (
Tfloat)*ptrs0, val0 = _val0<valm?valm:_val0>valM?valM:_val0,
15438 _val1 = (
Tfloat)*ptrs1, val1 = _val1<valm?valm:_val1>valM?valM:_val1,
15439 _val2 = (
Tfloat)*ptrs2, val2 = _val2<valm?valm:_val2>valM?valM:_val2;
15441 for (
const t *ptrp0 = palette.data, *ptrp1 = ptrp0 + pwhz, *ptrp2 = ptrp1 + pwhz, *ptrp_end = ptrp1; ptrp0<ptrp_end; ) {
15443 pval0 = (
Tfloat)*(ptrp0++) - val0, pval1 = (
Tfloat)*(ptrp1++) - val1, pval2 = (
Tfloat)*(ptrp2++) - val2,
15444 dist = pval0*pval0 + pval1*pval1 + pval2*pval2;
15445 if (dist<distmin) { ptrmin0 = ptrp0 - 1; distmin =
dist; }
15447 const t *
const ptrmin1 = ptrmin0 + pwhz, *
const ptrmin2 = ptrmin1 + pwhz;
15449 err0 = ((*(ptrs0++)=val0) - (
Tfloat)*ptrmin0)/16,
15450 err1 = ((*(ptrs1++)=val1) - (
Tfloat)*ptrmin1)/16,
15451 err2 = ((*(ptrs2++)=val2) - (
Tfloat)*ptrmin2)/16;
15452 *ptrs0 += 7*err0; *ptrs1 += 7*err1; *ptrs2 += 7*err2;
15453 *(ptrsn0-1) += 3*err0; *(ptrsn1-1) += 3*err1; *(ptrsn2-1) += 3*err2;
15454 *(ptrsn0++) += 5*err0; *(ptrsn1++) += 5*err1; *(ptrsn2++) += 5*err2;
15455 *ptrsn0 += err0; *ptrsn1 += err1; *ptrsn2 += err2;
15456 if (map_indexes) { *(ptrd++) = (tuint)*ptrmin0; *(ptrd1++) = (tuint)*ptrmin1; *(ptrd2++) = (tuint)*ptrmin2; }
15457 else *(ptrd++) = (tuint)(ptrmin0 - palette.data);
15465 Tfloat *ptrc = cache_next;
15467 Tfloat *_ptrc = ptrc;
const T *_ptrs =
ptr(0,
y+1,
z,
k);
15472 Tfloat *ptrs = cache_current, *ptrsn = cache_next;
15475 for (
const t *ptrp = palette.data, *ptrp_end = ptrp + pwhz; ptrp<ptrp_end; ++ptrp) {
15478 const Tfloat _val = *_ptrs, val = _val<valm?valm:_val>valM?valM:_val;
15479 dist +=
cimg::sqr((*_ptrs=val) - (
Tfloat)*_ptrp); _ptrs+=cwhz; _ptrp+=pwhz;
15481 if (dist<distmin) { ptrmin = ptrp; distmin =
dist; }
15483 const t *_ptrmin = ptrmin;
Tfloat *_ptrs = ptrs++, *_ptrsn = (ptrsn++)-1;
15485 const Tfloat err = (*(_ptrs++) - (
Tfloat)*_ptrmin)/16;
15486 *_ptrs += 7*err; *(_ptrsn++) += 3*err; *(_ptrsn++) += 5*err; *_ptrsn += err;
15487 _ptrmin+=pwhz; _ptrs+=cwhz-1; _ptrsn+=cwhz-2;
15489 if (map_indexes) { tuint *_ptrd = ptrd++;
cimg_forV(*
this,
k) { *_ptrd = (tuint)*ptrmin; _ptrd+=whz; ptrmin+=pwhz; }}
15490 else *(ptrd++) = (tuint)(ptrmin - palette.data);
15498 for (
const T *ptrs0 =
data, *ptrs_end = ptrs0 + whz; ptrs0<ptrs_end; ) {
15501 for (
const t *ptrp0 = palette.data, *ptrp_end = ptrp0 + pwhz; ptrp0<ptrp_end; ) {
15503 if (dist<distmin) { ptrmin0 = ptrp0 - 1; distmin =
dist; }
15505 if (map_indexes) *(ptrd++) = (tuint)*ptrmin0;
else *(ptrd++) = (tuint)(ptrmin0 - palette.data);
15509 tuint *ptrd1 = ptrd + whz;
15510 for (
const T *ptrs0 =
data, *ptrs1 = ptrs0 + whz, *ptrs_end = ptrs1; ptrs0<ptrs_end; ) {
15513 for (
const t *ptrp0 = palette.data, *ptrp1 = ptrp0 + pwhz, *ptrp_end = ptrp1; ptrp0<ptrp_end; ) {
15515 pval0 = (
Tfloat)*(ptrp0++) - val0, pval1 = (
Tfloat)*(ptrp1++) - val1,
15516 dist = pval0*pval0 + pval1*pval1;
15517 if (dist<distmin) { ptrmin0 = ptrp0 - 1; distmin =
dist; }
15519 if (map_indexes) { *(ptrd++) = (tuint)*ptrmin0; *(ptrd1++) = (tuint)*(ptrmin0 + pwhz); }
15520 else *(ptrd++) = (tuint)(ptrmin0 - palette.data);
15524 tuint *ptrd1 = ptrd + whz, *ptrd2 = ptrd1 + whz;
15525 for (
const T *ptrs0 =
data, *ptrs1 = ptrs0 + whz, *ptrs2 = ptrs1 + whz, *ptrs_end = ptrs1; ptrs0<ptrs_end; ) {
15528 for (
const t *ptrp0 = palette.data, *ptrp1 = ptrp0 + pwhz, *ptrp2 = ptrp1 + pwhz, *ptrp_end = ptrp1; ptrp0<ptrp_end; ) {
15530 pval0 = (
Tfloat)*(ptrp0++) - val0, pval1 = (
Tfloat)*(ptrp1++) - val1, pval2 = (
Tfloat)*(ptrp2++) - val2,
15531 dist = pval0*pval0 + pval1*pval1 + pval2*pval2;
15532 if (dist<distmin) { ptrmin0 = ptrp0 - 1; distmin =
dist; }
15534 if (map_indexes) { *(ptrd++) = (tuint)*ptrmin0; *(ptrd1++) = (tuint)*(ptrmin0 + pwhz); *(ptrd2++) = (tuint)*(ptrmin0 + 2*pwhz); }
15535 else *(ptrd++) = (tuint)(ptrmin0 - palette.data);
15539 for (
const T *ptrs =
data, *ptrs_end = ptrs + whz; ptrs<ptrs_end; ++ptrs) {
15541 for (
const t *ptrp = palette.data, *ptrp_end = ptrp + pwhz; ptrp<ptrp_end; ++ptrp) {
15542 Tfloat dist = 0;
const T *_ptrs = ptrs;
const t *_ptrp = ptrp;
15544 if (dist<distmin) { ptrmin = ptrp; distmin =
dist; }
15546 if (map_indexes) { tuint *_ptrd = ptrd++;
cimg_forV(*
this,
k) { *_ptrd = (tuint)*ptrmin; _ptrd+=whz; ptrmin+=pwhz; }}
15547 else *(ptrd++) = (tuint)(ptrmin - palette.data);
15570 template<
typename t>
15572 return get_map(palette).transfer_to(*
this);
15575 template<
typename t>
15577 if (dim!=1 && palette.dim!=1)
15578 throw CImgArgumentException(
"CImg<%s>::map() : Palette (%u,%u,%u,%u,%p) and instance image (%u,%u,%u,%u,%p) "
15580 palette.width,palette.height,palette.depth,palette.dim,palette.data,
15582 const unsigned int whz =
width*
height*
depth, pwhz = palette.width*palette.height*palette.depth;
15584 switch (palette.dim) {
15586 const T *ptrs =
data + whz*
dim;
15588 const unsigned int _ind = (
unsigned int)*(--ptrs), ind = _ind<pwhz?_ind:0;
15589 *ptrd = palette[ind];
15593 const t *
const ptrp0 = palette.data, *ptrp1 = ptrp0 + pwhz;
15594 t *ptrd0 = res.data, *ptrd1 = ptrd0 + whz;
15595 for (
const T *ptrs =
data, *ptrs_end = ptrs + whz; ptrs<ptrs_end; ) {
15596 const unsigned int _ind = (
unsigned int)*(ptrs++), ind = _ind<pwhz?_ind:0;
15597 *(ptrd0++) = ptrp0[ind]; *(ptrd1++) = ptrp1[ind];
15601 const t *
const ptrp0 = palette.data, *ptrp1 = ptrp0 + pwhz, *ptrp2 = ptrp1 + pwhz;
15602 t *ptrd0 = res.data, *ptrd1 = ptrd0 + whz, *ptrd2 = ptrd1 + whz;
15603 for (
const T *ptrs =
data, *ptrs_end = ptrs + whz; ptrs<ptrs_end; ) {
15604 const unsigned int _ind = (
unsigned int)*(ptrs++), ind = _ind<pwhz?_ind:0;
15605 *(ptrd0++) = ptrp0[ind]; *(ptrd1++) = ptrp1[ind]; *(ptrd2++) = ptrp2[ind];
15609 t *ptrd = res.data;
15610 for (
const T *ptrs =
data, *ptrs_end = ptrs + whz; ptrs<ptrs_end; ) {
15611 const unsigned int _ind = (
unsigned int)*(ptrs++), ind = _ind<pwhz?_ind:0;
15612 const t *ptrp = palette.data + ind;
15613 t *_ptrd = ptrd++;
cimg_forV(res,
k) { *_ptrd = *ptrp; _ptrd+=whz; ptrp+=pwhz; }
15639 #define _cimg_get_label_test(p,q) { \
15641 const T *ptr1 = ptr(x,y) + siz, *ptr2 = ptr(p,q) + siz; \
15642 for (unsigned int i = dim; flag && i; --i) { ptr1-=wh; ptr2-=wh; flag = (*ptr1==*ptr2); } \
15647 unsigned int label = 1;
15649 const int W1 =
dimx()-1, H1 =
dimy()-1;
15656 const unsigned int lab = (res(x,
y) = res(x,
y-1));
15658 if (x && res(x-1,
y)!=lab) {
15661 const unsigned int lold = res(x-1,
y), *
const cptr = res.
ptr(x,
y);
15668 if (!done) res(x,
y) = label++;
15670 for (
int y = H1;
y>=0; --
y)
for (
int x=W1; x>=0; --
x) {
15675 const unsigned int lab = (res(x,
y) = res(x,
y+1));
15677 if (x<W1 && res(x+1,
y)!=lab) {
15680 const unsigned int lold = res(x+1,
y), *
const cptr = res.
ptr(x,
y);
15688 const unsigned int lab0 = res.
max()+1;
15691 const unsigned int lab = res[off];
15692 if (lab<lab0) {
cimg_for(res,
ptr,
unsigned int)
if (*
ptr==lab) *
ptr = label; ++label; }
15694 return (res-=lab0);
15718 palette.assign(1,256,1,3);
15719 for (
unsigned int index = 0, r = 16; r<256; r+=32)
15720 for (
unsigned int g = 16; g<256; g+=32)
15721 for (
unsigned int b = 32; b<256; b+=64) {
15742 tmp.get_shared_channel(0).sequence(0,359);
15743 palette = tmp.HSVtoRGB();
15757 static const unsigned char pal[] = {
15758 217,62,88,75,1,237,240,12,56,160,165,116,1,1,204,2,15,248,148,185,133,141,46,246,222,116,16,5,207,226,
15759 17,114,247,1,214,53,238,0,95,55,233,235,109,0,17,54,33,0,90,30,3,0,94,27,19,0,68,212,166,130,0,15,7,119,
15760 238,2,246,198,0,3,16,10,13,2,25,28,12,6,2,99,18,141,30,4,3,140,12,4,30,233,7,10,0,136,35,160,168,184,20,
15761 233,0,1,242,83,90,56,180,44,41,0,6,19,207,5,31,214,4,35,153,180,75,21,76,16,202,218,22,17,2,136,71,74,
15762 81,251,244,148,222,17,0,234,24,0,200,16,239,15,225,102,230,186,58,230,110,12,0,7,129,249,22,241,37,219,
15763 1,3,254,210,3,212,113,131,197,162,123,252,90,96,209,60,0,17,0,180,249,12,112,165,43,27,229,77,40,195,12,
15764 87,1,210,148,47,80,5,9,1,137,2,40,57,205,244,40,8,252,98,0,40,43,206,31,187,0,180,1,69,70,227,131,108,0,
15765 223,94,228,35,248,243,4,16,0,34,24,2,9,35,73,91,12,199,51,1,249,12,103,131,20,224,2,70,32,
15766 233,1,165,3,8,154,246,233,196,5,0,6,183,227,247,195,208,36,0,0,226,160,210,198,69,153,210,1,23,8,192,2,4,
15767 137,1,0,52,2,249,241,129,0,0,234,7,238,71,7,32,15,157,157,252,158,2,250,6,13,30,11,162,0,199,21,11,27,224,
15768 4,157,20,181,111,187,218,3,0,11,158,230,196,34,223,22,248,135,254,210,157,219,0,117,239,3,255,4,227,5,247,
15769 11,4,3,188,111,11,105,195,2,0,14,1,21,219,192,0,183,191,113,241,1,12,17,248,0,48,7,19,1,254,212,0,239,246,
15770 0,23,0,250,165,194,194,17,3,253,0,24,6,0,141,167,221,24,212,2,235,243,0,0,205,1,251,133,204,28,4,6,1,10,
15771 141,21,74,12,236,254,228,19,1,0,214,1,186,13,13,6,13,16,27,209,6,216,11,207,251,59,32,9,155,23,19,235,143,
15772 116,6,213,6,75,159,23,6,0,228,4,10,245,249,1,7,44,234,4,102,174,0,19,239,103,16,15,18,8,214,22,4,47,244,
15773 255,8,0,251,173,1,212,252,250,251,252,6,0,29,29,222,233,246,5,149,0,182,180,13,151,0,203,183,0,35,149,0,
15774 235,246,254,78,9,17,203,73,11,195,0,3,5,44,0,0,237,5,106,6,130,16,214,20,168,247,168,4,207,11,5,1,232,251,
15775 129,210,116,231,217,223,214,27,45,38,4,177,186,249,7,215,172,16,214,27,249,230,236,2,34,216,217,0,175,30,
15776 243,225,244,182,20,212,2,226,21,255,20,0,2,13,62,13,191,14,76,64,20,121,4,118,0,216,1,147,0,2,210,1,215,
15777 95,210,236,225,184,46,0,248,24,11,1,9,141,250,243,9,221,233,160,11,147,2,55,8,23,12,253,9,0,54,0,231,6,3,
15778 141,8,2,246,9,180,5,11,8,227,8,43,110,242,1,130,5,97,36,10,6,219,86,133,11,108,6,1,5,244,67,19,28,0,174,
15779 154,16,127,149,252,188,196,196,228,244,9,249,0,0,0,37,170,32,250,0,73,255,23,3,224,234,38,195,198,0,255,87,
15780 33,221,174,31,3,0,189,228,6,153,14,144,14,108,197,0,9,206,245,254,3,16,253,178,248,0,95,125,8,0,3,168,21,
15781 23,168,19,50,240,244,185,0,1,144,10,168,31,82,1,13 };
15782 static const CImg<Tuchar> palette(pal,1,256,1,3,
false);
15791 "should be a (R,G,B) image.",
15793 T *
p1 =
ptr(0,0,0,0), *p2 =
ptr(0,0,0,1), *p3 =
ptr(0,0,0,2);
15799 nR = (R<0?0:(R>255?255:R))/255,
15800 nG = (G<0?0:(G>255?255:G))/255,
15801 nB = (B<0?0:(B>255?255:B))/255,
15807 f = (nR==m)?(nG-nB):((nG==m)?(nB-nR):(nR-nG)),
15808 i = (
Tfloat)((nR==m)?3:((nG==m)?5:1));
15830 "should be a (H,S,V) image",
15832 T *
p1 =
ptr(0,0,0,0), *p2 =
ptr(0,0,0,1), *p3 =
ptr(0,0,0,2);
15838 R = 0, G = 0, B = 0;
15839 if (H==0 && S==0) R = G = B = V;
15842 const int i = (int)std::floor(H);
15844 f = (i&1)?(H-i):(1-H+
i),
15849 case 0 : R = V; G =
n; B = m;
break;
15850 case 1 : R =
n; G = V; B = m;
break;
15851 case 2 : R = m; G = V; B =
n;
break;
15852 case 3 : R = m; G =
n; B = V;
break;
15853 case 4 : R =
n; G = m; B = V;
break;
15854 case 5 : R = V; G = m; B =
n;
break;
15857 R*=255; G*=255; B*=255;
15858 *(p1++) = (T)(R<0?0:(R>255?255:R));
15859 *(p2++) = (T)(G<0?0:(G>255?255:G));
15860 *(p3++) = (T)(B<0?0:(B>255?255:B));
15874 "should be a (R,G,B) image.",
15876 T *
p1 =
ptr(0,0,0,0), *p2 =
ptr(0,0,0,1), *p3 =
ptr(0,0,0,2);
15882 nR = (R<0?0:(R>255?255:R))/255,
15883 nG = (G<0?0:(G>255?255:G))/255,
15884 nB = (B<0?0:(B>255?255:B))/255,
15889 if (M==m) H = S = 0;
15892 f = (nR==m)?(nG-nB):((nG==m)?(nB-nR):(nR-nG)),
15893 i = (nR==m)?3.0f:((nG==m)?5.0f:1.0f);
15897 S = (2*L<=1)?((M-m)/(M+m)):((M-m)/(2-M-m));
15915 "should be a (H,S,V) image",
15917 T *
p1 =
ptr(0,0,0,0), *p2 =
ptr(0,0,0,1), *p3 =
ptr(0,0,0,2);
15923 q = 2*L<1?L*(1+S):(L+S-L*S),
15929 ntr = tr<0?tr+1:(tr>1?tr-1:tr),
15930 ntg = tg<0?tg+1:(tg>1?tg-1:tg),
15931 ntb = tb<0?tb+1:(tb>1?tb-1:tb),
15932 R = 255*(6*ntr<1?p+(
q-p)*6*ntr:(2*ntr<1?
q:(3*ntr<2?p+(
q-p)*6*(2.0f/3-ntr):p))),
15933 G = 255*(6*ntg<1?p+(
q-p)*6*ntg:(2*ntg<1?
q:(3*ntg<2?p+(
q-p)*6*(2.0f/3-ntg):p))),
15934 B = 255*(6*ntb<1?p+(
q-p)*6*ntb:(2*ntb<1?
q:(3*ntb<2?p+(
q-p)*6*(2.0f/3-ntb):p)));
15935 *(p1++) = (T)(R<0?0:(R>255?255:R));
15936 *(p2++) = (T)(G<0?0:(G>255?255:G));
15937 *(p3++) = (T)(B<0?0:(B>255?255:B));
15952 "should be a (R,G,B) image.",
15954 T *
p1 =
ptr(0,0,0,0), *p2 =
ptr(0,0,0,1), *p3 =
ptr(0,0,0,2);
15960 nR = (R<0?0:(R>255?255:R))/255,
15961 nG = (G<0?0:(G>255?255:G))/255,
15962 nB = (B<0?0:(B>255?255:B))/255,
15965 sum = nR + nG + nB;
15966 Tfloat H = 0, S = 0, I = 0;
15967 if (theta>0) H = (nB<=nG)?theta:360-theta;
15968 if (
sum>0) S = 1 - 3/
sum*m;
15986 "should be a (H,S,I) image",
15988 T *
p1 =
ptr(0,0,0,0), *p2 =
ptr(0,0,0,1), *p3 =
ptr(0,0,0,2);
15995 R = 0, G = 0, B = 0;
16000 }
else if (H<240) {
16011 R*=255; G*=255; B*=255;
16012 *(p1++) = (T)(R<0?0:(R>255?255:R));
16013 *(p2++) = (T)(G<0?0:(G>255?255:G));
16014 *(p3++) = (T)(B<0?0:(B>255?255:B));
16028 "should be a (R,G,B) image (dim=3)",
16030 T *
p1 =
ptr(0,0,0,0), *p2 =
ptr(0,0,0,1), *p3 =
ptr(0,0,0,2);
16036 Y = (66*R + 129*G + 25*B + 128)/256 + 16,
16037 Cb = (-38*R - 74*G + 112*B + 128)/256 + 128,
16038 Cr = (112*R - 94*G - 18*B + 128)/256 + 128;
16039 *(p1++) = (T)(Y<0?0:(Y>255?255:Y));
16040 *(p2++) = (T)(Cb<0?0:(Cb>255?255:Cb));
16041 *(p3++) = (T)(Cr<0?0:(Cr>255?255:Cr));
16055 "should be a (Y,Cb,Cr)_8 image (dim=3)",
16057 T *
p1 =
ptr(0,0,0,0), *p2 =
ptr(0,0,0,1), *p3 =
ptr(0,0,0,2);
16063 R = (298*Y + 409*Cr + 128)/256,
16064 G = (298*Y - 100*Cb - 208*Cr + 128)/256,
16065 B = (298*Y + 516*Cb + 128)/256;
16066 *(p1++) = (T)(R<0?0:(R>255?255:R));
16067 *(p2++) = (T)(G<0?0:(G>255?255:G));
16068 *(p3++) = (T)(B<0?0:(B>255?255:B));
16082 "should be a (R,G,B) image (dim=3)",
16084 T *
p1 =
ptr(0,0,0,0), *p2 =
ptr(0,0,0,1), *p3 =
ptr(0,0,0,2);
16090 Y = 0.299f*R + 0.587f*G + 0.114f*B;
16092 *(p2++) = (T)(0.492f*(B-Y));
16093 *(p3++) = (T)(0.877*(R-Y));
16107 "should be a (Y,U,V) image (dim=3)",
16109 T *
p1 =
ptr(0,0,0,0), *p2 =
ptr(0,0,0,1), *p3 =
ptr(0,0,0,2);
16115 R = (Y + 1.140f*V)*255,
16116 G = (Y - 0.395f*U - 0.581f*V)*255,
16117 B = (Y + 2.032f*U)*255;
16118 *(p1++) = (T)(R<0?0:(R>255?255:R));
16119 *(p2++) = (T)(G<0?0:(G>255?255:G));
16120 *(p3++) = (T)(B<0?0:(B>255?255:B));
16134 "should be a (R,G,B) image (dim=3)",
16136 T *
p1 =
ptr(0,0,0,0), *p2 =
ptr(0,0,0,1), *p3 =
ptr(0,0,0,2);
16142 *(p1++) = (T)(1 - R);
16143 *(p2++) = (T)(1 - G);
16144 *(p3++) = (T)(1 - B);
16158 "should be a (C,M,Y) image (dim=3)",
16160 T *
p1 =
ptr(0,0,0,0), *p2 =
ptr(0,0,0,1), *p3 =
ptr(0,0,0,2);
16169 *(p1++) = (T)(R<0?0:(R>255?255:R));
16170 *(p2++) = (T)(G<0?0:(G>255?255:G));
16171 *(p3++) = (T)(B<0?0:(B>255?255:B));
16189 "should be a (C,M,Y) image (dim=3)",
16192 const T *ps1 =
ptr(0,0,0,0), *ps2 =
ptr(0,0,0,1), *ps3 =
ptr(0,0,0,2);
16193 Tfloat *pd1 = res.ptr(0,0,0,0), *pd2 = res.ptr(0,0,0,1), *pd3 = res.ptr(0,0,0,2), *pd4 = res.ptr(0,0,0,3);
16200 if (K==1) C = M = Y = 0;
16201 else {
const Tfloat K1 = 1 - K; C = (C - K)/K1; M = (M - K)/K1; Y = (Y - K)/K1; }
16219 "should be a (C,M,Y,K) image (dim=4)",
16222 const T *ps1 =
ptr(0,0,0,0), *ps2 =
ptr(0,0,0,1), *ps3 =
ptr(0,0,0,2), *ps4 =
ptr(0,0,0,3);
16223 Tfloat *pd1 = res.ptr(0,0,0,0), *pd2 = res.ptr(0,0,0,1), *pd3 = res.ptr(0,0,0,2);
16231 *(pd1++) = C*K1 + K;
16232 *(pd2++) = M*K1 + K;
16233 *(pd3++) = Y*K1 + K;
16243 "should be a (R,G,B) image (dim=3)",
16245 T *
p1 =
ptr(0,0,0,0), *p2 =
ptr(0,0,0,1), *p3 =
ptr(0,0,0,2);
16251 *(p1++) = (T)(0.412453f*R + 0.357580f*G + 0.180423f*B);
16252 *(p2++) = (T)(0.212671f*R + 0.715160f*G + 0.072169f*B);
16253 *(p3++) = (T)(0.019334f*R + 0.119193f*G + 0.950227f*B);
16267 "should be a (X,Y,Z) image (dim=3)",
16269 T *
p1 =
ptr(0,0,0,0), *p2 =
ptr(0,0,0,1), *p3 =
ptr(0,0,0,2);
16275 R = 3.240479f*X - 1.537150f*Y - 0.498535f*Z,
16276 G = -0.969256f*X + 1.875992f*Y + 0.041556f*Z,
16277 B = 0.055648f*X - 0.204043f*Y + 1.057311f*Z;
16278 *(p1++) = (T)(R<0?0:(R>255?255:R));
16279 *(p2++) = (T)(G<0?0:(G>255?255:G));
16280 *(p3++) = (T)(B<0?0:(B>255?255:B));
16291 #define _cimg_Labf(x) ((x)>=0.008856f?(std::pow(x,(Tfloat)1/3)):(7.787f*(x)+16.0f/116))
16295 "should be a (X,Y,Z) image (dim=3)",
16298 Xn = (
Tfloat)(0.412453f + 0.357580f + 0.180423f),
16299 Yn = (
Tfloat)(0.212671f + 0.715160f + 0.072169f),
16300 Zn = (
Tfloat)(0.019334f + 0.119193f + 0.950227f);
16301 T *
p1 =
ptr(0,0,0,0), *p2 =
ptr(0,0,0,1), *p3 =
ptr(0,0,0,2);
16307 XXn = X/Xn, YYn = Y/Yn, ZZn = Z/Zn,
16311 *(p1++) = (T)(116*fY - 16);
16312 *(p2++) = (T)(500*(fX - fY));
16313 *(p3++) = (T)(200*(fY - fZ));
16324 #define _cimg_Labfi(x) ((x)>=0.206893f?((x)*(x)*(x)):(((x)-16.0f/116)/7.787f))
16328 "should be a (X,Y,Z) image (dim=3)",
16331 Xn = (
Tfloat)(0.412453f + 0.357580f + 0.180423f),
16332 Yn = (
Tfloat)(0.212671f + 0.715160f + 0.072169f),
16333 Zn = (
Tfloat)(0.019334f + 0.119193f + 0.950227f);
16334 T *
p1 =
ptr(0,0,0,0), *p2 =
ptr(0,0,0,1), *p3 =
ptr(0,0,0,2);
16363 "should be a (X,Y,Z) image (dim=3)",
16365 T *
p1 =
ptr(0,0,0,0), *p2 =
ptr(0,0,0,1), *p3 =
ptr(0,0,0,2);
16373 *(p1++) = (T)(X/nsum);
16374 *(p2++) = (T)(Y/nsum);
16389 "should be a (x,y,Y) image (dim=3)",
16391 T *
p1 =
ptr(0,0,0,0), *p2 =
ptr(0,0,0,1), *p3 =
ptr(0,0,0,2);
16398 *(p1++) = (T)(px*Y/ny);
16400 *(p3++) = (T)((1-px-py)*Y/ny);
16475 "should be a (R,G,B) image (dim=3)",
16478 const T *pR =
ptr(0,0,0,0), *pG =
ptr(0,0,0,1), *pB =
ptr(0,0,0,2);
16479 T *ptrd = res.data;
16482 if (x%2) *(ptrd++) = *pB;
16483 else *(ptrd++) = *pG;
16485 if (x%2) *(ptrd++) = *pG;
16486 else *(ptrd++) = *pR;
16502 "should be a Bayer image (dim=1)",
16506 Tuchar *pR = res.ptr(0,0,0,0), *pG = res.ptr(0,0,0,1), *pB = res.ptr(0,0,0,2);
16507 switch (interpolation_type) {
16513 const int _p1x = x?x-1:1, _p1y =
y?
y-1:1, _n1x = x<
dimx()-1?x+1:x-1, _n1y =
y<
dimy()-1?
y+1:
y-1;
16518 *pG = (
Tuchar)((cx*(Inc+Ipc) + cy*(Icn+Icp))/(2*(cx+cy)));
16519 }
else *pG = (
Tuchar)Icc;
16521 if (x%2) *pG = (
Tuchar)Icc;
16524 *pG = (
Tuchar)((cx*(Inc+Ipc) + cy*(Icn+Icp))/(2*(cx+cy)));
16530 const int _p1x = x?x-1:1, _p1y =
y?
y-1:1, _n1x = x<
dimx()-1?x+1:x-1, _n1y =
y<
dimy()-1?
y+1:
y-1;
16534 if (x%2) *pB = (
Tuchar)Icc;
16535 else { *pR = (
Tuchar)((Icn+Icp)/2); *pB = (
Tuchar)((Inc+Ipc)/2); }
16537 if (x%2) { *pR = (
Tuchar)((Inc+Ipc)/2); *pB = (
Tuchar)((Icn+Icp)/2); }
16542 pR = res.ptr(0,0,0,0);
16543 pG = res.ptr(0,0,0,1);
16544 pB = res.ptr(0,0,0,2);
16546 const int _p1x = x?x-1:1, _p1y =
y?
y-1:1, _n1x = x<
dimx()-1?x+1:x-1, _n1y =
y<
dimy()-1?
y+1:
y-1;
16552 const float alpha = (float)
cimg::sqr(Rnc-Rpc), beta = (float)
cimg::sqr(Rcn-Rcp), cx = 1/(1+alpha), cy = 1/(1+beta);
16553 *pR = (
Tuchar)((cx*(Rnc+Rpc) + cy*(Rcn+Rcp))/(2*(cx+cy)));
16557 const float alpha = (float)
cimg::sqr(Bnc-Bpc), beta = (float)
cimg::sqr(Bcn-Bcp), cx = 1/(1+alpha), cy = 1/(1+beta);
16558 *pB = (
Tuchar)((cx*(Bnc+Bpc) + cy*(Bcn+Bcp))/(2*(cx+cy)));
16566 const int _p1x = x?x-1:1, _p1y =
y?
y-1:1, _n1x = x<
dimx()-1?x+1:x-1, _n1y =
y<
dimy()-1?
y+1:
y-1;
16569 if (x%2) { *pR = (
Tuchar)((Ipp+Inn+Ipn+Inp)/4); *pG = (
Tuchar)((Inc+Ipc+Icn+Icp)/4); *pB = (
Tuchar)Icc; }
16570 else { *pR = (
Tuchar)((Icp+Icn)/2); *pG = (
Tuchar)Icc; *pB = (
Tuchar)((Inc+Ipc)/2); }
16572 if (x%2) { *pR = (
Tuchar)((Ipc+Inc)/2); *pG = (
Tuchar)Icc; *pB = (
Tuchar)((Icn+Icp)/2); }
16573 else { *pR = (
Tuchar)Icc; *pG = (
Tuchar)((Inc+Ipc+Icn+Icp)/4); *pB = (
Tuchar)((Ipp+Inn+Ipn+Inp)/4); }
16580 const int _p1x = x?x-1:1, _p1y =
y?
y-1:1, _n1x = x<
dimx()-1?x+1:x-1, _n1y =
y<
dimy()-1?
y+1:
y-1;
16593 const T *ptrs =
data;
16596 const T val = *(ptrs++);
16597 if (
y%2) {
if (x%2) *pB = val;
else *pG = val; }
else {
if (x%2) *pG = val;
else *pR = val; }
16630 CImg<T>&
resize(
const int pdx,
const int pdy=-100,
const int pdz=-100,
const int pdv=-100,
16631 const int interpolation_type=1,
const int border_condition=-1,
const bool center=
false) {
16632 if (!pdx || !pdy || !pdz || !pdv)
return assign();
16634 tdx = pdx<0?-pdx*
width/100:pdx,
16635 tdy = pdy<0?-pdy*
height/100:pdy,
16636 tdz = pdz<0?-pdz*
depth/100:pdz,
16637 tdv = pdv<0?-pdv*dim/100:pdv,
16643 if (interpolation_type==-1 && dx*
dy*dz*dv==
size()) {
16647 return get_resize(dx,
dy,dz,dv,interpolation_type,border_condition,center).transfer_to(*
this);
16651 const int interpolation_type=1,
const int border_condition=-1,
const bool center=
false)
const {
16652 if (!pdx || !pdy || !pdz || !pdv)
return CImg<T>();
16654 tdx = pdx<0?-pdx*
width/100:pdx,
16655 tdy = pdy<0?-pdy*
height/100:pdy,
16656 tdz = pdz<0?-pdz*
depth/100:pdz,
16657 tdv = pdv<0?-pdv*dim/100:pdv,
16666 switch (interpolation_type) {
16668 std::memcpy(res.assign(dx,
dy,dz,dv,0).data,
data,
sizeof(T)*
cimg::min(
size(),(
unsigned int)dx*
dy*dz*dv));
16673 res.assign(dx,
dy,dz,dv);
16674 switch (border_condition) {
16678 x0 = (res.dimx() -
dimx())/2,
16679 y0 = (res.dimy() -
dimy())/2,
16680 z0 = (res.dimz() -
dimz())/2,
16681 v0 = (res.dimv() -
dimv())/2,
16686 res.draw_image(x0,y0,z0,v0,*
this);
16687 cimg_for_outXYZV(res,x0,y0,z0,v0,x1,y1,z1,v1,x,
y,
z,
v) res(x,
y,
z,
v) =
_atXYZV(x - x0,
y - y0,
z - z0,
v - v0);
16689 res.draw_image(*
this);
16690 cimg_for_outXYZV(res,0,0,0,0,bx,by,bz,bv,x,
y,
z,
v) res(x,
y,
z,
v) =
_atXYZV(x,
y,
z,
v);
16694 int nx0 = 0, ny0 = 0, nz0 = 0, nv0 = 0;
16697 x0 = (res.dimx() -
dimx())/2,
16698 y0 = (res.dimy() -
dimy())/2,
16699 z0 = (res.dimz() -
dimz())/2,
16700 v0 = (res.dimv() -
dimv())/2;
16704 nv0 = v0>0?v0-(1+v0/
dim)*dim:v0;
16706 for (
int k = nv0;
k<(int)dv;
k+=
dimv())
16707 for (
int z = nz0;
z<(int)dz;
z+=
dimz())
16708 for (
int y = ny0;
y<(int)
dy;
y+=
dimy())
16709 for (
int x = nx0; x<(int)dx; x+=
dimx()) res.draw_image(x,y,z,k,*
this);
16713 if (center) res.draw_image((res.dimx()-
dimx())/2,(res.dimy()-
dimy())/2,(res.dimz()-
dimz())/2,(res.dimv()-
dimv())/2,*
this);
16714 else res.draw_image(*
this);
16720 res.assign(dx,
dy,dz,dv);
16722 *
const offx =
new unsigned int[
dx],
16723 *
const offy =
new unsigned int[
dy+1],
16724 *
const offz =
new unsigned int[dz+1],
16725 *
const offv =
new unsigned int[dv+1],
16726 *poffx, *poffy, *poffz, *poffv,
16729 poffx = offx; curr = 0;
cimg_forX(res,x) { old = curr; curr = (x+1)*
width/dx; *(poffx++) = (
unsigned int)curr - (
unsigned int)old; }
16730 poffy = offy; curr = 0;
cimg_forY(res,
y) { old = curr; curr = (
y+1)*height/dy; *(poffy++) =
width*((
unsigned int)curr - (
unsigned int)old); } *poffy = 0;
16731 poffz = offz; curr = 0;
cimg_forZ(res,
z) { old = curr; curr = (
z+1)*depth/dz; *(poffz++) = wh*((
unsigned int)curr - (
unsigned int)old); } *poffz = 0;
16732 poffv = offv; curr = 0;
cimg_forV(res,
k) { old = curr; curr = (
k+1)*dim/dv; *(poffv++) = whd*((
unsigned int)curr - (
unsigned int)old); } *poffv = 0;
16733 T *ptrd = res.data;
16734 const T* ptrv =
data;
16736 for (
unsigned int k = 0;
k<dv; ) {
16737 const T *ptrz = ptrv;
16739 for (
unsigned int z = 0;
z<dz; ) {
16740 const T *ptry = ptrz;
16742 for (
unsigned int y = 0;
y<
dy; ) {
16743 const T *ptrx = ptry;
16745 cimg_forX(res,x) { *(ptrd++) = *ptrx; ptrx+=*(poffx++); }
16747 unsigned int dy = *(poffy++);
16748 for (;!dy &&
y<
dy; std::memcpy(ptrd,ptrd - dx,
sizeof(T)*dx), ++
y, ptrd+=
dx, dy=*(poffy++)) {}
16752 unsigned int dz = *(poffz++);
16753 for (;!dz &&
z<dz; std::memcpy(ptrd,ptrd-rwh,
sizeof(T)*rwh), ++
z, ptrd+=rwh, dz=*(poffz++)) {}
16757 unsigned int dv = *(poffv++);
16758 for (;!dv &&
k<dv; std::memcpy(ptrd,ptrd-rwhd,
sizeof(T)*rwhd), ++
k, ptrd+=rwhd, dv=*(poffv++)) {}
16761 delete[] offx;
delete[] offy;
delete[] offz;
delete[] offv;
16765 bool instance_first =
true;
16768 for (
unsigned int a =
width*dx, b =
width, c = dx, s = 0, t = 0; a; ) {
16773 if (!c) { ++
s; c =
dx; }
16775 tmp.transfer_to(res);
16776 instance_first =
false;
16780 for (
unsigned int a =
height*
dy, b =
height, c = dy, s = 0, t = 0; a; ) {
16786 if (!c) { ++
s; c =
dy; }
16788 tmp.transfer_to(res);
16789 instance_first =
false;
16793 for (
unsigned int a =
depth*dz, b =
depth, c = dz, s = 0, t = 0; a; ) {
16799 if (!c) { ++
s; c = dz; }
16801 tmp.transfer_to(res);
16802 instance_first =
false;
16806 for (
unsigned int a = dim*dv, b = dim, c = dv, s = 0, t = 0; a; ) {
16812 if (!c) { ++
s; c = dv; }
16814 tmp.transfer_to(res);
16815 instance_first =
false;
16820 const unsigned int dimmax =
cimg::max(dx,
dy,dz,dv);
16822 sx = (border_condition<0 && dx>
width )?(dx>1?(
width-1.0f)/(dx-1) :0):(float)
width/dx,
16823 sy = (border_condition<0 && dy>
height)?(
dy>1?(height-1.0f)/(
dy-1):0):(
float)height/
dy,
16824 sz = (border_condition<0 && dz>
depth )?(dz>1?(
depth-1.0f)/(dz-1) :0):(float)
depth/dz,
16825 sv = (border_condition<0 && dv>dim )?(dv>1?(dim-1.0f)/(dv-1) :0):(
float)dim/dv;
16827 unsigned int *
const off =
new unsigned int[dimmax], *poff;
16828 float *
const foff =
new float[dimmax], *pfoff, old, curr;
16829 CImg<T> resx, resy, resz, resv;
16835 resx.assign(dx,height,
depth,dim);
16836 curr = old = 0; poff = off; pfoff = foff;
16837 cimg_forX(resx,x) { *(pfoff++) = curr-(
unsigned int)curr; old = curr; curr+=sx; *(poff++) = (
unsigned int)curr-(
unsigned int)old; }
16839 const T *ptrs0 =
data;
16841 poff = off; pfoff = foff;
16842 const T *ptrs = ptrs0, *
const ptrsmax = ptrs0 + (
width-1);
16844 const float alpha = *(pfoff++);
16845 const T val1 = *ptrs, val2 = ptrs<ptrsmax?*(ptrs+1):(border_condition?val1:(T)0);
16846 *(ptrd++) = (T)((1-alpha)*val1 + alpha*val2);
16852 }
else resx.assign(*
this,
true);
16855 if (height==1) resy = resx.get_resize(dx,
dy,
depth,dim,1,0);
16857 resy.assign(dx,
dy,
depth,dim);
16858 curr = old = 0; poff = off; pfoff = foff;
16859 cimg_forY(resy,
y) { *(pfoff++) = curr-(
unsigned int)curr; old = curr; curr+=sy; *(poff++) = dx*((
unsigned int)curr-(
unsigned int)old); }
16861 ptrd = resy.ptr(x,0,
z,
k);
16862 const T *ptrs = resx.ptr(x,0,
z,
k), *
const ptrsmax = ptrs + (height-1)*dx;
16863 poff = off; pfoff = foff;
16865 const float alpha = *(pfoff++);
16866 const T val1 = *ptrs, val2 = ptrs<ptrsmax?*(ptrs+
dx):(border_condition?val1:(T)0);
16867 *ptrd = (T)((1-alpha)*val1 + alpha*val2);
16874 }
else resy.assign(resx,
true);
16877 if (
depth==1) resz = resy.get_resize(dx,
dy,dz,dim,1,0);
16879 const unsigned int wh = dx*
dy;
16880 resz.assign(dx,dy,dz,dim);
16881 curr = old = 0; poff = off; pfoff = foff;
16882 cimg_forZ(resz,
z) { *(pfoff++) = curr-(
unsigned int)curr; old = curr; curr+=sz; *(poff++) = wh*((
unsigned int)curr-(
unsigned int)old); }
16884 ptrd = resz.ptr(x,
y,0,
k);
16885 const T *ptrs = resy.ptr(x,
y,0,
k), *
const ptrsmax = ptrs + (
depth-1)*wh;
16886 poff = off; pfoff = foff;
16888 const float alpha = *(pfoff++);
16889 const T val1 = *ptrs, val2 = ptrs<ptrsmax?*(ptrs+wh):(border_condition?val1:(T)0);
16890 *ptrd = (T)((1-alpha)*val1 + alpha*val2);
16897 }
else resz.assign(resy,
true);
16900 if (dim==1) resv = resz.get_resize(dx,
dy,dz,dv,1,0);
16902 const unsigned int whd = dx*
dy*dz;
16903 resv.assign(dx,
dy,dz,dv);
16904 curr = old = 0; poff = off; pfoff = foff;
16905 cimg_forV(resv,
k) { *(pfoff++) = curr-(
unsigned int)curr; old = curr; curr+=sv; *(poff++) = whd*((
unsigned int)curr-(
unsigned int)old); }
16907 ptrd = resv.ptr(x,
y,
z,0);
16908 const T *ptrs = resz.ptr(x,
y,
z,0), *
const ptrsmax = ptrs + (dim-1)*whd;
16909 poff = off; pfoff = foff;
16911 const float alpha = *(pfoff++);
16912 const T val1 = *ptrs, val2 = ptrs<ptrsmax?*(ptrs+whd):(border_condition?val1:(T)0);
16913 *ptrd = (T)((1-alpha)*val1 + alpha*val2);
16920 }
else resv.assign(resz,
true);
16922 delete[] off;
delete[] foff;
16923 return resv.is_shared?(resz.is_shared?(resy.is_shared?(resx.is_shared?(+(*this)):resx):resy):resz):resv;
16927 res.assign(dx,
dy,dz,dv,0);
16928 cimg_forXYZV(*
this,x,
y,
z,
k) res(x*dx/
width,
y*
dy/
height,
z*dz/
depth,
k*dv/dim) = (*this)(
x,
y,
z,
k);
16933 sx = (border_condition<0 && dx>
width )?(dx>1?(
width-1.0f)/(dx-1) :0):(float)
width/dx,
16934 sy = (border_condition<0 && dy>
height)?(
dy>1?(height-1.0f)/(
dy-1):0):(
float)height/
dy,
16935 sz = (border_condition<0 && dz>
depth )?(dz>1?(
depth-1.0f)/(dz-1) :0):(float)
depth/dz,
16936 sv = (border_condition<0 && dv>dim )?(dv>1?(dim-1.0f)/(dv-1) :0):(
float)dim/dv;
16937 res.assign(dx,
dy,dz,dv);
16938 T *ptrd = res.ptr();
16939 float cx, cy, cz, ck = 0;
16944 *(ptrd++) = (T)(border_condition?
_cubic_atXY(cx,cy,(
int)cz,(
int)ck):
cubic_atXY(cx,cy,(
int)cz,(
int)ck,0));
16954 "(should be { -1=raw, 0=zero, 1=nearest, 2=average, 3=linear, 4=grid, 5=bicubic}).",
16974 template<
typename t>
16976 const int border_condition=-1,
const bool center=
false) {
16977 return resize(src.width,src.height,src.depth,src.dim,interpolation_type,border_condition,center);
16980 template<
typename t>
16982 const int border_condition=-1,
const bool center=
false)
const {
16983 return get_resize(src.width,src.height,src.depth,src.dim,interpolation_type,border_condition,center);
17001 const int border_condition=-1,
const bool center=
false) {
17006 const int border_condition=-1,
const bool center=
false)
const {
17017 const Tfloat mask[9] = { 0.07842776544f, 0.1231940459f, 0.07842776544f,
17018 0.1231940459f, 0.1935127547f, 0.1231940459f,
17019 0.07842776544f, 0.1231940459f, 0.07842776544f };
17023 if (x%2 &&
y%2) dest(x/2,
y/2,
z,
k) = (T)
17024 (I[0]*mask[0] + I[1]*mask[1] + I[2]*mask[2] +
17025 I[3]*mask[3] + I[4]*mask[4] + I[5]*mask[5] +
17026 I[6]*mask[6] + I[7]*mask[7] + I[8]*mask[8]);
17040 #define _cimg_gs2x_for3(bound,i) \
17041 for (int i = 0, _p1##i = 0, \
17042 _n1##i = 1>=(bound)?(int)(bound)-1:1; \
17043 _n1##i<(int)(bound) || i==--_n1##i; \
17044 _p1##i = i++, ++_n1##i, ptrd1+=(res).width, ptrd2+=(res).width)
17046 #define _cimg_gs2x_for3x3(img,x,y,z,v,I) \
17047 _cimg_gs2x_for3((img).height,y) for (int x = 0, \
17050 (I[1] = (img)(0,_p1##y,z,v)), \
17051 (I[3] = I[4] = (img)(0,y,z,v)), \
17052 (I[7] = (img)(0,_n1##y,z,v)), \
17053 1>=(img).width?(int)((img).width)-1:1); \
17054 (_n1##x<(int)((img).width) && ( \
17055 (I[2] = (img)(_n1##x,_p1##y,z,v)), \
17056 (I[5] = (img)(_n1##x,y,z,v)), \
17057 (I[8] = (img)(_n1##x,_n1##y,z,v)),1)) || \
17060 I[3] = I[4], I[4] = I[5], \
17062 _p1##x = x++, ++_n1##x)
17069 *ptrd1 = res.ptr(0,0,0,
k),
17070 *ptrd2 = ptrd1 + res.width;
17072 if (Icp!=Icn && Ipc!=Inc) {
17073 *(ptrd1++) = Ipc==Icp?Ipc:Icc;
17074 *(ptrd1++) = Icp==Inc?Inc:Icc;
17075 *(ptrd2++) = Ipc==Icn?Ipc:Icc;
17076 *(ptrd2++) = Icn==Inc?Inc:Icc;
17077 }
else { *(ptrd1++) = Icc; *(ptrd1++) = Icc; *(ptrd2++) = Icc; *(ptrd2++) = Icc; }
17093 #define _cimg_gs3x_for3(bound,i) \
17094 for (int i = 0, _p1##i = 0, \
17095 _n1##i = 1>=(bound)?(int)(bound)-1:1; \
17096 _n1##i<(int)(bound) || i==--_n1##i; \
17097 _p1##i = i++, ++_n1##i, ptrd1+=2*(res).width, ptrd2+=2*(res).width, ptrd3+=2*(res).width)
17099 #define _cimg_gs3x_for3x3(img,x,y,z,v,I) \
17100 _cimg_gs3x_for3((img).height,y) for (int x = 0, \
17103 (I[0] = I[1] = (img)(0,_p1##y,z,v)), \
17104 (I[3] = I[4] = (img)(0,y,z,v)), \
17105 (I[6] = I[7] = (img)(0,_n1##y,z,v)), \
17106 1>=(img).width?(int)((img).width)-1:1); \
17107 (_n1##x<(int)((img).width) && ( \
17108 (I[2] = (img)(_n1##x,_p1##y,z,v)), \
17109 (I[5] = (img)(_n1##x,y,z,v)), \
17110 (I[8] = (img)(_n1##x,_n1##y,z,v)),1)) || \
17112 I[0] = I[1], I[1] = I[2], \
17113 I[3] = I[4], I[4] = I[5], \
17114 I[6] = I[7], I[7] = I[8], \
17115 _p1##x = x++, ++_n1##x)
17122 *ptrd1 = res.ptr(0,0,0,
k),
17123 *ptrd2 = ptrd1 + res.width,
17124 *ptrd3 = ptrd2 + res.width;
17126 if (Icp != Icn && Ipc != Inc) {
17127 *(ptrd1++) = Ipc==Icp?Ipc:Icc;
17128 *(ptrd1++) = (Ipc==Icp && Icc!=Inp) || (Icp==Inc && Icc!=Ipp)?Icp:Icc;
17129 *(ptrd1++) = Icp==Inc?Inc:Icc;
17130 *(ptrd2++) = (Ipc==Icp && Icc!=Ipn) || (Ipc==Icn && Icc!=Ipp)?Ipc:Icc;
17132 *(ptrd2++) = (Icp==Inc && Icc!=Inn) || (Icn==Inc && Icc!=Inp)?Inc:Icc;
17133 *(ptrd3++) = Ipc==Icn?Ipc:Icc;
17134 *(ptrd3++) = (Ipc==Icn && Icc!=Inn) || (Icn==Inc && Icc!=Ipn)?Icn:Icc;
17135 *(ptrd3++) = Icn==Inc?Inc:Icc;
17137 *(ptrd1++) = Icc; *(ptrd1++) = Icc; *(ptrd1++) = Icc;
17138 *(ptrd2++) = Icc; *(ptrd2++) = Icc; *(ptrd2++) = Icc;
17139 *(ptrd3++) = Icc; *(ptrd3++) = Icc; *(ptrd3++) = Icc;
17149 T *pf, *pb, *buf = 0;
17153 const unsigned int width2 =
width/2;
17155 for (
unsigned int x = 0; x<width2; ++
x) {
const T val = *pf; *(pf++) = *pb; *(pb--) = val; }
17156 pf+=
width - width2;
17157 pb+=
width + width2;
17161 buf =
new T[
width];
17163 const unsigned int height2 =
height/2;
17164 for (
unsigned int zv = 0; zv<
depth*
dim; ++zv) {
17165 for (
unsigned int y = 0;
y<height2; ++
y) {
17166 std::memcpy(buf,pf,
width*
sizeof(T));
17167 std::memcpy(pf,pb,
width*
sizeof(T));
17168 std::memcpy(pb,buf,
width*
sizeof(T));
17179 const unsigned int depth2 =
depth/2;
17181 for (
unsigned int z = 0;
z<depth2; ++
z) {
17194 pf =
data; pb =
ptr(0,0,0,dim-1);
17195 const unsigned int dim2 = dim/2;
17196 for (
unsigned int v = 0;
v<dim2; ++
v) {
17208 if (buf)
delete[] buf;
17213 return (+*
this).
mirror(axis);
17230 const int border_condition=0) {
17233 switch (border_condition) {
17238 std::memset(
ptr(
width+deltax,
y,
z,
k),0,-deltax*
sizeof(T));
17241 std::memset(
ptr(0,
y,
z,
k),0,deltax*
sizeof(T));
17246 const int ndeltax = (-deltax>=
dimx())?
width-1:-deltax;
17247 if (!ndeltax)
return *
this;
17251 const T val = *ptrd;
17252 for (
int l = 0; l<ndeltax-1; ++l) *(--ptrd) = val;
17255 const int ndeltax = (deltax>=
dimx())?
width-1:deltax;
17256 if (!ndeltax)
return *
this;
17260 const T val = *ptrd;
17261 for (
int l = 0; l<ndeltax-1; ++l) *(++ptrd) = val;
17267 if (!ndeltax)
return *
this;
17270 std::memcpy(buf,
ptr(0,
y,
z,
k),ndeltax*
sizeof(T));
17272 std::memcpy(
ptr(
width-ndeltax,
y,
z,
k),buf,ndeltax*
sizeof(T));
17274 std::memcpy(buf,
ptr(
width+ndeltax,
y,
z,
k),-ndeltax*
sizeof(T));
17276 std::memcpy(
ptr(0,
y,
z,
k),buf,-ndeltax*
sizeof(T));
17283 switch (border_condition) {
17291 std::memset(
ptr(0,0,
z,
k),0,deltay*
width*
sizeof(T));
17296 const int ndeltay = (-deltay>=
dimy())?
height-1:-deltay;
17297 if (!ndeltay)
return *
this;
17301 for (
int l = 0; l<ndeltay-1; ++l) { std::memcpy(ptrd,ptrs,
width*
sizeof(T)); ptrd+=
width; }
17304 const int ndeltay = (deltay>=
dimy())?
height-1:deltay;
17305 if (!ndeltay)
return *
this;
17308 T *ptrd =
ptr(0,1,
z,
k), *ptrs =
ptr(0,0,
z,
k);
17309 for (
int l = 0; l<ndeltay-1; ++l) { std::memcpy(ptrd,ptrs,
width*
sizeof(T)); ptrd+=
width; }
17315 if (!ndeltay)
return *
this;
17318 std::memcpy(buf,
ptr(0,0,
z,
k),
width*ndeltay*
sizeof(T));
17324 std::memcpy(
ptr(0,0,
z,
k),buf,-ndeltay*
width*
sizeof(T));
17331 switch (border_condition) {
17344 const int ndeltaz = (-deltaz>=
dimz())?
depth-1:-deltaz;
17345 if (!ndeltaz)
return *
this;
17349 for (
int l = 0; l<ndeltaz-1; ++l) { std::memcpy(ptrd,ptrs,
width*
height*
sizeof(T)); ptrd+=
width*
height; }
17352 const int ndeltaz = (deltaz>=
dimz())?
depth-1:deltaz;
17353 if (!ndeltaz)
return *
this;
17356 T *ptrd =
ptr(0,0,1,
k), *ptrs =
ptr(0,0,0,
k);
17357 for (
int l = 0; l<ndeltaz-1; ++l) { std::memcpy(ptrd,ptrs,
width*
height*
sizeof(T)); ptrd+=
width*
height; }
17363 if (!ndeltaz)
return *
this;
17379 switch (border_condition) {
17392 const int ndeltav = (-deltav>=
dimv())?dim-1:-deltav;
17393 if (!ndeltav)
return *
this;
17395 T *ptrd =
ptr(0,0,0,dim-ndeltav), *ptrs =
ptr(0,0,0,dim-1);
17398 const int ndeltav = (deltav>=
dimv())?dim-1:deltav;
17399 if (!ndeltav)
return *
this;
17401 T *ptrd =
ptr(0,0,0,1);
17407 if (!ndeltav)
return *
this;
17425 const int border_condition=0)
const {
17426 return (+*
this).
translate(deltax,deltay,deltaz,deltav,border_condition);
17430 template<
typename t>
17434 const T* ptrs =
data;
17472 t *ptrR = res.ptr(0,0,0,0);
17473 for (
unsigned int siz =
height*
depth*dim; siz; --siz) {
17474 *(ptrR++) = (t)*(ptrs++);
17478 t *ptrR = res.ptr(0,0,0,0), *ptrG = res.ptr(0,0,0,1);
17479 for (
unsigned int siz =
height*
depth*dim; siz; --siz) {
17480 *(ptrR++) = (t)*(ptrs++); *(ptrG++) = (t)*(ptrs++);
17484 t *ptrR = res.ptr(0,0,0,0), *ptrG = res.ptr(0,0,0,1), *ptrB = res.ptr(0,0,0,2);
17485 for (
unsigned int siz =
height*
depth*dim; siz; --siz) {
17486 *(ptrR++) = (t)*(ptrs++); *(ptrG++) = (t)*(ptrs++); *(ptrB++) = (t)*(ptrs++);
17490 t *ptrR = res.ptr(0,0,0,0), *ptrG = res.ptr(0,0,0,1), *ptrB = res.ptr(0,0,0,2), *ptrA = res.ptr(0,0,0,3);
17491 for (
unsigned int siz =
height*
depth*dim; siz; --siz) {
17492 *(ptrR++) = (t)*(ptrs++); *(ptrG++) = (t)*(ptrs++); *(ptrB++) = (t)*(ptrs++); *(ptrA++) = (t)*(ptrs++);
17537 const T *ptrR =
ptr(0,0,0,0);
17538 t *ptrd = res.ptr();
17540 *(ptrd++) = (t)*(ptrR++);
17544 const T *ptrR =
ptr(0,0,0,0), *ptrG =
ptr(0,0,0,1);
17545 t *ptrd = res.ptr();
17547 *(ptrd++) = (t)*(ptrR++); *(ptrd++) = (t)*(ptrG++);
17551 const T *ptrR =
ptr(0,0,0,0), *ptrG =
ptr(0,0,0,1), *ptrB =
ptr(0,0,0,2);
17552 t *ptrd = res.ptr();
17554 *(ptrd++) = (t)*(ptrR++); *(ptrd++) = (t)*(ptrG++); *(ptrd++) = (t)*(ptrB++);
17558 const T *ptrR =
ptr(0,0,0,0), *ptrG =
ptr(0,0,0,1), *ptrB =
ptr(0,0,0,2), *ptrA =
ptr(0,0,0,3);
17559 t *ptrd = res.ptr();
17561 *(ptrd++) = (t)*(ptrR++); *(ptrd++) = (t)*(ptrG++); *(ptrd++) = (t)*(ptrB++); *(ptrd++) = (t)*(ptrA++);
17605 const T foo = (T)0;
17611 const unsigned int siz =
size();
17612 if (siz)
switch (axis) {
17618 throw CImgArgumentException(
"CImg<%s>::unroll() : Given axis is '%c' which is not 'x','y','z' or 'v'",
17625 return (+*
this).
unroll(axis);
17637 CImg<T>&
rotate(
const float angle,
const unsigned int border_conditions=3,
const unsigned int interpolation=1) {
17638 return get_rotate(angle,border_conditions,interpolation).transfer_to(*
this);
17644 const float nangle =
cimg::mod(angle,360.0f);
17645 if (border_conditions!=1 &&
cimg::mod(nangle,90.0f)==0) {
17646 const int wm1 =
dimx()-1, hm1 =
dimy()-1;
17647 const int iangle = (int)nangle/90;
17651 cimg_forXYZV(dest,x,
y,
z,
v) dest(x,
y,
z,
v) = (*this)(
y,hm1-
x,
z,
v);
17655 cimg_forXYZV(dest,x,
y,
z,
v) dest(x,
y,
z,
v) = (*this)(wm1-
x,hm1-
y,
z,
v);
17659 cimg_forXYZV(dest,x,
y,
z,
v) dest(x,
y,
z,
v) = (*this)(wm1-
y,
x,
z,
v);
17672 dw2 = 0.5f*(ux+vx), dh2 = 0.5f*(uy+vy);
17673 dest.assign((
int)(ux+vx), (
int)(uy+vy),
depth,dim);
17674 switch (border_conditions) {
17676 switch (interpolation) {
17679 dest(x,
y,
z,
v) = (T)
cubic_atXY(w2 + (x-dw2)*ca + (
y-dh2)*sa,h2 - (x-dw2)*sa + (
y-dh2)*ca,
z,
v,0);
17683 dest(x,
y,
z,
v) = (T)
linear_atXY(w2 + (x-dw2)*ca + (
y-dh2)*sa,h2 - (x-dw2)*sa + (
y-dh2)*ca,
z,
v,0);
17687 dest(x,
y,
z,
v) =
atXY((
int)(w2 + (x-dw2)*ca + (
y-dh2)*sa),(
int)(h2 - (x-dw2)*sa + (
y-dh2)*ca),
z,
v,0);
17692 switch (interpolation) {
17695 dest(x,
y,
z,
v) = (T)
cubic_atXY(w2 + (x-dw2)*ca + (
y-dh2)*sa,h2 - (x-dw2)*sa + (
y-dh2)*ca,
z,
v);
17699 dest(x,
y,
z,
v) = (T)
linear_atXY(w2 + (x-dw2)*ca + (
y-dh2)*sa,h2 - (x-dw2)*sa + (
y-dh2)*ca,
z,
v);
17703 dest(x,
y,
z,
v) =
atXY((
int)(w2 + (x-dw2)*ca + (
y-dh2)*sa),(
int)(h2 - (x-dw2)*sa + (
y-dh2)*ca),
z,
v);
17708 switch (interpolation) {
17727 throw CImgArgumentException(
"CImg<%s>::rotate() : Invalid border conditions %d (should be 0,1 or 2).",
17746 const unsigned int border_conditions=3,
const unsigned int interpolation=1) {
17747 return get_rotate(angle,cx,cy,zoom,border_conditions,interpolation).transfer_to(*
this);
17751 const unsigned int border_conditions=3,
const unsigned int interpolation=1)
const {
17752 if (interpolation>2)
17753 throw CImgArgumentException(
"CImg<%s>::rotate() : Invalid interpolation parameter %d (should be {0=none, 1=linear or 2=cubic}).",
17757 const float nangle =
cimg::mod(angle,360.0f);
17758 if (border_conditions!=1 && zoom==1 &&
cimg::mod(nangle,90.0f)==0) {
17759 const int iangle = (int)nangle/90;
17768 cimg_forZV(dest,
z,
v)
for (
unsigned int y = ymin;
y<ymax; ++
y)
for (
unsigned int x = xmin; x<xmax; ++
x)
17772 cimg_forXYZV(dest,x,
y,
z,
v) dest(x,
y,
z,
v) = (*this)(
width-1-
x,
height-1-
y,
z,
v);
17781 cimg_forZV(dest,
z,
v)
for (
unsigned int y = ymin;
y<ymax; ++
y)
for (
unsigned int x = xmin; x<xmax; ++
x)
17782 dest(x,
y,
z,
v) = (*this)(
width-1-
y+yoff,x-xoff,
z,
v);
17792 switch (border_conditions) {
17794 switch (interpolation) {
17798 dest(x,
y,
z,
v) = (T)
cubic_atXY(cx + (x-cx)*ca + (
y-cy)*sa,cy - (x-cx)*sa + (
y-cy)*ca,
z,
v,0);
17803 dest(x,
y,
z,
v) = (T)
linear_atXY(cx + (x-cx)*ca + (
y-cy)*sa,cy - (x-cx)*sa + (
y-cy)*ca,
z,
v,0);
17808 dest(x,
y,
z,
v) =
atXY((
int)(cx + (x-cx)*ca + (
y-cy)*sa),(
int)(cy - (x-cx)*sa + (
y-cy)*ca),
z,
v,0);
17813 switch (interpolation) {
17817 dest(x,
y,
z,
v) = (T)
cubic_atXY(cx + (x-cx)*ca + (
y-cy)*sa,cy - (x-cx)*sa + (
y-cy)*ca,
z,
v);
17822 dest(x,
y,
z,
v) = (T)
linear_atXY(cx + (x-cx)*ca + (
y-cy)*sa,cy - (x-cx)*sa + (
y-cy)*ca,
z,
v);
17827 dest(x,
y,
z,
v) =
atXY((
int)(cx + (x-cx)*ca + (
y-cy)*sa),(
int)(cy - (x-cx)*sa + (
y-cy)*ca),
z,
v);
17832 switch (interpolation) {
17854 throw CImgArgumentException(
"CImg<%s>::rotate() : Incorrect border conditions %d (should be 0,1 or 2).",
17862 template<
typename t>
17864 const bool interpolation=
true,
const unsigned int border_conditions=0) {
17865 return get_warp(warp,relative,interpolation,border_conditions).transfer_to(*
this);
17868 template<
typename t>
17870 const bool interpolation=
true,
const unsigned int border_conditions=0)
const {
17871 if (
is_empty() || !warp)
return *
this;
17873 throw CImgArgumentException(
"CImg<%s>::warp() : Instance image (%u,%u,%u,%u,%p) and relative warping field (%u,%u,%u,%u,%p) "
17874 "have different XYZ dimensions.",
17876 warp.width,warp.height,warp.depth,warp.dim,warp.data);
17877 CImg<T> res(warp.width,warp.height,warp.depth,dim);
17878 switch (warp.dim) {
17881 if (interpolation)
switch (border_conditions) {
17884 res(x,
y,
z,
v) = (T)
_linear_atX(
cimg::mod(x-(
float)
warp(x,
y,
z,0),(
float)
width),
y,
z,
v);
17892 res(x,
y,
z,
v) = (T)
linear_atX(x-(
float)
warp(x,
y,
z,0),
y,
z,
v,0);
17894 }
else switch (border_conditions) {
17897 res(x,
y,
z,
v) = (*this)(
cimg::mod(x-(
int)
warp(x,
y,
z,0),(
int)
width),
y,
z,
v);
17905 res(x,
y,
z,
v) =
atX(x-(
int)
warp(x,
y,
z,0),
y,
z,
v,0);
17909 if (interpolation)
switch (border_conditions) {
17912 res(x,
y,
z,
v) = (T)
_linear_atX(
cimg::mod((
float)
warp(x,
y,
z,0),(
float)
width),
y,
z,
v);
17920 res(x,
y,
z,
v) = (T)
linear_atX((
float)
warp(x,
y,
z,0),
y,
z,
v,0);
17922 }
else switch (border_conditions) {
17925 res(x,
y,
z,
v) = (*this)(
cimg::mod((
int)
warp(x,
y,
z,0),(
int)
width),
y,
z,
v);
17933 res(x,
y,
z,
v) =
atX((
int)
warp(x,
y,
z,0),
y,
z,
v,0);
17941 if (interpolation)
switch (border_conditions) {
17949 res(x,
y,
z,
v) = (T)
_linear_atXY(x-(
float)
warp(x,
y,
z,0),
y-(float)
warp(x,
y,
z,1),
z,
v);
17953 res(x,
y,
z,
v) = (T)
linear_atXY(x-(
float)
warp(x,
y,
z,0),
y-(float)
warp(x,
y,
z,1),
z,
v,0);
17955 }
else switch (border_conditions) {
17963 res(x,
y,
z,
v) =
_atXY(x-(
int)
warp(x,
y,
z,0),
y-(
int)
warp(x,
y,
z,1),
z,
v);
17967 res(x,
y,
z,
v) =
atXY(x-(
int)
warp(x,
y,
z,0),
y-(
int)
warp(x,
y,
z,1),
z,
v,0);
17971 if (interpolation)
switch (border_conditions) {
17979 res(x,
y,
z,
v) = (T)
_linear_atXY((
float)
warp(x,
y,
z,0),(float)
warp(x,
y,
z,1),
z,
v);
17983 res(x,
y,
z,
v) = (T)
linear_atXY((
float)
warp(x,
y,
z,0),(float)
warp(x,
y,
z,1),
z,
v,0);
17985 }
else switch (border_conditions) {
17993 res(x,
y,
z,
v) =
_atXY((
int)
warp(x,
y,
z,0),(
int)
warp(x,
y,
z,1),
z,
v);
17997 res(x,
y,
z,
v) =
atXY((
int)
warp(x,
y,
z,0),(
int)
warp(x,
y,
z,1),
z,
v,0);
18005 if (interpolation)
switch (border_conditions) {
18014 res(x,
y,
z,
v) = (T)
_linear_atXYZ(x-(
float)
warp(x,
y,
z,0),
y-(float)
warp(x,
y,
z,1),
z-(float)
warp(x,
y,
z,2),
v);
18018 res(x,
y,
z,
v) = (T)
linear_atXYZ(x-(
float)
warp(x,
y,
z,0),
y-(float)
warp(x,
y,
z,1),
z-(float)
warp(x,
y,
z,2),
v,0);
18020 }
else switch (border_conditions) {
18029 res(x,
y,
z,
v) =
_atXYZ(x-(
int)
warp(x,
y,
z,0),
y-(
int)
warp(x,
y,
z,1),
z-(
int)
warp(x,
y,
z,2),
v);
18033 res(x,
y,
z,
v) =
atXYZ(x-(
int)
warp(x,
y,
z,0),
y-(
int)
warp(x,
y,
z,1),
z-(
int)
warp(x,
y,
z,2),
v,0);
18037 if (interpolation)
switch (border_conditions) {
18046 res(x,
y,
z,
v) = (T)
_linear_atXYZ((
float)
warp(x,
y,
z,0),(float)
warp(x,
y,
z,1),(float)
warp(x,
y,
z,2),
v);
18050 res(x,
y,
z,
v) = (T)
linear_atXYZ((
float)
warp(x,
y,
z,0),(float)
warp(x,
y,
z,1),(float)
warp(x,
y,
z,2),
v,0);
18052 }
else switch (border_conditions) {
18061 res(x,
y,
z,
v) =
_atXYZ((
int)
warp(x,
y,
z,0),(
int)
warp(x,
y,
z,1),(
int)
warp(x,
y,
z,2),
v);
18065 res(x,
y,
z,
v) =
atXYZ((
int)
warp(x,
y,
z,0),(
int)
warp(x,
y,
z,1),(
int)
warp(x,
y,
z,2),
v,0);
18073 if (interpolation)
switch (border_conditions) {
18083 res(x,
y,
z,
v) = (T)
_linear_atXYZV(x-(
float)
warp(x,
y,
z,0),
y-(float)
warp(x,
y,
z,1),
z-(float)
warp(x,
y,
z,2),
v-(float)
warp(x,
y,
z,3));
18087 res(x,
y,
z,
v) = (T)
linear_atXYZV(x-(
float)
warp(x,
y,
z,0),
y-(float)
warp(x,
y,
z,1),
z-(float)
warp(x,
y,
z,2),
v-(float)
warp(x,
y,
z,3),0);
18089 }
else switch (border_conditions) {
18099 res(x,
y,
z,
v) =
_atXYZV(x-(
int)
warp(x,
y,
z,0),
y-(
int)
warp(x,
y,
z,1),
z-(
int)
warp(x,
y,
z,2),
v-(
int)
warp(x,
y,
z,3));
18103 res(x,
y,
z,
v) =
atXYZ(x-(
int)
warp(x,
y,
z,0),
y-(
int)
warp(x,
y,
z,1),
z-(
int)
warp(x,
y,
z,2),
v-(
int)
warp(x,
y,
z,3),0);
18107 if (interpolation)
switch (border_conditions) {
18117 res(x,
y,
z,
v) = (T)
_linear_atXYZV((
float)
warp(x,
y,
z,0),(float)
warp(x,
y,
z,1),(float)
warp(x,
y,
z,2),(float)
warp(x,
y,
z,3));
18121 res(x,
y,
z,
v) = (T)
linear_atXYZV((
float)
warp(x,
y,
z,0),(float)
warp(x,
y,
z,1),(float)
warp(x,
y,
z,2),(float)
warp(x,
y,
z,3),0);
18123 }
else switch (border_conditions) {
18133 res(x,
y,
z,
v) =
_atXYZV((
int)
warp(x,
y,
z,0),(
int)
warp(x,
y,
z,1),(
int)
warp(x,
y,
z,2),(
int)
warp(x,
y,
z,3));
18137 res(x,
y,
z,
v) =
atXYZV((
int)
warp(x,
y,
z,0),(
int)
warp(x,
y,
z,1),(
int)
warp(x,
y,
z,2),(
int)
warp(x,
y,
z,3),0);
18147 const int dx=-100,
const int dy=-100,
const int dz=-100) {
18152 const int dx=-100,
const int dy=-100,
const int dz=-100)
const {
18165 imgxy.resize(
dx,
dy,1,dim,1);
18166 imgzy.resize(dz,
dy,1,dim,1);
18167 imgxz.resize(
dx,dz,1,dim,1);
18168 return CImg<T>(imgxy.width + imgzy.width,imgxy.height + imgxz.height,1,
dim,0).
18169 draw_image(imgxy).draw_image(imgxy.width,imgzy).draw_image(0,imgxy.height,imgxz);
18185 const int x1,
const int y1,
const int z1,
const int v1,
18186 const bool border_condition=
false) {
18187 return get_crop(x0,y0,z0,v0,x1,y1,z1,v1,border_condition).transfer_to(*
this);
18191 const int x1,
const int y1,
const int z1,
const int v1,
18192 const bool border_condition=
false)
const {
18195 nx0 = x0<x1?x0:x1, nx1 = x0^x1^nx0,
18196 ny0 = y0<y1?y0:y1, ny1 = y0^y1^ny0,
18197 nz0 = z0<z1?z0:z1, nz1 = z0^z1^nz0,
18198 nv0 = v0<v1?v0:v1, nv1 = v0^v1^nv0;
18199 CImg<T> dest(1U+nx1-nx0,1U+ny1-ny0,1U+nz1-nz0,1U+nv1-nv0);
18200 if (nx0<0 || nx1>=
dimx() || ny0<0 || ny1>=
dimy() || nz0<0 || nz1>=
dimz() || nv0<0 || nv1>=
dimv()) {
18201 if (border_condition)
cimg_forXYZV(dest,x,
y,
z,
v) dest(x,
y,
z,
v) =
_atXYZV(nx0+x,ny0+
y,nz0+
z,nv0+
v);
18202 else dest.fill(0).draw_image(-nx0,-ny0,-nz0,-nv0,*
this);
18203 }
else dest.draw_image(-nx0,-ny0,-nz0,-nv0,*
this);
18219 const int x1,
const int y1,
const int z1,
18220 const bool border_condition=
false) {
18221 return crop(x0,y0,z0,0,x1,y1,z1,dim-1,border_condition);
18225 const int x1,
const int y1,
const int z1,
18226 const bool border_condition=
false)
const {
18227 return get_crop(x0,y0,z0,0,x1,y1,z1,dim-1,border_condition);
18240 const int x1,
const int y1,
18241 const bool border_condition=
false) {
18242 return crop(x0,y0,0,0,x1,y1,
depth-1,dim-1,border_condition);
18246 const int x1,
const int y1,
18247 const bool border_condition=
false)
const {
18248 return get_crop(x0,y0,0,0,x1,y1,
depth-1,dim-1,border_condition);
18258 CImg<T>&
crop(
const int x0,
const int x1,
const bool border_condition=
false) {
18269 for (
const char *s = axes; *
s; ++
s) {
18274 const int x0 = coords[0], x1 = coords[1];
18275 if (x0>=0 && x1>=0)
crop(x0,x1);
18278 const int y0 = coords[0], y1 = coords[1];
18279 if (y0>=0 && y1>=0)
crop(0,y0,
width-1,y1);
18282 const int z0 = coords[0], z1 = coords[1];
18286 const int v0 = coords[0], v1 = coords[1];
18290 throw CImgArgumentException(
"CImg<%s>::autocrop() : Invalid axis '%c' (should be 'x','y','z' or 'v').",
18298 return (+*
this).
autocrop(value,axes);
18304 for (
const char *s = axes; *
s; ++
s) {
18308 int x0 =
width, x1 = -1;
18311 const int nx0 = coords[0], nx1 = coords[1];
18314 if (x0<=x1)
crop(x0,x1);
18317 int y0 =
height, y1 = -1;
18320 const int ny0 = coords[0], ny1 = coords[1];
18326 int z0 =
depth, z1 = -1;
18329 const int nz0 = coords[0], nz1 = coords[1];
18335 throw CImgArgumentException(
"CImg<%s>::autocrop() : Invalid axis '%c' (should be 'x','y' or 'z').",
18343 return (+*
this).
autocrop(color,axes);
18357 int x0 = -1, y0 = -1, z0 = -1, v0 = -1, x1 = -1, y1 = -1, z1 = -1, v1 = -1;
18422 return lines(y0,y0);
18431 return get_lines(y0,y1).transfer_to(*
this);
18449 return get_slices(z0,z1).transfer_to(*
this);
18476 const unsigned int y0=0,
const unsigned int z0=0,
const unsigned int v0=0) {
18477 const unsigned int beg = (
unsigned int)
offset(x0,y0,z0,v0),
end =
offset(x1,y0,z0,v0);
18479 throw CImgArgumentException(
"CImg<%s>::get_shared_points() : Cannot return a shared-memory subset (%u->%u,%u,%u,%u) from "
18480 "a (%u,%u,%u,%u) image.",
18486 const unsigned int y0=0,
const unsigned int z0=0,
const unsigned int v0=0)
const {
18487 const unsigned int beg = (
unsigned int)
offset(x0,y0,z0,v0),
end =
offset(x1,y0,z0,v0);
18489 throw CImgArgumentException(
"CImg<%s>::get_shared_points() : Cannot return a shared-memory subset (%u->%u,%u,%u,%u) from "
18490 "a (%u,%u,%u,%u) image.",
18497 const unsigned int z0=0,
const unsigned int v0=0) {
18498 const unsigned int beg =
offset(0,y0,z0,v0),
end =
offset(0,y1,z0,v0);
18500 throw CImgArgumentException(
"CImg<%s>::get_shared_lines() : Cannot return a shared-memory subset (0->%u,%u->%u,%u,%u) from "
18501 "a (%u,%u,%u,%u) image.",
18507 const unsigned int z0=0,
const unsigned int v0=0)
const {
18508 const unsigned int beg =
offset(0,y0,z0,v0),
end =
offset(0,y1,z0,v0);
18510 throw CImgArgumentException(
"CImg<%s>::get_shared_lines() : Cannot return a shared-memory subset (0->%u,%u->%u,%u,%u) from "
18511 "a (%u,%u,%u,%u) image.",
18529 throw CImgArgumentException(
"CImg<%s>::get_shared_planes() : Cannot return a shared-memory subset (0->%u,0->%u,%u->%u,%u) from "
18530 "a (%u,%u,%u,%u) image.",
18538 throw CImgArgumentException(
"CImg<%s>::get_shared_planes() : Cannot return a shared-memory subset (0->%u,0->%u,%u->%u,%u) from "
18539 "a (%u,%u,%u,%u) image.",
18557 throw CImgArgumentException(
"CImg<%s>::get_shared_channels() : Cannot return a shared-memory subset (0->%u,0->%u,0->%u,%u->%u) from "
18558 "a (%u,%u,%u,%u) image.",
18566 throw CImgArgumentException(
"CImg<%s>::get_shared_channels() : Cannot return a shared-memory subset (0->%u,0->%u,0->%u,%u->%u) from "
18567 "a (%u,%u,%u,%u) image.",
18585 const unsigned int nnb = (
unsigned int)(nb==0?1:(nb>0?nb:-nb));
18586 if (nb<=0)
switch (naxis) {
18599 const unsigned int siz = naxis==
'x'?
width:naxis==
'y'?
height:naxis==
'z'?
depth:naxis==
'v'?dim:0;
18600 if (nnb>siz)
throw CImgArgumentException(
"CImg<%s>::get_split() : Cannot split instance image (%u,%u,%u,%u,%p) along axis '%c' into %u blocs.",
18625 while (ptr0<ptr_end) {
18626 const T *ptr1 = ptr0;
18627 while (ptr1<ptr_end && *ptr1==value) ++ptr1;
18628 const unsigned int siz0 = ptr1 - ptr0;
18629 if (siz0 && keep_values) res.
insert(
CImg<T>(ptr0,1,siz0,1,1,shared));
18631 while (ptr1<ptr_end && *ptr1!=value) ++ptr1;
18632 const unsigned int siz1 = ptr1 - ptr0;
18633 if (siz1) res.
insert(
CImg<T>(ptr0,1,siz1,1,1,shared),~0U,shared);
18641 template<
typename t>
18644 if (!img)
return *
this;
18650 if (!img)
return *
this;
18654 template<
typename t>
18657 if (!img)
return +*
this;
18663 if (!img)
return +*
this;
18684 template<
typename t>
18686 return get_correlate(mask,cond,weighted_correl).transfer_to(*
this);
18689 template<
typename t>
18691 const bool weighted_correl=
false)
const {
18693 if (!mask || mask.dim!=1)
18694 throw CImgArgumentException(
"CImg<%s>::correlate() : Specified mask (%u,%u,%u,%u,%p) is not scalar.",
18695 pixel_type(),mask.width,mask.height,mask.depth,mask.dim,mask.data);
18698 if (cond && mask.width==mask.height && ((mask.depth==1 && mask.width<=5) || (mask.depth==mask.width && mask.width<=3))) {
18700 switch (mask.depth) {
18703 cimg_forZV(*
this,
z,
v)
cimg_for3x3x3(*
this,x,
y,
z,
v,I) dest(x,
y,
z,
v) = (Ttfloat)
18704 (I[ 0]*mask[ 0] + I[ 1]*mask[ 1] + I[ 2]*mask[ 2] +
18705 I[ 3]*mask[ 3] + I[ 4]*mask[ 4] + I[ 5]*mask[ 5] +
18706 I[ 6]*mask[ 6] + I[ 7]*mask[ 7] + I[ 8]*mask[ 8] +
18707 I[ 9]*mask[ 9] + I[10]*mask[10] + I[11]*mask[11] +
18708 I[12]*mask[12] + I[13]*mask[13] + I[14]*mask[14] +
18709 I[15]*mask[15] + I[16]*mask[16] + I[17]*mask[17] +
18710 I[18]*mask[18] + I[19]*mask[19] + I[20]*mask[20] +
18711 I[21]*mask[21] + I[22]*mask[22] + I[23]*mask[23] +
18712 I[24]*mask[24] + I[25]*mask[25] + I[26]*mask[26]);
18714 const double weight = (double)(I[ 0]*I[ 0] + I[ 1]*I[ 1] + I[ 2]*I[ 2] +
18715 I[ 3]*I[ 3] + I[ 4]*I[ 4] + I[ 5]*I[ 5] +
18716 I[ 6]*I[ 6] + I[ 7]*I[ 7] + I[ 8]*I[ 8] +
18717 I[ 9]*I[ 9] + I[10]*I[10] + I[11]*I[11] +
18718 I[12]*I[12] + I[13]*I[13] + I[14]*I[14] +
18719 I[15]*I[15] + I[16]*I[16] + I[17]*I[17] +
18720 I[18]*I[18] + I[19]*I[19] + I[20]*I[20] +
18721 I[21]*I[21] + I[22]*I[22] + I[23]*I[23] +
18722 I[24]*I[24] + I[25]*I[25] + I[26]*I[26]);
18723 if (weight>0) dest(x,
y,
z,
v)/=(Ttfloat)
std::sqrt(weight);
18728 cimg_forZV(*
this,
z,
v)
cimg_for2x2x2(*
this,x,
y,
z,
v,I) dest(x,
y,
z,
v) = (Ttfloat)
18729 (I[0]*mask[0] + I[1]*mask[1] +
18730 I[2]*mask[2] + I[3]*mask[3] +
18731 I[4]*mask[4] + I[5]*mask[5] +
18732 I[6]*mask[6] + I[7]*mask[7]);
18734 const double weight = (double)(I[0]*I[0] + I[1]*I[1] +
18735 I[2]*I[2] + I[3]*I[3] +
18736 I[4]*I[4] + I[5]*I[5] +
18737 I[6]*I[6] + I[7]*I[7]);
18738 if (weight>0) dest(x,
y,
z,
v)/=(Ttfloat)
std::sqrt(weight);
18743 switch (mask.width) {
18746 cimg_forZV(*
this,
z,
v)
cimg_for6x6(*
this,x,
y,
z,
v,I) dest(x,
y,
z,
v) = (Ttfloat)
18747 (I[ 0]*mask[ 0] + I[ 1]*mask[ 1] + I[ 2]*mask[ 2] + I[ 3]*mask[ 3] + I[ 4]*mask[ 4] + I[ 5]*mask[ 5] +
18748 I[ 6]*mask[ 6] + I[ 7]*mask[ 7] + I[ 8]*mask[ 8] + I[ 9]*mask[ 9] + I[10]*mask[10] + I[11]*mask[11] +
18749 I[12]*mask[12] + I[13]*mask[13] + I[14]*mask[14] + I[15]*mask[15] + I[16]*mask[16] + I[17]*mask[17] +
18750 I[18]*mask[18] + I[19]*mask[19] + I[20]*mask[20] + I[21]*mask[21] + I[22]*mask[22] + I[23]*mask[23] +
18751 I[24]*mask[24] + I[25]*mask[25] + I[26]*mask[26] + I[27]*mask[27] + I[28]*mask[28] + I[29]*mask[29] +
18752 I[30]*mask[30] + I[31]*mask[31] + I[32]*mask[32] + I[33]*mask[33] + I[34]*mask[34] + I[35]*mask[35]);
18754 const double weight = (double)(I[ 0]*I[ 0] + I[ 1]*I[ 1] + I[ 2]*I[ 2] + I[ 3]*I[ 3] + I[ 4]*I[ 4] + I[ 5]*I[ 5] +
18755 I[ 6]*I[ 6] + I[ 7]*I[ 7] + I[ 8]*I[ 8] + I[ 9]*I[ 9] + I[10]*I[10] + I[11]*I[11] +
18756 I[12]*I[12] + I[13]*I[13] + I[14]*I[14] + I[15]*I[15] + I[16]*I[16] + I[17]*I[17] +
18757 I[18]*I[18] + I[19]*I[19] + I[20]*I[20] + I[21]*I[21] + I[22]*I[22] + I[23]*I[23] +
18758 I[24]*I[24] + I[25]*I[25] + I[26]*I[26] + I[27]*I[27] + I[28]*I[28] + I[29]*I[29] +
18759 I[30]*I[30] + I[31]*I[31] + I[32]*I[32] + I[33]*I[33] + I[34]*I[34] + I[35]*I[35]);
18760 if (weight>0) dest(x,
y,
z,
v)/=(Ttfloat)
std::sqrt(weight);
18765 cimg_forZV(*
this,
z,
v)
cimg_for5x5(*
this,x,
y,
z,
v,I) dest(x,
y,
z,
v) = (Ttfloat)
18766 (I[ 0]*mask[ 0] + I[ 1]*mask[ 1] + I[ 2]*mask[ 2] + I[ 3]*mask[ 3] + I[ 4]*mask[ 4] +
18767 I[ 5]*mask[ 5] + I[ 6]*mask[ 6] + I[ 7]*mask[ 7] + I[ 8]*mask[ 8] + I[ 9]*mask[ 9] +
18768 I[10]*mask[10] + I[11]*mask[11] + I[12]*mask[12] + I[13]*mask[13] + I[14]*mask[14] +
18769 I[15]*mask[15] + I[16]*mask[16] + I[17]*mask[17] + I[18]*mask[18] + I[19]*mask[19] +
18770 I[20]*mask[20] + I[21]*mask[21] + I[22]*mask[22] + I[23]*mask[23] + I[24]*mask[24]);
18772 const double weight = (double)(I[ 0]*I[ 0] + I[ 1]*I[ 1] + I[ 2]*I[ 2] + I[ 3]*I[ 3] + I[ 4]*I[ 4] +
18773 I[ 5]*I[ 5] + I[ 6]*I[ 6] + I[ 7]*I[ 7] + I[ 8]*I[ 8] + I[ 9]*I[ 9] +
18774 I[10]*I[10] + I[11]*I[11] + I[12]*I[12] + I[13]*I[13] + I[14]*I[14] +
18775 I[15]*I[15] + I[16]*I[16] + I[17]*I[17] + I[18]*I[18] + I[19]*I[19] +
18776 I[20]*I[20] + I[21]*I[21] + I[22]*I[22] + I[23]*I[23] + I[24]*I[24]);
18777 if (weight>0) dest(x,
y,
z,
v)/=(Ttfloat)
std::sqrt(weight);
18782 cimg_forZV(*
this,
z,
v)
cimg_for4x4(*
this,x,
y,
z,
v,I) dest(x,
y,
z,
v) = (Ttfloat)
18783 (I[ 0]*mask[ 0] + I[ 1]*mask[ 1] + I[ 2]*mask[ 2] + I[ 3]*mask[ 3] +
18784 I[ 4]*mask[ 4] + I[ 5]*mask[ 5] + I[ 6]*mask[ 6] + I[ 7]*mask[ 7] +
18785 I[ 8]*mask[ 8] + I[ 9]*mask[ 9] + I[10]*mask[10] + I[11]*mask[11] +
18786 I[12]*mask[12] + I[13]*mask[13] + I[14]*mask[14] + I[15]*mask[15]);
18788 const double weight = (double)(I[ 0]*I[ 0] + I[ 1]*I[ 1] + I[ 2]*I[ 2] + I[ 3]*I[ 3] +
18789 I[ 4]*I[ 4] + I[ 5]*I[ 5] + I[ 6]*I[ 6] + I[ 7]*I[ 7] +
18790 I[ 8]*I[ 8] + I[ 9]*I[ 9] + I[10]*I[10] + I[11]*I[11] +
18791 I[12]*I[12] + I[13]*I[13] + I[14]*I[14] + I[15]*I[15]);
18792 if (weight>0) dest(x,
y,
z,
v)/=(Ttfloat)
std::sqrt(weight);
18797 cimg_forZV(*
this,
z,
v)
cimg_for3x3(*
this,x,
y,
z,
v,I) dest(x,
y,
z,
v) = (Ttfloat)
18798 (I[0]*mask[0] + I[1]*mask[1] + I[2]*mask[2] +
18799 I[3]*mask[3] + I[4]*mask[4] + I[5]*mask[5] +
18800 I[6]*mask[6] + I[7]*mask[7] + I[8]*mask[8]);
18802 const double weight = (double)(I[0]*I[0] + I[1]*I[1] + I[2]*I[2] +
18803 I[3]*I[3] + I[4]*I[4] + I[5]*I[5] +
18804 I[6]*I[6] + I[7]*I[7] + I[8]*I[8]);
18805 if (weight>0) dest(x,
y,
z,
v)/=(Ttfloat)
std::sqrt(weight);
18810 cimg_forZV(*
this,
z,
v)
cimg_for2x2(*
this,x,
y,
z,
v,I) dest(x,
y,
z,
v) = (Ttfloat)
18811 (I[0]*mask[0] + I[1]*mask[1] +
18812 I[2]*mask[2] + I[3]*mask[3]);
18814 const double weight = (double)(I[0]*I[0] + I[1]*I[1] +
18815 I[2]*I[2] + I[3]*I[3]);
18816 if (weight>0) dest(x,
y,
z,
v)/=(Ttfloat)
std::sqrt(weight);
18819 case 1 : (dest.assign(*
this))*=
mask(0);
break;
18824 mx2 = mask.dimx()/2, my2 = mask.dimy()/2, mz2 = mask.dimz()/2,
18825 mx1 = mx2 - 1 + (mask.dimx()%2), my1 = my2 - 1 + (mask.dimy()%2), mz1 = mz2 - 1 + (mask.dimz()%2),
18826 mxe =
dimx() - mx2, mye =
dimy() - my2, mze =
dimz() - mz2;
18828 if (!weighted_correl) {
18829 for (
int z = mz1;
z<mze; ++
z)
for (
int y = my1;
y<mye; ++
y)
for (
int x = mx1; x<mxe; ++
x) {
18831 for (
int zm = -mz1; zm<=mz2; ++zm)
for (
int ym = -my1; ym<=my2; ++ym)
for (
int xm = -mx1; xm<=mx2; ++xm)
18832 val+=(*
this)(x+xm,
y+ym,
z+zm,
v)*
mask(mx1+xm,my1+ym,mz1+zm);
18833 dest(x,
y,
z,
v) = (Ttfloat)val;
18837 for (
int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
18839 for (
int zm = -mz1; zm<=mz2; ++zm)
for (
int ym = -my1; ym<=my2; ++ym)
for (
int xm = -mx1; xm<=mx2; ++xm)
18841 dest(x,
y,
z,
v) = (Ttfloat)val;
18845 for (
int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
18847 for (
int zm = -mz1; zm<=mz2; ++zm)
for (
int ym = -my1; ym<=my2; ++ym)
for (
int xm = -mx1; xm<=mx2; ++xm)
18848 val+=
atXYZ(x+xm,
y+ym,
z+zm,
v,0)*
mask(mx1+xm,my1+ym,mz1+zm);
18849 dest(x,
y,
z,
v) = (Ttfloat)val;
18852 for (
int z = mz1;
z<mze; ++
z)
for (
int y = my1;
y<mye; ++
y)
for (
int x = mx1; x<mxe; ++
x) {
18853 Ttfloat val = 0, weight = 0;
18854 for (
int zm = -mz1; zm<=mz2; ++zm)
for (
int ym = -my1; ym<=my2; ++ym)
for (
int xm = -mx1; xm<=mx2; ++xm) {
18855 const Ttfloat cval = (Ttfloat)(*
this)(x+xm,
y+ym,
z+zm,
v);
18856 val+=cval*
mask(mx1+xm,my1+ym,mz1+zm);
18859 dest(x,
y,
z,
v) = (weight>(Ttfloat)0)?(Ttfloat)(val/
std::sqrt((
double)weight)):(Ttfloat)0;
18863 for (
int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
18864 Ttfloat val = 0, weight = 0;
18865 for (
int zm = -mz1; zm<=mz2; ++zm)
for (
int ym = -my1; ym<=my2; ++ym)
for (
int xm = -mx1; xm<=mx2; ++xm) {
18866 const Ttfloat cval = (Ttfloat)
_atXYZ(x+xm,
y+ym,
z+zm,
v);
18867 val+=cval*
mask(mx1+xm,my1+ym,mz1+zm);
18870 dest(x,
y,
z,
v) = (weight>(Ttfloat)0)?(Ttfloat)(val/
std::sqrt((
double)weight)):(Ttfloat)0;
18874 for (
int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
18875 Ttfloat val = 0, weight = 0;
18876 for (
int zm = -mz1; zm<=mz2; ++zm)
for (
int ym = -my1; ym<=my2; ++ym)
for (
int xm = -mx1; xm<=mx2; ++xm) {
18877 const Ttfloat cval = (Ttfloat)
atXYZ(x+xm,
y+ym,
z+zm,
v,0);
18878 val+=cval*
mask(mx1+xm,my1+ym,mz1+zm);
18881 dest(x,
y,
z,
v) = (weight>(Ttfloat)0)?(Ttfloat)(val/
std::sqrt((
double)weight)):(Ttfloat)0;
18898 template<
typename t>
18900 return get_convolve(mask,cond,weighted_convol).transfer_to(*
this);
18903 template<
typename t>
18905 const bool weighted_convol=
false)
const {
18907 if (!mask || mask.dim!=1)
18908 throw CImgArgumentException(
"CImg<%s>::convolve() : Specified mask (%u,%u,%u,%u,%p) is not scalar.",
18909 pixel_type(),mask.width,mask.height,mask.depth,mask.dim,mask.data);
18914 template<
typename t>
18916 return get_erode(mask,cond,weighted_erosion).transfer_to(*
this);
18919 template<
typename t>
18921 const bool weighted_erosion=
false)
const {
18923 if (!mask || mask.dim!=1)
18924 throw CImgArgumentException(
"CImg<%s>::erode() : Specified mask (%u,%u,%u,%u,%p) is not a scalar image.",
18925 pixel_type(),mask.width,mask.height,mask.depth,mask.dim,mask.data);
18929 mx2 = mask.dimx()/2, my2 = mask.dimy()/2, mz2 = mask.dimz()/2,
18930 mx1 = mx2 - 1 + (mask.dimx()%2), my1 = my2 - 1 + (mask.dimy()%2), mz1 = mz2 - 1 + (mask.dimz()%2),
18931 mxe =
dimx() - mx2, mye =
dimy() - my2, mze =
dimz() - mz2;
18933 if (!weighted_erosion) {
18934 for (
int z = mz1;
z<mze; ++
z)
for (
int y = my1;
y<mye; ++
y)
for (
int x = mx1; x<mxe; ++
x) {
18936 for (
int zm = -mz1; zm<=mz2; ++zm)
for (
int ym = -my1; ym<=my2; ++ym)
for (
int xm = -mx1; xm<=mx2; ++xm) {
18937 const Tt cval = (Tt)(*
this)(x+xm,
y+ym,
z+zm,
v);
18938 if (
mask(mx1+xm,my1+ym,mz1+zm) && cval<min_val) min_val = cval;
18940 dest(x,
y,
z,
v) = min_val;
18944 for (
int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
18946 for (
int zm = -mz1; zm<=mz2; ++zm)
for (
int ym = -my1; ym<=my2; ++ym)
for (
int xm = -mx1; xm<=mx2; ++xm) {
18947 const T cval = (Tt)
_atXYZ(x+xm,
y+ym,
z+zm,
v);
18948 if (
mask(mx1+xm,my1+ym,mz1+zm) && cval<min_val) min_val = cval;
18950 dest(x,
y,
z,
v) = min_val;
18954 for (
int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
18956 for (
int zm = -mz1; zm<=mz2; ++zm)
for (
int ym = -my1; ym<=my2; ++ym)
for (
int xm = -mx1; xm<=mx2; ++xm) {
18957 const T cval = (Tt)
atXYZ(x+xm,
y+ym,
z+zm,
v,0);
18958 if (
mask(mx1+xm,my1+ym,mz1+zm) && cval<min_val) min_val = cval;
18960 dest(x,
y,
z,
v) = min_val;
18963 for (
int z = mz1;
z<mze; ++
z)
for (
int y = my1;
y<mye; ++
y)
for (
int x = mx1; x<mxe; ++
x) {
18965 for (
int zm = -mz1; zm<=mz2; ++zm)
for (
int ym = -my1; ym<=my2; ++ym)
for (
int xm = -mx1; xm<=mx2; ++xm) {
18966 const t mval =
mask(mx1+xm,my1+ym,mz1+zm);
18967 const Tt cval = (Tt)((*
this)(x+xm,
y+ym,
z+zm,
v) + mval);
18968 if (mval && cval<min_val) min_val = cval;
18970 dest(x,
y,
z,
v) = min_val;
18974 for (
int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
18976 for (
int zm = -mz1; zm<=mz2; ++zm)
for (
int ym = -my1; ym<=my2; ++ym)
for (
int xm = -mx1; xm<=mx2; ++xm) {
18977 const t mval =
mask(mx1+xm,my1+ym,mz1+zm);
18978 const Tt cval = (Tt)(
_atXYZ(x+xm,
y+ym,
z+zm,
v) + mval);
18979 if (mval && cval<min_val) min_val = cval;
18981 dest(x,
y,
z,
v) = min_val;
18985 for (
int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
18987 for (
int zm = -mz1; zm<=mz2; ++zm)
for (
int ym = -my1; ym<=my2; ++ym)
for (
int xm = -mx1; xm<=mx2; ++xm) {
18988 const t mval =
mask(mx1+xm,my1+ym,mz1+zm);
18989 const Tt cval = (Tt)(
atXYZ(x+xm,
y+ym,
z+zm,
v,0) + mval);
18990 if (mval && cval<min_val) min_val = cval;
18992 dest(x,
y,
z,
v) = min_val;
19000 if (n<2)
return *
this;
19001 return get_erode(n,cond).transfer_to(*
this);
19006 if (n<2)
return *
this;
19007 if (mask.width!=n) mask.assign(n,n,1,1,1);
19009 if (n>20) mask.assign();
19014 template<
typename t>
19016 return get_dilate(mask,cond,weighted_dilatation).transfer_to(*
this);
19019 template<
typename t>
19021 const bool weighted_dilatation=
false)
const {
19023 if (!mask || mask.dim!=1)
19024 throw CImgArgumentException(
"CImg<%s>::dilate() : Specified mask (%u,%u,%u,%u,%p) is not a scalar image.",
19025 pixel_type(),mask.width,mask.height,mask.depth,mask.dim,mask.data);
19029 mx2 = mask.dimx()/2, my2 = mask.dimy()/2, mz2 = mask.dimz()/2,
19030 mx1 = mx2 - 1 + (mask.dimx()%2), my1 = my2 - 1 + (mask.dimy()%2), mz1 = mz2 - 1 + (mask.dimz()%2),
19031 mxe =
dimx() - mx2, mye =
dimy() - my2, mze =
dimz() - mz2;
19033 if (!weighted_dilatation) {
19034 for (
int z = mz1;
z<mze; ++
z)
for (
int y = my1;
y<mye; ++
y)
for (
int x = mx1; x<mxe; ++
x) {
19036 for (
int zm = -mz1; zm<=mz2; ++zm)
for (
int ym = -my1; ym<=my2; ++ym)
for (
int xm = -mx1; xm<=mx2; ++xm) {
19037 const Tt cval = (Tt)(*
this)(x+xm,
y+ym,
z+zm,
v);
19038 if (
mask(mx1+xm,my1+ym,mz1+zm) && cval>max_val) max_val = cval;
19040 dest(x,
y,
z,
v) = max_val;
19044 for (
int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
19046 for (
int zm = -mz1; zm<=mz2; ++zm)
for (
int ym = -my1; ym<=my2; ++ym)
for (
int xm = -mx1; xm<=mx2; ++xm) {
19047 const T cval = (Tt)
_atXYZ(x+xm,
y+ym,
z+zm,
v);
19048 if (
mask(mx1+xm,my1+ym,mz1+zm) && cval>max_val) max_val = cval;
19050 dest(x,
y,
z,
v) = max_val;
19054 for (
int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
19056 for (
int zm = -mz1; zm<=mz2; ++zm)
for (
int ym = -my1; ym<=my2; ++ym)
for (
int xm = -mx1; xm<=mx2; ++xm) {
19057 const T cval = (Tt)
atXYZ(x+xm,
y+ym,
z+zm,
v,0);
19058 if (
mask(mx1+xm,my1+ym,mz1+zm) && cval>max_val) max_val = cval;
19060 dest(x,
y,
z,
v) = max_val;
19063 for (
int z = mz1;
z<mze; ++
z)
for (
int y = my1;
y<mye; ++
y)
for (
int x = mx1; x<mxe; ++
x) {
19065 for (
int zm = -mz1; zm<=mz2; ++zm)
for (
int ym = -my1; ym<=my2; ++ym)
for (
int xm = -mx1; xm<=mx2; ++xm) {
19066 const t mval =
mask(mx1+xm,my1+ym,mz1+zm);
19067 const Tt cval = (Tt)((*
this)(x+xm,
y+ym,
z+zm,
v) - mval);
19068 if (mval && cval>max_val) max_val = cval;
19070 dest(x,
y,
z,
v) = max_val;
19074 for (
int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
19076 for (
int zm = -mz1; zm<=mz2; ++zm)
for (
int ym = -my1; ym<=my2; ++ym)
for (
int xm = -mx1; xm<=mx2; ++xm) {
19077 const t mval =
mask(mx1+xm,my1+ym,mz1+zm);
19078 const Tt cval = (Tt)(
_atXYZ(x+xm,
y+ym,
z+zm,
v) - mval);
19079 if (mval && cval>max_val) max_val = cval;
19081 dest(x,
y,
z,
v) = max_val;
19085 for (
int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
19087 for (
int zm = -mz1; zm<=mz2; ++zm)
for (
int ym = -my1; ym<=my2; ++ym)
for (
int xm = -mx1; xm<=mx2; ++xm) {
19088 const t mval =
mask(mx1+xm,my1+ym,mz1+zm);
19089 const Tt cval = (Tt)(
atXYZ(x+xm,
y+ym,
z+zm,
v,0) - mval);
19090 if (mval && cval>max_val) max_val = cval;
19092 dest(x,
y,
z,
v) = max_val;
19100 if (n<2)
return *
this;
19101 return get_dilate(n,cond).transfer_to(*
this);
19106 if (n<2)
return *
this;
19107 if (mask.width!=n) mask.assign(n,n,1,1,1);
19109 if (n>20) mask.assign();
19118 CImg<T>&
deriche(
const float sigma,
const int order=0,
const char axis=
'x',
const bool cond=
true) {
19119 #define _cimg_deriche2_apply \
19120 Tfloat *ptrY = Y.data, yb = 0, yp = 0; \
19122 if (cond) { xp = *ptrX; yb = yp = (Tfloat)(coefp*xp); } \
19123 for (int m = 0; m<N; ++m) { \
19124 const T xc = *ptrX; ptrX+=off; \
19125 const Tfloat yc = *(ptrY++) = (Tfloat)(a0*xc + a1*xp - b1*yp - b2*yb); \
19126 xp = xc; yb = yp; yp = yc; \
19128 T xn = (T)0, xa = (T)0; \
19129 Tfloat yn = 0, ya = 0; \
19130 if (cond) { xn = xa = *(ptrX-off); yn = ya = (Tfloat)coefn*xn; } \
19131 for (int n = N-1; n>=0; --n) { \
19132 const T xc = *(ptrX-=off); \
19133 const Tfloat yc = (Tfloat)(a2*xn + a3*xa - b1*yn - b2*ya); \
19134 xa = xn; xn = xc; ya = yn; yn = yc; \
19135 *ptrX = (T)(*(--ptrY)+yc); \
19138 const float nsigma = sigma>=0?sigma:-sigma*(naxis==
'x'?
width:naxis==
'y'?
height:naxis==
'z'?
depth:
dim)/100;
19139 if (
is_empty() || (nsigma<0.1 && !order))
return *
this;
19141 nnsigma = nsigma<0.1f?0.1f:nsigma,
19142 alpha = 1.695f/nnsigma,
19147 float a0 = 0, a1 = 0, a2 = 0, a3 = 0, coefp = 0, coefn = 0;
19150 const float k = (1-ema)*(1-ema)/(1+2*alpha*ema-ema2);
19152 a1 = k*(alpha-1)*ema;
19153 a2 = k*(alpha+1)*ema;
19157 const float k = (1-ema)*(1-ema)/ema;
19165 k = -(ema2-1)/(2*alpha*ema),
19166 kn = (-2*(-1+3*ea-3*ea*ea+ea*ea*ea)/(3*ea+1+3*ea*ea+ea*ea*ea));
19168 a1 = -kn*(1+
k*alpha)*ema;
19169 a2 = kn*(1-
k*alpha)*ema;
19173 throw CImgArgumentException(
"CImg<%s>::deriche() : Given filter order (order = %u) must be 0,1 or 2",
19176 coefp = (a0+a1)/(1+b1+b2);
19177 coefn = (a2+a3)/(1+b1+b2);
19180 const int N =
width, off = 1;
19211 CImg<T>&
blur(
const float sigmax,
const float sigmay,
const float sigmaz,
const bool cond=
true) {
19227 return blur(nsigma,nsigma,nsigma,cond);
19245 template<
typename t>
19247 const float amplitude=60,
const float dl=0.8f,
const float da=30,
19248 const float gauss_prec=2,
const unsigned int interpolation_type=0,
19249 const unsigned int fast_approx=1) {
19252 if (
is_empty() || amplitude<=0 || dl<0)
return *
this;
19253 if (!
is_sameXYZ(G) || (G.dim!=3 && G.dim!=6))
19254 throw CImgArgumentException(
"CImg<%s>::blur_anisotropic() : Invalid diffusion tensor field (%u,%u,%u,%u,%p) "
19255 "for instance image (%u,%u,%u,%u,%p).",
19256 pixel_type(),G.width,G.height,G.depth,G.dim,G.data,
width,
height,
depth,dim,
data);
19257 const bool threed = G.dim==6;
19261 for (
unsigned int iter = 0; iter<(
unsigned int)amplitude; ++iter) {
19262 Tfloat *ptrd = veloc.fill(0).ptr(), betamax = 0;
19267 ixx = (
Tfloat)(Incc + Ipcc - 2*Iccc),
19268 iyy = (
Tfloat)(Icnc + Icpc - 2*Iccc),
19269 izz = (
Tfloat)(Iccn + Iccp - 2*Iccc),
19270 ixy = (
Tfloat)(0.25f*(Innc + Ippc - Inpc - Ipnc)),
19271 ixz = (
Tfloat)(0.25f*(Incn + Ipcp - Incp - Ipcn)),
19272 iyz = (
Tfloat)(0.25f*(Icnn + Icpp - Icnp - Icpn)),
19273 beta = (
Tfloat)(G(x,
y,
z,0)*ixx + 2*G(x,
y,
z,1)*ixy + 2*G(x,
y,
z,2)*ixz + G(x,
y,
z,3)*iyy + 2*G(x,
y,
z,4)*iyz + G(x,
y,
z,5)*izz);
19275 betamax = beta>betamax?beta:(-beta>betamax?-beta:betamax);
19279 Tfloat *ptrd = veloc.ptr();
19283 ixx = (
Tfloat)(Inc + Ipc - 2*Icc),
19284 iyy = (
Tfloat)(Icn + Icp - 2*Icc),
19285 ixy = (
Tfloat)(0.25f*(Inn + Ipp - Inp - Ipn)),
19286 beta = (
Tfloat)(G(x,
y,0,0)*ixx + G(x,
y,0,1)*ixy + G(x,
y,0,2)*iyy);
19288 betamax = beta>betamax?beta:(-beta>betamax?-beta:betamax);
19291 if (betamax>0) (*this)+=(veloc*=dl/betamax);
19294 #define _cimg_valign2d(i,j) { Tfloat &u = W(i,j,0,0), &v = W(i,j,0,1); if (u*curru + v*currv<0) { u=-u; v=-v; }}
19295 #define _cimg_valign3d(i,j,k) { Tfloat &u = W(i,j,k,0), &v = W(i,j,k,1), &w = W(i,j,k,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}
19297 const float sqrt2amplitude = (float)
std::sqrt(2*amplitude);
19298 const int dx1 =
dimx()-1, dy1 =
dimy()-1, dz1 =
dimz()-1;
19302 for (
float phi = (180%(
int)da)/2.0f; phi<=180; phi+=da) {
19303 const float phir = (float)(phi*
cimg::valuePI/180), datmp = (float)(da/
std::cos(phir)), da2 = datmp<1?360.0f:datmp;
19304 for (
float theta = 0; theta<360; (theta+=da2),++N) {
19311 *pa = G.ptr(0,0,0,0), *pb = G.ptr(0,0,0,1), *pc = G.ptr(0,0,0,2),
19312 *pd = G.ptr(0,0,0,3), *pe = G.ptr(0,0,0,4), *pf = G.ptr(0,0,0,5);
19313 Tfloat *pd0 = W.ptr(0,0,0,0), *pd1 = W.ptr(0,0,0,1), *pd2 = W.ptr(0,0,0,2), *pd3 = W.ptr(0,0,0,3);
19315 const t a = *(pa++), b = *(pb++), c = *(pc++),
d = *(pd++), e = *(pe++), f = *(pf++);
19316 const float u = (float)(a*vx + b*vy + c*vz),
v = (float)(b*vx +
d*vy + e*vz), w = (float)(c*vx + e*vy + f*vz),
19318 *(pd0++) = (
Tfloat)(u*dln);
19320 *(pd2++) = (
Tfloat)(w*dln);
19326 const float cu = (float)W(x,
y,
z,0), cv = (float)W(x,
y,
z,1), cw = (float)W(x,
y,
z,2),
n = (float)W(x,
y,
z,3),
19327 fsigma = (float)(
n*sqrt2amplitude),
length = gauss_prec*fsigma, fsigma2 = 2*fsigma*fsigma;
19328 float S = 0, pu = cu, pv = cv, pw = cw, X = (float)x, Y = (
float)
y, Z = (float)
z;
19329 switch (interpolation_type) {
19331 for (
float l = 0; l<length && X>=0 && X<=dx1 && Y>=0 && Y<=dy1 && Z>=0 && Z<=dz1; l+=dl) {
19332 const int cx = (int)(X+0.5f), cy = (int)(Y+0.5f), cz = (int)(Z+0.5f);
19333 float u = (float)W(cx,cy,cz,0),
v = (float)W(cx,cy,cz,1), w = (float)W(cx,cy,cz,2);
19334 if ((pu*u + pv*
v + pw*w)<0) { u=-u;
v=-
v; w=-w; }
19337 const float coef = (float)
std::exp(-l*l/fsigma2);
19341 X+=(pu=u); Y+=(pv=
v); Z+=(pw=w);
19345 for (
float l = 0; l<length && X>=0 && X<=dx1 && Y>=0 && Y<=dy1 && Z>=0 && Z<=dz1; l+=dl) {
19347 cx = (int)X, px = (cx-1<0)?0:cx-1, nx = (cx+1>dx1)?dx1:cx+1,
19348 cy = (
int)Y, py = (cy-1<0)?0:cy-1, ny = (cy+1>dy1)?dy1:cy+1,
19349 cz = (int)Z, pz = (cz-1<0)?0:cz-1, nz = (cz+1>dz1)?dz1:cz+1;
19350 const float curru = (float)W(cx,cy,cz,0), currv = (float)W(cx,cy,cz,1), currw = (float)W(cx,cy,cz,2);
19360 float u = (float)(W._linear_atXYZ(X,Y,Z,0)),
v = (
float)(W._linear_atXYZ(X,Y,Z,1)), w = (
float)(W._linear_atXYZ(X,Y,Z,2));
19361 if ((pu*u + pv*
v + pw*w)<0) { u=-u;
v=-
v; w=-w; }
19364 const float coef = (float)
std::exp(-l*l/fsigma2);
19368 X+=(pu=u); Y+=(pv=
v); Z+=(pw=w);
19372 for (
float l = 0; l<length && X>=0 && X<=dx1 && Y>=0 && Y<=dy1 && Z>=0 && Z<=dz1; l+=dl) {
19374 cx = (int)X, px = (cx-1<0)?0:cx-1, nx = (cx+1>dx1)?dx1:cx+1,
19375 cy = (
int)Y, py = (cy-1<0)?0:cy-1, ny = (cy+1>dy1)?dy1:cy+1,
19376 cz = (int)Z, pz = (cz-1<0)?0:cz-1, nz = (cz+1>dz1)?dz1:cz+1;
19377 const float curru = (float)W(cx,cy,cz,0), currv = (float)W(cx,cy,cz,1), currw = (float)W(cx,cy,cz,2);
19388 u0 = (float)(0.5f*W._linear_atXYZ(X,Y,Z,0)),
19389 v0 = (
float)(0.5f*W._linear_atXYZ(X,Y,Z,1)),
19390 w0 = (
float)(0.5f*W._linear_atXYZ(X,Y,Z,2));
19392 u = (float)(W._linear_atXYZ(X+u0,Y+v0,Z+w0,0)),
19393 v = (
float)(W._linear_atXYZ(X+u0,Y+v0,Z+w0,1)),
19394 w = (
float)(W._linear_atXYZ(X+u0,Y+v0,Z+w0,2));
19395 if ((pu*u + pv*
v + pw*w)<0) { u=-u;
v=-
v; w=-w; }
19398 const float coef = (float)
std::exp(-l*l/fsigma2);
19402 X+=(pu=u); Y+=(pv=
v); Z+=(pw=w);
19412 for (
float theta = (360%(
int)da)/2.0f; theta<360; (theta+=da),++N) {
19414 const t *pa = G.ptr(0,0,0,0), *pb = G.ptr(0,0,0,1), *pc = G.ptr(0,0,0,2);
19415 Tfloat *pd0 = W.ptr(0,0,0,0), *pd1 = W.ptr(0,0,0,1), *pd2 = W.ptr(0,0,0,2);
19417 const t a = *(pa++), b = *(pb++), c = *(pc++);
19418 const float u = (float)(a*vx + b*vy),
v = (float)(b*vx + c*vy),
n = (float)
std::sqrt(1e-5+u*u+
v*
v), dln = dl/
n;
19419 *(pd0++) = (
Tfloat)(u*dln);
19420 *(pd1++) = (
Tfloat)(v*dln);
19426 cu = (float)W(x,
y,0,0), cv = (float)W(x,
y,0,1),
n = (float)W(x,
y,0,2),
19427 fsigma = (float)(
n*sqrt2amplitude),
length = gauss_prec*fsigma, fsigma2 = 2*fsigma*fsigma;
19428 float S = 0, pu = cu, pv = cv, X = (float)x, Y = (
float)
y;
19430 switch (interpolation_type) {
19432 for (
float l = 0; l<length && X>=0 && X<=dx1 && Y>=0 && Y<=dy1; l+=dl) {
19433 const int cx = (int)(X+0.5f), cy = (int)(Y+0.5f);
19434 float u = (float)W(cx,cy,0,0),
v = (float)W(cx,cy,0,1);
19435 if ((pu*u + pv*
v)<0) { u=-u; v=-
v; }
19438 const float coef = (float)
std::exp(-l*l/fsigma2);
19442 X+=(pu=u); Y+=(pv=
v);
19446 for (
float l = 0; l<length && X>=0 && X<=dx1 && Y>=0 && Y<=dy1; l+=dl) {
19448 cx = (int)X, px = (cx-1<0)?0:cx-1, nx = (cx+1>dx1)?dx1:cx+1,
19449 cy = (
int)Y, py = (cy-1<0)?0:cy-1, ny = (cy+1>dy1)?dy1:cy+1;
19450 const float curru = (float)W(cx,cy,0,0), currv = (float)W(cx,cy,0,1);
19454 float u = (float)(W._linear_atXY(X,Y,0,0)),
v = (
float)(W._linear_atXY(X,Y,0,1));
19455 if ((pu*u + pv*
v)<0) { u=-u; v=-
v; }
19458 const float coef = (float)
std::exp(-l*l/fsigma2);
19462 X+=(pu=u); Y+=(pv=
v);
19466 for (
float l = 0; l<length && X>=0 && X<=dx1 && Y>=0 && Y<=dy1; l+=dl) {
19468 cx = (int)X, px = (cx-1<0)?0:cx-1, nx = (cx+1>dx1)?dx1:cx+1,
19469 cy = (
int)Y, py = (cy-1<0)?0:cy-1, ny = (cy+1>dy1)?dy1:cy+1;
19470 const float curru = (float)W(cx,cy,0,0), currv = (float)W(cx,cy,0,1);
19474 const float u0 = (float)(0.5f*W._linear_atXY(X,Y,0,0)), v0 = (
float)(0.5f*W._linear_atXY(X,Y,0,1));
19475 float u = (float)(W._linear_atXY(X+u0,Y+v0,0,0)),
v = (
float)(W._linear_atXY(X+u0,Y+v0,0,1));
19476 if ((pu*u + pv*
v)<0) { u=-u; v=-
v; }
19479 const float coef = (float)
std::exp(-l*l/fsigma2);
19483 X+=(pu=u); Y+=(pv=
v);
19492 const Tfloat *ptrs = dest.data + dest.size();
19494 cimg_for(*
this,ptrd,T) {
const Tfloat val = *(--ptrs)/N; *ptrd = val<m?m:(val>M?M:(T)val); }
19499 template<
typename t>
19501 const float amplitude=60,
const float dl=0.8f,
const float da=30,
19502 const float gauss_prec=2,
const unsigned int interpolation_type=0,
19503 const unsigned int fast_approx=1)
const {
19504 return (+*
this).
blur_anisotropic(G,amplitude,dl,da,gauss_prec,interpolation_type,fast_approx);
19509 const float alpha=0.6f,
const float sigma=1.1f,
const float dl=0.8f,
const float da=30,
19510 const float gauss_prec=2,
const unsigned int interpolation_type=0,
19511 const unsigned int fast_approx=1) {
19513 amplitude,dl,da,gauss_prec,interpolation_type,fast_approx);
19517 const float alpha=0.6f,
const float sigma=1.1f,
const float dl=0.8f,
19518 const float da=30,
const float gauss_prec=2,
const unsigned int interpolation_type=0,
19519 const unsigned int fast_approx=1)
const {
19520 return (+*
this).
blur_anisotropic(amplitude,sharpness,anisotropy,alpha,sigma,dl,da,gauss_prec,interpolation_type,fast_approx);
19538 const int bgrid_x,
const int bgrid_y,
const int bgrid_z,
const int bgrid_r,
19539 const bool interpolation_type=
true) {
19542 const float range = (float)(1.0f+M-m);
19544 bx0 = bgrid_x>=0?bgrid_x:
width*(-bgrid_x)/100,
19545 by0 = bgrid_y>=0?bgrid_y:
height*(-bgrid_y)/100,
19546 bz0 = bgrid_z>=0?bgrid_z:
depth*(-bgrid_z)/100,
19547 br0 = bgrid_r>=0?bgrid_r:(
int)(-range*bgrid_r/100),
19553 _sigma_x = sigma_x>=0?sigma_x:-sigma_x*
width/100,
19554 _sigma_y = sigma_y>=0?sigma_y:-sigma_y*
height/100,
19555 _sigma_z = sigma_z>=0?sigma_z:-sigma_z*
depth/100,
19556 nsigma_x = _sigma_x*bx/
width,
19558 nsigma_z = _sigma_z*bz/
depth,
19559 nsigma_r = sigma_r*br/range;
19560 if (nsigma_x>0 || nsigma_y>0 || nsigma_z>0 || nsigma_r>0) {
19561 const bool threed =
depth>1;
19565 bgrid.fill(0); bgridw.fill(0);
19567 const T val = (*this)(
x,
y,
z,
k);
19568 const int X = x*bx/
width, Y = y*
by/
height, Z = z*bz/
depth, R = (int)((val-m)*br/range);
19569 bgrid(X,Y,Z,R) = (float)val;
19570 bgridw(X,Y,Z,R) = 1;
19572 bgrid.blur(nsigma_x,nsigma_y,nsigma_z,
true).deriche(nsigma_r,0,
'v',
false);
19573 bgridw.blur(nsigma_x,nsigma_y,nsigma_z,
true).deriche(nsigma_r,0,
'v',
false);
19575 const T val = (*this)(
x,
y,
z,
k);
19576 const float X = (float)x*bx/
width, Y = (
float)y*
by/
height, Z = (float)z*bz/
depth, R = (
float)((val-m)*br/range),
19577 bval0 = bgrid._linear_atXYZV(X,Y,Z,R), bval1 = bgridw._linear_atXYZV(X,Y,Z,R);
19578 (*this)(
x,
y,
z,
k) = (T)(bval0/bval1);
19580 const T val = (*this)(
x,
y,
z,
k);
19581 const int X = x*bx/
width, Y = y*
by/
height, Z = z*bz/
depth, R = (int)((val-m)*br/range);
19582 const float bval0 = bgrid(X,Y,Z,R), bval1 = bgridw(X,Y,Z,R);
19583 (*this)(
x,
y,
z,
k) = (T)(bval0/bval1);
19591 const T val = (*this)(
x,
y,
k);
19592 const int X = x*bx/
width, Y = y*
by/
height, R = (int)((val-m)*br/range);
19593 bgrid(X,Y,R,0) = (float)val;
19594 bgrid(X,Y,R,1) = 1;
19596 bgrid.blur(nsigma_x,nsigma_y,0,
true).blur(0,0,nsigma_r,
false);
19598 const T val = (*this)(
x,
y,
k);
19599 const float X = (float)x*bx/
width, Y = (
float)y*
by/
height, R = (float)((val-m)*br/range),
19600 bval0 = bgrid._linear_atXYZ(X,Y,R,0), bval1 = bgrid._linear_atXYZ(X,Y,R,1);
19601 (*this)(
x,
y,
k) = (T)(bval0/bval1);
19603 const T val = (*this)(
x,
y,
k);
19604 const int X = x*bx/
width, Y = y*
by/
height, R = (int)((val-m)*br/range);
19605 const float bval0 = bgrid(X,Y,R,0), bval1 = bgrid(X,Y,R,1);
19606 (*this)(
x,
y,
k) = (T)(bval0/bval1);
19615 const int bgrid_x,
const int bgrid_y,
const int bgrid_z,
const int bgrid_r,
19616 const bool interpolation_type=
true)
const {
19617 return (+*
this).
blur_bilateral(sigma_x,sigma_y,sigma_z,sigma_r,bgrid_x,bgrid_y,bgrid_z,bgrid_r,interpolation_type);
19622 const bool interpolation_type=
true) {
19624 return blur_bilateral(nsigma_s,nsigma_s,nsigma_s,sigma_r,bgrid_s,bgrid_s,bgrid_s,bgrid_r,interpolation_type);
19628 const bool interpolation_type=
true)
const {
19629 return (+*
this).
blur_bilateral(sigma_s,sigma_s,sigma_s,sigma_r,bgrid_s,bgrid_s,bgrid_s,bgrid_r,interpolation_type);
19634 const unsigned int lookup_size=4,
const float smoothness=0,
const bool fast_approx=
true) {
19635 return get_blur_patch(sigma_s,sigma_p,patch_size,lookup_size,smoothness,fast_approx).transfer_to(*
this);
19639 const unsigned int lookup_size=4,
const float smoothness=0,
const bool fast_approx=
true)
const {
19641 #define _cimg_blur_patch3d_fast(N) \
19642 cimg_for##N##XYZ(res,x,y,z) { \
19643 cimg_forV(res,k) cimg_get##N##x##N##x##N(img,x,y,z,k,P.ptr(N3*k)); \
19644 const int x0 = x - rsize1, y0 = y - rsize1, z0 = z - rsize1, x1 = x + rsize2, y1 = y + rsize2, z1 = z + rsize2; \
19645 float sum_weights = 0; \
19646 cimg_for_in##N##XYZ(res,x0,y0,z0,x1,y1,z1,p,q,r) if (cimg::abs(img(x,y,z,0)-img(p,q,r,0))<sigma_p3) { \
19647 cimg_forV(res,k) cimg_get##N##x##N##x##N(img,p,q,r,k,Q.ptr(N3*k)); \
19648 float distance2 = 0; \
19649 const T *pQ = Q.end(); cimg_for(P,pP,T) { const float dI = (float)*pP - (float)*(--pQ); distance2+=dI*dI; } \
19650 distance2/=Pnorm; \
19651 const float dx = (float)p - x, dy = (float)q - y, dz = (float)r - z, \
19652 alldist = distance2 + (dx*dx + dy*dy + dz*dz)/sigma_s2, weight = alldist>3?0.0f:1.0f; \
19653 sum_weights+=weight; \
19654 cimg_forV(res,k) res(x,y,z,k)+=weight*(*this)(p,q,r,k); \
19656 if (sum_weights>0) cimg_forV(res,k) res(x,y,z,k)/=sum_weights; \
19657 else cimg_forV(res,k) res(x,y,z,k) = (Tfloat)((*this)(x,y,z,k)); \
19660 #define _cimg_blur_patch3d(N) \
19661 cimg_for##N##XYZ(res,x,y,z) { \
19662 cimg_forV(res,k) cimg_get##N##x##N##x##N(img,x,y,z,k,P.ptr(N3*k)); \
19663 const int x0 = x - rsize1, y0 = y - rsize1, z0 = z - rsize1, x1 = x + rsize2, y1 = y + rsize2, z1 = z + rsize2; \
19664 float sum_weights = 0; \
19665 cimg_for_in##N##XYZ(res,x0,y0,z0,x1,y1,z1,p,q,r) { \
19666 cimg_forV(res,k) cimg_get##N##x##N##x##N(img,p,q,r,k,Q.ptr(N3*k)); \
19667 float distance2 = 0; \
19668 const T *pQ = Q.end(); cimg_for(P,pP,T) { const float dI = (float)*pP - (float)*(--pQ); distance2+=dI*dI; } \
19669 distance2/=Pnorm; \
19670 const float dx = (float)p - x, dy = (float)q - y, dz = (float)r - z, \
19671 alldist = distance2 + (dx*dx + dy*dy + dz*dz)/sigma_s2, weight = (float)std::exp(-alldist); \
19672 sum_weights+=weight; \
19673 cimg_forV(res,k) res(x,y,z,k)+=weight*(*this)(p,q,r,k); \
19675 if (sum_weights>0) cimg_forV(res,k) res(x,y,z,k)/=sum_weights; \
19676 else cimg_forV(res,k) res(x,y,z,k) = (Tfloat)((*this)(x,y,z,k)); \
19679 #define _cimg_blur_patch2d_fast(N) \
19680 cimg_for##N##XY(res,x,y) { \
19681 cimg_forV(res,k) cimg_get##N##x##N(img,x,y,0,k,P.ptr(N2*k)); \
19682 const int x0 = x-rsize1, y0 = y-rsize1, x1 = x+rsize2, y1 = y+rsize2; \
19683 float sum_weights = 0; \
19684 cimg_for_in##N##XY(res,x0,y0,x1,y1,p,q) if (cimg::abs(img(x,y,0,0)-img(p,q,0,0))<sigma_p3) { \
19685 cimg_forV(res,k) cimg_get##N##x##N(img,p,q,0,k,Q.ptr(N2*k)); \
19686 float distance2 = 0; \
19687 const T *pQ = Q.end(); cimg_for(P,pP,T) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } \
19688 distance2/=Pnorm; \
19689 const float dx = (float)p-x, dy = (float)q-y, \
19690 alldist = distance2 + (dx*dx+dy*dy)/sigma_s2, weight = alldist>3?0.0f:1.0f; \
19691 sum_weights+=weight; \
19692 cimg_forV(res,k) res(x,y,k)+=weight*(*this)(p,q,k); \
19694 if (sum_weights>0) cimg_forV(res,k) res(x,y,k)/=sum_weights; \
19695 else cimg_forV(res,k) res(x,y,k) = (Tfloat)((*this)(x,y,k)); \
19698 #define _cimg_blur_patch2d(N) \
19699 cimg_for##N##XY(res,x,y) { \
19700 cimg_forV(res,k) cimg_get##N##x##N(img,x,y,0,k,P.ptr(N2*k)); \
19701 const int x0 = x-rsize1, y0 = y-rsize1, x1 = x+rsize2, y1 = y+rsize2; \
19702 float sum_weights = 0; \
19703 cimg_for_in##N##XY(res,x0,y0,x1,y1,p,q) { \
19704 cimg_forV(res,k) cimg_get##N##x##N(img,p,q,0,k,Q.ptr(N2*k)); \
19705 float distance2 = 0; \
19706 const T *pQ = Q.end(); cimg_for(P,pP,T) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } \
19707 distance2/=Pnorm; \
19708 const float dx = (float)p-x, dy = (float)q-y, \
19709 alldist = distance2 + (dx*dx+dy*dy)/sigma_s2, weight = (float)std::exp(-alldist); \
19710 sum_weights+=weight; \
19711 cimg_forV(res,k) res(x,y,k)+=weight*(*this)(p,q,k); \
19713 if (sum_weights>0) cimg_forV(res,k) res(x,y,k)/=sum_weights; \
19714 else cimg_forV(res,k) res(x,y,k) = (Tfloat)((*this)(x,y,k)); \
19719 CImg<T> P(patch_size*patch_size*dim), Q(P);
19722 sigma_s2 = nsigma_s*nsigma_s, sigma_p2 = sigma_p*sigma_p, sigma_p3 = 3*sigma_p,
19723 Pnorm = P.size()*sigma_p2;
19724 const int rsize2 = (int)lookup_size/2, rsize1 = rsize2-1+(lookup_size%2);
19725 const unsigned int N2 = patch_size*patch_size, N3 = N2*patch_size;
19726 if (
depth>1)
switch (patch_size) {
19730 const int psize1 = (int)patch_size/2, psize0 = psize1-1+(patch_size%2);
19732 P = img.get_crop(x - psize0,
y - psize0,
z - psize0,x + psize1,
y + psize1,
z + psize1,
true);
19733 const int x0 = x - rsize1, y0 =
y - rsize1, z0 =
z - rsize1, x1 = x + rsize2, y1 =
y + rsize2, z1 =
z + rsize2;
19734 float sum_weights = 0;
19735 cimg_for_inXYZ(res,x0,y0,z0,x1,y1,z1,p,
q,r)
if (
cimg::abs(img(x,
y,
z,0)-img(p,
q,r,0))<sigma_p3) {
19736 (Q = img.get_crop(p - psize0,
q - psize0,r - psize0,p + psize1,
q + psize1,r + psize1,
true))-=P;
19738 dx = (float)x - p,
dy = (
float)
y -
q, dz = (float)
z - r,
19739 distance2 = (
float)(Q.pow(2).sum()/Pnorm + (dx*dx +
dy*
dy + dz*dz)/sigma_s2),
19740 weight = distance2>3?0.0f:1.0f;
19741 sum_weights+=weight;
19744 if (sum_weights>0)
cimg_forV(res,
k) res(x,
y,
z,
k)/=sum_weights;
19747 P = img.get_crop(x - psize0,
y - psize0,
z - psize0,x + psize1,
y + psize1,
z + psize1,
true);
19748 const int x0 = x - rsize1, y0 =
y - rsize1, z0 =
z - rsize1, x1 = x + rsize2, y1 =
y + rsize2, z1 =
z + rsize2;
19749 float sum_weights = 0;
19751 (Q = img.get_crop(p - psize0,
q - psize0,r - psize0,p + psize1,
q + psize1,r + psize1,
true))-=P;
19753 dx = (float)x - p,
dy = (
float)
y -
q, dz = (float)
z - r,
19754 distance2 = (
float)(Q.pow(2).sum()/Pnorm + (dx*dx +
dy*
dy + dz*dz)/sigma_s2),
19755 weight = (float)
std::exp(-distance2);
19756 sum_weights+=weight;
19759 if (sum_weights>0)
cimg_forV(res,
k) res(x,
y,
z,
k)/=sum_weights;
19763 }
else switch (patch_size) {
19773 const int psize1 = (int)patch_size/2, psize0 = psize1-1+(patch_size%2);
19775 P = img.get_crop(x - psize0,
y - psize0,x + psize1,
y + psize1,
true);
19776 const int x0 = x - rsize1, y0 =
y - rsize1, x1 = x + rsize2, y1 =
y + rsize2;
19777 float sum_weights = 0;
19778 cimg_for_inXY(res,x0,y0,x1,y1,p,
q)
if (
cimg::abs(img(x,
y,0,0)-img(p,
q,0,0))<sigma_p3) {
19779 (Q = img.get_crop(p - psize0,
q - psize0,p + psize1,
q + psize1,
true))-=P;
19781 dx = (float)x - p,
dy = (
float)
y -
q,
19782 distance2 = (float)(Q.pow(2).sum()/Pnorm + (dx*dx +
dy*
dy)/sigma_s2),
19783 weight = distance2>3?0.0f:1.0f;
19784 sum_weights+=weight;
19787 if (sum_weights>0)
cimg_forV(res,
k) res(x,
y,0,
k)/=sum_weights;
19790 P = img.get_crop(x - psize0,
y - psize0,x + psize1,
y + psize1,
true);
19791 const int x0 = x - rsize1, y0 =
y - rsize1, x1 = x + rsize2, y1 =
y + rsize2;
19792 float sum_weights = 0;
19794 (Q = img.get_crop(p - psize0,
q - psize0,p + psize1,
q + psize1,
true))-=P;
19796 dx = (float)x - p,
dy = (
float)
y -
q,
19797 distance2 = (float)(Q.pow(2).sum()/Pnorm + (dx*dx +
dy*
dy)/sigma_s2),
19798 weight = (float)
std::exp(-distance2);
19799 sum_weights+=weight;
19802 if (sum_weights>0)
cimg_forV(res,
k) res(x,
y,0,
k)/=sum_weights;
19817 if (!n || n==1)
return *
this;
19818 const int hl=n/2, hr=hl-1+n%2;
19819 if (res.depth!=1) {
19823 x0 = x - hl, y0 =
y - hl, z0 =
z-hl, x1 = x + hr, y1 =
y + hr, z1 =
z+hr,
19824 nx0 = x0<0?0:x0, ny0 = y0<0?0:y0, nz0 = z0<0?0:z0,
19826 vois =
get_crop(nx0,ny0,nz0,
k,nx1,ny1,nz1,
k);
19827 res(x,
y,
z,
k) = vois.median();
19830 #define _cimg_median_sort(a,b) if ((a)>(b)) cimg::swap(a,b)
19831 if (res.height!=1)
switch (n) {
19836 std::memcpy(J,I,9*
sizeof(T));
19844 res(x,
y,0,
k) = Jcc;
19851 std::memcpy(J,I,25*
sizeof(T));
19877 res(x,
y,0,
k) = Jcc;
19884 x0 = x - hl, y0 =
y - hl, x1 = x + hr, y1 =
y + hr,
19885 nx0 = x0<0?0:x0, ny0 = y0<0?0:y0,
19888 res(x,
y,0,
k) = vois.median();
19891 }
else switch (n) {
19899 res(x,0,0,
k) = I[3]<I[4]?
19901 (I[3]<I[5]?I[5]:I[3])):
19903 (I[4]<I[5]?I[5]:I[4]));
19910 x0 = x - hl, x1 = x + hr,
19911 nx0 = x0<0?0:x0, nx1 = x1>=
dimx()?
dimx()-1:x1;
19913 res(x,0,0,
k) = vois.median();
19922 CImg<T>&
sharpen(
const float amplitude,
const bool sharpen_type=
false,
const float edge=1,
const float alpha=0,
const float sigma=0) {
19924 T valm, valM =
maxmin(valm);
19925 const bool threed = (
depth>1);
19926 const float nedge = 0.5f*edge;
19931 if (sharpen_type) {
19933 if (sigma>0) G.blur(sigma);
19936 G.get_tensor_at(x,
y,
z).symmetric_eigen(val,vec);
19937 G(x,
y,
z,0) = vec(0,0);
19938 G(x,
y,
z,1) = vec(0,1);
19939 G(x,
y,
z,2) = vec(0,2);
19948 ixx = (
Tfloat)Incc + Ipcc - 2*Iccc,
19949 ixy = 0.25f*((
Tfloat)Innc + Ippc - Inpc - Ipnc),
19950 ixz = 0.25f*((
Tfloat)Incn + Ipcp - Incp - Ipcn),
19951 iyy = (
Tfloat)Icnc + Icpc - 2*Iccc,
19952 iyz = 0.25f*((
Tfloat)Icnn + Icpp - Icnp - Icpn),
19953 izz = (
Tfloat)Iccn + Iccp - 2*Iccc,
19954 ixf = (
Tfloat)Incc - Iccc,
19955 ixb = (
Tfloat)Iccc - Ipcc,
19956 iyf = (
Tfloat)Icnc - Iccc,
19957 iyb = (
Tfloat)Iccc - Icpc,
19958 izf = (
Tfloat)Iccn - Iccc,
19959 izb = (
Tfloat)Iccc - Iccp,
19960 itt = u*u*ixx +
v*
v*iyy + w*w*izz + 2*u*
v*ixy + 2*u*w*ixz + 2*
v*w*iyz,
19967 if (sharpen_type) {
19969 if (sigma>0) G.blur(sigma);
19971 G.get_tensor_at(x,
y).symmetric_eigen(val,vec);
19972 G(x,
y,0) = vec(0,0);
19973 G(x,
y,1) = vec(0,1);
19981 ixx = (
Tfloat)Inc + Ipc - 2*Icc,
19982 ixy = 0.25f*((
Tfloat)Inn + Ipp - Inp - Ipn),
19983 iyy = (
Tfloat)Icn + Icp - 2*Icc,
19984 ixf = (
Tfloat)Inc - Icc,
19985 ixb = (
Tfloat)Icc - Ipc,
19986 iyf = (
Tfloat)Icn - Icc,
19987 iyb = (
Tfloat)Icc - Icp,
19988 itt = u*u*ixx +
v*
v*iyy + 2*u*
v*ixy,
19994 float m, M = (float)veloc.maxmin(m);
19996 if (vmax!=0) { veloc*=amplitude/vmax; (*this)+=veloc; }
19997 return cut(valm,valM);
20000 CImg<T> get_sharpen(
const float amplitude,
const bool sharpen_type=
false,
const float edge=1,
const float alpha=0,
const float sigma=0)
const {
20001 return (+*
this).
sharpen(amplitude,sharpen_type,edge,alpha,sigma);
20016 bool threed =
false;
20018 for (
unsigned int a = 0; axes[a]; ++a) {
20021 case 'x' :
case 'y' :
break;
20022 case 'z' : threed =
true;
break;
20028 }
else threed = (
depth>1);
20056 grad[0](
x,
y,
z,
k) = 0.5f*((
Tfloat)Incc - Ipcc);
20057 grad[1](
x,
y,
z,
k) = 0.5f*((
Tfloat)Icnc - Icpc);
20058 grad[2](
x,
y,
z,
k) = 0.5f*((
Tfloat)Iccn - Iccp);
20062 }
else switch (
scheme) {
20079 const Tfloat a = 1, b = 2;
20081 grad[0](
x,
y,
z,
k) = -a*Ipp - b*Ipc - a*Ipn + a*Inp + b*Inc + a*Inn;
20082 grad[1](
x,
y,
z,
k) = -a*Ipp - b*Icp - a*Inp + a*Ipn + b*Icn + a*Inn;
20089 grad[0](
x,
y,
z,
k) = -a*Ipp - b*Ipc - a*Ipn + a*Inp + b*Inc + a*Inn;
20090 grad[1](
x,
y,
z,
k) = -a*Ipp - b*Icp - a*Inp + a*Ipn + b*Icn + a*Inn;
20100 grad[0](
x,
y,
z,
k) = 0.5f*((
Tfloat)Inc - Ipc);
20101 grad[1](
x,
y,
z,
k) = 0.5f*((
Tfloat)Icn - Icp);
20105 if (!axes)
return grad;
20107 for (
unsigned int l = 0; axes[l]; ++l) {
20110 case 'x' : res.
insert(grad[0]);
break;
20111 case 'y' : res.
insert(grad[1]);
break;
20112 case 'z' : res.
insert(grad[2]);
break;
20121 const char *naxes = axes, *
const def_axes2d =
"xxxyyy", *
const def_axes3d =
"xxxyxzyyyzzz";
20122 if (!axes) naxes =
depth>1?def_axes3d:def_axes2d;
20124 const unsigned int lmax = std::strlen(naxes);
20132 res[0](
x,
y,
z,
k) = (
Tfloat)Ipcc + Incc - 2*Iccc;
20133 res[1](
x,
y,
z,
k) = 0.25f*((
Tfloat)Ippc + Innc - Ipnc - Inpc);
20134 res[2](
x,
y,
z,
k) = 0.25f*((
Tfloat)Ipcp + Incn - Ipcn - Incp);
20135 res[3](
x,
y,
z,
k) = (
Tfloat)Icpc + Icnc - 2*Iccc;
20136 res[4](
x,
y,
z,
k) = 0.25f*((
Tfloat)Icpp + Icnn - Icpn - Icnp);
20137 res[5](
x,
y,
z,
k) = (
Tfloat)Iccn + Iccp - 2*Iccc;
20142 res[0](
x,
y,0,
k) = (
Tfloat)Ipc + Inc - 2*Icc;
20143 res[1](
x,
y,0,
k) = 0.25f*((
Tfloat)Ipp + Inn - Ipn - Inp);
20144 res[2](
x,
y,0,
k) = (
Tfloat)Icp + Icn - 2*Icc;
20146 }
else for (
unsigned int l = 0; l<lmax; ) {
20147 const unsigned int l2 = l/2;
20148 char axis1 = naxes[l++], axis2 = naxes[l++];
20150 bool valid_axis =
false;
20151 if (axis1==
'x' && axis2==
'x') {
20153 cimg_forZV(*
this,
z,
k)
cimg_for3x3(*
this,x,
y,
z,
k,I) res[l2](
x,
y,
z,
k) = (
Tfloat)Ipc + Inc - 2*Icc;
20155 else if (axis1==
'x' && axis2==
'y') {
20157 cimg_forZV(*
this,
z,
k)
cimg_for3x3(*
this,x,
y,
z,
k,I) res[l2](
x,
y,
z,
k) = 0.25f*((
Tfloat)Ipp + Inn - Ipn - Inp);
20159 else if (axis1==
'x' && axis2==
'z') {
20163 else if (axis1==
'y' && axis2==
'y') {
20165 cimg_forZV(*
this,
z,
k)
cimg_for3x3(*
this,x,
y,
z,
k,I) res[l2](
x,
y,
z,
k) = (
Tfloat)Icp + Icn - 2*Icc;
20167 else if (axis1==
'y' && axis2==
'z') {
20171 else if (axis1==
'z' && axis2==
'z') {
20175 else if (!valid_axis)
throw CImgArgumentException(
"CImg<%s>::get_hessian() : Invalid parameter axes = '%s'.",
20196 ix = 0.5f*((
Tfloat)Incc - Ipcc),
20197 iy = 0.5f*((
Tfloat)Icnc - Icpc),
20198 iz = 0.5f*((
Tfloat)Iccn - Iccp);
20199 res(x,
y,
z,0)+=ix*ix;
20200 res(x,
y,
z,1)+=ix*iy;
20201 res(x,
y,
z,2)+=ix*iz;
20202 res(x,
y,
z,3)+=iy*iy;
20203 res(x,
y,
z,4)+=iy*iz;
20204 res(x,
y,
z,5)+=iz*iz;
20213 res(x,
y,
z,0) += 0.25f*(ixf*ixf + ixf*ixb + ixb*ixf + ixb*ixb);
20214 res(x,
y,
z,1) += 0.25f*(ixf*iyf + ixf*iyb + ixb*iyf + ixb*iyb);
20215 res(x,
y,
z,2) += 0.25f*(ixf*izf + ixf*izb + ixb*izf + ixb*izb);
20216 res(x,
y,
z,3) += 0.25f*(iyf*iyf + iyf*iyb + iyb*iyf + iyb*iyb);
20217 res(x,
y,
z,4) += 0.25f*(iyf*izf + iyf*izb + iyb*izf + iyb*izb);
20218 res(x,
y,
z,5) += 0.25f*(izf*izf + izf*izb + izb*izf + izb*izb);
20227 res(x,
y,
z,0) += 0.5f*(ixf*ixf + ixb*ixb);
20228 res(x,
y,
z,1) += 0.25f*(ixf*iyf + ixf*iyb + ixb*iyf + ixb*iyb);
20229 res(x,
y,
z,2) += 0.25f*(ixf*izf + ixf*izb + ixb*izf + ixb*izb);
20230 res(x,
y,
z,3) += 0.5f*(iyf*iyf + iyb*iyb);
20231 res(x,
y,
z,4) += 0.25f*(iyf*izf + iyf*izb + iyb*izf + iyb*izb);
20232 res(x,
y,
z,5) += 0.5f*(izf*izf + izb*izb);
20243 ix = 0.5f*((
Tfloat)Inc - Ipc),
20244 iy = 0.5f*((
Tfloat)Icn - Icp);
20245 res(x,
y,0,0)+=ix*ix;
20246 res(x,
y,0,1)+=ix*iy;
20247 res(x,
y,0,2)+=iy*iy;
20255 res(x,
y,0,0) += 0.25f*(ixf*ixf + ixf*ixb + ixb*iyf + ixb*ixb);
20256 res(x,
y,0,1) += 0.25f*(ixf*iyf + ixf*iyb + ixb*iyf + ixb*iyb);
20257 res(x,
y,0,2) += 0.25f*(iyf*iyf + iyf*iyb + iyb*iyf + iyb*iyb);
20265 res(x,
y,0,0) += 0.5f*(ixf*ixf + ixb*ixb);
20266 res(x,
y,0,1) += 0.25f*(ixf*iyf + ixf*iyb + ixb*iyf + ixb*iyb);
20267 res(x,
y,0,2) += 0.5f*(iyf*iyf + iyb*iyb);
20277 const float alpha=0.6f,
const float sigma=1.1f,
const bool is_sqrt=
false) {
20279 const float nsharpness =
cimg::max(sharpness,1e-5f), power1 = (is_sqrt?0.5f:1)*nsharpness, power2 = power1/(1e-7f+1-anisotropy);
20280 blur(alpha).normalize(0,(T)255);
20286 dest.get_tensor_at(x,
y,
z).symmetric_eigen(val,vec);
20288 _l1 = val[2], _l2 = val[1], _l3 = val[0],
20289 l1 = _l1>0?_l1:0, l2 = _l2>0?_l2:0, l3 = _l3>0?_l3:0,
20290 ux = vec(0,0), uy = vec(0,1), uz = vec(0,2),
20291 vx = vec(1,0), vy = vec(1,1), vz = vec(1,2),
20292 wx = vec(2,0), wy = vec(2,1), wz = vec(2,2),
20293 n1 = (float)
std::pow(1+l1+l2+l3,-power1),
20294 n2 = (float)
std::pow(1+l1+l2+l3,-power2);
20295 dest(x,
y,
z,0) = n1*(ux*ux + vx*vx) + n2*wx*wx;
20296 dest(x,
y,
z,1) = n1*(ux*uy + vx*vy) + n2*wx*wy;
20297 dest(x,
y,
z,2) = n1*(ux*uz + vx*vz) + n2*wx*wz;
20298 dest(x,
y,
z,3) = n1*(uy*uy + vy*vy) + n2*wy*wy;
20299 dest(x,
y,
z,4) = n1*(uy*uz + vy*vz) + n2*wy*wz;
20300 dest(x,
y,
z,5) = n1*(uz*uz + vz*vz) + n2*wz*wz;
20306 dest.get_tensor_at(x,
y).symmetric_eigen(val,vec);
20308 _l1 = val[1], _l2 = val[0],
20309 l1 = _l1>0?_l1:0, l2 = _l2>0?_l2:0,
20310 ux = vec(1,0), uy = vec(1,1),
20311 vx = vec(0,0), vy = vec(0,1),
20312 n1 = (float)
std::pow(1+l1+l2,-power1),
20313 n2 = (float)
std::pow(1+l1+l2,-power2);
20314 dest(x,
y,0,0) = n1*ux*ux + n2*vx*vx;
20315 dest(x,
y,0,1) = n1*ux*uy + n2*vx*vy;
20316 dest(x,
y,0,2) = n1*uy*uy + n2*vy*vy;
20319 return dest.transfer_to(*
this);
20323 const float alpha=0.6f,
const float sigma=1.1f,
const bool is_sqrt=
false)
const {
20324 return (+*
this).
edge_tensors(sharpness,anisotropy,alpha,sigma,is_sqrt);
20332 const unsigned int nb_scales=0,
const unsigned int itermax=1000,
20333 const bool backward =
true) {
20338 const float smoothness=0.1f,
const float precision=0.1f,
20339 const unsigned int nb_scales=0,
const unsigned int itermax=1000,
20340 const bool backward =
true)
const {
20341 if (
is_empty() || !target)
return *
this;
20343 throw CImgArgumentException(
"CImg<%s>::displacement_field() : Instance image (%u,%u,%u,%u,%p) and target image (%u,%u,%u,%u,%p) "
20344 "have different size.",
20346 target.width,target.height,target.depth,target.dim,target.data);
20348 throw CImgArgumentException(
"CImg<%s>::displacement_field() : Smoothness parameter %g is negative.",
20351 throw CImgArgumentException(
"CImg<%s>::displacement_field() : Precision parameter %g is negative.",
20358 const bool threed = (
depth>1);
20361 for (
int scale = (
int)nscales-1; scale>=0; --scale) {
20364 sw = (int)(
width/sfactor), sh = (int)(
height/sfactor), sd = (int)(
depth/sfactor),
20365 swidth = sw?sw:1, sheight = sh?sh:1, sdepth = sd?sd:1;
20367 I1 =
get_resize(swidth,sheight,sdepth,-100,2),
20368 I2 = target.get_resize(swidth,sheight,sdepth,-100,2);
20369 I1/=factor; I2/=factor;
20371 if (U0) U = (U0*=1.5f).
get_resize(I1.dimx(),I1.dimy(),I1.dimz(),-100,3);
20372 else U.assign(I1.dimx(),I1.dimy(),I1.dimz(),threed?3:2,0);
20378 for (
unsigned int iter = 0; iter<itermax; iter++) {
20384 sgnU = backward?-1.0f:1.0f,
20385 X = (float)(x + sgnU * U(x,
y,
z,0)),
20386 Y = (
float)(
y + sgnU * U(x,
y,
z,1)),
20387 Z = (
float)(
z + sgnU * U(x,
y,
z,2));
20390 Ux = 0.5f*(U(_n1x,
y,
z,
k) - U(_p1x,
y,
z,
k)),
20391 Uy = 0.5f*(U(x,_n1y,
z,
k) - U(x,_p1y,
z,
k)),
20392 Uz = 0.5f*(U(x,
y,_n1z,
k) - U(x,
y,_p1z,
k)),
20393 Uxx = U(_n1x,
y,
z,
k) + U(_p1x,
y,
z,
k) - 2*U(x,
y,
z,
k),
20394 Uyy = U(x,_n1y,
z,
k) + U(x,_p1y,
z,
k) - 2*U(x,
y,
z,
k),
20395 Uzz = U(x,
y,_n1z,
k) + U(x,
y,_n1z,
k) - 2*U(x,
y,
z,
k);
20396 nenergy += (float)(smoothness*(Ux*Ux + Uy*Uy + Uz*Uz));
20399 const Tfloat deltaIi = (float)(backward?I2(x,
y,
z,i)-I1._linear_atXYZ(X,Y,Z,i):I2._linear_atXYZ(X,Y,Z,i)-I1(x,
y,
z,i));
20400 nenergy += (float)(deltaIi*deltaIi/2);
20401 deltaIgrad+=-deltaIi*dI[
k]._linear_atXYZ(X,Y,Z,i);
20403 veloc(x,
y,
z,
k) = deltaIgrad + smoothness*(Uxx + Uyy + Uzz);
20409 sgnU = backward?-1.0f:1.0f,
20410 X = (float)(x + sgnU * U(x,
y,0)),
20411 Y = (
float)(
y + sgnU * U(x,
y,1));
20414 Ux = 0.5f*(U(_n1x,
y,
k) - U(_p1x,
y,
k)),
20415 Uy = 0.5f*(U(x,_n1y,
k) - U(x,_p1y,
k)),
20416 Uxx = U(_n1x,
y,
k) + U(_p1x,
y,
k) - 2*U(x,
y,
k),
20417 Uyy = U(x,_n1y,
k) + U(x,_p1y,
k) - 2*U(x,
y,
k);
20418 nenergy += (float)(smoothness*(Ux*Ux + Uy*Uy));
20421 const Tfloat deltaIi = (float)(backward?I2(x,
y,i)-I1.linear_atXY(X,Y,i):I2._linear_atXY(X,Y,i)-I1(x,
y,i));
20422 nenergy += (float)(deltaIi*deltaIi/2);
20423 deltaIgrad+=-deltaIi*dI[
k]._linear_atXY(X,Y,i);
20425 veloc(x,
y,
k) = deltaIgrad + smoothness*(Uxx + Uyy);
20430 U+=(veloc*=dt/(1e-6+vmax));
20431 if (
cimg::abs(nenergy-energy)<sprecision)
break;
20432 if (nenergy<energy) dt*=0.5f;
20442 const float sizex=1,
const float sizey=1,
const float sizez=1,
20443 const bool compute_sqrt=
true) {
20444 return get_distance(isovalue,sizex,sizey,sizez,compute_sqrt).transfer_to(*
this);
20448 const float sizex=1,
const float sizey=1,
const float sizez=1,
20449 const bool compute_sqrt=
true)
const {
20453 const float maxdist = (float)
std::sqrt((
float)dx*dx +
dy*
dy + dz*dz);
20455 bool is_isophote =
false;
20459 if ((*
this)(0,
y,
z,
k)==isovalue) { is_isophote =
true; res(0,
y,
z,
k) = 0; }
else res(0,
y,
z,
k) = maxdist;
20460 for (
int x = 1; x<
dx; ++
x)
if ((*
this)(x,
y,
z,
k)==isovalue) { is_isophote =
true; res(x,
y,
z,
k) = 0; }
20461 else res(x,
y,
z,
k) = res(x-1,
y,
z,
k) + sizex;
20462 for (
int x = dx-2; x>=0; --
x)
if (res(x+1,
y,
z,
k)<res(x,
y,
z,
k)) res(x,
y,
z,
k) = res(x+1,
y,
z,
k) + sizex;
20469 int q = s[0] = t[0] = 0;
20470 for (
int y = 1;
y<
dy; ++
y) {
20471 const float val = tmp[
y], val2 = val*val;
20473 if (q<0) { q = 0; s[0] =
y; }
20476 if (w<dy) { s[++
q] =
y; t[
q] = w; }
20479 for (
int y = dy - 1;
y>=0; --
y) {
20486 int q = s[0] = t[0] = 0;
20487 for (
int z = 1;
z<dz; ++
z) {
20488 const float val = tmp[
z];
20490 if (q<0) { q = 0; s[0] =
z; }
20492 const int w = 1 +
_distance_sep(s[q],z,(
int)tmp[s[q]],(
int)val,sizez);
20493 if (w<dz) { s[++
q] =
z; t[
q] = w; }
20496 for (
int z = dz - 1;
z>=0; --
z) {
20497 const float val =
_distance_f(
z,s[q],tmp[s[q]],sizez);
20498 res(x,
y,
z,
k) = compute_sqrt?(float)
std::sqrt(val):val;
20504 const T *ptrs =
ptr(x,0,0,
k);
20505 float *ptrd = res.ptr(x,0,0,
k),
d = *ptrd = *ptrs==isovalue?(is_isophote=
true),0:maxdist;
20506 for (
int y = 1;
y<
dy; ++
y) { ptrs+=
width; ptrd+=
width;
d = *ptrd = *ptrs==isovalue?(is_isophote=
true),0:
d+sizey; }
20507 for (
int y = dy - 2;
y>=0; --
y) { ptrd-=
width;
if (
d<*ptrd) *ptrd = (
d+=sizey);
else d = *ptrd; }
20513 float *ptmp = tmp.ptr();
20514 std::memcpy(ptmp,res.ptr(0,
y,0,
k),
sizeof(float)*dx);
20515 int q = s[0] = t[0] = 0;
20516 for (
int x = 1; x<
dx; ++
x) {
20517 const float val = *(++ptmp), val2 = val*val;
20519 if (q<0) { q = 0; s[0] =
x; }
20522 if (w<dx) { q++; s[
q] =
x; t[
q] = w; }
20525 float *pres = res.ptr(0,
y,0,
k) +
width;
20526 for (
int x = dx - 1; x>=0; --
x) {
20528 *(--pres) = compute_sqrt?(
float)
std::sqrt(val):val;
20537 static float _distance_f(
const int x,
const int i,
const float gi2,
const float fact) {
20538 const float xmi = fact*((float)x - i);
20539 return xmi*xmi + gi2;
20541 static int _distance_sep(
const int i,
const int u,
const int gi2,
const int gu2,
const float fact) {
20542 const float fact2 = fact*fact;
20543 return (
int)(fact2*(u*u - i*
i) + gu2 - gi2)/(int)(2*fact2*(u - i));
20550 for (
unsigned int iter = 0; iter<nb_iter; ++iter) {
20556 gx = 0.5f*((
Tfloat)Incc - Ipcc),
20557 gy = 0.5f*((
Tfloat)Icnc - Icpc),
20558 gz = 0.5f*((
Tfloat)Iccn - Iccp),
20560 ix = gx*sgn>0?(
Tfloat)Incc - Iccc:(
Tfloat)Iccc - Ipcc,
20561 iy = gy*sgn>0?(
Tfloat)Icnc - Iccc:(
Tfloat)Iccc - Icpc,
20562 iz = gz*sgn>0?(
Tfloat)Iccn - Iccc:(
Tfloat)Iccc - Iccp,
20567 veloc(x,
y,
z,
k) = sgn*(ngx*ix + ngy*iy + ngz*iz - 1);
20573 gx = 0.5f*((
Tfloat)Inc - Ipc),
20574 gy = 0.5f*((
Tfloat)Icn - Icp),
20581 veloc(x,
y,
k) = sgn*(ngx*ix + ngy*iy - 1);
20585 *
this+=(veloc*=xdt);
20605 if (
is_empty() || !nb_scales)
return *
this;
20608 if (nb_scales==1) {
20611 const unsigned int w =
width/2;
20614 throw CImgInstanceException(
"CImg<%s>::haar() : Sub-image width = %u is not even at a particular scale (=%u).",
20618 for (
unsigned int x = 0, xw = w, x2 = 0; x<w; ++
x, ++xw) {
20620 res(x2++,y,z,
v) = val0 - val1;
20621 res(x2++,y,z,
v) = val0 + val1;
20624 for (
unsigned int x = 0, xw = w, x2 = 0; x<w; ++
x, ++xw) {
20626 res(x,y,z,
v) = (val0 + val1)/2;
20627 res(xw,y,z,
v) = (val1 - val0)/2;
20630 }
else return *
this;
20633 const unsigned int h =
height/2;
20636 throw CImgInstanceException(
"CImg<%s>::haar() : Sub-image height = %u is not even at a particular scale.",
20640 for (
unsigned int y = 0, yh = h, y2 = 0;
y<h; ++
y, ++yh) {
20642 res(x,y2++,z,
v) = val0 - val1;
20643 res(x,y2++,z,
v) = val0 + val1;
20646 for (
unsigned int y = 0, yh = h, y2 = 0;
y<h; ++
y, ++yh) {
20648 res(x,
y,z,
v) = (val0 + val1)/2;
20649 res(x,yh,z,
v) = (val1 - val0)/2;
20652 }
else return *
this;
20655 const unsigned int d =
depth/2;
20658 throw CImgInstanceException(
"CImg<%s>::haar() : Sub-image depth = %u is not even at a particular scale.",
20662 for (
unsigned int z = 0, zd = d, z2 = 0;
z<
d; ++
z, ++zd) {
20664 res(x,y,z2++,
v) = val0 - val1;
20665 res(x,y,z2++,
v) = val0 + val1;
20668 for (
unsigned int z = 0, zd = d, z2 = 0;
z<
d; ++
z, ++zd) {
20670 res(x,y,
z,
v) = (val0 + val1)/2;
20671 res(x,y,zd,
v) = (val1 - val0)/2;
20674 }
else return *
this;
20685 unsigned int w =
width;
20686 for (
unsigned int s=1; w && s<nb_scales; ++
s) w/=2;
20687 for (w=w?w:1; w<=
width; w*=2) res.draw_image(res.get_crop(0,w-1).get_haar(
'x',
true,1));
20690 unsigned int h =
width;
20691 for (
unsigned int s=1; h && s<nb_scales; ++
s) h/=2;
20692 for (h=h?h:1; h<=
height; h*=2) res.draw_image(res.get_crop(0,0,
width-1,h-1).get_haar(
'y',
true,1));
20696 for (
unsigned int s=1; d && s<nb_scales; ++
s) d/=2;
20697 for (d=d?d:1; d<=
depth; d*=2) res.draw_image(res.get_crop(0,0,0,
width-1,
height-1,d-1).get_haar(
'z',
true,1));
20707 for (
unsigned int s=1, w=
width/2; w && s<nb_scales; ++
s, w/=2) res.draw_image(res.get_crop(0,w-1).get_haar(
'x',
false,1));
20710 for (
unsigned int s=1, h=
height/2; h && s<nb_scales; ++
s, h/=2) res.draw_image(res.get_crop(0,0,
width-1,h-1).get_haar(
'y',
false,1));
20713 for (
unsigned int s=1,
d=
depth/2;
d && s<nb_scales; ++
s,
d/=2) res.draw_image(res.get_crop(0,0,0,
width-1,
height-1,
d-1).get_haar(
'z',
false,1));
20736 if (nb_scales==1) {
20740 if (res)
return res;
20747 unsigned int w =
width, h =
height,
d =
depth;
for (
unsigned int s=1; w && h && d && s<nb_scales; ++
s) { w/=2; h/=2; d/=2; }
20748 for (w=w?w:1, h=h?h:1, d=d?d:1; w<=
width && h<=
height && d<=
depth; w*=2, h*=2, d*=2)
20749 res.draw_image(res.get_crop(0,0,0,w-1,h-1,d-1).get_haar(
true,1));
20751 unsigned int w =
width, h =
height;
for (
unsigned int s=1; w && h && s<nb_scales; ++
s) { w/=2; h/=2; }
20752 for (w=w?w:1, h=h?h:1; w<=
width && h<=
height; w*=2, h*=2)
20753 res.draw_image(res.get_crop(0,0,0,w-1,h-1,0).get_haar(
true,1));
20757 unsigned int w =
width,
d =
depth;
for (
unsigned int s=1; w && d && s<nb_scales; ++
s) { w/=2; d/=2; }
20758 for (w=w?w:1, d=d?d:1; w<=
width && d<=
depth; w*=2, d*=2)
20759 res.draw_image(res.get_crop(0,0,0,w-1,0,d-1).get_haar(
true,1));
20761 unsigned int w =
width;
for (
unsigned int s=1; w && s<nb_scales; ++
s) w/=2;
20762 for (w=w?w:1; w<=
width; w*=2)
20763 res.draw_image(res.get_crop(0,0,0,w-1,0,0).get_haar(
true,1));
20769 unsigned int h =
height,
d =
depth;
for (
unsigned int s=1; h && d && s<nb_scales; ++
s) { h/=2; d/=2; }
20770 for (h=h?h:1, d=d?d:1; h<=
height && d<=
depth; h*=2, d*=2)
20771 res.draw_image(res.get_crop(0,0,0,0,h-1,d-1).get_haar(
true,1));
20773 unsigned int h =
height;
for (
unsigned int s=1; h && s<nb_scales; ++
s) h/=2;
20774 for (h=h?h:1; h<=
height; h*=2)
20775 res.draw_image(res.get_crop(0,0,0,0,h-1,0).get_haar(
true,1));
20779 unsigned int d =
depth;
for (
unsigned int s=1; d && s<nb_scales; ++
s) d/=2;
20780 for (d=d?d:1; d<=
depth; d*=2)
20781 res.draw_image(res.get_crop(0,0,0,0,0,d-1).get_haar(
true,1));
20782 }
else return *
this;
20789 if (
depth>1)
for (
unsigned int s=1, w=
width/2, h=
height/2,
d=
depth/2; w && h &&
d && s<nb_scales; ++
s, w/=2, h/=2,
d/=2)
20790 res.draw_image(res.get_crop(0,0,0,w-1,h-1,
d-1).haar(
false,1));
20791 else for (
unsigned int s=1, w=
width/2, h=
height/2; w && h && s<nb_scales; ++
s, w/=2, h/=2)
20792 res.draw_image(res.get_crop(0,0,0,w-1,h-1,0).haar(
false,1));
20794 if (
depth>1)
for (
unsigned int s=1, w=
width/2,
d=
depth/2; w &&
d && s<nb_scales; ++
s, w/=2,
d/=2)
20795 res.draw_image(res.get_crop(0,0,0,w-1,0,
d-1).haar(
false,1));
20796 else for (
unsigned int s=1, w=
width/2; w && s<nb_scales; ++
s, w/=2)
20797 res.draw_image(res.get_crop(0,0,0,w-1,0,0).haar(
false,1));
20801 if (
depth>1)
for (
unsigned int s=1, h=
height/2,
d=
depth/2; h &&
d && s<nb_scales; ++
s, h/=2,
d/=2)
20802 res.draw_image(res.get_crop(0,0,0,0,h-1,
d-1).haar(
false,1));
20803 else for (
unsigned int s=1, h=
height/2; h && s<nb_scales; ++
s, h/=2)
20804 res.draw_image(res.get_crop(0,0,0,0,h-1,0).haar(
false,1));
20806 if (
depth>1)
for (
unsigned int s=1,
d=
depth/2;
d && s<nb_scales; ++
s,
d/=2)
20807 res.draw_image(res.get_crop(0,0,0,0,0,
d-1).haar(
false,1));
20834 if (!imag) imag.assign(real.width,real.height,real.depth,real.dim,0);
20835 if (!real.is_sameXYZV(imag))
20836 throw CImgInstanceException(
"CImg<%s>::FFT() : Real image (%u,%u,%u,%u,%p) and imaginary image (%u,%u,%u,%u,%p) "
20837 "have different dimensions",
20838 pixel_type(),real.width,real.height,real.depth,real.dim,real.data,
20839 imag.width,imag.height,imag.depth,imag.dim,imag.data);
20840 #ifdef cimg_use_fftw3
20841 fftw_complex *data_in;
20842 fftw_plan data_plan;
20846 data_in = (fftw_complex*)fftw_malloc(
sizeof(fftw_complex)*real.width);
20847 data_plan = fftw_plan_dft_1d(real.width,data_in,data_in,
invert?FFTW_BACKWARD:FFTW_FORWARD,FFTW_ESTIMATE);
20849 T *ptrr = real.ptr(0,
y,
z,
k), *ptri = imag.ptr(0,
y,
z,
k);
20850 double *ptrd = (
double*)data_in;
20851 cimg_forX(real,x) { *(ptrd++) = (
double)*(ptrr++); *(ptrd++) = (
double)*(ptri++); }
20852 fftw_execute(data_plan);
20853 const unsigned int fact = real.width;
20854 if (
invert)
cimg_forX(real,x) { *(--ptri) = (T)(*(--ptrd)/fact); *(--ptrr) = (T)(*(--ptrd)/fact); }
20855 else cimg_forX(real,x) { *(--ptri) = (T)*(--ptrd); *(--ptrr) = (T)*(--ptrd); }
20859 data_in = (fftw_complex*)fftw_malloc(
sizeof(fftw_complex) * real.height);
20860 data_plan = fftw_plan_dft_1d(real.height,data_in,data_in,
invert?FFTW_BACKWARD:FFTW_FORWARD,FFTW_ESTIMATE);
20861 const unsigned int off = real.width;
20863 T *ptrr = real.ptr(x,0,
z,
k), *ptri = imag.ptr(x,0,
z,
k);
20864 double *ptrd = (
double*)data_in;
20865 cimg_forY(real,
y) { *(ptrd++) = (
double)*ptrr; *(ptrd++) = (
double)*ptri; ptrr+=off; ptri+=off; }
20866 fftw_execute(data_plan);
20867 const unsigned int fact = real.height;
20868 if (
invert)
cimg_forY(real,
y) { ptrr-=off; ptri-=off; *ptri = (T)(*(--ptrd)/fact); *ptrr = (T)(*(--ptrd)/fact); }
20869 else cimg_forY(real,
y) { ptrr-=off; ptri-=off; *ptri = (T)*(--ptrd); *ptrr = (T)*(--ptrd); }
20873 data_in = (fftw_complex*)fftw_malloc(
sizeof(fftw_complex) * real.depth);
20874 data_plan = fftw_plan_dft_1d(real.depth,data_in,data_in,
invert?FFTW_BACKWARD:FFTW_FORWARD,FFTW_ESTIMATE);
20875 const unsigned int off = real.width*real.height;
20877 T *ptrr = real.ptr(x,
y,0,
k), *ptri = imag.ptr(x,
y,0,
k);
20878 double *ptrd = (
double*)data_in;
20879 cimg_forZ(real,
z) { *(ptrd++) = (
double)*ptrr; *(ptrd++) = (
double)*ptri; ptrr+=off; ptri+=off; }
20880 fftw_execute(data_plan);
20881 const unsigned int fact = real.depth;
20882 if (
invert)
cimg_forZ(real,
z) { ptrr-=off; ptri-=off; *ptri = (T)(*(--ptrd)/fact); *ptrr = (T)(*(--ptrd)/fact); }
20883 else cimg_forZ(real,
z) { ptrr-=off; ptri-=off; *ptri = (T)*(--ptrd); *ptrr = (T)*(--ptrd); }
20887 data_in = (fftw_complex*)fftw_malloc(
sizeof(fftw_complex) * real.dim);
20888 data_plan = fftw_plan_dft_1d(real.dim,data_in,data_in,
invert?FFTW_BACKWARD:FFTW_FORWARD,FFTW_ESTIMATE);
20889 const unsigned int off = real.width*real.height*real.depth;
20891 T *ptrr = real.ptr(x,
y,
z,0), *ptri = imag.ptr(x,
y,
z,0);
20892 double *ptrd = (
double*)data_in;
20893 cimg_forV(real,
k) { *(ptrd++) = (
double)*ptrr; *(ptrd++) = (
double)*ptri; ptrr+=off; ptri+=off; }
20894 fftw_execute(data_plan);
20895 const unsigned int fact = real.dim;
20896 if (
invert)
cimg_forV(real,
k) { ptrr-=off; ptri-=off; *ptri = (T)(*(--ptrd)/fact); *ptrr = (T)(*(--ptrd)/fact); }
20897 else cimg_forV(real,
k) { ptrr-=off; ptri-=off; *ptri = (T)*(--ptrd); *ptrr = (T)*(--ptrd); }
20901 fftw_destroy_plan(data_plan);
20902 fftw_free(data_in);
20906 const unsigned int N = real.width, N2 = (N>>1);
20907 if (((N-1)&N) && N!=1)
20908 throw CImgInstanceException(
"CImgList<%s>::FFT() : Dimension of instance image along 'x' is %d != 2^N",
20910 for (
unsigned int i = 0,
j = 0; i<N2; ++
i) {
20911 if (
j>i)
cimg_forYZV(real,
y,
z,
v) {
cimg::swap(
real(i,
y,
z,
v),
real(
j,
y,
z,
v));
cimg::swap(imag(i,
y,
z,
v),imag(
j,
y,
z,
v));
20913 const unsigned int ri = N-1-
i, rj = N-1-
j;
20914 cimg::swap(
real(ri,
y,
z,
v),
real(rj,
y,
z,
v));
cimg::swap(imag(ri,
y,
z,
v),imag(rj,
y,
z,
v));
20916 for (
unsigned int m = N,
n = N2; (
j+=
n)>=m;
j-=m, m =
n,
n>>=1) {}
20918 for (
unsigned int delta = 2; delta<=N; delta<<=1) {
20919 const unsigned int delta2 = (delta>>1);
20920 for (
unsigned int i = 0; i<N; i+=delta) {
20921 float wr = 1, wi = 0;
20925 for (
unsigned int k = 0;
k<delta2; ++
k) {
20926 const unsigned int j = i +
k,
nj = j + delta2;
20928 T &ir =
real(j,
y,
z,k), &ii = imag(j,
y,
z,k), &nir =
real(nj,
y,
z,k), &nii = imag(nj,
y,
z,k);
20929 const float tmpr = (float)(wr*nir - wi*nii), tmpi = (float)(wr*nii + wi*nir);
20930 nir = (T)(ir - tmpr);
20931 nii = (T)(ii - tmpi);
20935 const float nwr = wr*ca-wi*sa;
20936 wi = wi*ca + wr*sa;
20941 if (
invert) { real/=N; imag/=N; }
20944 const unsigned int N = real.height, N2 = (N>>1);
20945 if (((N-1)&N) && N!=1)
20946 throw CImgInstanceException(
"CImgList<%s>::FFT() : Dimension of instance image(s) along 'y' is %d != 2^N",
20948 for (
unsigned int i = 0,
j = 0; i<N2; ++
i) {
20949 if (
j>i)
cimg_forXZV(real,x,
z,
v) {
cimg::swap(
real(x,i,
z,
v),
real(x,
j,
z,
v));
cimg::swap(imag(x,i,
z,
v),imag(x,
j,
z,
v));
20951 const unsigned int ri = N-1-
i, rj = N-1-
j;
20952 cimg::swap(
real(x,ri,
z,
v),
real(x,rj,
z,
v));
cimg::swap(imag(x,ri,
z,
v),imag(x,rj,
z,
v));
20954 for (
unsigned int m = N,
n = N2; (
j+=
n)>=m;
j-=m, m =
n,
n>>=1) {}
20956 for (
unsigned int delta = 2; delta<=N; delta<<=1) {
20957 const unsigned int delta2 = (delta>>1);
20958 for (
unsigned int i = 0; i<N; i+=delta) {
20959 float wr = 1, wi = 0;
20962 for (
unsigned int k = 0;
k<delta2; ++
k) {
20963 const unsigned int j = i +
k,
nj = j + delta2;
20965 T &ir =
real(x,j,
z,k), &ii = imag(x,j,
z,k), &nir =
real(x,nj,
z,k), &nii = imag(x,nj,
z,k);
20966 const float tmpr = (float)(wr*nir - wi*nii), tmpi = (float)(wr*nii + wi*nir);
20967 nir = (T)(ir - tmpr);
20968 nii = (T)(ii - tmpi);
20972 const float nwr = wr*ca-wi*sa;
20973 wi = wi*ca + wr*sa;
20978 if (
invert) { real/=N; imag/=N; }
20981 const unsigned int N = real.depth, N2 = (N>>1);
20982 if (((N-1)&N) && N!=1)
20983 throw CImgInstanceException(
"CImgList<%s>::FFT() : Dimension of instance image(s) along 'z' is %d != 2^N",
20985 for (
unsigned int i = 0,
j = 0; i<N2; ++
i) {
20986 if (
j>i)
cimg_forXYV(real,x,
y,
v) {
cimg::swap(
real(x,
y,i,
v),
real(x,
y,
j,
v));
cimg::swap(imag(x,
y,i,
v),imag(x,
y,
j,
v));
20988 const unsigned int ri = N-1-
i, rj = N-1-
j;
20989 cimg::swap(
real(x,
y,ri,
v),
real(x,
y,rj,
v));
cimg::swap(imag(x,
y,ri,
v),imag(x,
y,rj,
v));
20991 for (
unsigned int m = N,
n = N2; (
j+=
n)>=m;
j-=m, m =
n,
n>>=1) {}
20993 for (
unsigned int delta = 2; delta<=N; delta<<=1) {
20994 const unsigned int delta2 = (delta>>1);
20995 for (
unsigned int i = 0; i<N; i+=delta) {
20996 float wr = 1, wi = 0;
20999 for (
unsigned int k = 0;
k<delta2; ++
k) {
21000 const unsigned int j = i +
k,
nj = j + delta2;
21002 T &ir =
real(x,
y,j,k), &ii = imag(x,
y,j,k), &nir =
real(x,
y,nj,k), &nii = imag(x,
y,nj,k);
21003 const float tmpr = (float)(wr*nir - wi*nii), tmpi = (float)(wr*nii + wi*nir);
21004 nir = (T)(ir - tmpr);
21005 nii = (T)(ii - tmpi);
21009 const float nwr = wr*ca-wi*sa;
21010 wi = wi*ca + wr*sa;
21015 if (
invert) { real/=N; imag/=N; }
21026 if (!imag) imag.assign(real.width,real.height,real.depth,real.dim,0);
21027 if (!real.is_sameXYZV(imag))
21028 throw CImgInstanceException(
"CImgList<%s>::FFT() : Real image (%u,%u,%u,%u,%p) and imaginary image (%u,%u,%u,%u,%p) "
21029 "have different dimensions",
21030 pixel_type(),real.width,real.height,real.depth,real.dim,real.data,
21031 imag.width,imag.height,imag.depth,imag.dim,imag.data);
21032 #ifdef cimg_use_fftw3
21033 fftw_complex *data_in = (fftw_complex*)fftw_malloc(
sizeof(fftw_complex)*real.width*real.height*real.depth);
21034 fftw_plan data_plan;
21035 const unsigned int w = real.width, wh = w*real.height, whd = wh*real.depth;
21036 data_plan = fftw_plan_dft_3d(real.width,real.height,real.depth,data_in,data_in,
invert?FFTW_BACKWARD:FFTW_FORWARD,FFTW_ESTIMATE);
21038 T *ptrr = real.ptr(0,0,0,
k), *ptri = imag.ptr(0,0,0,
k);
21039 double *ptrd = (
double*)data_in;
21040 for (
unsigned int x = 0; x<real.width; ++
x, ptrr-=wh-1, ptri-=wh-1)
21041 for (
unsigned int y = 0;
y<real.height; ++
y, ptrr-=whd-w, ptri-=whd-w)
21042 for (
unsigned int z = 0;
z<real.depth; ++
z, ptrr+=wh, ptri+=wh) {
21043 *(ptrd++) = (
double)*ptrr; *(ptrd++) = (
double)*ptri;
21045 fftw_execute(data_plan);
21046 ptrd = (
double*)data_in;
21047 ptrr = real.ptr(0,0,0,
k);
21048 ptri = imag.ptr(0,0,0,
k);
21049 if (!
invert)
for (
unsigned int x = 0; x<real.width; ++
x, ptrr-=wh-1, ptri-=wh-1)
21050 for (
unsigned int y = 0;
y<real.height; ++
y, ptrr-=whd-w, ptri-=whd-w)
21051 for (
unsigned int z = 0;
z<real.depth; ++
z, ptrr+=wh, ptri+=wh) {
21052 *ptrr = (T)*(ptrd++); *ptri = (T)*(ptrd++);
21054 else for (
unsigned int x = 0; x<real.width; ++
x, ptrr-=wh-1, ptri-=wh-1)
21055 for (
unsigned int y = 0;
y<real.height; ++
y, ptrr-=whd-w, ptri-=whd-w)
21056 for (
unsigned int z = 0;
z<real.depth; ++
z, ptrr+=wh, ptri+=wh) {
21057 *ptrr = (T)(*(ptrd++)/whd); *ptri = (T)(*(ptrd++)/whd);
21060 fftw_destroy_plan(data_plan);
21061 fftw_free(data_in);
21063 if (real.depth>1)
FFT(real,imag,
'z',
invert);
21064 if (real.height>1)
FFT(real,imag,
'y',
invert);
21065 if (real.width>1)
FFT(real,imag,
'x',
invert);
21080 throw CImgInstanceException(
"CImg<%s>::translate_object3d() : Instance image (%u,%u,%u,%u,%p) is not a set of 3D vertices.",
21094 throw CImgInstanceException(
"CImg<%s>::translate_object3d() : Instance image (%u,%u,%u,%u,%p) is not a set of 3D vertices.",
21097 float xm, xM = (float)xcoords.maxmin(xm), ym, yM = (float)ycoords.maxmin(ym), zm, zM = (float)zcoords.maxmin(zm);
21098 xcoords-=(xm + xM)/2; ycoords-=(ym + yM)/2; zcoords-=(zm + zM)/2;
21110 throw CImgInstanceException(
"CImg<%s>::resize_object3d() : Instance image (%u,%u,%u,%u,%p) is not a set of 3D vertices.",
21113 float xm, xM = (float)xcoords.maxmin(xm), ym, yM = (float)ycoords.maxmin(ym), zm, zM = (float)zcoords.maxmin(zm);
21114 if (xm<xM) {
if (sx>0) xcoords*=sx/(xM-xm);
else xcoords*=-sx/100; }
21115 if (ym<yM) {
if (sy>0) ycoords*=sy/(yM-ym);
else ycoords*=-sy/100; }
21116 if (zm<zM) {
if (sz>0) zcoords*=sz/(zM-zm);
else zcoords*=-sz/100; }
21128 throw CImgInstanceException(
"CImg<%s>::resize_object3d() : Instance image (%u,%u,%u,%u,%p) is not a set of 3D vertices.",
21131 float xm, xM = (float)xcoords.maxmin(xm), ym, yM = (float)ycoords.maxmin(ym), zm, zM = (float)zcoords.maxmin(zm);
21132 const float dx = xM - xm,
dy = yM - ym, dz = zM - zm, dmax =
cimg::max(dx,dy,dz);
21133 if (dmax>0) { xcoords/=dmax; ycoords/=dmax; zcoords/=dmax; }
21142 template<
typename tf,
typename tp,
typename tff>
21144 if (!obj_vertices || !obj_primitives)
return *
this;
21145 if (obj_vertices.height!=3 || obj_vertices.depth>1 || obj_vertices.dim>1)
21146 throw CImgInstanceException(
"CImg<%s>::append_object3d() : Vertice image argument (%u,%u,%u,%u,%p) is not a set of 3D vertices.",
21147 pixel_type(),obj_vertices.width,obj_vertices.height,obj_vertices.depth,obj_vertices.dim,obj_vertices.data);
21150 throw CImgInstanceException(
"CImg<%s>::append_object3d() : Instance image (%u,%u,%u,%u,%p) is not a set of 3D vertices.",
21152 const unsigned int P =
width;
21153 append(obj_vertices,
'x');
21154 const unsigned int N = primitives.
width;
21155 primitives.
insert(obj_primitives);
21156 for (
unsigned int i = N; i<primitives.
width; ++
i) {
21158 switch (p.size()) {
21159 case 1 : p[0]+=P;
break;
21160 case 5 : p[0]+=P;
if (!p[2]) p[1]+=P;
break;
21161 case 2 :
case 6 : p[0]+=P; p[1]+=P;
break;
21162 case 3 :
case 9 : p[0]+=P; p[1]+=P; p[2]+=P;
break;
21163 case 4 :
case 12 : p[0]+=P; p[1]+=P; p[2]+=P; p[3]+=P;
break;
21186 template<
typename tf,
typename tc,
typename te>
21189 if (!
is_sameXY(elevation) || elevation.depth>1 || elevation.dim>1)
21190 throw CImgArgumentException(
"CImg<%s>::get_elevation3d() : Elevation image (%u,%u,%u,%u,%p) and instance image (%u,%u,%u,%u,%p) "
21192 elevation.width,elevation.height,elevation.depth,elevation.dim,elevation.data,
21194 float m, M = (float)
maxmin(m);
21197 const unsigned int size_x1 =
width - 1, size_y1 =
height - 1;
21198 for (
unsigned int y = 0;
y<size_y1; ++
y)
21199 for (
unsigned int x = 0; x<size_x1; x++) {
21200 const unsigned char
21201 r = (
unsigned char)(((*
this)(x,
y,0) - m)*255/(M-m)),
21202 g = dim>1?(
unsigned char)(((*
this)(
x,
y,1) - m)*255/(M-m)):r,
21203 b = dim>2?(
unsigned char)(((*
this)(x,y,2) - m)*255/(M-m)):(dim>1?0:r);
21227 template<
typename tf>
21229 const float isovalue,
const int size_x=-100,
const int size_y=-100)
const {
21231 throw CImgInstanceException(
"CImg<%s>::get_isocurve3d() : Instance image (%u,%u,%u,%u,%p) is not scalar.",
21236 if ((size_x==-100 && size_y==-100) || (size_x==
dimx() && size_y==
dimy())) {
21237 const _marching2d_func func(*
this);
21238 vertices =
isocurve3d(primitives,func,isovalue,0,0,
dimx()-1.0f,
dimy()-1.0f,size_x,size_y);
21240 const _marching2d_func_float func(*
this);
21241 vertices =
isocurve3d(primitives,func,isovalue,0,0,
dimx()-1.0f,
dimy()-1.0f,size_x,size_y);
21263 template<
typename tf>
21265 const int size_x=-100,
const int size_y=-100,
const int size_z=-100)
const {
21267 throw CImgInstanceException(
"CImg<%s>::get_isosurface3d() : Instance image (%u,%u,%u,%u,%p) is not scalar.",
21272 if ((size_x==-100 && size_y==-100 && size_z==-100) || (size_x==
dimx() && size_y==
dimy() && size_z==
dimz())) {
21273 const _marching3d_func func(*
this);
21274 vertices =
isosurface3d(primitives,func,isovalue,0,0,0,
dimx()-1.0f,
dimy()-1.0f,
dimz()-1.0f,size_x,size_y,size_z);
21276 const _marching3d_func_float func(*
this);
21277 vertices =
isosurface3d(primitives,func,isovalue,0,0,0,
dimx()-1.0f,
dimy()-1.0f,
dimz()-1.0f,size_x,size_y,size_z);
21283 template<
typename tf,
typename tfunc>
21285 const float x0,
const float y0,
const float x1,
const float y1,
21286 const int size_x=256,
const int size_y=256) {
21288 nx0 = x0<x1?x0:x1, ny0 = y0<y1?y0:y1,
21289 nx1 = x0<x1?x1:x0, ny1 = y0<y1?y1:y0;
21291 _nsize_x = (
unsigned int)(size_x>=0?size_x:(nx1-nx0)*-size_x/100), nsize_x = _nsize_x?_nsize_x:1, nsize_x1 = nsize_x - 1,
21292 _nsize_y = (
unsigned int)(size_y>=0?size_y:(ny1-ny0)*-size_y/100), nsize_y = _nsize_y?_nsize_y:1, nsize_y1 = nsize_y - 1;
21293 if (nsize_x<2 || nsize_y<2)
21297 floatT *ptr_x = vertices.ptr(0,0), *ptr_y = vertices.ptr(0,1), *ptr_z = vertices.ptr(0,2);
21298 for (
unsigned int y = 0;
y<nsize_y; ++
y) {
21299 const float Y = ny0 +
y*(ny1-ny0)/nsize_y1;
21300 for (
unsigned int x = 0; x<nsize_x; ++
x) {
21301 const float X = nx0 + x*(nx1-nx0)/nsize_x1;
21302 *(ptr_x++) = (
float)
x;
21303 *(ptr_y++) = (
float)
y;
21304 *(ptr_z++) = (
float)func(X,Y);
21307 primitives.
assign(nsize_x1*nsize_y1,1,4);
21308 for (
unsigned int p = 0,
y = 0;
y<nsize_y1; ++
y) {
21309 const unsigned int yw =
y*nsize_x;
21310 for (
unsigned int x = 0; x<nsize_x1; ++
x) {
21311 const unsigned int xpyw = x + yw, xpyww = xpyw + nsize_x;
21312 primitives[p++].fill(xpyw,xpyww,xpyww+1,xpyw+1);
21318 template<
typename tf>
21320 const float x0,
const float y0,
const float x1,
const float y1,
21321 const int sizex=256,
const int sizey=256) {
21322 const _marching2d_func_expr func(expression);
21323 return elevation3d(primitives,func,x0,y0,x1,y1,sizex,sizey);
21327 template<
typename tf,
typename tfunc>
21329 const float x0,
const float y0,
const float x1,
const float y1,
21330 const int sizex=256,
const int sizey=256) {
21331 static const unsigned int edges[16] = { 0x0, 0x9, 0x3, 0xa, 0x6, 0xf, 0x5, 0xc, 0xc, 0x5, 0xf, 0x6, 0xa, 0x3, 0x9, 0x0 };
21332 static const int segments[16][4] = { { -1,-1,-1,-1 }, { 0,3,-1,-1 }, { 0,1,-1,-1 }, { 1,3,-1,-1 },
21333 { 1,2,-1,-1 }, { 0,1,2,3 }, { 0,2,-1,-1 }, { 2,3,-1,-1 },
21334 { 2,3,-1,-1 }, { 0,2,-1,-1}, { 0,3,1,2 }, { 1,2,-1,-1 },
21335 { 1,3,-1,-1 }, { 0,1,-1,-1}, { 0,3,-1,-1}, { -1,-1,-1,-1 } };
21337 _nx = (
unsigned int)(sizex>=0?sizex:((x1-x0)*-sizex/100 + 1)),
21338 _ny = (
unsigned int)(sizey>=0?sizey:((y1-y0)*-sizey/100 + 1)),
21345 const float dx = (x1 - x0)/nxm1,
dy = (y1 - y0)/nym1;
21347 CImg<intT> indices1(nx,1,1,2,-1), indices2(nx,1,1,2);
21349 float X = x0, Y = y0, nX = X +
dx, nY = Y +
dy;
21352 cimg_forX(values1,x) { values1(x) = (float)func(X,Y); X+=
dx; }
21355 for (
unsigned int yi = 0, nyi = 1; yi<nym1; ++yi, ++nyi, Y=nY, nY+=
dy) {
21356 X = x0; nX = X +
dx;
21358 for (
unsigned int xi = 0, nxi = 1; xi<nxm1; ++xi, ++nxi, X=nX, nX+=
dx) {
21362 val0 = values1(xi),
21363 val1 = values1(nxi),
21364 val2 = values2(nxi) = (float)func(nX,nY),
21365 val3 = values2(xi) = (float)func(X,nY);
21367 configuration = (val0<isovalue?1:0) | (val1<isovalue?2:0) | (val2<isovalue?4:0) | (val3<isovalue?8:0),
21368 edge = edges[configuration];
21372 if ((edge&1) && indices1(xi,0)<0) {
21373 const float Xi = X + (isovalue-val0)*dx/(val1-val0);
21374 indices1(xi,0) = vertices.
width;
21377 if ((edge&2) && indices1(nxi,1)<0) {
21378 const float Yi = Y + (isovalue-val1)*dy/(val2-val1);
21379 indices1(nxi,1) = vertices.
width;
21382 if ((edge&4) && indices2(xi,0)<0) {
21383 const float Xi = X + (isovalue-val3)*dx/(val2-val3);
21384 indices2(xi,0) = vertices.
width;
21387 if ((edge&8) && indices1(xi,1)<0) {
21388 const float Yi = Y + (isovalue-val0)*dy/(val3-val0);
21389 indices1(xi,1) = vertices.
width;
21394 for (
const int *segment = segments[configuration]; *segment!=-1; ) {
21395 const unsigned int p0 = *(segment++),
p1 = *(segment++);
21403 values1.swap(values2);
21404 indices1.swap(indices2);
21406 return vertices>
'x';
21409 template<
typename tf>
21411 const float x0,
const float y0,
const float x1,
const float y1,
21412 const int sizex=256,
const int sizey=256) {
21413 const _marching2d_func_expr func(expression);
21414 return isocurve3d(primitives,func,isovalue,x0,y0,x1,y1,sizex,sizey);
21417 template<
typename t>
21419 const unsigned int x,
const unsigned int nx) {
21421 case 0 :
return (
int)indices1(x,0);
21422 case 1 :
return (
int)indices1(nx,1);
21423 case 2 :
return (
int)indices2(x,0);
21424 case 3 :
return (
int)indices1(x,1);
21433 return (
float)
ref((
int)x,(
int)y);
21441 return (
float)
ref._linear_atXY(x,y);
21451 return (
float)
mp->
eval(x,y,0,0);
21459 template<
typename tf,
typename tfunc>
21461 const float x0,
const float y0,
const float z0,
21462 const float x1,
const float y1,
const float z1,
21463 const int size_x=32,
const int size_y=32,
const int size_z=32) {
21464 static unsigned int edges[256] = {
21465 0x000, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c, 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,
21466 0x190, 0x99 , 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c, 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,
21467 0x230, 0x339, 0x33 , 0x13a, 0x636, 0x73f, 0x435, 0x53c, 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,
21468 0x3a0, 0x2a9, 0x1a3, 0xaa , 0x7a6, 0x6af, 0x5a5, 0x4ac, 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,
21469 0x460, 0x569, 0x663, 0x76a, 0x66 , 0x16f, 0x265, 0x36c, 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,
21470 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff , 0x3f5, 0x2fc, 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,
21471 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55 , 0x15c, 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,
21472 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc , 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,
21473 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc, 0xcc , 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,
21474 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c, 0x15c, 0x55 , 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,
21475 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc, 0x2fc, 0x3f5, 0xff , 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,
21476 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c, 0x36c, 0x265, 0x16f, 0x66 , 0x76a, 0x663, 0x569, 0x460,
21477 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac, 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa , 0x1a3, 0x2a9, 0x3a0,
21478 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c, 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33 , 0x339, 0x230,
21479 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c, 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99 , 0x190,
21480 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c, 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x000 };
21482 static int triangles[256][16] =
21483 {{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21484 { 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21485 { 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21486 { 9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1 },
21487 { 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21488 { 1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1 },
21489 { 3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1 },
21490 { 3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1 }, { 9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21491 { 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21492 { 0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1 },
21493 { 1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1 },
21494 { 9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1 }, { 2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1 },
21495 { 8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1 },
21496 { 9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1 }, { 4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1 },
21497 { 3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1 }, { 1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1 },
21498 { 4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1 }, { 4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1 },
21499 { 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21500 { 0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1 },
21501 { 1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1 },
21502 { 5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1 }, { 2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1 },
21503 { 9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1 },
21504 { 0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1 }, { 2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1 },
21505 { 10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1 }, { 4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1 },
21506 { 5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1 }, { 5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1 },
21507 { 9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1 },
21508 { 0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1 }, { 1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21509 { 9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1 }, { 10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1 },
21510 { 8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1 }, { 2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1 },
21511 { 7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1 }, { 9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1 },
21512 { 2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1 }, { 11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1 },
21513 { 9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1 }, { 5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1 },
21514 { 11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1 }, { 11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21515 { 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21516 { 9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1 },
21517 { 1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1 },
21518 { 9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1 }, { 5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1 },
21519 { 2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1 },
21520 { 0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1 }, { 5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1 },
21521 { 6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1 }, { 0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1 },
21522 { 3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1 }, { 6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1 },
21523 { 5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1 },
21524 { 1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1 }, { 10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1 },
21525 { 6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1 }, { 1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1 },
21526 { 8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1 }, { 7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1 },
21527 { 3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1 }, { 5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1 },
21528 { 0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1 }, { 9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1 },
21529 { 8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1 }, { 5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1 },
21530 { 0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1 }, { 6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1 },
21531 { 10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1 },
21532 { 10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1 }, { 8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1 },
21533 { 1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1 }, { 3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1 },
21534 { 0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1 },
21535 { 10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1 }, { 0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1 },
21536 { 3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1 }, { 6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1 },
21537 { 9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1 }, { 8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1 },
21538 { 3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1 }, { 6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21539 { 7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1 }, { 0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1 },
21540 { 10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1 }, { 10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1 },
21541 { 1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1 }, { 2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1 },
21542 { 7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1 }, { 7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21543 { 2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1 }, { 2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1 },
21544 { 1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1 }, { 11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1 },
21545 { 8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1 }, { 0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21546 { 7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1 }, { 7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21547 { 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21548 { 0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1 },
21549 { 10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1 },
21550 { 2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1 }, { 6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1 },
21551 { 7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1 },
21552 { 2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1 }, { 1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1 },
21553 { 10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1 }, { 10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1 },
21554 { 0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1 }, { 7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1 },
21555 { 6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1 },
21556 { 8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1 }, { 9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1 },
21557 { 6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1 }, { 1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1 },
21558 { 4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1 }, { 10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1 },
21559 { 8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1 }, { 0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21560 { 1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1 }, { 1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1 },
21561 { 8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1 }, { 10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1 },
21562 { 4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1 }, { 10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21563 { 4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1 },
21564 { 5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1 }, { 11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1 },
21565 { 9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1 }, { 6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1 },
21566 { 7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1 }, { 3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1 },
21567 { 7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1 }, { 9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1 },
21568 { 3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1 }, { 6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1 },
21569 { 9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1 }, { 1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1 },
21570 { 4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1 }, { 7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1 },
21571 { 6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1 }, { 3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1 },
21572 { 0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1 }, { 6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1 },
21573 { 1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1 }, { 0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1 },
21574 { 11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1 }, { 6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1 },
21575 { 5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1 }, { 9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1 },
21576 { 1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1 }, { 1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21577 { 1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1 }, { 10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1 },
21578 { 0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21579 { 11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1 },
21580 { 5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1 }, { 10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1 },
21581 { 11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1 },
21582 { 9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1 }, { 7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1 },
21583 { 2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1 }, { 8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1 },
21584 { 9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1 }, { 9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1 },
21585 { 1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1 },
21586 { 9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1 }, { 9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21587 { 5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1 }, { 5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1 },
21588 { 0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1 }, { 10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1 },
21589 { 2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1 }, { 0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1 },
21590 { 0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1 }, { 9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21591 { 2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1 }, { 5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1 },
21592 { 3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1 }, { 5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1 },
21593 { 8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21594 { 8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1 }, { 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21595 { 4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1 }, { 0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1 },
21596 { 1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1 }, { 3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1 },
21597 { 4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1 }, { 9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1 },
21598 { 11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1 }, { 11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1 },
21599 { 2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1 }, { 9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1 },
21600 { 3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1 }, { 1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21601 { 4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1 }, { 4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1 },
21602 { 4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21603 { 9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1 },
21604 { 0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1 }, { 3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21605 { 1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1 }, { 3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1 },
21606 { 0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21607 { 2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1 }, { 9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21608 { 2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1 }, { 1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21609 { 1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21610 { 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }};
21613 _nx = (
unsigned int)(size_x>=0?size_x:((x1-x0)*-size_x/100 + 1)),
21614 _ny = (
unsigned int)(size_y>=0?size_y:((y1-y0)*-size_y/100 + 1)),
21615 _nz = (
unsigned int)(size_z>=0?size_y:((z1-z0)*-size_z/100 + 1)),
21624 const float dx = (x1 - x0)/nxm1,
dy = (y1 - y0)/nym1, dz = (z1 - z0)/nzm1;
21626 CImg<intT> indices1(nx,ny,1,3,-1), indices2(indices1);
21628 float X = 0, Y = 0, Z = 0, nX = 0, nY = 0, nZ = 0;
21634 cimg_forX(values1,x) { values1(x,
y) = (float)func(X,Y,z0); X+=
dx; }
21639 Z = z0; nZ = Z + dz;
21640 for (
unsigned int zi = 0; zi<nzm1; ++zi, Z = nZ, nZ+=dz) {
21641 Y = y0; nY = Y +
dy;
21643 for (
unsigned int yi = 0, nyi = 1; yi<nym1; ++yi, ++nyi, Y = nY, nY+=
dy) {
21644 X = x0; nX = X +
dx;
21645 for (
unsigned int xi = 0, nxi = 1; xi<nxm1; ++xi, ++nxi, X = nX, nX+=
dx) {
21649 val0 = values1(xi,yi),
21650 val1 = values1(nxi,yi),
21651 val2 = values1(nxi,nyi),
21652 val3 = values1(xi,nyi),
21653 val4 = values2(xi,yi) = (float)func(X,Y,nZ),
21654 val5 = values2(nxi,yi) = (float)func(nX,Y,nZ),
21655 val6 = values2(nxi,nyi) = (float)func(nX,nY,nZ),
21656 val7 = values2(xi,nyi) = (float)func(X,nY,nZ);
21658 const unsigned int configuration =
21659 (val0<isovalue?1:0) | (val1<isovalue?2:0) | (val2<isovalue?4:0) | (val3<isovalue?8:0) |
21660 (val4<isovalue?16:0) | (val5<isovalue?32:0) | (val6<isovalue?64:0) | (val7<isovalue?128:0),
21661 edge = edges[configuration];
21665 if ((edge&1) && indices1(xi,yi,0)<0) {
21666 const float Xi = X + (isovalue-val0)*dx/(val1-val0);
21667 indices1(xi,yi,0) = vertices.
width;
21670 if ((edge&2) && indices1(nxi,yi,1)<0) {
21671 const float Yi = Y + (isovalue-val1)*dy/(val2-val1);
21672 indices1(nxi,yi,1) = vertices.
width;
21675 if ((edge&4) && indices1(xi,nyi,0)<0) {
21676 const float Xi = X + (isovalue-val3)*dx/(val2-val3);
21677 indices1(xi,nyi,0) = vertices.
width;
21680 if ((edge&8) && indices1(xi,yi,1)<0) {
21681 const float Yi = Y + (isovalue-val0)*dy/(val3-val0);
21682 indices1(xi,yi,1) = vertices.
width;
21685 if ((edge&16) && indices2(xi,yi,0)<0) {
21686 const float Xi = X + (isovalue-val4)*dx/(val5-val4);
21687 indices2(xi,yi,0) = vertices.
width;
21690 if ((edge&32) && indices2(nxi,yi,1)<0) {
21691 const float Yi = Y + (isovalue-val5)*dy/(val6-val5);
21692 indices2(nxi,yi,1) = vertices.
width;
21695 if ((edge&64) && indices2(xi,nyi,0)<0) {
21696 const float Xi = X + (isovalue-val7)*dx/(val6-val7);
21697 indices2(xi,nyi,0) = vertices.
width;
21700 if ((edge&128) && indices2(xi,yi,1)<0) {
21701 const float Yi = Y + (isovalue-val4)*dy/(val7-val4);
21702 indices2(xi,yi,1) = vertices.
width;
21705 if ((edge&256) && indices1(xi,yi,2)<0) {
21706 const float Zi = Z+ (isovalue-val0)*dz/(val4-val0);
21707 indices1(xi,yi,2) = vertices.
width;
21710 if ((edge&512) && indices1(nxi,yi,2)<0) {
21711 const float Zi = Z + (isovalue-val1)*dz/(val5-val1);
21712 indices1(nxi,yi,2) = vertices.
width;
21715 if ((edge&1024) && indices1(nxi,nyi,2)<0) {
21716 const float Zi = Z + (isovalue-val2)*dz/(val6-val2);
21717 indices1(nxi,nyi,2) = vertices.
width;
21720 if ((edge&2048) && indices1(xi,nyi,2)<0) {
21721 const float Zi = Z + (isovalue-val3)*dz/(val7-val3);
21722 indices1(xi,nyi,2) = vertices.
width;
21727 for (
const int *triangle = triangles[configuration]; *triangle!=-1; ) {
21728 const unsigned int p0 = *(triangle++),
p1 = *(triangle++), p2 = *(triangle++);
21741 return vertices>
'x';
21744 template<
typename tf>
21746 const float x0,
const float y0,
const float z0,
21747 const float x1,
const float y1,
const float z1,
21748 const int dx=32,
const int dy=32,
const int dz=32) {
21749 const _marching3d_func_expr func(expression);
21750 return isosurface3d(primitives,func,isovalue,x0,y0,z0,x1,y1,z1,
dx,
dy,dz);
21753 template<
typename t>
21755 const unsigned int x,
const unsigned int y,
const unsigned int nx,
const unsigned int ny) {
21757 case 0 :
return indices1(x,y,0);
21758 case 1 :
return indices1(nx,y,1);
21759 case 2 :
return indices1(x,ny,0);
21760 case 3 :
return indices1(x,y,1);
21761 case 4 :
return indices2(x,y,0);
21762 case 5 :
return indices2(nx,y,1);
21763 case 6 :
return indices2(x,ny,0);
21764 case 7 :
return indices2(x,y,1);
21765 case 8 :
return indices1(x,y,2);
21766 case 9 :
return indices1(nx,y,2);
21767 case 10 :
return indices1(nx,ny,2);
21768 case 11 :
return indices1(x,ny,2);
21777 return (
float)
ref((
int)x,(
int)y,(
int)z);
21785 return (
float)
ref._linear_atXYZ(x,y,z);
21795 return (
float)
mp->
eval(x,y,z,0);
21818 template<
typename tf>
21820 const float size_x=200,
const float size_y=100,
const float size_z=100) {
21821 primitives.
assign(6,1,4,1,1, 0,3,2,1, 4,5,6,7, 0,1,5,4, 3,7,6,2, 0,4,7,3, 1,2,6,5);
21823 0.,size_x,size_x, 0., 0.,size_x,size_x, 0.,
21824 0., 0.,size_y,size_y, 0., 0.,size_y,size_y,
21825 0., 0., 0., 0.,size_z,size_z,size_z,size_z);
21844 template<
typename tf>
21846 const float radius=50,
const float size_z=100,
const unsigned int subdivisions=24) {
21852 for (
float delta = 360.0f/subdivisions,
angle = 0;
angle<360;
angle+=delta) {
21856 const unsigned int nbr = vertices.width - 2;
21857 for (
unsigned int p = 0; p<nbr; ++p) {
21858 const unsigned int curr = 2 + p, next = 2 + ((p+1)%nbr);
21862 return vertices>
'x';
21881 template<
typename tf>
21883 const float radius=50,
const float size_z=100,
const unsigned int subdivisions=24) {
21889 for (
float delta = 360.0f/subdivisions,
angle = 0;
angle<360;
angle+=delta) {
21894 const unsigned int nbr = (vertices.width - 2)/2;
21895 for (
unsigned int p = 0; p<nbr; ++p) {
21896 const unsigned int curr = 2+2*p, next = 2+(2*((p+1)%nbr));
21901 return vertices>
'x';
21921 template<
typename tf>
21923 const float radius1=100,
const float radius2=30,
21924 const unsigned int subdivisions1=24,
const unsigned int subdivisions2=12) {
21926 if (!subdivisions1 || !subdivisions2)
return CImg<floatT>();
21928 for (
unsigned int v = 0;
v<subdivisions1; ++
v) {
21931 xc = radius1*(float)
std::cos(beta),
21932 yc = radius1*(float)
std::sin(beta);
21933 for (
unsigned int u = 0; u<subdivisions2; ++u) {
21942 for (
unsigned int vv = 0; vv<subdivisions1; ++vv) {
21943 const unsigned int nv = (vv+1)%subdivisions1;
21944 for (
unsigned int uu = 0; uu<subdivisions2; ++uu) {
21945 const unsigned int nu = (uu+1)%subdivisions2, svv = subdivisions2*vv, snv = subdivisions2*nv;
21950 return vertices>
'x';
21971 template<
typename tf>
21973 const float size_x=100,
const float size_y=100,
21974 const unsigned int subdivisions_x=10,
const unsigned int subdivisions_y=10,
21975 const bool double_sided=
false) {
21977 if (!subdivisions_x || !subdivisions_y)
return CImg<floatT>();
21979 const unsigned int w = subdivisions_x + 1, h = subdivisions_y + 1;
21980 const float fx = (float)size_x/w, fy = (
float)size_y/h;
21981 for (
unsigned int y = 0;
y<h; ++
y)
for (
unsigned int x = 0; x<w; ++
x)
21983 for (
unsigned int y = 0; y<subdivisions_y; ++
y)
for (
unsigned int x = 0; x<subdivisions_x; ++
x) {
21984 const int off1 = x+y*w, off2 = x+1+y*w, off3 = x+1+(y+1)*w, off4 = x+(y+1)*w;
21986 if (double_sided)
CImg<tf>::vector(off1,off2,off3,off4).transfer_to(primitives);
21988 return vertices>
'x';
22006 template<
typename tf>
22012 CImgList<floatT> vertices(12,1,3,1,1, b,a,0.0, -b,a,0.0, -b,-a,0.0, b,-a,0.0, a,0.0,b, a,0.0,-b,
22013 -a,0.0,-b, -a,0.0,b, 0.0,b,a, 0.0,-b,a, 0.0,-b,-a, 0.0,b,-a);
22014 primitives.
assign(20,1,3,1,1, 4,8,7, 4,7,9, 5,6,11, 5,10,6, 0,4,3, 0,3,5, 2,7,1, 2,1,6,
22015 8,0,11, 8,11,1, 9,10,3, 9,2,10, 8,4,0, 11,0,5, 4,9,3,
22016 5,3,10, 7,8,1, 6,1,11, 7,2,9, 6,10,2);
22019 for (
unsigned int i = 0; i<subdivisions; ++
i) {
22020 const unsigned int L = primitives.
width;
22021 for (
unsigned int l = 0; l<L; ++l) {
22023 p0 = (
unsigned int)primitives(0,0),
p1 = (
unsigned int)primitives(0,1), p2 = (
unsigned int)primitives(0,2);
22025 x0 = vertices(p0,0), y0 = vertices(p0,1), z0 = vertices(p0,2),
22026 x1 = vertices(
p1,0), y1 = vertices(
p1,1), z1 = vertices(
p1,2),
22027 x2 = vertices(p2,0), y2 = vertices(p2,1), z2 = vertices(p2,2),
22028 tnx0 = (x0+x1)/2, tny0 = (y0+y1)/2, tnz0 = (z0+z1)/2, nn0 = (
float)
std::sqrt(tnx0*tnx0+tny0*tny0+tnz0*tnz0),
22029 tnx1 = (x0+x2)/2, tny1 = (y0+y2)/2, tnz1 = (z0+z2)/2, nn1 = (
float)
std::sqrt(tnx1*tnx1+tny1*tny1+tnz1*tnz1),
22030 tnx2 = (x1+x2)/2, tny2 = (y1+y2)/2, tnz2 = (z1+z2)/2, nn2 = (
float)
std::sqrt(tnx2*tnx2+tny2*tny2+tnz2*tnz2),
22031 nx0 = tnx0/nn0, ny0 = tny0/nn0, nz0 = tnz0/nn0,
22032 nx1 = tnx1/nn1, ny1 = tny1/nn1, nz1 = tnz1/nn1,
22033 nx2 = tnx2/nn2, ny2 = tny2/nn2, nz2 = tnz2/nn2;
22034 int i0 = -1, i1 = -1, i2 = -1;
22036 const float x = (float)vertices(p,0),
y = (float)vertices(p,1),
z = (float)vertices(p,2);
22037 if (x==nx0 &&
y==ny0 &&
z==nz0) i0 = p;
22038 if (x==nx1 &&
y==ny1 &&
z==nz1) i1 = p;
22039 if (x==nx2 &&
y==ny2 &&
z==nz2) i2 = p;
22051 return (vertices>
'x')*=radius;
22070 template<
typename tf,
typename t>
22072 const CImg<t>&
tensor,
const unsigned int subdivisions=3) {
22076 tensor.symmetric_eigen(S,V);
22077 const float l0 = S[0], l1 = S[1], l2 = S[2];
22078 CImg<floatT> vertices = sphere(primitives,subdivisions);
22079 vertices.get_shared_line(0)*=l0;
22080 vertices.get_shared_line(1)*=l1;
22081 vertices.get_shared_line(2)*=l2;
22082 return V.transpose()*vertices;
22094 template<
typename tc>
22096 const tc *
const color,
const float opacity=1,
22097 const float brightness=1,
const bool init=
false) {
22099 static float nopacity = 0, copacity = 0;
22100 static unsigned int whz = 0;
22101 static const tc *col = 0;
22107 const int nx0 = x0>0?x0:0, nx1 = x1<
dimx()?x1:
dimx()-1,
dx = nx1 - nx0;
22110 const unsigned int off = whz-
dx-1;
22111 T *ptrd =
ptr(nx0,y);
22113 if (brightness==1) {
22115 const T val = (T)*(col++);
22116 for (
int x = dx; x>=0; --
x) *(ptrd++) = val;
22119 const T val = (T)*(col++);
22120 std::memset(ptrd,(
int)val,dx+1);
22123 }
else if (brightness<1) {
22125 const T val = (T)(*(col++)*brightness);
22126 for (
int x = dx; x>=0; --
x) *(ptrd++) = val;
22129 const T val = (T)(*(col++)*brightness);
22130 std::memset(ptrd,(
int)val,dx+1);
22135 const T val = (T)((2-brightness)**(col++) + (brightness-1)*maxval);
22136 for (
int x = dx; x>=0; --
x) *(ptrd++) = val;
22139 const T val = (T)((2-brightness)**(col++) + (brightness-1)*maxval);
22140 std::memset(ptrd,(
int)val,dx+1);
22145 if (brightness==1) {
22147 const T val = (T)*(col++);
22148 for (
int x = dx; x>=0; --
x) { *ptrd = (T)(val*nopacity + *ptrd*copacity); ++ptrd; }
22151 }
else if (brightness<=1) {
22153 const T val = (T)(*(col++)*brightness);
22154 for (
int x = dx; x>=0; --
x) { *ptrd = (T)(val*nopacity + *ptrd*copacity); ++ptrd; }
22159 const T val = (T)((2-brightness)**(col++) + (brightness-1)*maxval);
22160 for (
int x = dx; x>=0; --
x) { *ptrd = (T)(val*nopacity + *ptrd*copacity); ++ptrd; }
22170 template<
typename tc>
22191 template<
typename tc>
22193 const tc *
const color,
const float opacity=1) {
22198 template<
typename tc>
22200 const CImg<tc>& color,
const float opacity=1) {
22201 return draw_point(x0,y0,color.data,opacity);
22205 template<
typename tc>
22207 const tc *
const color,
const float opacity=1) {
22212 if (x0>=0 && y0>=0 && z0>=0 && x0<
dimx() && y0<
dimy() && z0<
dimz()) {
22215 T *ptrd =
ptr(x0,y0,z0,0);
22216 const tc *col = color;
22217 if (opacity>=1)
cimg_forV(*
this,
k) { *ptrd = (T)*(col++); ptrd+=whz; }
22218 else cimg_forV(*
this,
k) { *ptrd = (T)(*(col++)*nopacity + *ptrd*copacity); ptrd+=whz; }
22224 template<
typename tc>
22226 const CImg<tc>& color,
const float opacity=1) {
22227 return draw_point(x0,y0,z0,color.data,opacity);
22231 template<
typename t,
typename tc>
22233 const tc *
const color,
const float opacity) {
22234 if (
is_empty() || !points || !W)
return *
this;
22240 for (
unsigned int i = 0; i<W; ++
i) {
22241 const int x = (int)points(i,0),
y = (int)points(i,1);
22246 for (
unsigned int i = 0; i<W; ++
i) {
22247 const int x = (int)points(i,0),
y = (int)points(i,1),
z = (int)points(i,2);
22275 template<
typename t,
typename tc>
22277 const tc *
const color,
const float opacity=1) {
22283 template<
typename t,
typename tc>
22285 const CImg<tc>& color,
const float opacity=1) {
22286 return draw_point(points,color.data,opacity);
22295 template<
typename t,
typename tc>
22297 const tc *
const color,
const float opacity=1) {
22298 return _draw_point(points,points.width,points.height,color,opacity);
22302 template<
typename t,
typename tc>
22304 const CImg<tc>& color,
const float opacity=1) {
22305 return draw_point(points,color.data,opacity);
22329 template<
typename tc>
22331 const int x1,
const int y1,
22332 const tc *
const color,
const float opacity=1,
22333 const unsigned int pattern=~0U,
const bool init_hatch=
true) {
22338 static unsigned int hatch = ~0U - (~0U>>1);
22339 if (init_hatch) hatch = ~0U - (~0U>>1);
22340 const bool xdir = x0<x1, ydir = y0<y1;
22342 nx0 = x0, nx1 = x1, ny0 = y0, ny1 = y1,
22343 &xleft = xdir?nx0:nx1, &yleft = xdir?ny0:ny1,
22344 &xright = xdir?nx1:nx0, &yright = xdir?ny1:ny0,
22345 &xup = ydir?nx0:nx1, &yup = ydir?ny0:ny1,
22346 &xdown = ydir?nx1:nx0, &ydown = ydir?ny1:ny0;
22347 if (xright<0 || xleft>=
dimx())
return *
this;
22348 if (xleft<0) { yleft-=xleft*(yright - yleft)/(xright - xleft); xleft = 0; }
22349 if (xright>=
dimx()) { yright-=(xright -
dimx())*(yright - yleft)/(xright - xleft); xright =
dimx()-1; }
22350 if (ydown<0 || yup>=
dimy())
return *
this;
22351 if (yup<0) { xup-=yup*(xdown - xup)/(ydown - yup); yup = 0; }
22352 if (ydown>=
dimy()) { xdown-=(ydown -
dimy())*(xdown - xup)/(ydown - yup); ydown =
dimy()-1; }
22353 T *ptrd0 =
ptr(nx0,ny0);
22354 int dx = xright - xleft,
dy = ydown - yup;
22355 const bool steep = dy>
dx;
22356 if (steep)
cimg::swap(nx0,ny0,nx1,ny1,dx,dy);
22358 offx = (nx0<nx1?1:-1)*(steep?
width:1),
22359 offy = (ny0<ny1?1:-1)*(steep?1:width),
22362 if (~pattern)
for (
int error = dx>>1, x = 0; x<=
dx; ++
x) {
22363 if (pattern&hatch) { T *ptrd = ptrd0;
const tc* col = color;
cimg_forV(*
this,
k) { *ptrd = (T)*(col++); ptrd+=wh; }}
22364 hatch>>=1;
if (!hatch) hatch = ~0U - (~0U>>1);
22366 if ((error-=dy)<0) { ptrd0+=offy; error+=
dx; }
22367 }
else for (
int error = dx>>1, x = 0; x<=
dx; ++
x) {
22368 T *ptrd = ptrd0;
const tc* col = color;
cimg_forV(*
this,
k) { *ptrd = (T)*(col++); ptrd+=wh; }
22370 if ((error-=dy)<0) { ptrd0+=offy; error+=
dx; }
22374 if (~pattern)
for (
int error = dx>>1, x = 0; x<=
dx; ++
x) {
22375 if (pattern&hatch) {
22376 T *ptrd = ptrd0;
const tc* col = color;
22377 cimg_forV(*
this,
k) { *ptrd = (T)(nopacity**(col++) + *ptrd*copacity); ptrd+=wh; }
22379 hatch>>=1;
if (!hatch) hatch = ~0U - (~0U>>1);
22381 if ((error-=dy)<0) { ptrd0+=offy; error+=
dx; }
22382 }
else for (
int error = dx>>1, x = 0; x<=
dx; ++
x) {
22383 T *ptrd = ptrd0;
const tc* col = color;
cimg_forV(*
this,
k) { *ptrd = (T)(nopacity**(col++) + *ptrd*copacity); ptrd+=wh; }
22385 if ((error-=dy)<0) { ptrd0+=offy; error+=
dx; }
22392 template<
typename tc>
22394 const int x1,
const int y1,
22395 const CImg<tc>& color,
const float opacity=1,
22396 const unsigned int pattern=~0U,
const bool init_hatch=
true) {
22397 return draw_line(x0,y0,x1,y1,color.data,opacity,pattern,init_hatch);
22401 template<
typename tc>
22403 const int x0,
const int y0,
const float z0,
22404 const int x1,
const int y1,
const float z1,
22405 const tc *
const color,
const float opacity=1,
22406 const unsigned int pattern=~0U,
const bool init_hatch=
true) {
22407 if (
is_empty() || z0<=0 || z1<=0)
return *
this;
22412 throw CImgArgumentException(
"CImg<%s>::draw_line() : Z-buffer (%u,%u,%u,%u,%p) and instance image (%u,%u,%u,%u,%p) have different dimensions.",
22413 pixel_type(),zbuffer.width,zbuffer.height,zbuffer.depth,zbuffer.dim,zbuffer.data,
width,
height,
depth,dim,
data);
22414 static unsigned int hatch = ~0U - (~0U>>1);
22415 if (init_hatch) hatch = ~0U - (~0U>>1);
22416 const bool xdir = x0<x1, ydir = y0<y1;
22418 nx0 = x0, nx1 = x1, ny0 = y0, ny1 = y1,
22419 &xleft = xdir?nx0:nx1, &yleft = xdir?ny0:ny1,
22420 &xright = xdir?nx1:nx0, &yright = xdir?ny1:ny0,
22421 &xup = ydir?nx0:nx1, &yup = ydir?ny0:ny1,
22422 &xdown = ydir?nx1:nx0, &ydown = ydir?ny1:ny0;
22424 Z0 = 1/z0, Z1 = 1/z1, nz0 = Z0, nz1 = Z1, dz = Z1 - Z0,
22425 &zleft = xdir?nz0:nz1,
22426 &zright = xdir?nz1:nz0,
22427 &zup = ydir?nz0:nz1,
22428 &zdown = ydir?nz1:nz0;
22429 if (xright<0 || xleft>=
dimx())
return *
this;
22431 const int D = xright - xleft;
22432 yleft-=xleft*(yright - yleft)/D;
22433 zleft-=xleft*(zright - zleft)/D;
22436 if (xright>=
dimx()) {
22437 const int d = xright -
dimx(), D = xright - xleft;
22438 yright-=d*(yright - yleft)/D;
22439 zright-=d*(zright - zleft)/D;
22442 if (ydown<0 || yup>=
dimy())
return *
this;
22444 const int D = ydown - yup;
22445 xup-=yup*(xdown - xup)/D;
22446 zup-=yup*(zdown - zup)/D;
22449 if (ydown>=
dimy()) {
22450 const int d = ydown -
dimy(), D = ydown - yup;
22451 xdown-=d*(xdown - xup)/D;
22452 zdown-=d*(zdown - zup)/D;
22455 T *ptrd0 =
ptr(nx0,ny0);
22456 float *ptrz = zbuffer.ptr(nx0,ny0);
22457 int dx = xright - xleft,
dy = ydown - yup;
22458 const bool steep = dy>
dx;
22459 if (steep)
cimg::swap(nx0,ny0,nx1,ny1,dx,dy);
22461 offx = (nx0<nx1?1:-1)*(steep?
width:1),
22462 offy = (ny0<ny1?1:-1)*(steep?1:width),
22466 if (~pattern)
for (
int error = dx>>1, x = 0; x<=
dx; ++
x) {
22467 const float z = Z0 + x*dz/ndx;
22468 if (z>*ptrz && pattern&hatch) {
22470 T *ptrd = ptrd0;
const tc *col = color;
22471 cimg_forV(*
this,
k) { *ptrd = (T)*(col++); ptrd+=wh; }
22473 hatch>>=1;
if (!hatch) hatch = ~0U - (~0U>>1);
22474 ptrd0+=offx; ptrz+=offx;
22475 if ((error-=dy)<0) { ptrd0+=offy; ptrz+=offy; error+=
dx; }
22476 }
else for (
int error = dx>>1, x = 0; x<=
dx; ++
x) {
22477 const float z = Z0 + x*dz/ndx;
22480 T *ptrd = ptrd0;
const tc *col = color;
22481 cimg_forV(*
this,
k) { *ptrd = (T)*(col++); ptrd+=wh; }
22483 ptrd0+=offx; ptrz+=offx;
22484 if ((error-=dy)<0) { ptrd0+=offy; ptrz+=offy; error+=
dx; }
22488 if (~pattern)
for (
int error = dx>>1, x = 0; x<=
dx; ++
x) {
22489 const float z = Z0 + x*dz/ndx;
22490 if (z>*ptrz && pattern&hatch) {
22492 T *ptrd = ptrd0;
const tc *col = color;
22493 cimg_forV(*
this,
k) { *ptrd = (T)(nopacity**(col++) + *ptrd*copacity); ptrd+=wh; }
22495 hatch>>=1;
if (!hatch) hatch = ~0U - (~0U>>1);
22496 ptrd0+=offx; ptrz+=offx;
22497 if ((error-=dy)<0) { ptrd0+=offy; ptrz+=offy; error+=
dx; }
22498 }
else for (
int error = dx>>1, x = 0; x<=
dx; ++
x) {
22499 const float z = Z0 + x*dz/ndx;
22502 T *ptrd = ptrd0;
const tc *col = color;
22503 cimg_forV(*
this,
k) { *ptrd = (T)(nopacity**(col++) + *ptrd*copacity); ptrd+=wh; }
22505 ptrd0+=offx; ptrz+=offx;
22506 if ((error-=dy)<0) { ptrd0+=offy; ptrz+=offy; error+=
dx; }
22513 template<
typename tc>
22515 const int x0,
const int y0,
const float z0,
22516 const int x1,
const int y1,
const float z1,
22517 const CImg<tc>& color,
const float opacity=1,
22518 const unsigned int pattern=~0U,
const bool init_hatch=
true) {
22519 return draw_line(zbuffer,x0,y0,z0,x1,y1,z1,color.data,opacity,pattern,init_hatch);
22523 template<
typename tc>
22525 const int x1,
const int y1,
const int z1,
22526 const tc *
const color,
const float opacity=1,
22527 const unsigned int pattern=~0U,
const bool init_hatch=
true) {
22532 static unsigned int hatch = ~0U - (~0U>>1);
22533 if (init_hatch) hatch = ~0U - (~0U>>1);
22534 int nx0 = x0, ny0 = y0, nz0 = z0, nx1 = x1, ny1 = y1, nz1 = z1;
22535 if (nx0>nx1)
cimg::swap(nx0,nx1,ny0,ny1,nz0,nz1);
22536 if (nx1<0 || nx0>=
dimx())
return *
this;
22537 if (nx0<0) {
const int D = 1 + nx1 - nx0; ny0-=nx0*(1 + ny1 - ny0)/D; nz0-=nx0*(1 + nz1 - nz0)/D; nx0 = 0; }
22538 if (nx1>=
dimx()) {
const int d = nx1-
dimx(), D = 1 + nx1 - nx0; ny1+=d*(1 + ny0 - ny1)/D; nz1+=d*(1 + nz0 - nz1)/D; nx1 =
dimx()-1; }
22539 if (ny0>ny1)
cimg::swap(nx0,nx1,ny0,ny1,nz0,nz1);
22540 if (ny1<0 || ny0>=
dimy())
return *
this;
22541 if (ny0<0) {
const int D = 1 + ny1 - ny0; nx0-=ny0*(1 + nx1 - nx0)/D; nz0-=ny0*(1 + nz1 - nz0)/D; ny0 = 0; }
22542 if (ny1>=
dimy()) {
const int d = ny1-
dimy(), D = 1 + ny1 - ny0; nx1+=d*(1 + nx0 - nx1)/D; nz1+=d*(1 + nz0 - nz1)/D; ny1 =
dimy()-1; }
22543 if (nz0>nz1)
cimg::swap(nx0,nx1,ny0,ny1,nz0,nz1);
22544 if (nz1<0 || nz0>=
dimz())
return *
this;
22545 if (nz0<0) {
const int D = 1 + nz1 - nz0; nx0-=nz0*(1 + nx1 - nx0)/D; ny0-=nz0*(1 + ny1 - ny0)/D; nz0 = 0; }
22546 if (nz1>=
dimz()) {
const int d = nz1-
dimz(), D = 1 + nz1 - nz0; nx1+=d*(1 + nx0 - nx1)/D; ny1+=d*(1 + ny0 - ny1)/D; nz1 =
dimz()-1; }
22548 const float px = (nx1 - nx0)/(
float)dmax, py = (ny1 - ny0)/(
float)dmax, pz = (nz1 - nz0)/(
float)dmax;
22549 float x = (float)nx0,
y = (
float)ny0,
z = (float)nz0;
22550 if (opacity>=1)
for (
unsigned int t = 0; t<=dmax; ++t) {
22551 if (!(~pattern) || (~pattern && pattern&hatch)) {
22552 T* ptrd =
ptr((
unsigned int)x,(
unsigned int)
y,(
unsigned int)z);
22553 const tc *col = color;
cimg_forV(*
this,
k) { *ptrd = (T)*(col++); ptrd+=whz; }
22555 x+=px;
y+=py; z+=pz;
if (pattern) { hatch>>=1;
if (!hatch) hatch = ~0U - (~0U>>1); }
22558 for (
unsigned int t = 0; t<=dmax; ++t) {
22559 if (!(~pattern) || (~pattern && pattern&hatch)) {
22560 T* ptrd =
ptr((
unsigned int)x,(
unsigned int)
y,(
unsigned int)z);
22561 const tc *col = color;
cimg_forV(*
this,
k) { *ptrd = (T)(*(col++)*nopacity + *ptrd*copacity); ptrd+=whz; }
22563 x+=px;
y+=py; z+=pz;
if (pattern) { hatch>>=1;
if (!hatch) hatch = ~0U - (~0U>>1); }
22570 template<
typename tc>
22572 const int x1,
const int y1,
const int z1,
22573 const CImg<tc>& color,
const float opacity=1,
22574 const unsigned int pattern=~0U,
const bool init_hatch=
true) {
22575 return draw_line(x0,y0,z0,x1,y1,z1,color.data,opacity,pattern,init_hatch);
22602 template<
typename tc>
22604 const int x1,
const int y1,
22606 const int tx0,
const int ty0,
22607 const int tx1,
const int ty1,
22608 const float opacity=1,
22609 const unsigned int pattern=~0U,
const bool init_hatch=
true) {
22611 if (!texture || texture.dim<dim)
22612 throw CImgArgumentException(
"CImg<%s>::draw_line() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
22613 pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
22614 if (
is_overlapped(texture))
return draw_line(x0,y0,x1,y1,+texture,tx0,ty0,tx1,ty1,opacity,pattern,init_hatch);
22615 static unsigned int hatch = ~0U - (~0U>>1);
22616 if (init_hatch) hatch = ~0U - (~0U>>1);
22617 const bool xdir = x0<x1, ydir = y0<y1;
22619 dtx = tx1-tx0, dty = ty1-ty0,
22620 nx0 = x0, nx1 = x1, ny0 = y0, ny1 = y1,
22621 tnx0 = tx0, tnx1 = tx1, tny0 = ty0, tny1 = ty1,
22622 &xleft = xdir?nx0:nx1, &yleft = xdir?ny0:ny1, &xright = xdir?nx1:nx0, &yright = xdir?ny1:ny0,
22623 &txleft = xdir?tnx0:tnx1, &tyleft = xdir?tny0:tny1, &txright = xdir?tnx1:tnx0, &tyright = xdir?tny1:tny0,
22624 &xup = ydir?nx0:nx1, &yup = ydir?ny0:ny1, &xdown = ydir?nx1:nx0, &ydown = ydir?ny1:ny0,
22625 &txup = ydir?tnx0:tnx1, &tyup = ydir?tny0:tny1, &txdown = ydir?tnx1:tnx0, &tydown = ydir?tny1:tny0;
22626 if (xright<0 || xleft>=
dimx())
return *
this;
22628 const int D = xright - xleft;
22629 yleft-=xleft*(yright - yleft)/D;
22630 txleft-=xleft*(txright - txleft)/D;
22631 tyleft-=xleft*(tyright - tyleft)/D;
22634 if (xright>=
dimx()) {
22635 const int d = xright -
dimx(), D = xright - xleft;
22636 yright-=d*(yright - yleft)/D;
22637 txright-=d*(txright - txleft)/D;
22638 tyright-=d*(tyright - tyleft)/D;
22641 if (ydown<0 || yup>=
dimy())
return *
this;
22643 const int D = ydown - yup;
22644 xup-=yup*(xdown - xup)/D;
22645 txup-=yup*(txdown - txup)/D;
22646 tyup-=yup*(tydown - tyup)/D;
22649 if (ydown>=
dimy()) {
22650 const int d = ydown -
dimy(), D = ydown - yup;
22651 xdown-=d*(xdown - xup)/D;
22652 txdown-=d*(txdown - txup)/D;
22653 tydown-=d*(tydown - tyup)/D;
22656 T *ptrd0 =
ptr(nx0,ny0);
22657 int dx = xright - xleft,
dy = ydown - yup;
22658 const bool steep = dy>
dx;
22659 if (steep)
cimg::swap(nx0,ny0,nx1,ny1,dx,dy);
22661 offx = (nx0<nx1?1:-1)*(steep?
width:1),
22662 offy = (ny0<ny1?1:-1)*(steep?1:width),
22666 if (~pattern)
for (
int error = dx>>1, x = 0; x<=
dx; ++
x) {
22667 if (pattern&hatch) {
22669 const int tx = tx0 + x*dtx/ndx, ty = ty0 + x*dty/ndx;
22670 cimg_forV(*
this,
k) { *ptrd = (T)texture(tx,ty,0,
k); ptrd+=wh; }
22672 hatch>>=1;
if (!hatch) hatch = ~0U - (~0U>>1);
22674 if ((error-=dy)<0) { ptrd0+=offy; error+=
dx; }
22675 }
else for (
int error = dx>>1, x = 0; x<=
dx; ++
x) {
22677 const int tx = tx0 + x*dtx/ndx, ty = ty0 + x*dty/ndx;
22678 cimg_forV(*
this,
k) { *ptrd = (T)texture(tx,ty,0,
k); ptrd+=wh; }
22680 if ((error-=dy)<0) { ptrd0+=offy; error+=
dx; }
22684 if (~pattern)
for (
int error = dx>>1, x = 0; x<=
dx; ++
x) {
22686 if (pattern&hatch) {
22687 const int tx = tx0 + x*dtx/ndx, ty = ty0 + x*dty/ndx;
22688 cimg_forV(*
this,
k) { *ptrd = (T)(nopacity*texture(tx,ty,0,
k) + *ptrd*copacity); ptrd+=wh; }
22690 hatch>>=1;
if (!hatch) hatch = ~0U - (~0U>>1);
22692 if ((error-=dy)<0) { ptrd0+=offy; error+=
dx; }
22693 }
else for (
int error = dx>>1, x = 0; x<=
dx; ++
x) {
22695 const int tx = tx0 + x*dtx/ndx, ty = ty0 + x*dty/ndx;
22696 cimg_forV(*
this,
k) { *ptrd = (T)(nopacity*texture(tx,ty,0,
k) + *ptrd*copacity); ptrd+=wh; }
22698 if ((error-=dy)<0) { ptrd0+=offy; error+=
dx; }
22705 template<
typename tc>
22707 const int x1,
const int y1,
const float z1,
22709 const int tx0,
const int ty0,
22710 const int tx1,
const int ty1,
22711 const float opacity=1,
22712 const unsigned int pattern=~0U,
const bool init_hatch=
true) {
22713 if (
is_empty() && z0<=0 && z1<=0)
return *
this;
22714 if (!texture || texture.dim<dim)
22715 throw CImgArgumentException(
"CImg<%s>::draw_line() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
22716 pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
22717 if (
is_overlapped(texture))
return draw_line(x0,y0,z0,x1,y1,z1,+texture,tx0,ty0,tx1,ty1,opacity,pattern,init_hatch);
22718 static unsigned int hatch = ~0U - (~0U>>1);
22719 if (init_hatch) hatch = ~0U - (~0U>>1);
22720 const bool xdir = x0<x1, ydir = y0<y1;
22722 nx0 = x0, nx1 = x1, ny0 = y0, ny1 = y1,
22723 &xleft = xdir?nx0:nx1, &yleft = xdir?ny0:ny1,
22724 &xright = xdir?nx1:nx0, &yright = xdir?ny1:ny0,
22725 &xup = ydir?nx0:nx1, &yup = ydir?ny0:ny1,
22726 &xdown = ydir?nx1:nx0, &ydown = ydir?ny1:ny0;
22728 Tx0 = tx0/z0, Tx1 = tx1/z1,
22729 Ty0 = ty0/z0, Ty1 = ty1/z1,
22730 Z0 = 1/z0, Z1 = 1/z1,
22731 dz = Z1 - Z0, dtx = Tx1 - Tx0, dty = Ty1 - Ty0,
22732 tnx0 = Tx0, tnx1 = Tx1, tny0 = Ty0, tny1 = Ty1, nz0 = Z0, nz1 = Z1,
22733 &zleft = xdir?nz0:nz1, &txleft = xdir?tnx0:tnx1, &tyleft = xdir?tny0:tny1,
22734 &zright = xdir?nz1:nz0, &txright = xdir?tnx1:tnx0, &tyright = xdir?tny1:tny0,
22735 &zup = ydir?nz0:nz1, &txup = ydir?tnx0:tnx1, &tyup = ydir?tny0:tny1,
22736 &zdown = ydir?nz1:nz0, &txdown = ydir?tnx1:tnx0, &tydown = ydir?tny1:tny0;
22737 if (xright<0 || xleft>=
dimx())
return *
this;
22739 const int D = xright - xleft;
22740 yleft-=xleft*(yright - yleft)/D;
22741 zleft-=xleft*(zright - zleft)/D;
22742 txleft-=xleft*(txright - txleft)/D;
22743 tyleft-=xleft*(tyright - tyleft)/D;
22746 if (xright>=
dimx()) {
22747 const int d = xright -
dimx(), D = xright - xleft;
22748 yright-=d*(yright - yleft)/D;
22749 zright-=d*(zright - zleft)/D;
22750 txright-=d*(txright - txleft)/D;
22751 tyright-=d*(tyright - tyleft)/D;
22754 if (ydown<0 || yup>=
dimy())
return *
this;
22756 const int D = ydown - yup;
22757 xup-=yup*(xdown - xup)/D;
22758 zup-=yup*(zdown - zup)/D;
22759 txup-=yup*(txdown - txup)/D;
22760 tyup-=yup*(tydown - tyup)/D;
22763 if (ydown>=
dimy()) {
22764 const int d = ydown -
dimy(), D = ydown - yup;
22765 xdown-=d*(xdown - xup)/D;
22766 zdown-=d*(zdown - zup)/D;
22767 txdown-=d*(txdown - txup)/D;
22768 tydown-=d*(tydown - tyup)/D;
22771 T *ptrd0 =
ptr(nx0,ny0);
22772 int dx = xright - xleft,
dy = ydown - yup;
22773 const bool steep = dy>
dx;
22774 if (steep)
cimg::swap(nx0,ny0,nx1,ny1,dx,dy);
22776 offx = (nx0<nx1?1:-1)*(steep?
width:1),
22777 offy = (ny0<ny1?1:-1)*(steep?1:width),
22781 if (~pattern)
for (
int error = dx>>1, x = 0; x<=
dx; ++
x) {
22782 if (pattern&hatch) {
22783 const float z = Z0 + x*dz/ndx, tx = Tx0 + x*dtx/ndx, ty = Ty0 + x*dty/ndx;
22784 T *ptrd = ptrd0;
cimg_forV(*
this,
k) { *ptrd = (T)texture((
int)(tx/
z),(
int)(ty/
z),0,
k); ptrd+=wh; }
22786 hatch>>=1;
if (!hatch) hatch = ~0U - (~0U>>1);
22788 if ((error-=dy)<0) { ptrd0+=offy; error+=
dx; }
22789 }
else for (
int error = dx>>1, x = 0; x<=
dx; ++
x) {
22790 const float z = Z0 + x*dz/ndx, tx = Tx0 + x*dtx/ndx, ty = Ty0 + x*dty/ndx;
22791 T *ptrd = ptrd0;
cimg_forV(*
this,
k) { *ptrd = (T)texture((
int)(tx/
z),(
int)(ty/
z),0,
k); ptrd+=wh; }
22793 if ((error-=dy)<0) { ptrd0+=offy; error+=
dx; }
22797 if (~pattern)
for (
int error = dx>>1, x = 0; x<=
dx; ++
x) {
22798 if (pattern&hatch) {
22799 const float z = Z0 + x*dz/ndx, tx = Tx0 + x*dtx/ndx, ty = Ty0 + x*dty/ndx;
22800 T *ptrd = ptrd0;
cimg_forV(*
this,
k) { *ptrd = (T)(nopacity*texture((
int)(tx/z),(
int)(ty/z),0,
k) + *ptrd*copacity); ptrd+=wh; }
22802 hatch>>=1;
if (!hatch) hatch = ~0U - (~0U>>1);
22804 if ((error-=dy)<0) { ptrd0+=offy; error+=
dx; }
22805 }
else for (
int error = dx>>1, x = 0; x<=
dx; ++
x) {
22806 const float z = Z0 + x*dz/ndx, tx = Tx0 + x*dtx/ndx, ty = Ty0 + x*dty/ndx;
22808 cimg_forV(*
this,
k) { *ptrd = (T)(nopacity*texture((
int)(tx/z),(
int)(ty/z),0,
k) + *ptrd*copacity); ptrd+=wh; }
22810 if ((error-=dy)<0) { ptrd0+=offy; error+=
dx; }
22817 template<
typename tc>
22819 const int x0,
const int y0,
const float z0,
22820 const int x1,
const int y1,
const float z1,
22822 const int tx0,
const int ty0,
22823 const int tx1,
const int ty1,
22824 const float opacity=1,
22825 const unsigned int pattern=~0U,
const bool init_hatch=
true) {
22826 if (
is_empty() || z0<=0 || z1<=0)
return *
this;
22828 throw CImgArgumentException(
"CImg<%s>::draw_line() : Z-buffer (%u,%u,%u,%u,%p) and instance image (%u,%u,%u,%u,%p) have different dimensions.",
22829 pixel_type(),zbuffer.width,zbuffer.height,zbuffer.depth,zbuffer.dim,zbuffer.data,
width,
height,
depth,dim,
data);
22830 if (!texture || texture.dim<dim)
22831 throw CImgArgumentException(
"CImg<%s>::draw_line() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
22832 pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
22833 if (
is_overlapped(texture))
return draw_line(zbuffer,x0,y0,z0,x1,y1,z1,+texture,tx0,ty0,tx1,ty1,opacity,pattern,init_hatch);
22834 static unsigned int hatch = ~0U - (~0U>>1);
22835 if (init_hatch) hatch = ~0U - (~0U>>1);
22836 const bool xdir = x0<x1, ydir = y0<y1;
22838 nx0 = x0, nx1 = x1, ny0 = y0, ny1 = y1,
22839 &xleft = xdir?nx0:nx1, &yleft = xdir?ny0:ny1,
22840 &xright = xdir?nx1:nx0, &yright = xdir?ny1:ny0,
22841 &xup = ydir?nx0:nx1, &yup = ydir?ny0:ny1,
22842 &xdown = ydir?nx1:nx0, &ydown = ydir?ny1:ny0;
22844 Tx0 = tx0/z0, Tx1 = tx1/z1,
22845 Ty0 = ty0/z0, Ty1 = ty1/z1,
22846 Z0 = 1/z0, Z1 = 1/z1,
22847 dz = Z1 - Z0, dtx = Tx1 - Tx0, dty = Ty1 - Ty0,
22848 tnx0 = Tx0, tnx1 = Tx1, tny0 = Ty0, tny1 = Ty1, nz0 = Z0, nz1 = Z1,
22849 &zleft = xdir?nz0:nz1, &txleft = xdir?tnx0:tnx1, &tyleft = xdir?tny0:tny1,
22850 &zright = xdir?nz1:nz0, &txright = xdir?tnx1:tnx0, &tyright = xdir?tny1:tny0,
22851 &zup = ydir?nz0:nz1, &txup = ydir?tnx0:tnx1, &tyup = ydir?tny0:tny1,
22852 &zdown = ydir?nz1:nz0, &txdown = ydir?tnx1:tnx0, &tydown = ydir?tny1:tny0;
22853 if (xright<0 || xleft>=
dimx())
return *
this;
22855 const int D = xright - xleft;
22856 yleft-=xleft*(yright - yleft)/D;
22857 zleft-=xleft*(zright - zleft)/D;
22858 txleft-=xleft*(txright - txleft)/D;
22859 tyleft-=xleft*(tyright - tyleft)/D;
22862 if (xright>=
dimx()) {
22863 const int d = xright -
dimx(), D = xright - xleft;
22864 yright-=d*(yright - yleft)/D;
22865 zright-=d*(zright - zleft)/D;
22866 txright-=d*(txright - txleft)/D;
22867 tyright-=d*(tyright - tyleft)/D;
22870 if (ydown<0 || yup>=
dimy())
return *
this;
22872 const int D = ydown - yup;
22873 xup-=yup*(xdown - xup)/D;
22874 zup-=yup*(zdown - zup)/D;
22875 txup-=yup*(txdown - txup)/D;
22876 tyup-=yup*(tydown - tyup)/D;
22879 if (ydown>=
dimy()) {
22880 const int d = ydown -
dimy(), D = ydown - yup;
22881 xdown-=d*(xdown - xup)/D;
22882 zdown-=d*(zdown - zup)/D;
22883 txdown-=d*(txdown - txup)/D;
22884 tydown-=d*(tydown - tyup)/D;
22887 T *ptrd0 =
ptr(nx0,ny0);
22888 float *ptrz = zbuffer.ptr(nx0,ny0);
22889 int dx = xright - xleft,
dy = ydown - yup;
22890 const bool steep = dy>
dx;
22891 if (steep)
cimg::swap(nx0,ny0,nx1,ny1,dx,dy);
22893 offx = (nx0<nx1?1:-1)*(steep?
width:1),
22894 offy = (ny0<ny1?1:-1)*(steep?1:width),
22898 if (~pattern)
for (
int error = dx>>1, x = 0; x<=
dx; ++
x) {
22899 if (pattern&hatch) {
22900 const float z = Z0 + x*dz/ndx;
22903 const float tx = Tx0 + x*dtx/ndx, ty = Ty0 + x*dty/ndx;
22904 T *ptrd = ptrd0;
cimg_forV(*
this,
k) { *ptrd = (T)texture((
int)(tx/
z),(
int)(ty/
z),0,
k); ptrd+=wh; }
22907 hatch>>=1;
if (!hatch) hatch = ~0U - (~0U>>1);
22908 ptrd0+=offx; ptrz+=offx;
22909 if ((error-=dy)<0) { ptrd0+=offy; ptrz+=offy; error+=
dx; }
22910 }
else for (
int error = dx>>1, x = 0; x<=
dx; ++
x) {
22911 const float z = Z0 + x*dz/ndx;
22914 const float tx = Tx0 + x*dtx/ndx, ty = Ty0 + x*dty/ndx;
22915 T *ptrd = ptrd0;
cimg_forV(*
this,
k) { *ptrd = (T)texture((
int)(tx/
z),(
int)(ty/
z),0,
k); ptrd+=wh; }
22917 ptrd0+=offx; ptrz+=offx;
22918 if ((error-=dy)<0) { ptrd0+=offy; ptrz+=offy; error+=
dx; }
22922 if (~pattern)
for (
int error = dx>>1, x = 0; x<=
dx; ++
x) {
22923 if (pattern&hatch) {
22924 const float z = Z0 + x*dz/ndx;
22927 const float tx = Tx0 + x*dtx/ndx, ty = Ty0 + x*dty/ndx;
22928 T *ptrd = ptrd0;
cimg_forV(*
this,
k) { *ptrd = (T)(nopacity*texture((
int)(tx/z),(
int)(ty/z),0,
k) + *ptrd*copacity); ptrd+=wh; }
22931 hatch>>=1;
if (!hatch) hatch = ~0U - (~0U>>1);
22932 ptrd0+=offx; ptrz+=offx;
22933 if ((error-=dy)<0) { ptrd0+=offy; ptrz+=offy; error+=
dx; }
22934 }
else for (
int error = dx>>1, x = 0; x<=
dx; ++
x) {
22935 const float z = Z0 + x*dz/ndx;
22938 const float tx = Tx0 + x*dtx/ndx, ty = Ty0 + x*dty/ndx;
22939 T *ptrd = ptrd0;
cimg_forV(*
this,
k) { *ptrd = (T)(nopacity*texture((
int)(tx/z),(
int)(ty/z),0,
k) + *ptrd*copacity); ptrd+=wh; }
22941 ptrd0+=offx; ptrz+=offx;
22942 if ((error-=dy)<0) { ptrd0+=offy; ptrz+=offx; error+=
dx; }
22949 template<
typename t,
typename tc>
22951 const tc *
const color,
const float opacity,
22952 const unsigned int pattern,
const bool init_hatch) {
22953 if (
is_empty() || !points || W<2)
return *
this;
22954 bool ninit_hatch = init_hatch;
22960 const int x0 = (int)points(0,0), y0 = (int)points(0,1);
22961 int ox = x0, oy = y0;
22962 for (
unsigned int i = 1; i<W; ++
i) {
22963 const int x = (int)points(i,0),
y = (int)points(i,1);
22964 draw_line(ox,oy,x,
y,color,opacity,pattern,ninit_hatch);
22965 ninit_hatch =
false;
22970 const int x0 = (int)points(0,0), y0 = (int)points(0,1), z0 = (int)points(0,2);
22971 int ox = x0, oy = y0, oz = z0;
22972 for (
unsigned int i = 1; i<W; ++
i) {
22973 const int x = (int)points(i,0),
y = (int)points(i,1),
z = (int)points(i,2);
22974 draw_line(ox,oy,oz,x,
y,
z,color,opacity,pattern,ninit_hatch);
22975 ninit_hatch =
false;
22976 ox =
x; oy =
y; oz =
z;
23005 template<
typename t,
typename tc>
23007 const tc *
const color,
const float opacity=1,
23008 const unsigned int pattern=~0U,
const bool init_hatch=
true) {
23010 return _draw_line(points,points.
width,H,color,opacity,pattern,init_hatch);
23014 template<
typename t,
typename tc>
23016 const CImg<tc>& color,
const float opacity=1,
23017 const unsigned int pattern=~0U,
const bool init_hatch=
true) {
23018 return draw_line(points,color.data,opacity,pattern,init_hatch);
23027 template<
typename t,
typename tc>
23029 const tc *
const color,
const float opacity=1,
23030 const unsigned int pattern=~0U,
const bool init_hatch=
true) {
23031 return _draw_line(points,points.width,points.height,color,opacity,pattern,init_hatch);
23035 template<
typename t,
typename tc>
23037 const CImg<tc>& color,
const float opacity=1,
23038 const unsigned int pattern=~0U,
const bool init_hatch=
true) {
23039 return draw_line(points,color.data,opacity,pattern,init_hatch);
23056 template<
typename tc>
23058 const int x1,
const int y1,
23059 const tc *
const color,
const float opacity=1,
23061 const unsigned int pattern=~0U) {
23063 const float u = (float)(x0 - x1),
v = (float)(y0 - y1), sq = u*u +
v*
v,
23071 xl = x1 + (int)(l*cl), yl = y1 + (int)(l*sl),
23072 xr = x1 + (int)(l*cr), yr = y1 + (int)(l*sr),
23073 xc = x1 + (int)((l+1)*(cl+cr))/2, yc = y1 + (int)((l+1)*(sl+sr))/2;
23074 draw_line(x0,y0,xc,yc,color,opacity,pattern).draw_triangle(x1,y1,xl,yl,xr,yr,color,opacity);
23080 template<
typename tc>
23082 const int x1,
const int y1,
23083 const CImg<tc>& color,
const float opacity=1,
23085 const unsigned int pattern=~0U) {
23121 template<
typename tc>
23123 const int x1,
const int y1,
const float u1,
const float v1,
23124 const tc *
const color,
const float opacity=1,
23125 const float precision=4,
const unsigned int pattern=~0U,
23126 const bool init_hatch=
true) {
23131 bool ninit_hatch = init_hatch;
23133 dx = (float)(x1 - x0),
23134 dy = (float)(y1 - y0),
23136 ax = -2*dx + u0 + u1,
23137 bx = 3*dx - 2*u0 - u1,
23138 ay = -2*
dy + v0 + v1,
23139 by = 3*
dy - 2*v0 - v1,
23140 xprecision = dmax>0?
precision/dmax:1.0f,
23141 tmax = 1 + (dmax>0?xprecision:0.0f);
23142 int ox = x0, oy = y0;
23143 for (
float t = 0; t<tmax; t+=xprecision) {
23148 nx = (int)(ax*t3 + bx*t2 + u0*t + x0),
23149 ny = (int)(ay*t3 + by*t2 + v0*t + y0);
23150 draw_line(ox,oy,nx,ny,color,opacity,pattern,ninit_hatch);
23151 ninit_hatch =
false;
23158 template<
typename tc>
23160 const int x1,
const int y1,
const float u1,
const float v1,
23161 const CImg<tc>& color,
const float opacity=1,
23162 const float precision=4,
const unsigned int pattern=~0U,
23163 const bool init_hatch=
true) {
23164 return draw_spline(x0,y0,u0,v0,x1,y1,u1,v1,color.data,opacity,
precision,pattern,init_hatch);
23172 template<
typename tc>
23173 CImg<T>&
draw_spline(
const int x0,
const int y0,
const int z0,
const float u0,
const float v0,
const float w0,
23174 const int x1,
const int y1,
const int z1,
const float u1,
const float v1,
const float w1,
23175 const tc *
const color,
const float opacity=1,
23176 const float precision=4,
const unsigned int pattern=~0U,
23177 const bool init_hatch=
true) {
23182 bool ninit_hatch = init_hatch;
23184 dx = (float)(x1 - x0),
23185 dy = (float)(y1 - y0),
23186 dz = (float)(z1 - z0),
23188 ax = -2*dx + u0 + u1,
23189 bx = 3*dx - 2*u0 - u1,
23190 ay = -2*
dy + v0 + v1,
23191 by = 3*
dy - 2*v0 - v1,
23192 az = -2*dz + w0 + w1,
23193 bz = 3*dz - 2*w0 - w1,
23194 xprecision = dmax>0?
precision/dmax:1.0f,
23195 tmax = 1 + (dmax>0?xprecision:0.0f);
23196 int ox = x0, oy = y0, oz = z0;
23197 for (
float t = 0; t<tmax; t+=xprecision) {
23202 nx = (int)(ax*t3 + bx*t2 + u0*t + x0),
23203 ny = (int)(ay*t3 + by*t2 + v0*t + y0),
23204 nz = (int)(az*t3 + bz*t2 + w0*t + z0);
23205 draw_line(ox,oy,oz,nx,ny,nz,color,opacity,pattern,ninit_hatch);
23206 ninit_hatch =
false;
23207 ox = nx; oy = ny; oz = nz;
23213 template<
typename tc>
23214 CImg<T>&
draw_spline(
const int x0,
const int y0,
const int z0,
const float u0,
const float v0,
const float w0,
23215 const int x1,
const int y1,
const int z1,
const float u1,
const float v1,
const float w1,
23216 const CImg<tc>& color,
const float opacity=1,
23217 const float precision=4,
const unsigned int pattern=~0U,
23218 const bool init_hatch=
true) {
23219 return draw_spline(x0,y0,z0,u0,v0,w0,x1,y1,z1,u1,v1,w1,color.data,opacity,
precision,pattern,init_hatch);
23242 template<
typename t>
23244 const int x1,
const int y1,
const float u1,
const float v1,
23246 const int tx0,
const int ty0,
const int tx1,
const int ty1,
23247 const float opacity=1,
23248 const float precision=4,
const unsigned int pattern=~0U,
23249 const bool init_hatch=
true) {
23251 if (!texture || texture.dim<dim)
23252 throw CImgArgumentException(
"CImg<%s>::draw_line() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
23253 pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
23254 if (
is_overlapped(texture))
return draw_spline(x0,y0,u0,v0,x1,y1,u1,v1,+texture,tx0,ty0,tx1,ty1,
precision,opacity,pattern,init_hatch);
23255 bool ninit_hatch =
true;
23257 dx = (float)(x1 - x0),
23258 dy = (float)(y1 - y0),
23260 ax = -2*dx + u0 + u1,
23261 bx = 3*dx - 2*u0 - u1,
23262 ay = -2*
dy + v0 + v1,
23263 by = 3*
dy - 2*v0 - v1,
23264 xprecision = dmax>0?
precision/dmax:1.0f,
23265 tmax = 1 + (dmax>0?xprecision:0.0f);
23266 int ox = x0, oy = y0, otx = tx0, oty = ty0;
23267 for (
float t1 = 0; t1<tmax; t1+=xprecision) {
23272 nx = (int)(ax*t3 + bx*t2 + u0*t1 + x0),
23273 ny = (int)(ay*t3 + by*t2 + v0*t1 + y0),
23274 ntx = tx0 + (int)((tx1-tx0)*t1/tmax),
23275 nty = ty0 + (
int)((ty1-ty0)*t1/tmax);
23276 draw_line(ox,oy,nx,ny,texture,otx,oty,ntx,nty,opacity,pattern,ninit_hatch);
23277 ninit_hatch =
false;
23278 ox = nx; oy = ny; otx = ntx; oty = nty;
23284 template<
typename tp,
typename tt,
typename tc>
23286 const tc *
const color,
const float opacity,
23287 const bool close_set,
const float precision,
23288 const unsigned int pattern,
const bool init_hatch) {
23289 if (
is_empty() || !points || !tangents || W<2)
return *
this;
23290 bool ninit_hatch = init_hatch;
23293 throw CImgArgumentException(
"CImg<%s>::draw_spline() : Given list of points or tangents is not valid.",
23296 const int x0 = (int)points(0,0), y0 = (int)points(0,1);
23297 const float u0 = (float)tangents(0,0), v0 = (float)tangents(0,1);
23298 int ox = x0, oy = y0;
23299 float ou = u0, ov = v0;
23300 for (
unsigned int i = 1; i<W; ++
i) {
23301 const int x = (int)points(i,0),
y = (int)points(i,1);
23302 const float u = (float)tangents(i,0),
v = (float)tangents(i,1);
23303 draw_spline(ox,oy,ou,ov,x,
y,u,
v,color,precision,opacity,pattern,ninit_hatch);
23304 ninit_hatch =
false;
23305 ox =
x; oy =
y; ou = u; ov =
v;
23307 if (close_set)
draw_spline(ox,oy,ou,ov,x0,y0,u0,v0,color,precision,opacity,pattern,
false);
23310 const int x0 = (int)points(0,0), y0 = (int)points(0,1), z0 = (int)points(0,2);
23311 const float u0 = (float)tangents(0,0), v0 = (float)tangents(0,1), w0 = (float)tangents(0,2);
23312 int ox = x0, oy = y0, oz = z0;
23313 float ou = u0, ov = v0, ow = w0;
23314 for (
unsigned int i = 1; i<W; ++
i) {
23315 const int x = (int)points(i,0),
y = (int)points(i,1),
z = (int)points(i,2);
23316 const float u = (float)tangents(i,0),
v = (float)tangents(i,1), w = (float)tangents(i,2);
23317 draw_spline(ox,oy,oz,ou,ov,ow,x,
y,
z,u,
v,w,color,opacity,pattern,ninit_hatch);
23318 ninit_hatch =
false;
23319 ox =
x; oy =
y; oz =
z; ou = u; ov =
v; ow = w;
23321 if (close_set)
draw_spline(ox,oy,oz,ou,ov,ow,x0,y0,z0,u0,v0,w0,color,precision,opacity,pattern,
false);
23328 template<
typename tp,
typename tc>
23330 const tc *
const color,
const float opacity,
23331 const bool close_set,
const float precision,
23332 const unsigned int pattern,
const bool init_hatch) {
23333 if (
is_empty() || !points || W<2)
return *
this;
23337 throw CImgArgumentException(
"CImg<%s>::draw_spline() : Given list of points or tangents is not valid.",
23340 tangents.assign(W,H);
23341 for (
unsigned int p = 0; p<W; ++p) {
23343 p0 = close_set?(p+W-1)%W:(p?p-1:0),
23344 p1 = close_set?(p+1)%W:(p+1<W?p+1:p);
23346 x = (float)points(p,0),
23347 y = (float)points(p,1),
23348 x0 = (float)points(p0,0),
23349 y0 = (float)points(p0,1),
23350 x1 = (float)points(
p1,0),
23351 y1 = (float)points(
p1,1),
23354 n0 = 1e-8f + (float)
std::sqrt(u0*u0 + v0*v0),
23357 n1 = 1e-8f + (float)
std::sqrt(u1*u1 + v1*v1),
23361 fact = 0.5f*(n0 + n1);
23362 tangents(p,0) = (
Tfloat)(fact*u/n);
23363 tangents(p,1) = (
Tfloat)(fact*v/n);
23367 tangents.assign(W,H);
23368 for (
unsigned int p = 0; p<W; ++p) {
23370 p0 = close_set?(p+W-1)%W:(p?p-1:0),
23371 p1 = close_set?(p+1)%W:(p+1<W?p+1:p);
23373 x = (float)points(p,0),
23374 y = (float)points(p,1),
23375 z = (float)points(p,2),
23376 x0 = (float)points(p0,0),
23377 y0 = (float)points(p0,1),
23378 z0 = (float)points(p0,2),
23379 x1 = (float)points(
p1,0),
23380 y1 = (float)points(
p1,1),
23381 z1 = (float)points(
p1,2),
23385 n0 = 1e-8f + (float)
std::sqrt(u0*u0 + v0*v0 + w0*w0),
23389 n1 = 1e-8f + (float)
std::sqrt(u1*u1 + v1*v1 + w1*w1),
23393 n = 1e-8f + (float)
std::sqrt(u*u + v*v + w*w),
23394 fact = 0.5f*(n0 + n1);
23395 tangents(p,0) = (
Tfloat)(fact*u/n);
23396 tangents(p,1) = (
Tfloat)(fact*v/n);
23397 tangents(p,2) = (
Tfloat)(fact*w/n);
23401 return _draw_spline(points,tangents,W,H,color,opacity,close_set,precision,pattern,init_hatch);
23405 template<
typename tp,
typename tt,
typename tc>
23407 const tc *
const color,
const float opacity=1,
23408 const bool close_set=
false,
const float precision=4,
23409 const unsigned int pattern=~0U,
const bool init_hatch=
true) {
23415 template<
typename tp,
typename tt,
typename tc>
23417 const CImg<tc>& color,
const float opacity=1,
23418 const bool close_set=
false,
const float precision=4,
23419 const unsigned int pattern=~0U,
const bool init_hatch=
true) {
23420 return draw_spline(points,tangents,color.data,opacity,close_set,
precision,pattern,init_hatch);
23424 template<
typename tp,
typename tt,
typename tc>
23426 const tc *
const color,
const float opacity=1,
23427 const bool close_set=
false,
const float precision=4,
23428 const unsigned int pattern=~0U,
const bool init_hatch=
true) {
23429 return _draw_spline(points,tangents,color,opacity,close_set,
precision,pattern,init_hatch,points.width,points.height);
23433 template<
typename tp,
typename tt,
typename tc>
23435 const CImg<tc>& color,
const float opacity=1,
23436 const bool close_set=
false,
const float precision=4,
23437 const unsigned int pattern=~0U,
const bool init_hatch=
true) {
23438 return draw_spline(points,tangents,color.data,opacity,close_set,
precision,pattern,init_hatch);
23442 template<
typename t,
typename tc>
23444 const tc *
const color,
const float opacity=1,
23445 const bool close_set=
false,
const float precision=4,
23446 const unsigned int pattern=~0U,
const bool init_hatch=
true) {
23447 unsigned int H = ~0U;
23448 cimglist_for(points,p) {
const unsigned int s = points[p].
size();
if (s<H) H =
s; }
23453 template<
typename t,
typename tc>
23455 CImg<tc>& color,
const float opacity=1,
23456 const bool close_set=
false,
const float precision=4,
23457 const unsigned int pattern=~0U,
const bool init_hatch=
true) {
23462 template<
typename t,
typename tc>
23464 const tc *
const color,
const float opacity=1,
23465 const bool close_set=
false,
const float precision=4,
23466 const unsigned int pattern=~0U,
const bool init_hatch=
true) {
23467 return _draw_spline(points,color,opacity,close_set,
precision,pattern,init_hatch,points.width,points.height);
23471 template<
typename t,
typename tc>
23473 const CImg<tc>& color,
const float opacity=1,
23474 const bool close_set=
false,
const float precision=4,
23475 const unsigned int pattern=~0U,
const bool init_hatch=
true) {
23480 #define _cimg_for_triangle1(img,xl,xr,y,x0,y0,x1,y1,x2,y2) \
23481 for (int y = y0<0?0:y0, \
23482 xr = y0>=0?x0:(x0-y0*(x2-x0)/(y2-y0)), \
23483 xl = y1>=0?(y0>=0?(y0==y1?x1:x0):(x0-y0*(x1-x0)/(y1-y0))):(x1-y1*(x2-x1)/(y2-y1)), \
23487 _dxn = x2>x1?x2-x1:(_sxn=-1,x1-x2), \
23488 _dxr = x2>x0?x2-x0:(_sxr=-1,x0-x2), \
23489 _dxl = x1>x0?x1-x0:(_sxl=-1,x0-x1), \
23493 _counter = (_dxn-=_dyn?_dyn*(_dxn/_dyn):0, \
23494 _dxr-=_dyr?_dyr*(_dxr/_dyr):0, \
23495 _dxl-=_dyl?_dyl*(_dxl/_dyl):0, \
23496 cimg::min((int)(img).height-y-1,y2-y)), \
23500 _rxn = _dyn?(x2-x1)/_dyn:0, \
23501 _rxr = _dyr?(x2-x0)/_dyr:0, \
23502 _rxl = (y0!=y1 && y1>0)?(_dyl?(x1-x0)/_dyl:0): \
23503 (_errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxn); \
23504 _counter>=0; --_counter, ++y, \
23505 xr+=_rxr+((_errr-=_dxr)<0?_errr+=_dyr,_sxr:0), \
23506 xl+=(y!=y1)?_rxl+((_errl-=_dxl)<0?(_errl+=_dyl,_sxl):0): \
23507 (_errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxl=_rxn, x1-xl))
23509 #define _cimg_for_triangle2(img,xl,cl,xr,cr,y,x0,y0,c0,x1,y1,c1,x2,y2,c2) \
23510 for (int y = y0<0?0:y0, \
23511 xr = y0>=0?x0:(x0-y0*(x2-x0)/(y2-y0)), \
23512 cr = y0>=0?c0:(c0-y0*(c2-c0)/(y2-y0)), \
23513 xl = y1>=0?(y0>=0?(y0==y1?x1:x0):(x0-y0*(x1-x0)/(y1-y0))):(x1-y1*(x2-x1)/(y2-y1)), \
23514 cl = y1>=0?(y0>=0?(y0==y1?c1:c0):(c0-y0*(c1-c0)/(y1-y0))):(c1-y1*(c2-c1)/(y2-y1)), \
23518 _dxn = x2>x1?x2-x1:(_sxn=-1,x1-x2), \
23519 _dxr = x2>x0?x2-x0:(_sxr=-1,x0-x2), \
23520 _dxl = x1>x0?x1-x0:(_sxl=-1,x0-x1), \
23521 _dcn = c2>c1?c2-c1:(_scn=-1,c1-c2), \
23522 _dcr = c2>c0?c2-c0:(_scr=-1,c0-c2), \
23523 _dcl = c1>c0?c1-c0:(_scl=-1,c0-c1), \
23527 _counter =(_dxn-=_dyn?_dyn*(_dxn/_dyn):0, \
23528 _dxr-=_dyr?_dyr*(_dxr/_dyr):0, \
23529 _dxl-=_dyl?_dyl*(_dxl/_dyl):0, \
23530 _dcn-=_dyn?_dyn*(_dcn/_dyn):0, \
23531 _dcr-=_dyr?_dyr*(_dcr/_dyr):0, \
23532 _dcl-=_dyl?_dyl*(_dcl/_dyl):0, \
23533 cimg::min((int)(img).height-y-1,y2-y)), \
23534 _errn = _dyn/2, _errcn = _errn, \
23535 _errr = _dyr/2, _errcr = _errr, \
23536 _errl = _dyl/2, _errcl = _errl, \
23537 _rxn = _dyn?(x2-x1)/_dyn:0, \
23538 _rcn = _dyn?(c2-c1)/_dyn:0, \
23539 _rxr = _dyr?(x2-x0)/_dyr:0, \
23540 _rcr = _dyr?(c2-c0)/_dyr:0, \
23541 _rxl = (y0!=y1 && y1>0)?(_dyl?(x1-x0)/_dyl:0): \
23542 (_errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxn), \
23543 _rcl = (y0!=y1 && y1>0)?(_dyl?(c1-c0)/_dyl:0): \
23544 (_errcl=_errcn, _dcl=_dcn, _dyl=_dyn, _scl=_scn, _rcn ); \
23545 _counter>=0; --_counter, ++y, \
23546 xr+=_rxr+((_errr-=_dxr)<0?_errr+=_dyr,_sxr:0), \
23547 cr+=_rcr+((_errcr-=_dcr)<0?_errcr+=_dyr,_scr:0), \
23548 xl+=(y!=y1)?(cl+=_rcl+((_errcl-=_dcl)<0?(_errcl+=_dyl,_scl):0), \
23549 _rxl+((_errl-=_dxl)<0?(_errl+=_dyl,_sxl):0)): \
23550 (_errcl=_errcn, _dcl=_dcn, _dyl=_dyn, _scl=_scn, _rcl=_rcn, cl=c1, \
23551 _errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxl=_rxn, x1-xl))
23553 #define _cimg_for_triangle3(img,xl,txl,tyl,xr,txr,tyr,y,x0,y0,tx0,ty0,x1,y1,tx1,ty1,x2,y2,tx2,ty2) \
23554 for (int y = y0<0?0:y0, \
23555 xr = y0>=0?x0:(x0-y0*(x2-x0)/(y2-y0)), \
23556 txr = y0>=0?tx0:(tx0-y0*(tx2-tx0)/(y2-y0)), \
23557 tyr = y0>=0?ty0:(ty0-y0*(ty2-ty0)/(y2-y0)), \
23558 xl = y1>=0?(y0>=0?(y0==y1?x1:x0):(x0-y0*(x1-x0)/(y1-y0))):(x1-y1*(x2-x1)/(y2-y1)), \
23559 txl = y1>=0?(y0>=0?(y0==y1?tx1:tx0):(tx0-y0*(tx1-tx0)/(y1-y0))):(tx1-y1*(tx2-tx1)/(y2-y1)), \
23560 tyl = y1>=0?(y0>=0?(y0==y1?ty1:ty0):(ty0-y0*(ty1-ty0)/(y1-y0))):(ty1-y1*(ty2-ty1)/(y2-y1)), \
23561 _sxn=1, _stxn=1, _styn=1, \
23562 _sxr=1, _stxr=1, _styr=1, \
23563 _sxl=1, _stxl=1, _styl=1, \
23564 _dxn = x2>x1?x2-x1:(_sxn=-1,x1-x2), \
23565 _dxr = x2>x0?x2-x0:(_sxr=-1,x0-x2), \
23566 _dxl = x1>x0?x1-x0:(_sxl=-1,x0-x1), \
23567 _dtxn = tx2>tx1?tx2-tx1:(_stxn=-1,tx1-tx2), \
23568 _dtxr = tx2>tx0?tx2-tx0:(_stxr=-1,tx0-tx2), \
23569 _dtxl = tx1>tx0?tx1-tx0:(_stxl=-1,tx0-tx1), \
23570 _dtyn = ty2>ty1?ty2-ty1:(_styn=-1,ty1-ty2), \
23571 _dtyr = ty2>ty0?ty2-ty0:(_styr=-1,ty0-ty2), \
23572 _dtyl = ty1>ty0?ty1-ty0:(_styl=-1,ty0-ty1), \
23576 _counter =(_dxn-=_dyn?_dyn*(_dxn/_dyn):0, \
23577 _dxr-=_dyr?_dyr*(_dxr/_dyr):0, \
23578 _dxl-=_dyl?_dyl*(_dxl/_dyl):0, \
23579 _dtxn-=_dyn?_dyn*(_dtxn/_dyn):0, \
23580 _dtxr-=_dyr?_dyr*(_dtxr/_dyr):0, \
23581 _dtxl-=_dyl?_dyl*(_dtxl/_dyl):0, \
23582 _dtyn-=_dyn?_dyn*(_dtyn/_dyn):0, \
23583 _dtyr-=_dyr?_dyr*(_dtyr/_dyr):0, \
23584 _dtyl-=_dyl?_dyl*(_dtyl/_dyl):0, \
23585 cimg::min((int)(img).height-y-1,y2-y)), \
23586 _errn = _dyn/2, _errtxn = _errn, _errtyn = _errn, \
23587 _errr = _dyr/2, _errtxr = _errr, _errtyr = _errr, \
23588 _errl = _dyl/2, _errtxl = _errl, _errtyl = _errl, \
23589 _rxn = _dyn?(x2-x1)/_dyn:0, \
23590 _rtxn = _dyn?(tx2-tx1)/_dyn:0, \
23591 _rtyn = _dyn?(ty2-ty1)/_dyn:0, \
23592 _rxr = _dyr?(x2-x0)/_dyr:0, \
23593 _rtxr = _dyr?(tx2-tx0)/_dyr:0, \
23594 _rtyr = _dyr?(ty2-ty0)/_dyr:0, \
23595 _rxl = (y0!=y1 && y1>0)?(_dyl?(x1-x0)/_dyl:0): \
23596 (_errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxn), \
23597 _rtxl = (y0!=y1 && y1>0)?(_dyl?(tx1-tx0)/_dyl:0): \
23598 (_errtxl=_errtxn, _dtxl=_dtxn, _dyl=_dyn, _stxl=_stxn, _rtxn ), \
23599 _rtyl = (y0!=y1 && y1>0)?(_dyl?(ty1-ty0)/_dyl:0): \
23600 (_errtyl=_errtyn, _dtyl=_dtyn, _dyl=_dyn, _styl=_styn, _rtyn ); \
23601 _counter>=0; --_counter, ++y, \
23602 xr+=_rxr+((_errr-=_dxr)<0?_errr+=_dyr,_sxr:0), \
23603 txr+=_rtxr+((_errtxr-=_dtxr)<0?_errtxr+=_dyr,_stxr:0), \
23604 tyr+=_rtyr+((_errtyr-=_dtyr)<0?_errtyr+=_dyr,_styr:0), \
23605 xl+=(y!=y1)?(txl+=_rtxl+((_errtxl-=_dtxl)<0?(_errtxl+=_dyl,_stxl):0), \
23606 tyl+=_rtyl+((_errtyl-=_dtyl)<0?(_errtyl+=_dyl,_styl):0), \
23607 _rxl+((_errl-=_dxl)<0?(_errl+=_dyl,_sxl):0)): \
23608 (_errtxl=_errtxn, _dtxl=_dtxn, _dyl=_dyn, _stxl=_stxn, _rtxl=_rtxn, txl=tx1, \
23609 _errtyl=_errtyn, _dtyl=_dtyn, _dyl=_dyn, _styl=_styn, _rtyl=_rtyn, tyl=ty1,\
23610 _errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxl=_rxn, x1-xl))
23612 #define _cimg_for_triangle4(img,xl,cl,txl,tyl,xr,cr,txr,tyr,y,x0,y0,c0,tx0,ty0,x1,y1,c1,tx1,ty1,x2,y2,c2,tx2,ty2) \
23613 for (int y = y0<0?0:y0, \
23614 xr = y0>=0?x0:(x0-y0*(x2-x0)/(y2-y0)), \
23615 cr = y0>=0?c0:(c0-y0*(c2-c0)/(y2-y0)), \
23616 txr = y0>=0?tx0:(tx0-y0*(tx2-tx0)/(y2-y0)), \
23617 tyr = y0>=0?ty0:(ty0-y0*(ty2-ty0)/(y2-y0)), \
23618 xl = y1>=0?(y0>=0?(y0==y1?x1:x0):(x0-y0*(x1-x0)/(y1-y0))):(x1-y1*(x2-x1)/(y2-y1)), \
23619 cl = y1>=0?(y0>=0?(y0==y1?c1:c0):(c0-y0*(c1-c0)/(y1-y0))):(c1-y1*(c2-c1)/(y2-y1)), \
23620 txl = y1>=0?(y0>=0?(y0==y1?tx1:tx0):(tx0-y0*(tx1-tx0)/(y1-y0))):(tx1-y1*(tx2-tx1)/(y2-y1)), \
23621 tyl = y1>=0?(y0>=0?(y0==y1?ty1:ty0):(ty0-y0*(ty1-ty0)/(y1-y0))):(ty1-y1*(ty2-ty1)/(y2-y1)), \
23622 _sxn=1, _scn=1, _stxn=1, _styn=1, \
23623 _sxr=1, _scr=1, _stxr=1, _styr=1, \
23624 _sxl=1, _scl=1, _stxl=1, _styl=1, \
23625 _dxn = x2>x1?x2-x1:(_sxn=-1,x1-x2), \
23626 _dxr = x2>x0?x2-x0:(_sxr=-1,x0-x2), \
23627 _dxl = x1>x0?x1-x0:(_sxl=-1,x0-x1), \
23628 _dcn = c2>c1?c2-c1:(_scn=-1,c1-c2), \
23629 _dcr = c2>c0?c2-c0:(_scr=-1,c0-c2), \
23630 _dcl = c1>c0?c1-c0:(_scl=-1,c0-c1), \
23631 _dtxn = tx2>tx1?tx2-tx1:(_stxn=-1,tx1-tx2), \
23632 _dtxr = tx2>tx0?tx2-tx0:(_stxr=-1,tx0-tx2), \
23633 _dtxl = tx1>tx0?tx1-tx0:(_stxl=-1,tx0-tx1), \
23634 _dtyn = ty2>ty1?ty2-ty1:(_styn=-1,ty1-ty2), \
23635 _dtyr = ty2>ty0?ty2-ty0:(_styr=-1,ty0-ty2), \
23636 _dtyl = ty1>ty0?ty1-ty0:(_styl=-1,ty0-ty1), \
23640 _counter =(_dxn-=_dyn?_dyn*(_dxn/_dyn):0, \
23641 _dxr-=_dyr?_dyr*(_dxr/_dyr):0, \
23642 _dxl-=_dyl?_dyl*(_dxl/_dyl):0, \
23643 _dcn-=_dyn?_dyn*(_dcn/_dyn):0, \
23644 _dcr-=_dyr?_dyr*(_dcr/_dyr):0, \
23645 _dcl-=_dyl?_dyl*(_dcl/_dyl):0, \
23646 _dtxn-=_dyn?_dyn*(_dtxn/_dyn):0, \
23647 _dtxr-=_dyr?_dyr*(_dtxr/_dyr):0, \
23648 _dtxl-=_dyl?_dyl*(_dtxl/_dyl):0, \
23649 _dtyn-=_dyn?_dyn*(_dtyn/_dyn):0, \
23650 _dtyr-=_dyr?_dyr*(_dtyr/_dyr):0, \
23651 _dtyl-=_dyl?_dyl*(_dtyl/_dyl):0, \
23652 cimg::min((int)(img).height-y-1,y2-y)), \
23653 _errn = _dyn/2, _errcn = _errn, _errtxn = _errn, _errtyn = _errn, \
23654 _errr = _dyr/2, _errcr = _errr, _errtxr = _errr, _errtyr = _errr, \
23655 _errl = _dyl/2, _errcl = _errl, _errtxl = _errl, _errtyl = _errl, \
23656 _rxn = _dyn?(x2-x1)/_dyn:0, \
23657 _rcn = _dyn?(c2-c1)/_dyn:0, \
23658 _rtxn = _dyn?(tx2-tx1)/_dyn:0, \
23659 _rtyn = _dyn?(ty2-ty1)/_dyn:0, \
23660 _rxr = _dyr?(x2-x0)/_dyr:0, \
23661 _rcr = _dyr?(c2-c0)/_dyr:0, \
23662 _rtxr = _dyr?(tx2-tx0)/_dyr:0, \
23663 _rtyr = _dyr?(ty2-ty0)/_dyr:0, \
23664 _rxl = (y0!=y1 && y1>0)?(_dyl?(x1-x0)/_dyl:0): \
23665 (_errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxn), \
23666 _rcl = (y0!=y1 && y1>0)?(_dyl?(c1-c0)/_dyl:0): \
23667 (_errcl=_errcn, _dcl=_dcn, _dyl=_dyn, _scl=_scn, _rcn ), \
23668 _rtxl = (y0!=y1 && y1>0)?(_dyl?(tx1-tx0)/_dyl:0): \
23669 (_errtxl=_errtxn, _dtxl=_dtxn, _dyl=_dyn, _stxl=_stxn, _rtxn ), \
23670 _rtyl = (y0!=y1 && y1>0)?(_dyl?(ty1-ty0)/_dyl:0): \
23671 (_errtyl=_errtyn, _dtyl=_dtyn, _dyl=_dyn, _styl=_styn, _rtyn ); \
23672 _counter>=0; --_counter, ++y, \
23673 xr+=_rxr+((_errr-=_dxr)<0?_errr+=_dyr,_sxr:0), \
23674 cr+=_rcr+((_errcr-=_dcr)<0?_errcr+=_dyr,_scr:0), \
23675 txr+=_rtxr+((_errtxr-=_dtxr)<0?_errtxr+=_dyr,_stxr:0), \
23676 tyr+=_rtyr+((_errtyr-=_dtyr)<0?_errtyr+=_dyr,_styr:0), \
23677 xl+=(y!=y1)?(cl+=_rcl+((_errcl-=_dcl)<0?(_errcl+=_dyl,_scl):0), \
23678 txl+=_rtxl+((_errtxl-=_dtxl)<0?(_errtxl+=_dyl,_stxl):0), \
23679 tyl+=_rtyl+((_errtyl-=_dtyl)<0?(_errtyl+=_dyl,_styl):0), \
23680 _rxl+((_errl-=_dxl)<0?(_errl+=_dyl,_sxl):0)): \
23681 (_errcl=_errcn, _dcl=_dcn, _dyl=_dyn, _scl=_scn, _rcl=_rcn, cl=c1, \
23682 _errtxl=_errtxn, _dtxl=_dtxn, _dyl=_dyn, _stxl=_stxn, _rtxl=_rtxn, txl=tx1, \
23683 _errtyl=_errtyn, _dtyl=_dtyn, _dyl=_dyn, _styl=_styn, _rtyl=_rtyn, tyl=ty1, \
23684 _errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxl=_rxn, x1-xl))
23686 #define _cimg_for_triangle5(img,xl,txl,tyl,lxl,lyl,xr,txr,tyr,lxr,lyr,y,x0,y0,tx0,ty0,lx0,ly0,x1,y1,tx1,ty1,lx1,ly1,x2,y2,tx2,ty2,lx2,ly2) \
23687 for (int y = y0<0?0:y0, \
23688 xr = y0>=0?x0:(x0-y0*(x2-x0)/(y2-y0)), \
23689 txr = y0>=0?tx0:(tx0-y0*(tx2-tx0)/(y2-y0)), \
23690 tyr = y0>=0?ty0:(ty0-y0*(ty2-ty0)/(y2-y0)), \
23691 lxr = y0>=0?lx0:(lx0-y0*(lx2-lx0)/(y2-y0)), \
23692 lyr = y0>=0?ly0:(ly0-y0*(ly2-ly0)/(y2-y0)), \
23693 xl = y1>=0?(y0>=0?(y0==y1?x1:x0):(x0-y0*(x1-x0)/(y1-y0))):(x1-y1*(x2-x1)/(y2-y1)), \
23694 txl = y1>=0?(y0>=0?(y0==y1?tx1:tx0):(tx0-y0*(tx1-tx0)/(y1-y0))):(tx1-y1*(tx2-tx1)/(y2-y1)), \
23695 tyl = y1>=0?(y0>=0?(y0==y1?ty1:ty0):(ty0-y0*(ty1-ty0)/(y1-y0))):(ty1-y1*(ty2-ty1)/(y2-y1)), \
23696 lxl = y1>=0?(y0>=0?(y0==y1?lx1:lx0):(lx0-y0*(lx1-lx0)/(y1-y0))):(lx1-y1*(lx2-lx1)/(y2-y1)), \
23697 lyl = y1>=0?(y0>=0?(y0==y1?ly1:ly0):(ly0-y0*(ly1-ly0)/(y1-y0))):(ly1-y1*(ly2-ly1)/(y2-y1)), \
23698 _sxn=1, _stxn=1, _styn=1, _slxn=1, _slyn=1, \
23699 _sxr=1, _stxr=1, _styr=1, _slxr=1, _slyr=1, \
23700 _sxl=1, _stxl=1, _styl=1, _slxl=1, _slyl=1, \
23701 _dxn = x2>x1?x2-x1:(_sxn=-1,x1-x2), _dyn = y2-y1, \
23702 _dxr = x2>x0?x2-x0:(_sxr=-1,x0-x2), _dyr = y2-y0, \
23703 _dxl = x1>x0?x1-x0:(_sxl=-1,x0-x1), _dyl = y1-y0, \
23704 _dtxn = tx2>tx1?tx2-tx1:(_stxn=-1,tx1-tx2), \
23705 _dtxr = tx2>tx0?tx2-tx0:(_stxr=-1,tx0-tx2), \
23706 _dtxl = tx1>tx0?tx1-tx0:(_stxl=-1,tx0-tx1), \
23707 _dtyn = ty2>ty1?ty2-ty1:(_styn=-1,ty1-ty2), \
23708 _dtyr = ty2>ty0?ty2-ty0:(_styr=-1,ty0-ty2), \
23709 _dtyl = ty1>ty0?ty1-ty0:(_styl=-1,ty0-ty1), \
23710 _dlxn = lx2>lx1?lx2-lx1:(_slxn=-1,lx1-lx2), \
23711 _dlxr = lx2>lx0?lx2-lx0:(_slxr=-1,lx0-lx2), \
23712 _dlxl = lx1>lx0?lx1-lx0:(_slxl=-1,lx0-lx1), \
23713 _dlyn = ly2>ly1?ly2-ly1:(_slyn=-1,ly1-ly2), \
23714 _dlyr = ly2>ly0?ly2-ly0:(_slyr=-1,ly0-ly2), \
23715 _dlyl = ly1>ly0?ly1-ly0:(_slyl=-1,ly0-ly1), \
23716 _counter =(_dxn-=_dyn?_dyn*(_dxn/_dyn):0, \
23717 _dxr-=_dyr?_dyr*(_dxr/_dyr):0, \
23718 _dxl-=_dyl?_dyl*(_dxl/_dyl):0, \
23719 _dtxn-=_dyn?_dyn*(_dtxn/_dyn):0, \
23720 _dtxr-=_dyr?_dyr*(_dtxr/_dyr):0, \
23721 _dtxl-=_dyl?_dyl*(_dtxl/_dyl):0, \
23722 _dtyn-=_dyn?_dyn*(_dtyn/_dyn):0, \
23723 _dtyr-=_dyr?_dyr*(_dtyr/_dyr):0, \
23724 _dtyl-=_dyl?_dyl*(_dtyl/_dyl):0, \
23725 _dlxn-=_dyn?_dyn*(_dlxn/_dyn):0, \
23726 _dlxr-=_dyr?_dyr*(_dlxr/_dyr):0, \
23727 _dlxl-=_dyl?_dyl*(_dlxl/_dyl):0, \
23728 _dlyn-=_dyn?_dyn*(_dlyn/_dyn):0, \
23729 _dlyr-=_dyr?_dyr*(_dlyr/_dyr):0, \
23730 _dlyl-=_dyl?_dyl*(_dlyl/_dyl):0, \
23731 cimg::min((int)(img).height-y-1,y2-y)), \
23732 _errn = _dyn/2, _errtxn = _errn, _errtyn = _errn, _errlxn = _errn, _errlyn = _errn, \
23733 _errr = _dyr/2, _errtxr = _errr, _errtyr = _errr, _errlxr = _errr, _errlyr = _errr, \
23734 _errl = _dyl/2, _errtxl = _errl, _errtyl = _errl, _errlxl = _errl, _errlyl = _errl, \
23735 _rxn = _dyn?(x2-x1)/_dyn:0, \
23736 _rtxn = _dyn?(tx2-tx1)/_dyn:0, \
23737 _rtyn = _dyn?(ty2-ty1)/_dyn:0, \
23738 _rlxn = _dyn?(lx2-lx1)/_dyn:0, \
23739 _rlyn = _dyn?(ly2-ly1)/_dyn:0, \
23740 _rxr = _dyr?(x2-x0)/_dyr:0, \
23741 _rtxr = _dyr?(tx2-tx0)/_dyr:0, \
23742 _rtyr = _dyr?(ty2-ty0)/_dyr:0, \
23743 _rlxr = _dyr?(lx2-lx0)/_dyr:0, \
23744 _rlyr = _dyr?(ly2-ly0)/_dyr:0, \
23745 _rxl = (y0!=y1 && y1>0)?(_dyl?(x1-x0)/_dyl:0): \
23746 (_errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxn), \
23747 _rtxl = (y0!=y1 && y1>0)?(_dyl?(tx1-tx0)/_dyl:0): \
23748 (_errtxl=_errtxn, _dtxl=_dtxn, _dyl=_dyn, _stxl=_stxn, _rtxn ), \
23749 _rtyl = (y0!=y1 && y1>0)?(_dyl?(ty1-ty0)/_dyl:0): \
23750 (_errtyl=_errtyn, _dtyl=_dtyn, _dyl=_dyn, _styl=_styn, _rtyn ), \
23751 _rlxl = (y0!=y1 && y1>0)?(_dyl?(lx1-lx0)/_dyl:0): \
23752 (_errlxl=_errlxn, _dlxl=_dlxn, _dyl=_dyn, _slxl=_slxn, _rlxn ), \
23753 _rlyl = (y0!=y1 && y1>0)?(_dyl?(ly1-ly0)/_dyl:0): \
23754 (_errlyl=_errlyn, _dlyl=_dlyn, _dyl=_dyn, _slyl=_slyn, _rlyn ); \
23755 _counter>=0; --_counter, ++y, \
23756 xr+=_rxr+((_errr-=_dxr)<0?_errr+=_dyr,_sxr:0), \
23757 txr+=_rtxr+((_errtxr-=_dtxr)<0?_errtxr+=_dyr,_stxr:0), \
23758 tyr+=_rtyr+((_errtyr-=_dtyr)<0?_errtyr+=_dyr,_styr:0), \
23759 lxr+=_rlxr+((_errlxr-=_dlxr)<0?_errlxr+=_dyr,_slxr:0), \
23760 lyr+=_rlyr+((_errlyr-=_dlyr)<0?_errlyr+=_dyr,_slyr:0), \
23761 xl+=(y!=y1)?(txl+=_rtxl+((_errtxl-=_dtxl)<0?(_errtxl+=_dyl,_stxl):0), \
23762 tyl+=_rtyl+((_errtyl-=_dtyl)<0?(_errtyl+=_dyl,_styl):0), \
23763 lxl+=_rlxl+((_errlxl-=_dlxl)<0?(_errlxl+=_dyl,_slxl):0), \
23764 lyl+=_rlyl+((_errlyl-=_dlyl)<0?(_errlyl+=_dyl,_slyl):0), \
23765 _rxl+((_errl-=_dxl)<0?(_errl+=_dyl,_sxl):0)): \
23766 (_errtxl=_errtxn, _dtxl=_dtxn, _dyl=_dyn, _stxl=_stxn, _rtxl=_rtxn, txl=tx1, \
23767 _errtyl=_errtyn, _dtyl=_dtyn, _dyl=_dyn, _styl=_styn, _rtyl=_rtyn, tyl=ty1, \
23768 _errlxl=_errlxn, _dlxl=_dlxn, _dyl=_dyn, _slxl=_slxn, _rlxl=_rlxn, lxl=lx1, \
23769 _errlyl=_errlyn, _dlyl=_dlyn, _dyl=_dyn, _slyl=_slyn, _rlyl=_rlyn, lyl=ly1, \
23770 _errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxl=_rxn, x1-xl))
23773 template<
typename tc>
23775 const int x1,
const int y1,
23776 const int x2,
const int y2,
23777 const tc *
const color,
const float opacity,
23778 const float brightness) {
23780 const float nbrightness = brightness<0?0:(brightness>2?2:brightness);
23781 int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2;
23785 if (ny0<
dimy() && ny2>=0) {
23786 if ((nx1 - nx0)*(ny2 - ny0) - (nx2 - nx0)*(ny1 - ny0)<0)
23787 _cimg_for_triangle1(*
this,xl,xr,
y,nx0,ny0,nx1,ny1,nx2,ny2)
_draw_scanline(xl,xr,
y,color,opacity,nbrightness);
23789 _cimg_for_triangle1(*
this,xl,xr,
y,nx0,ny0,nx1,ny1,nx2,ny2)
_draw_scanline(xr,xl,
y,color,opacity,nbrightness);
23795 template<
typename tc>
23797 const int x1,
const int y1,
23798 const int x2,
const int y2,
23799 const tc *
const color,
const float opacity=1) {
23809 template<
typename tc>
23811 const int x1,
const int y1,
23812 const int x2,
const int y2,
23813 const CImg<tc>& color,
const float opacity=1) {
23814 return draw_triangle(x0,y0,x1,y1,x2,y2,color.data,opacity);
23818 template<
typename tc>
23820 const int x1,
const int y1,
23821 const int x2,
const int y2,
23822 const tc *
const color,
const float opacity,
23823 const unsigned int pattern) {
23828 draw_line(x0,y0,x1,y1,color,opacity,pattern,
true).
23829 draw_line(x1,y1,x2,y2,color,opacity,pattern,
false).
23830 draw_line(x2,y2,x0,y0,color,opacity,pattern,
false);
23835 template<
typename tc>
23837 const int x1,
const int y1,
23838 const int x2,
const int y2,
23839 const CImg<tc>& color,
const float opacity,
23840 const unsigned int pattern) {
23841 return draw_triangle(x0,y0,x1,y1,x2,y2,color.data,opacity,pattern);
23845 template<
typename tc>
23847 const int x0,
const int y0,
const float z0,
23848 const int x1,
const int y1,
const float z1,
23849 const int x2,
const int y2,
const float z2,
23850 const tc *
const color,
const float opacity=1,
23851 const float brightness=1) {
23852 if (
is_empty() || z0<=0 || z1<=0 || z2<=0)
return *
this;
23857 throw CImgArgumentException(
"CImg<%s>::draw_line() : Z-buffer (%u,%u,%u,%u,%p) and instance image (%u,%u,%u,%u,%p) have different dimensions.",
23858 pixel_type(),zbuffer.width,zbuffer.height,zbuffer.depth,zbuffer.dim,zbuffer.data,
width,
height,
depth,dim,
data);
23862 nbrightness = brightness<0?0:(brightness>2?2:brightness);
23864 int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2;
23865 float nz0 = 1/z0, nz1 = 1/z1, nz2 = 1/z2;
23866 if (ny0>ny1)
cimg::swap(nx0,nx1,ny0,ny1,nz0,nz1);
23867 if (ny0>ny2)
cimg::swap(nx0,nx2,ny0,ny2,nz0,nz2);
23868 if (ny1>ny2)
cimg::swap(nx1,nx2,ny1,ny2,nz1,nz2);
23869 if (ny0>=
dimy() || ny2<0)
return *
this;
23871 pzl = (nz1 - nz0)/(ny1 - ny0),
23872 pzr = (nz2 - nz0)/(ny2 - ny0),
23873 pzn = (nz2 - nz1)/(ny2 - ny1),
23874 zr = ny0>=0?nz0:(nz0 - ny0*(nz2 - nz0)/(ny2 - ny0)),
23875 zl = ny1>=0?(ny0>=0?nz0:(nz0 - ny0*(nz1 - nz0)/(ny1 - ny0))):(pzl=pzn,(nz1 - ny1*(nz2 - nz1)/(ny2 - ny1)));
23877 if (
y==ny1) { zl = nz1; pzl = pzn; }
23878 int xleft = xleft0, xright = xright0;
23879 float zleft = zl, zright = zr;
23880 if (xright<xleft)
cimg::swap(xleft,xright,zleft,zright);
23881 const int dx = xright - xleft;
23882 const float pentez = (zright - zleft)/dx;
23883 if (xleft<0 && dx) zleft-=xleft*(zright - zleft)/dx;
23884 if (xleft<0) xleft = 0;
23885 if (xright>=
dimx()-1) xright =
dimx()-1;
23886 T* ptrd =
ptr(xleft,
y,0,0);
23887 float *ptrz = zbuffer.ptr(xleft,
y);
23889 if (nbrightness==1)
for (
int x = xleft; x<=xright; ++
x, ++ptrz, ++ptrd) {
23892 const tc *col = color;
cimg_forV(*
this,
k) { *ptrd = (T)*(col++); ptrd+=whz; }
23896 }
else if (nbrightness<1)
for (
int x = xleft; x<=xright; ++
x, ++ptrz, ++ptrd) {
23899 const tc *col = color;
cimg_forV(*
this,
k) { *ptrd = (T)(nbrightness*(*col++)); ptrd+=whz; }
23903 }
else for (
int x = xleft; x<=xright; ++
x, ++ptrz, ++ptrd) {
23906 const tc *col = color;
cimg_forV(*
this,
k) { *ptrd = (T)((2-nbrightness)**(col++) + (nbrightness-1)*maxval); ptrd+=whz; }
23912 if (nbrightness==1)
for (
int x = xleft; x<=xright; ++
x, ++ptrz, ++ptrd) {
23915 const tc *col = color;
cimg_forV(*
this,
k) { *ptrd = (T)(nopacity**(col++) + *ptrd*copacity); ptrd+=whz; }
23919 }
else if (nbrightness<1)
for (
int x = xleft; x<=xright; ++
x, ++ptrz, ++ptrd) {
23922 const tc *col = color;
cimg_forV(*
this,
k) { *ptrd = (T)(nopacity*nbrightness**(col++) + *ptrd*copacity); ptrd+=whz; }
23926 }
else for (
int x = xleft; x<=xright; ++
x, ++ptrz, ++ptrd) {
23929 const tc *col = color;
23931 const T val = (T)((2-nbrightness)**(col++) + (nbrightness-1)*maxval);
23932 *ptrd = (T)(nopacity*val + *ptrd*copacity);
23946 template<
typename tc>
23948 const int x0,
const int y0,
const float z0,
23949 const int x1,
const int y1,
const float z1,
23950 const int x2,
const int y2,
const float z2,
23951 const CImg<tc>& color,
const float opacity=1,
23952 const float brightness=1) {
23953 return draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color.data,opacity,brightness);
23971 template<
typename tc>
23973 const int x1,
const int y1,
23974 const int x2,
const int y2,
23975 const tc *
const color,
23976 const float brightness0,
23977 const float brightness1,
23978 const float brightness2,
23979 const float opacity=1) {
23987 int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2,
23988 nc0 = (int)((brightness0<0.0f?0.0f:(brightness0>2.0f?2.0f:brightness0))*256.0f),
23989 nc1 = (
int)((brightness1<0.0f?0.0f:(brightness1>2.0f?2.0f:brightness1))*256.0f),
23990 nc2 = (
int)((brightness2<0.0f?0.0f:(brightness2>2.0f?2.0f:brightness2))*256.0f);
23991 if (ny0>ny1)
cimg::swap(nx0,nx1,ny0,ny1,nc0,nc1);
23992 if (ny0>ny2)
cimg::swap(nx0,nx2,ny0,ny2,nc0,nc2);
23993 if (ny1>ny2)
cimg::swap(nx1,nx2,ny1,ny2,nc1,nc2);
23994 if (ny0>=
dimy() || ny2<0)
return *
this;
23995 _cimg_for_triangle2(*
this,xleft0,cleft0,xright0,cright0,
y,nx0,ny0,nc0,nx1,ny1,nc1,nx2,ny2,nc2) {
23996 int xleft = xleft0, xright = xright0, cleft = cleft0, cright = cright0;
23997 if (xright<xleft)
cimg::swap(xleft,xright,cleft,cright);
23999 dx = xright - xleft,
24000 dc = cright>cleft?cright - cleft:cleft - cright,
24001 rc = dx?(cright - cleft)/dx:0,
24002 sc = cright>cleft?1:-1,
24003 ndc = dc-(dx?dx*(dc/dx):0);
24005 if (xleft<0 && dx) cleft-=xleft*(cright - cleft)/dx;
24006 if (xleft<0) xleft = 0;
24007 if (xright>=
dimx()-1) xright =
dimx()-1;
24008 T* ptrd =
ptr(xleft,
y);
24009 if (opacity>=1)
for (
int x = xleft; x<=xright; ++
x) {
24010 const tc *col = color;
24012 *ptrd = (T)(cleft<256?cleft**(col++)/256:((512-cleft)**(col++)+(cleft-256)*maxval)/256);
24016 cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0);
24017 }
else for (
int x = xleft; x<=xright; ++
x) {
24018 const tc *col = color;
24020 const T val = (T)(cleft<256?cleft**(col++)/256:((512-cleft)**(col++)+(cleft-256)*maxval)/256);
24021 *ptrd = (T)(nopacity*val + *ptrd*copacity);
24025 cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0);
24032 template<
typename tc>
24034 const int x1,
const int y1,
24035 const int x2,
const int y2,
24037 const float brightness0,
24038 const float brightness1,
24039 const float brightness2,
24040 const float opacity=1) {
24041 return draw_triangle(x0,y0,x1,y1,x2,y2,color.data,brightness0,brightness1,brightness2,opacity);
24045 template<
typename tc>
24047 const int x0,
const int y0,
const float z0,
24048 const int x1,
const int y1,
const float z1,
24049 const int x2,
const int y2,
const float z2,
24050 const tc *
const color,
24051 const float brightness0,
24052 const float brightness1,
24053 const float brightness2,
24054 const float opacity=1) {
24055 if (
is_empty() || z0<=0 || z1<=0 || z2<=0)
return *
this;
24060 throw CImgArgumentException(
"CImg<%s>::draw_line() : Z-buffer (%u,%u,%u,%u,%p) and instance image (%u,%u,%u,%u,%p) have different dimensions.",
24061 pixel_type(),zbuffer.width,zbuffer.height,zbuffer.depth,zbuffer.dim,zbuffer.data,
width,
height,
depth,dim,
data);
24065 int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2,
24066 nc0 = (int)((brightness0<0.0f?0.0f:(brightness0>2.0f?2.0f:brightness0))*256.0f),
24067 nc1 = (
int)((brightness1<0.0f?0.0f:(brightness1>2.0f?2.0f:brightness1))*256.0f),
24068 nc2 = (
int)((brightness2<0.0f?0.0f:(brightness2>2.0f?2.0f:brightness2))*256.0f);
24069 float nz0 = 1/z0, nz1 = 1/z1, nz2 = 1/z2;
24070 if (ny0>ny1)
cimg::swap(nx0,nx1,ny0,ny1,nz0,nz1,nc0,nc1);
24071 if (ny0>ny2)
cimg::swap(nx0,nx2,ny0,ny2,nz0,nz2,nc0,nc2);
24072 if (ny1>ny2)
cimg::swap(nx1,nx2,ny1,ny2,nz1,nz2,nc1,nc2);
24073 if (ny0>=
dimy() || ny2<0)
return *
this;
24075 pzl = (nz1 - nz0)/(ny1 - ny0),
24076 pzr = (nz2 - nz0)/(ny2 - ny0),
24077 pzn = (nz2 - nz1)/(ny2 - ny1),
24078 zr = ny0>=0?nz0:(nz0 - ny0*(nz2 - nz0)/(ny2 - ny0)),
24079 zl = ny1>=0?(ny0>=0?nz0:(nz0 - ny0*(nz1 - nz0)/(ny1 - ny0))):(pzl=pzn,(nz1 - ny1*(nz2 - nz1)/(ny2 - ny1)));
24080 _cimg_for_triangle2(*
this,xleft0,cleft0,xright0,cright0,
y,nx0,ny0,nc0,nx1,ny1,nc1,nx2,ny2,nc2) {
24081 if (
y==ny1) { zl = nz1; pzl = pzn; }
24082 int xleft = xleft0, xright = xright0, cleft = cleft0, cright = cright0;
24083 float zleft = zl, zright = zr;
24084 if (xright<xleft)
cimg::swap(xleft,xright,zleft,zright,cleft,cright);
24086 dx = xright - xleft,
24087 dc = cright>cleft?cright - cleft:cleft - cright,
24088 rc = dx?(cright-cleft)/dx:0,
24089 sc = cright>cleft?1:-1,
24090 ndc = dc-(dx?dx*(dc/dx):0);
24091 const float pentez = (zright - zleft)/dx;
24093 if (xleft<0 && dx) {
24094 cleft-=xleft*(cright - cleft)/dx;
24095 zleft-=xleft*(zright - zleft)/dx;
24097 if (xleft<0) xleft = 0;
24098 if (xright>=
dimx()-1) xright =
dimx()-1;
24099 T *ptrd =
ptr(xleft,
y);
24100 float *ptrz = zbuffer.ptr(xleft,
y);
24101 if (opacity>=1)
for (
int x = xleft; x<=xright; ++
x, ++ptrd, ++ptrz) {
24104 const tc *col = color;
24106 *ptrd = (T)(cleft<256?cleft**(col++)/256:((512-cleft)**(col++)+(cleft-256)*maxval)/256);
24112 cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0);
24113 }
else for (
int x = xleft; x<=xright; ++
x, ++ptrd, ++ptrz) {
24116 const tc *col = color;
24118 const T val = (T)(cleft<256?cleft**(col++)/256:((512-cleft)**(col++)+(cleft-256)*maxval)/256);
24119 *ptrd = (T)(nopacity*val + *ptrd*copacity);
24125 cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0);
24133 template<
typename tc>
24135 const int x0,
const int y0,
const float z0,
24136 const int x1,
const int y1,
const float z1,
24137 const int x2,
const int y2,
const float z2,
24139 const float brightness0,
24140 const float brightness1,
24141 const float brightness2,
24142 const float opacity=1) {
24143 return draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color.data,brightness0,brightness1,brightness2,opacity);
24147 template<
typename tc1,
typename tc2,
typename tc3>
24149 const int x1,
const int y1,
24150 const int x2,
const int y2,
24151 const tc1 *
const color1,
24152 const tc2 *
const color2,
24153 const tc3 *
const color3,
24154 const float opacity=1) {
24155 const unsigned char one = 1;
24156 cimg_forV(*
this,
k)
get_shared_channel(
k).draw_triangle(x0,y0,x1,y1,x2,y2,&one,color1[
k],color2[k],color3[k],opacity);
24160 template<
typename tc1,
typename tc2,
typename tc3>
24162 const int x1,
const int y1,
24163 const int x2,
const int y2,
24167 const float opacity=1) {
24168 return draw_triangle(x0,y0,x1,y1,x2,y2,color1.data,color2.data,color3.data,opacity);
24190 template<
typename tc>
24192 const int x1,
const int y1,
24193 const int x2,
const int y2,
24195 const int tx0,
const int ty0,
24196 const int tx1,
const int ty1,
24197 const int tx2,
const int ty2,
24198 const float opacity=1,
24199 const float brightness=1) {
24201 if (!texture || texture.dim<dim)
24202 throw CImgArgumentException(
"CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
24203 pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
24204 if (
is_overlapped(texture))
return draw_triangle(x0,y0,x1,y1,x2,y2,+texture,tx0,ty0,tx1,ty1,tx2,ty2,opacity,brightness);
24208 nbrightness = brightness<0?0:(brightness>2?2:brightness);
24209 const int whz =
width*
height*
depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz-1;
24210 int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2,
24211 ntx0 = tx0, nty0 = ty0, ntx1 = tx1, nty1 = ty1, ntx2 = tx2, nty2 = ty2;
24212 if (ny0>ny1)
cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1);
24213 if (ny0>ny2)
cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2);
24214 if (ny1>ny2)
cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2);
24215 if (ny0>=
dimy() || ny2<0)
return *
this;
24217 nx0,ny0,ntx0,nty0,nx1,ny1,ntx1,nty1,nx2,ny2,ntx2,nty2) {
24219 xleft = xleft0, xright = xright0,
24220 txleft = txleft0, txright = txright0,
24221 tyleft = tyleft0, tyright = tyright0;
24222 if (xright<xleft)
cimg::swap(xleft,xright,txleft,txright,tyleft,tyright);
24224 dx = xright - xleft,
24225 dtx = txright>txleft?txright - txleft:txleft - txright,
24226 dty = tyright>tyleft?tyright - tyleft:tyleft - tyright,
24227 rtx = dx?(txright - txleft)/dx:0,
24228 rty = dx?(tyright - tyleft)/dx:0,
24229 stx = txright>txleft?1:-1,
24230 sty = tyright>tyleft?1:-1,
24231 ndtx = dtx - (dx?dx*(dtx/
dx):0),
24232 ndty = dty - (dx?dx*(dty/
dx):0);
24233 int errtx = dx>>1, errty = errtx;
24234 if (xleft<0 && dx) {
24235 txleft-=xleft*(txright - txleft)/dx;
24236 tyleft-=xleft*(tyright - tyleft)/dx;
24238 if (xleft<0) xleft = 0;
24239 if (xright>=
dimx()-1) xright =
dimx()-1;
24240 T* ptrd =
ptr(xleft,
y,0,0);
24242 if (nbrightness==1)
for (
int x = xleft; x<=xright; ++
x) {
24243 const tc *col = texture.ptr(txleft,tyleft);
24246 ptrd+=whz; col+=twhz;
24249 txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0);
24250 tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0);
24251 }
else if (nbrightness<1)
for (
int x = xleft; x<=xright; ++
x) {
24252 const tc *col = texture.ptr(txleft,tyleft);
24254 *ptrd = (T)(nbrightness**col);
24255 ptrd+=whz; col+=twhz;
24258 txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0);
24259 tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0);
24260 }
else for (
int x = xleft; x<=xright; ++
x) {
24261 const tc *col = texture.ptr(txleft,tyleft);
24263 *ptrd = (T)((2-nbrightness)**(col++) + (nbrightness-1)*maxval);
24264 ptrd+=whz; col+=twhz;
24267 txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0);
24268 tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0);
24271 if (nbrightness==1)
for (
int x = xleft; x<=xright; ++
x) {
24272 const tc *col = texture.ptr(txleft,tyleft);
24274 *ptrd = (T)(nopacity**col + *ptrd*copacity);
24275 ptrd+=whz; col+=twhz;
24278 txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0);
24279 tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0);
24280 }
else if (nbrightness<1)
for (
int x = xleft; x<=xright; ++
x) {
24281 const tc *col = texture.ptr(txleft,tyleft);
24283 *ptrd = (T)(nopacity*nbrightness**col + *ptrd*copacity);
24284 ptrd+=whz; col+=twhz;
24287 txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0);
24288 tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0);
24289 }
else for (
int x = xleft; x<=xright; ++
x) {
24290 const tc *col = texture.ptr(txleft,tyleft);
24292 const T val = (T)((2-nbrightness)**(col++) + (nbrightness-1)*maxval);
24293 *ptrd = (T)(nopacity*val + *ptrd*copacity);
24294 ptrd+=whz; col+=twhz;
24297 txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0);
24298 tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0);
24306 template<
typename tc>
24308 const int x1,
const int y1,
const float z1,
24309 const int x2,
const int y2,
const float z2,
24311 const int tx0,
const int ty0,
24312 const int tx1,
const int ty1,
24313 const int tx2,
const int ty2,
24314 const float opacity=1,
24315 const float brightness=1) {
24316 if (
is_empty() || z0<=0 || z1<=0 || z2<=0)
return *
this;
24317 if (!texture || texture.dim<dim)
24318 throw CImgArgumentException(
"CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
24319 pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
24320 if (
is_overlapped(texture))
return draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,+texture,tx0,ty0,tx1,ty1,tx2,ty2,opacity,brightness);
24324 nbrightness = brightness<0?0:(brightness>2?2:brightness);
24325 const int whz =
width*
height*
depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz-1;
24326 int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2;
24328 ntx0 = tx0/z0, nty0 = ty0/z0,
24329 ntx1 = tx1/z1, nty1 = ty1/z1,
24330 ntx2 = tx2/z2, nty2 = ty2/z2,
24331 nz0 = 1/z0, nz1 = 1/z1, nz2 = 1/z2;
24332 if (ny0>ny1)
cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1,nz0,nz1);
24333 if (ny0>ny2)
cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2,nz0,nz2);
24334 if (ny1>ny2)
cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2,nz1,nz2);
24335 if (ny0>=
dimy() || ny2<0)
return *
this;
24337 ptxl = (ntx1 - ntx0)/(ny1 - ny0),
24338 ptxr = (ntx2 - ntx0)/(ny2 - ny0),
24339 ptxn = (ntx2 - ntx1)/(ny2 - ny1),
24340 ptyl = (nty1 - nty0)/(ny1 - ny0),
24341 ptyr = (nty2 - nty0)/(ny2 - ny0),
24342 ptyn = (nty2 - nty1)/(ny2 - ny1),
24343 pzl = (nz1 - nz0)/(ny1 - ny0),
24344 pzr = (nz2 - nz0)/(ny2 - ny0),
24345 pzn = (nz2 - nz1)/(ny2 - ny1),
24346 zr = ny0>=0?nz0:(nz0 - ny0*(nz2 - nz0)/(ny2 - ny0)),
24347 txr = ny0>=0?ntx0:(ntx0 - ny0*(ntx2 - ntx0)/(ny2 - ny0)),
24348 tyr = ny0>=0?nty0:(nty0 - ny0*(nty2 - nty0)/(ny2 - ny0)),
24349 zl = ny1>=0?(ny0>=0?nz0:(nz0 - ny0*(nz1 - nz0)/(ny1 - ny0))):(pzl=pzn,(nz1 - ny1*(nz2 - nz1)/(ny2 - ny1))),
24350 txl = ny1>=0?(ny0>=0?ntx0:(ntx0 - ny0*(ntx1 - ntx0)/(ny1 - ny0))):(ptxl=ptxn,(ntx1 - ny1*(ntx2 - ntx1)/(ny2 - ny1))),
24351 tyl = ny1>=0?(ny0>=0?nty0:(nty0 - ny0*(nty1 - nty0)/(ny1 - ny0))):(ptyl=ptyn,(nty1 - ny1*(nty2 - nty1)/(ny2 - ny1)));
24353 if (
y==ny1) { zl = nz1; txl = ntx1; tyl = nty1; pzl = pzn; ptxl = ptxn; ptyl = ptyn; }
24354 int xleft = xleft0, xright = xright0;
24356 zleft = zl, zright = zr,
24357 txleft = txl, txright = txr,
24358 tyleft = tyl, tyright = tyr;
24359 if (xright<xleft)
cimg::swap(xleft,xright,zleft,zright,txleft,txright,tyleft,tyright);
24360 const int dx = xright - xleft;
24362 pentez = (zright - zleft)/dx,
24363 pentetx = (txright - txleft)/
dx,
24364 pentety = (tyright - tyleft)/dx;
24365 if (xleft<0 && dx) {
24366 zleft-=xleft*(zright - zleft)/dx;
24367 txleft-=xleft*(txright - txleft)/dx;
24368 tyleft-=xleft*(tyright - tyleft)/dx;
24370 if (xleft<0) xleft = 0;
24371 if (xright>=
dimx()-1) xright =
dimx()-1;
24372 T* ptrd =
ptr(xleft,
y,0,0);
24374 if (nbrightness==1)
for (
int x = xleft; x<=xright; ++
x) {
24375 const float invz = 1/zleft;
24376 const tc *col = texture.ptr((
int)(txleft*invz),(
int)(tyleft*invz));
24379 ptrd+=whz; col+=twhz;
24381 ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24382 }
else if (nbrightness<1)
for (
int x=xleft; x<=xright; ++
x) {
24383 const float invz = 1/zleft;
24384 const tc *col = texture.ptr((
int)(txleft*invz),(
int)(tyleft*invz));
24386 *ptrd = (T)(nbrightness**col);
24387 ptrd+=whz; col+=twhz;
24389 ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24390 }
else for (
int x = xleft; x<=xright; ++
x) {
24391 const float invz = 1/zleft;
24392 const tc *col = texture.ptr((
int)(txleft*invz),(
int)(tyleft*invz));
24394 *ptrd = (T)((2-nbrightness)**col + (nbrightness-1)*maxval);
24395 ptrd+=whz; col+=twhz;
24397 ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24400 if (nbrightness==1)
for (
int x = xleft; x<=xright; ++
x) {
24401 const float invz = 1/zleft;
24402 const tc *col = texture.ptr((
int)(txleft*invz),(
int)(tyleft*invz));
24404 *ptrd = (T)(nopacity**col + *ptrd*copacity);
24405 ptrd+=whz; col+=twhz;
24407 ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24408 }
else if (nbrightness<1)
for (
int x = xleft; x<=xright; ++
x) {
24409 const float invz = 1/zleft;
24410 const tc *col = texture.ptr((
int)(txleft*invz),(
int)(tyleft*invz));
24412 *ptrd = (T)(nopacity*nbrightness**col + *ptrd*copacity);
24413 ptrd+=whz; col+=twhz;
24415 ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24416 }
else for (
int x = xleft; x<=xright; ++
x) {
24417 const float invz = 1/zleft;
24418 const tc *col = texture.ptr((
int)(txleft*invz),(
int)(tyleft*invz));
24420 const T val = (T)((2-nbrightness)**col + (nbrightness-1)*maxval);
24421 *ptrd = (T)(nopacity*val + *ptrd*copacity);
24422 ptrd+=whz; col+=twhz;
24424 ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24427 zr+=pzr; txr+=ptxr; tyr+=ptyr; zl+=pzl; txl+=ptxl; tyl+=ptyl;
24433 template<
typename tc>
24435 const int x0,
const int y0,
const float z0,
24436 const int x1,
const int y1,
const float z1,
24437 const int x2,
const int y2,
const float z2,
24439 const int tx0,
const int ty0,
24440 const int tx1,
const int ty1,
24441 const int tx2,
const int ty2,
24442 const float opacity=1,
24443 const float brightness=1) {
24444 if (
is_empty() || z0<=0 || z1<=0 || z2<=0)
return *
this;
24446 throw CImgArgumentException(
"CImg<%s>::draw_line() : Z-buffer (%u,%u,%u,%u,%p) and instance image (%u,%u,%u,%u,%p) have different dimensions.",
24447 pixel_type(),zbuffer.width,zbuffer.height,zbuffer.depth,zbuffer.dim,zbuffer.data,
width,
height,
depth,dim,
data);
24448 if (!texture || texture.dim<dim)
24449 throw CImgArgumentException(
"CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
24450 pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
24451 if (
is_overlapped(texture))
return draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,+texture,tx0,ty0,tx1,ty1,tx2,ty2,opacity,brightness);
24455 nbrightness = brightness<0?0:(brightness>2?2:brightness);
24456 const int whz =
width*
height*
depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz;
24457 int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2;
24459 ntx0 = tx0/z0, nty0 = ty0/z0,
24460 ntx1 = tx1/z1, nty1 = ty1/z1,
24461 ntx2 = tx2/z2, nty2 = ty2/z2,
24462 nz0 = 1/z0, nz1 = 1/z1, nz2 = 1/z2;
24463 if (ny0>ny1)
cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1,nz0,nz1);
24464 if (ny0>ny2)
cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2,nz0,nz2);
24465 if (ny1>ny2)
cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2,nz1,nz2);
24466 if (ny0>=
dimy() || ny2<0)
return *
this;
24468 ptxl = (ntx1 - ntx0)/(ny1 - ny0),
24469 ptxr = (ntx2 - ntx0)/(ny2 - ny0),
24470 ptxn = (ntx2 - ntx1)/(ny2 - ny1),
24471 ptyl = (nty1 - nty0)/(ny1 - ny0),
24472 ptyr = (nty2 - nty0)/(ny2 - ny0),
24473 ptyn = (nty2 - nty1)/(ny2 - ny1),
24474 pzl = (nz1 - nz0)/(ny1 - ny0),
24475 pzr = (nz2 - nz0)/(ny2 - ny0),
24476 pzn = (nz2 - nz1)/(ny2 - ny1),
24477 zr = ny0>=0?nz0:(nz0 - ny0*(nz2 - nz0)/(ny2 - ny0)),
24478 txr = ny0>=0?ntx0:(ntx0 - ny0*(ntx2 - ntx0)/(ny2 - ny0)),
24479 tyr = ny0>=0?nty0:(nty0 - ny0*(nty2 - nty0)/(ny2 - ny0)),
24480 zl = ny1>=0?(ny0>=0?nz0:(nz0 - ny0*(nz1 - nz0)/(ny1 - ny0))):(pzl=pzn,(nz1 - ny1*(nz2 - nz1)/(ny2 - ny1))),
24481 txl = ny1>=0?(ny0>=0?ntx0:(ntx0 - ny0*(ntx1 - ntx0)/(ny1 - ny0))):(ptxl=ptxn,(ntx1 - ny1*(ntx2 - ntx1)/(ny2 - ny1))),
24482 tyl = ny1>=0?(ny0>=0?nty0:(nty0 - ny0*(nty1 - nty0)/(ny1 - ny0))):(ptyl=ptyn,(nty1 - ny1*(nty2 - nty1)/(ny2 - ny1)));
24484 if (
y==ny1) { zl = nz1; txl = ntx1; tyl = nty1; pzl = pzn; ptxl = ptxn; ptyl = ptyn; }
24485 int xleft = xleft0, xright = xright0;
24487 zleft = zl, zright = zr,
24488 txleft = txl, txright = txr,
24489 tyleft = tyl, tyright = tyr;
24490 if (xright<xleft)
cimg::swap(xleft,xright,zleft,zright,txleft,txright,tyleft,tyright);
24491 const int dx = xright - xleft;
24493 pentez = (zright - zleft)/dx,
24494 pentetx = (txright - txleft)/
dx,
24495 pentety = (tyright - tyleft)/dx;
24496 if (xleft<0 && dx) {
24497 zleft-=xleft*(zright - zleft)/dx;
24498 txleft-=xleft*(txright - txleft)/dx;
24499 tyleft-=xleft*(tyright - tyleft)/dx;
24501 if (xleft<0) xleft = 0;
24502 if (xright>=
dimx()-1) xright =
dimx()-1;
24503 T *ptrd =
ptr(xleft,
y,0,0);
24504 float *ptrz = zbuffer.ptr(xleft,
y);
24506 if (nbrightness==1)
for (
int x = xleft; x<=xright; ++
x, ++ptrz, ++ptrd) {
24509 const float invz = 1/zleft;
24510 const tc *col = texture.ptr((
int)(txleft*invz),(
int)(tyleft*invz));
24513 ptrd+=whz; col+=twhz;
24517 zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24518 }
else if (nbrightness<1)
for (
int x = xleft; x<=xright; ++
x, ++ptrz, ++ptrd) {
24521 const float invz = 1/zleft;
24522 const tc *col = texture.ptr((
int)(txleft*invz),(
int)(tyleft*invz));
24524 *ptrd = (T)(nbrightness**col);
24525 ptrd+=whz; col+=twhz;
24529 zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24530 }
else for (
int x = xleft; x<=xright; ++
x, ++ptrz, ++ptrd) {
24533 const float invz = 1/zleft;
24534 const tc *col = texture.ptr((
int)(txleft*invz),(
int)(tyleft*invz));
24536 *ptrd = (T)((2-nbrightness)**col + (nbrightness-1)*maxval);
24537 ptrd+=whz; col+=twhz;
24541 zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24544 if (nbrightness==1)
for (
int x = xleft; x<=xright; ++
x, ++ptrz, ++ptrd) {
24547 const float invz = 1/zleft;
24548 const tc *col = texture.ptr((
int)(txleft*invz),(
int)(tyleft*invz));
24550 *ptrd = (T)(nopacity**col + *ptrd*copacity);
24551 ptrd+=whz; col+=twhz;
24555 zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24556 }
else if (nbrightness<1)
for (
int x = xleft; x<=xright; ++
x, ++ptrz, ++ptrd) {
24559 const float invz = 1/zleft;
24560 const tc *col = texture.ptr((
int)(txleft*invz),(
int)(tyleft*invz));
24562 *ptrd = (T)(nopacity*nbrightness**col + *ptrd*copacity);
24563 ptrd+=whz; col+=twhz;
24567 zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24568 }
else for (
int x = xleft; x<=xright; ++
x, ++ptrz, ++ptrd) {
24571 const float invz = 1/zleft;
24572 const tc *col = texture.ptr((
int)(txleft*invz),(
int)(tyleft*invz));
24574 const T val = (T)((2-nbrightness)**col + (nbrightness-1)*maxval);
24575 *ptrd = (T)(nopacity*val + *ptrd*copacity);
24576 ptrd+=whz; col+=twhz;
24580 zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24583 zr+=pzr; txr+=ptxr; tyr+=ptyr; zl+=pzl; txl+=ptxl; tyl+=ptyl;
24607 template<
typename tc,
typename tl>
24609 const int x1,
const int y1,
24610 const int x2,
const int y2,
24611 const tc *
const color,
24613 const int lx0,
const int ly0,
24614 const int lx1,
const int ly1,
24615 const int lx2,
const int ly2,
24616 const float opacity=1) {
24622 throw CImgArgumentException(
"CImg<%s>::draw_triangle() : Specified light texture (%u,%u,%u,%u,%p) is empty.",
24623 pixel_type(),light.width,light.height,light.depth,light.dim,light.data);
24624 if (
is_overlapped(light))
return draw_triangle(x0,y0,x1,y1,x2,y2,color,+light,lx0,ly0,lx1,ly1,lx2,ly2,opacity);
24627 int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2,
24628 nlx0 = lx0, nly0 = ly0, nlx1 = lx1, nly1 = ly1, nlx2 = lx2, nly2 = ly2;
24630 if (ny0>ny1)
cimg::swap(nx0,nx1,ny0,ny1,nlx0,nlx1,nly0,nly1);
24631 if (ny0>ny2)
cimg::swap(nx0,nx2,ny0,ny2,nlx0,nlx2,nly0,nly2);
24632 if (ny1>ny2)
cimg::swap(nx1,nx2,ny1,ny2,nlx1,nlx2,nly1,nly2);
24633 if (ny0>=
dimy() || ny2<0)
return *
this;
24635 nx0,ny0,nlx0,nly0,nx1,ny1,nlx1,nly1,nx2,ny2,nlx2,nly2) {
24637 xleft = xleft0, xright = xright0,
24638 lxleft = lxleft0, lxright = lxright0,
24639 lyleft = lyleft0, lyright = lyright0;
24640 if (xright<xleft)
cimg::swap(xleft,xright,lxleft,lxright,lyleft,lyright);
24642 dx = xright - xleft,
24643 dlx = lxright>lxleft?lxright - lxleft:lxleft - lxright,
24644 dly = lyright>lyleft?lyright - lyleft:lyleft - lyright,
24645 rlx = dx?(lxright - lxleft)/dx:0,
24646 rly = dx?(lyright - lyleft)/dx:0,
24647 slx = lxright>lxleft?1:-1,
24648 sly = lyright>lyleft?1:-1,
24649 ndlx = dlx - (dx?dx*(dlx/
dx):0),
24650 ndly = dly - (dx?dx*(dly/
dx):0);
24651 int errlx = dx>>1, errly = errlx;
24652 if (xleft<0 && dx) {
24653 lxleft-=xleft*(lxright - lxleft)/dx;
24654 lyleft-=xleft*(lyright - lyleft)/dx;
24656 if (xleft<0) xleft = 0;
24657 if (xright>=
dimx()-1) xright =
dimx()-1;
24658 T* ptrd =
ptr(xleft,
y,0,0);
24659 if (opacity>=1)
for (
int x = xleft; x<=xright; ++
x) {
24660 const tl l = light(lxleft,lyleft);
24661 const tc *col = color;
24663 *ptrd = (T)(l<1?l**(col++):((2-l)**(col++)+(l-1)*maxval));
24667 lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0);
24668 lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0);
24669 }
else for (
int x = xleft; x<=xright; ++
x) {
24670 const tl l = light(lxleft,lyleft);
24671 const tc *col = color;
24673 const T val = (T)(l<1?l**(col++):((2-l)**(col++)+(l-1)*maxval));
24674 *ptrd = (T)(nopacity*val + *ptrd*copacity);
24678 lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0);
24679 lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0);
24686 template<
typename tc,
typename tl>
24688 const int x1,
const int y1,
24689 const int x2,
const int y2,
24692 const int lx0,
const int ly0,
24693 const int lx1,
const int ly1,
24694 const int lx2,
const int ly2,
24695 const float opacity=1) {
24696 return draw_triangle(x0,y0,x1,y1,x2,y2,color.data,light,lx0,ly0,lx1,ly1,lx2,ly2,opacity);
24700 template<
typename tc,
typename tl>
24702 const int x0,
const int y0,
const float z0,
24703 const int x1,
const int y1,
const float z1,
24704 const int x2,
const int y2,
const float z2,
24705 const tc *
const color,
24707 const int lx0,
const int ly0,
24708 const int lx1,
const int ly1,
24709 const int lx2,
const int ly2,
24710 const float opacity=1) {
24711 if (
is_empty() || z0<=0 || z1<=0 || z2<=0)
return *
this;
24716 throw CImgArgumentException(
"CImg<%s>::draw_triangle() : Specified light texture (%u,%u,%u,%u,%p) is empty.",
24717 pixel_type(),light.width,light.height,light.depth,light.dim,light.data);
24719 throw CImgArgumentException(
"CImg<%s>::draw_line() : Z-buffer (%u,%u,%u,%u,%p) and instance image (%u,%u,%u,%u,%p) have different dimensions.",
24720 pixel_type(),zbuffer.width,zbuffer.height,zbuffer.depth,zbuffer.dim,zbuffer.data,
width,
height,
depth,dim,
data);
24721 if (
is_overlapped(light))
return draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,
24722 +light,lx0,ly0,lx1,ly1,lx2,ly2,opacity);
24726 int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2,
24727 nlx0 = lx0, nly0 = ly0, nlx1 = lx1, nly1 = ly1, nlx2 = lx2, nly2 = ly2;
24728 float nz0 = 1/z0, nz1 = 1/z1, nz2 = 1/z2;
24729 if (ny0>ny1)
cimg::swap(nx0,nx1,ny0,ny1,nlx0,nlx1,nly0,nly1,nz0,nz1);
24730 if (ny0>ny2)
cimg::swap(nx0,nx2,ny0,ny2,nlx0,nlx2,nly0,nly2,nz0,nz2);
24731 if (ny1>ny2)
cimg::swap(nx1,nx2,ny1,ny2,nlx1,nlx2,nly1,nly2,nz1,nz2);
24732 if (ny0>=
dimy() || ny2<0)
return *
this;
24734 pzl = (nz1 - nz0)/(ny1 - ny0),
24735 pzr = (nz2 - nz0)/(ny2 - ny0),
24736 pzn = (nz2 - nz1)/(ny2 - ny1),
24737 zr = ny0>=0?nz0:(nz0 - ny0*(nz2 - nz0)/(ny2 - ny0)),
24738 zl = ny1>=0?(ny0>=0?nz0:(nz0 - ny0*(nz1 - nz0)/(ny1 - ny0))):(pzl=pzn,(nz1 - ny1*(nz2 - nz1)/(ny2 - ny1)));
24740 nx0,ny0,nlx0,nly0,nx1,ny1,nlx1,nly1,nx2,ny2,nlx2,nly2) {
24741 if (
y==ny1) { zl = nz1; pzl = pzn; }
24743 xleft = xleft0, xright = xright0,
24744 lxleft = lxleft0, lxright = lxright0,
24745 lyleft = lyleft0, lyright = lyright0;
24746 float zleft = zl, zright = zr;
24747 if (xright<xleft)
cimg::swap(xleft,xright,zleft,zright,lxleft,lxright,lyleft,lyright);
24749 dx = xright - xleft,
24750 dlx = lxright>lxleft?lxright - lxleft:lxleft - lxright,
24751 dly = lyright>lyleft?lyright - lyleft:lyleft - lyright,
24752 rlx = dx?(lxright - lxleft)/dx:0,
24753 rly = dx?(lyright - lyleft)/dx:0,
24754 slx = lxright>lxleft?1:-1,
24755 sly = lyright>lyleft?1:-1,
24756 ndlx = dlx - (dx?dx*(dlx/
dx):0),
24757 ndly = dly - (dx?dx*(dly/
dx):0);
24758 const float pentez = (zright - zleft)/dx;
24759 int errlx = dx>>1, errly = errlx;
24760 if (xleft<0 && dx) {
24761 zleft-=xleft*(zright - zleft)/dx;
24762 lxleft-=xleft*(lxright - lxleft)/dx;
24763 lyleft-=xleft*(lyright - lyleft)/dx;
24765 if (xleft<0) xleft = 0;
24766 if (xright>=
dimx()-1) xright =
dimx()-1;
24767 T *ptrd =
ptr(xleft,
y,0,0);
24768 float *ptrz = zbuffer.ptr(xleft,
y);
24769 if (opacity>=1)
for (
int x = xleft; x<=xright; ++
x, ++ptrz, ++ptrd) {
24772 const tl l = light(lxleft,lyleft);
24773 const tc *col = color;
24775 const tc cval = *(col++);
24776 *ptrd = (T)(l<1?l*cval:(2-l)*cval+(l-1)*maxval);
24782 lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0);
24783 lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0);
24784 }
else for (
int x = xleft; x<=xright; ++
x, ++ptrz, ++ptrd) {
24787 const tl l = light(lxleft,lyleft);
24788 const tc *col = color;
24790 const tc cval = *(col++);
24791 const T val = (T)(l<1?l*cval:(2-l)*cval+(l-1)*maxval);
24792 *ptrd = (T)(nopacity*val + *ptrd*copacity);
24798 lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0);
24799 lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0);
24807 template<
typename tc,
typename tl>
24809 const int x0,
const int y0,
const float z0,
24810 const int x1,
const int y1,
const float z1,
24811 const int x2,
const int y2,
const float z2,
24814 const int lx0,
const int ly0,
24815 const int lx1,
const int ly1,
24816 const int lx2,
const int ly2,
24817 const float opacity=1) {
24818 return draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color.data,light,lx0,ly0,lx1,ly1,lx2,ly2,opacity);
24842 template<
typename tc>
24844 const int x1,
const int y1,
24845 const int x2,
const int y2,
24847 const int tx0,
const int ty0,
24848 const int tx1,
const int ty1,
24849 const int tx2,
const int ty2,
24850 const float brightness0,
24851 const float brightness1,
24852 const float brightness2,
24853 const float opacity=1) {
24855 if (!texture || texture.dim<dim)
24856 throw CImgArgumentException(
"CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
24857 pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
24859 return draw_triangle(x0,y0,x1,y1,x2,y2,+texture,tx0,ty0,tx1,ty1,tx2,ty2,brightness0,brightness1,brightness2,opacity);
24862 const int whz =
width*
height*
depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz-1;
24863 int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2,
24864 ntx0 = tx0, nty0 = ty0, ntx1 = tx1, nty1 = ty1, ntx2 = tx2, nty2 = ty2,
24865 nc0 = (int)((brightness0<0.0f?0.0f:(brightness0>2.0f?2.0f:brightness0))*256.0f),
24866 nc1 = (
int)((brightness1<0.0f?0.0f:(brightness1>2.0f?2.0f:brightness1))*256.0f),
24867 nc2 = (
int)((brightness2<0.0f?0.0f:(brightness2>2.0f?2.0f:brightness2))*256.0f);
24868 if (ny0>ny1)
cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1,nc0,nc1);
24869 if (ny0>ny2)
cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2,nc0,nc2);
24870 if (ny1>ny2)
cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2,nc1,nc2);
24871 if (ny0>=
dimy() || ny2<0)
return *
this;
24872 _cimg_for_triangle4(*
this,xleft0,cleft0,txleft0,tyleft0,xright0,cright0,txright0,tyright0,
y,
24873 nx0,ny0,nc0,ntx0,nty0,nx1,ny1,nc1,ntx1,nty1,nx2,ny2,nc2,ntx2,nty2) {
24875 xleft = xleft0, xright = xright0,
24876 cleft = cleft0, cright = cright0,
24877 txleft = txleft0, txright = txright0,
24878 tyleft = tyleft0, tyright = tyright0;
24879 if (xright<xleft)
cimg::swap(xleft,xright,cleft,cright,txleft,txright,tyleft,tyright);
24881 dx = xright - xleft,
24882 dc = cright>cleft?cright - cleft:cleft - cright,
24883 dtx = txright>txleft?txright - txleft:txleft - txright,
24884 dty = tyright>tyleft?tyright - tyleft:tyleft - tyright,
24885 rc = dx?(cright - cleft)/dx:0,
24886 rtx = dx?(txright - txleft)/dx:0,
24887 rty = dx?(tyright - tyleft)/dx:0,
24888 sc = cright>cleft?1:-1,
24889 stx = txright>txleft?1:-1,
24890 sty = tyright>tyleft?1:-1,
24891 ndc = dc - (dx?dx*(dc/dx):0),
24892 ndtx = dtx - (dx?dx*(dtx/dx):0),
24893 ndty = dty - (dx?dx*(dty/dx):0);
24894 int errc = dx>>1, errtx = errc, errty = errc;
24895 if (xleft<0 && dx) {
24896 cleft-=xleft*(cright - cleft)/dx;
24897 txleft-=xleft*(txright - txleft)/dx;
24898 tyleft-=xleft*(tyright - tyleft)/dx;
24900 if (xleft<0) xleft = 0;
24901 if (xright>=
dimx()-1) xright =
dimx()-1;
24902 T* ptrd =
ptr(xleft,
y,0,0);
24903 if (opacity>=1)
for (
int x = xleft; x<=xright; ++
x) {
24904 const tc *col = texture.ptr(txleft,tyleft);
24906 *ptrd = (T)(cleft<256?cleft**col/256:((512-cleft)**col+(cleft-256)*maxval)/256);
24907 ptrd+=whz; col+=twhz;
24910 cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0);
24911 txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0);
24912 tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0);
24913 }
else for (
int x = xleft; x<=xright; ++
x) {
24914 const tc *col = texture.ptr(txleft,tyleft);
24916 const T val = (T)(cleft<256?cleft**col/256:((512-cleft)**col+(cleft-256)*maxval)/256);
24917 *ptrd = (T)(nopacity*val + *ptrd*copacity);
24918 ptrd+=whz; col+=twhz;
24921 cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0);
24922 txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0);
24923 tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0);
24930 template<
typename tc>
24932 const int x1,
const int y1,
const float z1,
24933 const int x2,
const int y2,
const float z2,
24935 const int tx0,
const int ty0,
24936 const int tx1,
const int ty1,
24937 const int tx2,
const int ty2,
24938 const float brightness0,
24939 const float brightness1,
24940 const float brightness2,
24941 const float opacity=1) {
24942 if (
is_empty() || z0<=0 || z1<=0 || z2<=0)
return *
this;
24943 if (!texture || texture.dim<dim)
24944 throw CImgArgumentException(
"CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
24945 pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
24946 if (
is_overlapped(texture))
return draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,+texture,tx0,ty0,tx1,ty1,tx2,ty2,
24947 brightness0,brightness1,brightness2,opacity);
24950 const int whz =
width*
height*
depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz-1;
24951 int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2,
24952 nc0 = (int)((brightness0<0.0f?0.0f:(brightness0>2.0f?2.0f:brightness0))*256.0f),
24953 nc1 = (
int)((brightness1<0.0f?0.0f:(brightness1>2.0f?2.0f:brightness1))*256.0f),
24954 nc2 = (
int)((brightness2<0.0f?0.0f:(brightness2>2.0f?2.0f:brightness2))*256.0f);
24956 ntx0 = tx0/z0, nty0 = ty0/z0,
24957 ntx1 = tx1/z1, nty1 = ty1/z1,
24958 ntx2 = tx2/z2, nty2 = ty2/z2,
24959 nz0 = 1/z0, nz1 = 1/z1, nz2 = 1/z2;
24960 if (ny0>ny1)
cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1,nz0,nz1,nc0,nc1);
24961 if (ny0>ny2)
cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2,nz0,nz2,nc0,nc2);
24962 if (ny1>ny2)
cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2,nz1,nz2,nc1,nc2);
24963 if (ny0>=
dimy() || ny2<0)
return *
this;
24965 ptxl = (ntx1 - ntx0)/(ny1 - ny0),
24966 ptxr = (ntx2 - ntx0)/(ny2 - ny0),
24967 ptxn = (ntx2 - ntx1)/(ny2 - ny1),
24968 ptyl = (nty1 - nty0)/(ny1 - ny0),
24969 ptyr = (nty2 - nty0)/(ny2 - ny0),
24970 ptyn = (nty2 - nty1)/(ny2 - ny1),
24971 pzl = (nz1 - nz0)/(ny1 - ny0),
24972 pzr = (nz2 - nz0)/(ny2 - ny0),
24973 pzn = (nz2 - nz1)/(ny2 - ny1),
24974 zr = ny0>=0?nz0:(nz0 - ny0*(nz2 - nz0)/(ny2 - ny0)),
24975 txr = ny0>=0?ntx0:(ntx0 - ny0*(ntx2 - ntx0)/(ny2 - ny0)),
24976 tyr = ny0>=0?nty0:(nty0 - ny0*(nty2 - nty0)/(ny2 - ny0)),
24977 zl = ny1>=0?(ny0>=0?nz0:(nz0 - ny0*(nz1 - nz0)/(ny1 - ny0))):(pzl=pzn,(nz1 - ny1*(nz2 - nz1)/(ny2 - ny1))),
24978 txl = ny1>=0?(ny0>=0?ntx0:(ntx0 - ny0*(ntx1 - ntx0)/(ny1 - ny0))):(ptxl=ptxn,(ntx1 - ny1*(ntx2 - ntx1)/(ny2 - ny1))),
24979 tyl = ny1>=0?(ny0>=0?nty0:(nty0 - ny0*(nty1 - nty0)/(ny1 - ny0))):(ptyl=ptyn,(nty1 - ny1*(nty2 - nty1)/(ny2 - ny1)));
24980 _cimg_for_triangle2(*
this,xleft0,cleft0,xright0,cright0,
y,nx0,ny0,nc0,nx1,ny1,nc1,nx2,ny2,nc2) {
24981 if (
y==ny1) { zl = nz1; txl = ntx1; tyl = nty1; pzl = pzn; ptxl = ptxn; ptyl = ptyn; }
24983 xleft = xleft0, xright = xright0,
24984 cleft = cleft0, cright = cright0;
24986 zleft = zl, zright = zr,
24987 txleft = txl, txright = txr,
24988 tyleft = tyl, tyright = tyr;
24989 if (xright<xleft)
cimg::swap(xleft,xright,zleft,zright,txleft,txright,tyleft,tyright,cleft,cright);
24991 dx = xright - xleft,
24992 dc = cright>cleft?cright - cleft:cleft - cright,
24993 rc = dx?(cright - cleft)/dx:0,
24994 sc = cright>cleft?1:-1,
24995 ndc = dc - (dx?dx*(dc/dx):0);
24997 pentez = (zright - zleft)/dx,
24998 pentetx = (txright - txleft)/
dx,
24999 pentety = (tyright - tyleft)/dx;
25001 if (xleft<0 && dx) {
25002 cleft-=xleft*(cright - cleft)/dx;
25003 zleft-=xleft*(zright - zleft)/dx;
25004 txleft-=xleft*(txright - txleft)/dx;
25005 tyleft-=xleft*(tyright - tyleft)/dx;
25007 if (xleft<0) xleft = 0;
25008 if (xright>=
dimx()-1) xright =
dimx()-1;
25009 T* ptrd =
ptr(xleft,
y,0,0);
25010 if (opacity>=1)
for (
int x = xleft; x<=xright; ++
x) {
25011 const float invz = 1/zleft;
25012 const tc *col = texture.ptr((
int)(txleft*invz),(
int)(tyleft*invz));
25014 *ptrd = (T)(cleft<256?cleft**col/256:((512-cleft)**col+(cleft-256)*maxval)/256);
25015 ptrd+=whz; col+=twhz;
25017 ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
25018 cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0);
25019 }
else for (
int x = xleft; x<=xright; ++
x) {
25020 const float invz = 1/zleft;
25021 const tc *col = texture.ptr((
int)(txleft*invz),(
int)(tyleft*invz));
25023 const T val = (T)(cleft<256?cleft**col/256:((512-cleft)**col+(cleft-256)*maxval)/256);
25024 *ptrd = (T)(nopacity*val + *ptrd*copacity);
25025 ptrd+=whz; col+=twhz;
25027 ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
25028 cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0);
25030 zr+=pzr; txr+=ptxr; tyr+=ptyr; zl+=pzl; txl+=ptxl; tyl+=ptyl;
25036 template<
typename tc>
25038 const int x0,
const int y0,
const float z0,
25039 const int x1,
const int y1,
const float z1,
25040 const int x2,
const int y2,
const float z2,
25042 const int tx0,
const int ty0,
25043 const int tx1,
const int ty1,
25044 const int tx2,
const int ty2,
25045 const float brightness0,
25046 const float brightness1,
25047 const float brightness2,
25048 const float opacity=1) {
25049 if (
is_empty() || z0<=0 || z1<=0 || z2<=0)
return *
this;
25051 throw CImgArgumentException(
"CImg<%s>::draw_line() : Z-buffer (%u,%u,%u,%u,%p) and instance image (%u,%u,%u,%u,%p) have different dimensions.",
25052 pixel_type(),zbuffer.width,zbuffer.height,zbuffer.depth,zbuffer.dim,zbuffer.data,
width,
height,
depth,dim,
data);
25053 if (!texture || texture.dim<dim)
25054 throw CImgArgumentException(
"CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
25055 pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
25056 if (
is_overlapped(texture))
return draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,+texture,tx0,ty0,tx1,ty1,tx2,ty2,
25057 brightness0,brightness1,brightness2,opacity);
25060 const int whz =
width*
height*
depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz;
25061 int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2,
25062 nc0 = (int)((brightness0<0.0f?0.0f:(brightness0>2.0f?2.0f:brightness0))*256.0f),
25063 nc1 = (
int)((brightness1<0.0f?0.0f:(brightness1>2.0f?2.0f:brightness1))*256.0f),
25064 nc2 = (
int)((brightness2<0.0f?0.0f:(brightness2>2.0f?2.0f:brightness2))*256.0f);
25066 ntx0 = tx0/z0, nty0 = ty0/z0,
25067 ntx1 = tx1/z1, nty1 = ty1/z1,
25068 ntx2 = tx2/z2, nty2 = ty2/z2,
25069 nz0 = 1/z0, nz1 = 1/z1, nz2 = 1/z2;
25070 if (ny0>ny1)
cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1,nz0,nz1,nc0,nc1);
25071 if (ny0>ny2)
cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2,nz0,nz2,nc0,nc2);
25072 if (ny1>ny2)
cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2,nz1,nz2,nc1,nc2);
25073 if (ny0>=
dimy() || ny2<0)
return *
this;
25075 ptxl = (ntx1 - ntx0)/(ny1 - ny0),
25076 ptxr = (ntx2 - ntx0)/(ny2 - ny0),
25077 ptxn = (ntx2 - ntx1)/(ny2 - ny1),
25078 ptyl = (nty1 - nty0)/(ny1 - ny0),
25079 ptyr = (nty2 - nty0)/(ny2 - ny0),
25080 ptyn = (nty2 - nty1)/(ny2 - ny1),
25081 pzl = (nz1 - nz0)/(ny1 - ny0),
25082 pzr = (nz2 - nz0)/(ny2 - ny0),
25083 pzn = (nz2 - nz1)/(ny2 - ny1),
25084 zr = ny0>=0?nz0:(nz0 - ny0*(nz2 - nz0)/(ny2 - ny0)),
25085 txr = ny0>=0?ntx0:(ntx0 - ny0*(ntx2 - ntx0)/(ny2 - ny0)),
25086 tyr = ny0>=0?nty0:(nty0 - ny0*(nty2 - nty0)/(ny2 - ny0)),
25087 zl = ny1>=0?(ny0>=0?nz0:(nz0 - ny0*(nz1 - nz0)/(ny1 - ny0))):(pzl=pzn,(nz1 - ny1*(nz2 - nz1)/(ny2 - ny1))),
25088 txl = ny1>=0?(ny0>=0?ntx0:(ntx0 - ny0*(ntx1 - ntx0)/(ny1 - ny0))):(ptxl=ptxn,(ntx1 - ny1*(ntx2 - ntx1)/(ny2 - ny1))),
25089 tyl = ny1>=0?(ny0>=0?nty0:(nty0 - ny0*(nty1 - nty0)/(ny1 - ny0))):(ptyl=ptyn,(nty1 - ny1*(nty2 - nty1)/(ny2 - ny1)));
25090 _cimg_for_triangle2(*
this,xleft0,cleft0,xright0,cright0,
y,nx0,ny0,nc0,nx1,ny1,nc1,nx2,ny2,nc2) {
25091 if (
y==ny1) { zl = nz1; txl = ntx1; tyl = nty1; pzl = pzn; ptxl = ptxn; ptyl = ptyn; }
25093 xleft = xleft0, xright = xright0,
25094 cleft = cleft0, cright = cright0;
25096 zleft = zl, zright = zr,
25097 txleft = txl, txright = txr,
25098 tyleft = tyl, tyright = tyr;
25099 if (xright<xleft)
cimg::swap(xleft,xright,zleft,zright,txleft,txright,tyleft,tyright,cleft,cright);
25101 dx = xright - xleft,
25102 dc = cright>cleft?cright - cleft:cleft - cright,
25103 rc = dx?(cright - cleft)/dx:0,
25104 sc = cright>cleft?1:-1,
25105 ndc = dc - (dx?dx*(dc/dx):0);
25107 pentez = (zright - zleft)/dx,
25108 pentetx = (txright - txleft)/
dx,
25109 pentety = (tyright - tyleft)/dx;
25111 if (xleft<0 && dx) {
25112 cleft-=xleft*(cright - cleft)/dx;
25113 zleft-=xleft*(zright - zleft)/dx;
25114 txleft-=xleft*(txright - txleft)/dx;
25115 tyleft-=xleft*(tyright - tyleft)/dx;
25117 if (xleft<0) xleft = 0;
25118 if (xright>=
dimx()-1) xright =
dimx()-1;
25119 T* ptrd =
ptr(xleft,
y);
25120 float *ptrz = zbuffer.ptr(xleft,
y);
25121 if (opacity>=1)
for (
int x = xleft; x<=xright; ++
x, ++ptrd, ++ptrz) {
25124 const float invz = 1/zleft;
25125 const tc *col = texture.ptr((
int)(txleft*invz),(
int)(tyleft*invz));
25127 *ptrd = (T)(cleft<256?cleft**col/256:((512-cleft)**col+(cleft-256)*maxval)/256);
25128 ptrd+=whz; col+=twhz;
25132 zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
25133 cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0);
25134 }
else for (
int x = xleft; x<=xright; ++
x, ++ptrd, ++ptrz) {
25137 const float invz = 1/zleft;
25138 const tc *col = texture.ptr((
int)(txleft*invz),(
int)(tyleft*invz));
25140 const T val = (T)(cleft<256?cleft**col/256:((512-cleft)**col+(cleft-256)*maxval)/256);
25141 *ptrd = (T)(nopacity*val + *ptrd*copacity);
25142 ptrd+=whz; col+=twhz;
25146 zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
25147 cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0);
25149 zr+=pzr; txr+=ptxr; tyr+=ptyr; zl+=pzl; txl+=ptxl; tyl+=ptyl;
25179 template<
typename tc,
typename tl>
25181 const int x1,
const int y1,
25182 const int x2,
const int y2,
25184 const int tx0,
const int ty0,
25185 const int tx1,
const int ty1,
25186 const int tx2,
const int ty2,
25188 const int lx0,
const int ly0,
25189 const int lx1,
const int ly1,
25190 const int lx2,
const int ly2,
25191 const float opacity=1) {
25193 if (!texture || texture.dim<dim)
25194 throw CImgArgumentException(
"CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
25195 pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
25197 throw CImgArgumentException(
"CImg<%s>::draw_triangle() : Specified light texture (%u,%u,%u,%u,%p) is empty.",
25198 pixel_type(),light.width,light.height,light.depth,light.dim,light.data);
25199 if (
is_overlapped(texture))
return draw_triangle(x0,y0,x1,y1,x2,y2,+texture,tx0,ty0,tx1,ty1,tx2,ty2,light,lx0,ly0,lx1,ly1,lx2,ly2,opacity);
25200 if (
is_overlapped(light))
return draw_triangle(x0,y0,x1,y1,x2,y2,texture,tx0,ty0,tx1,ty1,tx2,ty2,+light,lx0,ly0,lx1,ly1,lx2,ly2,opacity);
25203 const int whz =
width*
height*
depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz-1;
25204 int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2,
25205 ntx0 = tx0, nty0 = ty0, ntx1 = tx1, nty1 = ty1, ntx2 = tx2, nty2 = ty2,
25206 nlx0 = lx0, nly0 = ly0, nlx1 = lx1, nly1 = ly1, nlx2 = lx2, nly2 = ly2;
25207 if (ny0>ny1)
cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1,nlx0,nlx1,nly0,nly1);
25208 if (ny0>ny2)
cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2,nlx0,nlx2,nly0,nly2);
25209 if (ny1>ny2)
cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2,nlx1,nlx2,nly1,nly2);
25210 if (ny0>=
dimy() || ny2<0)
return *
this;
25211 _cimg_for_triangle5(*
this,xleft0,lxleft0,lyleft0,txleft0,tyleft0,xright0,lxright0,lyright0,txright0,tyright0,
y,
25212 nx0,ny0,nlx0,nly0,ntx0,nty0,nx1,ny1,nlx1,nly1,ntx1,nty1,nx2,ny2,nlx2,nly2,ntx2,nty2) {
25214 xleft = xleft0, xright = xright0,
25215 lxleft = lxleft0, lxright = lxright0,
25216 lyleft = lyleft0, lyright = lyright0,
25217 txleft = txleft0, txright = txright0,
25218 tyleft = tyleft0, tyright = tyright0;
25219 if (xright<xleft)
cimg::swap(xleft,xright,lxleft,lxright,lyleft,lyright,txleft,txright,tyleft,tyright);
25221 dx = xright - xleft,
25222 dlx = lxright>lxleft?lxright - lxleft:lxleft - lxright,
25223 dly = lyright>lyleft?lyright - lyleft:lyleft - lyright,
25224 dtx = txright>txleft?txright - txleft:txleft - txright,
25225 dty = tyright>tyleft?tyright - tyleft:tyleft - tyright,
25226 rlx = dx?(lxright - lxleft)/dx:0,
25227 rly = dx?(lyright - lyleft)/dx:0,
25228 rtx = dx?(txright - txleft)/dx:0,
25229 rty = dx?(tyright - tyleft)/dx:0,
25230 slx = lxright>lxleft?1:-1,
25231 sly = lyright>lyleft?1:-1,
25232 stx = txright>txleft?1:-1,
25233 sty = tyright>tyleft?1:-1,
25234 ndlx = dlx - (dx?dx*(dlx/
dx):0),
25235 ndly = dly - (dx?dx*(dly/
dx):0),
25236 ndtx = dtx - (dx?dx*(dtx/
dx):0),
25237 ndty = dty - (dx?dx*(dty/
dx):0);
25238 int errlx = dx>>1, errly = errlx, errtx = errlx, errty = errlx;
25239 if (xleft<0 && dx) {
25240 lxleft-=xleft*(lxright - lxleft)/dx;
25241 lyleft-=xleft*(lyright - lyleft)/dx;
25242 txleft-=xleft*(txright - txleft)/dx;
25243 tyleft-=xleft*(tyright - tyleft)/dx;
25245 if (xleft<0) xleft = 0;
25246 if (xright>=
dimx()-1) xright =
dimx()-1;
25247 T* ptrd =
ptr(xleft,
y,0,0);
25248 if (opacity>=1)
for (
int x = xleft; x<=xright; ++
x) {
25249 const tl l = light(lxleft,lyleft);
25250 const tc *col = texture.ptr(txleft,tyleft);
25252 *ptrd = (T)(l<1?l**col:(2-l)**col+(l-1)*maxval);
25253 ptrd+=whz; col+=twhz;
25256 lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0);
25257 lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0);
25258 txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0);
25259 tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0);
25260 }
else for (
int x = xleft; x<=xright; ++
x) {
25261 const tl l = light(lxleft,lyleft);
25262 const tc *col = texture.ptr(txleft,tyleft);
25264 const T val = (T)(l<1?l**col:(2-l)**col+(l-1)*maxval);
25265 *ptrd = (T)(nopacity*val + *ptrd*copacity);
25266 ptrd+=whz; col+=twhz;
25269 lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0);
25270 lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0);
25271 txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0);
25272 tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0);
25279 template<
typename tc,
typename tl>
25281 const int x1,
const int y1,
const float z1,
25282 const int x2,
const int y2,
const float z2,
25284 const int tx0,
const int ty0,
25285 const int tx1,
const int ty1,
25286 const int tx2,
const int ty2,
25288 const int lx0,
const int ly0,
25289 const int lx1,
const int ly1,
25290 const int lx2,
const int ly2,
25291 const float opacity=1) {
25292 if (
is_empty() || z0<=0 || z1<=0 || z2<=0)
return *
this;
25293 if (!texture || texture.dim<dim)
25294 throw CImgArgumentException(
"CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
25295 pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
25297 throw CImgArgumentException(
"CImg<%s>::draw_triangle() : Specified light texture (%u,%u,%u,%u,%p) is empty.",
25298 pixel_type(),light.width,light.height,light.depth,light.dim,light.data);
25299 if (
is_overlapped(texture))
return draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,+texture,tx0,ty0,tx1,ty1,tx2,ty2,light,lx0,ly0,lx1,ly1,lx2,ly2,opacity);
25300 if (
is_overlapped(light))
return draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,texture,tx0,ty0,tx1,ty1,tx2,ty2,+light,lx0,ly0,lx1,ly1,lx2,ly2,opacity);
25303 const int whz =
width*
height*
depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz-1;
25304 int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2,
25305 nlx0 = lx0, nly0 = ly0, nlx1 = lx1, nly1 = ly1, nlx2 = lx2, nly2 = ly2;
25307 ntx0 = tx0/z0, nty0 = ty0/z0,
25308 ntx1 = tx1/z1, nty1 = ty1/z1,
25309 ntx2 = tx2/z2, nty2 = ty2/z2,
25310 nz0 = 1/z0, nz1 = 1/z1, nz2 = 1/z2;
25311 if (ny0>ny1)
cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1,nlx0,nlx1,nly0,nly1,nz0,nz1);
25312 if (ny0>ny2)
cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2,nlx0,nlx2,nly0,nly2,nz0,nz2);
25313 if (ny1>ny2)
cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2,nlx1,nlx2,nly1,nly2,nz1,nz2);
25314 if (ny0>=
dimy() || ny2<0)
return *
this;
25316 ptxl = (ntx1 - ntx0)/(ny1 - ny0),
25317 ptxr = (ntx2 - ntx0)/(ny2 - ny0),
25318 ptxn = (ntx2 - ntx1)/(ny2 - ny1),
25319 ptyl = (nty1 - nty0)/(ny1 - ny0),
25320 ptyr = (nty2 - nty0)/(ny2 - ny0),
25321 ptyn = (nty2 - nty1)/(ny2 - ny1),
25322 pzl = (nz1 - nz0)/(ny1 - ny0),
25323 pzr = (nz2 - nz0)/(ny2 - ny0),
25324 pzn = (nz2 - nz1)/(ny2 - ny1),
25325 zr = ny0>=0?nz0:(nz0 - ny0*(nz2 - nz0)/(ny2 - ny0)),
25326 txr = ny0>=0?ntx0:(ntx0 - ny0*(ntx2 - ntx0)/(ny2 - ny0)),
25327 tyr = ny0>=0?nty0:(nty0 - ny0*(nty2 - nty0)/(ny2 - ny0)),
25328 zl = ny1>=0?(ny0>=0?nz0:(nz0 - ny0*(nz1 - nz0)/(ny1 - ny0))):(pzl=pzn,(nz1 - ny1*(nz2 - nz1)/(ny2 - ny1))),
25329 txl = ny1>=0?(ny0>=0?ntx0:(ntx0 - ny0*(ntx1 - ntx0)/(ny1 - ny0))):(ptxl=ptxn,(ntx1 - ny1*(ntx2 - ntx1)/(ny2 - ny1))),
25330 tyl = ny1>=0?(ny0>=0?nty0:(nty0 - ny0*(nty1 - nty0)/(ny1 - ny0))):(ptyl=ptyn,(nty1 - ny1*(nty2 - nty1)/(ny2 - ny1)));
25332 nx0,ny0,nlx0,nly0,nx1,ny1,nlx1,nly1,nx2,ny2,nlx2,nly2) {
25333 if (
y==ny1) { zl = nz1; txl = ntx1; tyl = nty1; pzl = pzn; ptxl = ptxn; ptyl = ptyn; }
25335 xleft = xleft0, xright = xright0,
25336 lxleft = lxleft0, lxright = lxright0,
25337 lyleft = lyleft0, lyright = lyright0;
25339 zleft = zl, zright = zr,
25340 txleft = txl, txright = txr,
25341 tyleft = tyl, tyright = tyr;
25342 if (xright<xleft)
cimg::swap(xleft,xright,zleft,zright,txleft,txright,tyleft,tyright,lxleft,lxright,lyleft,lyright);
25344 dx = xright - xleft,
25345 dlx = lxright>lxleft?lxright - lxleft:lxleft - lxright,
25346 dly = lyright>lyleft?lyright - lyleft:lyleft - lyright,
25347 rlx = dx?(lxright - lxleft)/dx:0,
25348 rly = dx?(lyright - lyleft)/dx:0,
25349 slx = lxright>lxleft?1:-1,
25350 sly = lyright>lyleft?1:-1,
25351 ndlx = dlx - (dx?dx*(dlx/
dx):0),
25352 ndly = dly - (dx?dx*(dly/
dx):0);
25354 pentez = (zright - zleft)/dx,
25355 pentetx = (txright - txleft)/
dx,
25356 pentety = (tyright - tyleft)/dx;
25357 int errlx = dx>>1, errly = errlx;
25358 if (xleft<0 && dx) {
25359 zleft-=xleft*(zright - zleft)/dx;
25360 lxleft-=xleft*(lxright - lxleft)/dx;
25361 lyleft-=xleft*(lyright - lyleft)/dx;
25362 txleft-=xleft*(txright - txleft)/dx;
25363 tyleft-=xleft*(tyright - tyleft)/dx;
25365 if (xleft<0) xleft = 0;
25366 if (xright>=
dimx()-1) xright =
dimx()-1;
25367 T* ptrd =
ptr(xleft,
y,0,0);
25368 if (opacity>=1)
for (
int x = xleft; x<=xright; ++
x) {
25369 const float invz = 1/zleft;
25370 const tl l = light(lxleft,lyleft);
25371 const tc *col = texture.ptr((
int)(txleft*invz),(
int)(tyleft*invz));
25373 *ptrd = (T)(l<1?l**col:(2-l)**col+(l-1)*maxval);
25374 ptrd+=whz; col+=twhz;
25376 ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
25377 lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0);
25378 lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0);
25379 }
else for (
int x = xleft; x<=xright; ++
x) {
25380 const float invz = 1/zleft;
25381 const tl l = light(lxleft,lyleft);
25382 const tc *col = texture.ptr((
int)(txleft*invz),(
int)(tyleft*invz));
25384 const T val = (T)(l<1?l**col:(2-l)**col+(l-1)*maxval);
25385 *ptrd = (T)(nopacity*val + *ptrd*copacity);
25386 ptrd+=whz; col+=twhz;
25388 ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
25389 lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0);
25390 lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0);
25392 zr+=pzr; txr+=ptxr; tyr+=ptyr; zl+=pzl; txl+=ptxl; tyl+=ptyl;
25398 template<
typename tc,
typename tl>
25400 const int x0,
const int y0,
const float z0,
25401 const int x1,
const int y1,
const float z1,
25402 const int x2,
const int y2,
const float z2,
25404 const int tx0,
const int ty0,
25405 const int tx1,
const int ty1,
25406 const int tx2,
const int ty2,
25408 const int lx0,
const int ly0,
25409 const int lx1,
const int ly1,
25410 const int lx2,
const int ly2,
25411 const float opacity=1) {
25412 if (
is_empty() || z0<=0 || z1<=0 || z2<=0)
return *
this;
25414 throw CImgArgumentException(
"CImg<%s>::draw_triangle() : Z-buffer (%u,%u,%u,%u,%p) and instance image (%u,%u,%u,%u,%p) have different dimensions.",
25415 pixel_type(),zbuffer.width,zbuffer.height,zbuffer.depth,zbuffer.dim,zbuffer.data,
width,
height,
depth,dim,
data);
25416 if (!texture || texture.dim<dim)
25417 throw CImgArgumentException(
"CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
25418 pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
25420 throw CImgArgumentException(
"CImg<%s>::draw_triangle() : Specified light texture (%u,%u,%u,%u,%p) is empty.",
25421 pixel_type(),light.width,light.height,light.depth,light.dim,light.data);
25422 if (
is_overlapped(texture))
return draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,
25423 +texture,tx0,ty0,tx1,ty1,tx2,ty2,light,lx0,ly0,lx1,ly1,lx2,ly2,opacity);
25424 if (
is_overlapped(light))
return draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,
25425 texture,tx0,ty0,tx1,ty1,tx2,ty2,+light,lx0,ly0,lx1,ly1,lx2,ly2,opacity);
25428 const int whz =
width*
height*
depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz;
25429 int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2,
25430 nlx0 = lx0, nly0 = ly0, nlx1 = lx1, nly1 = ly1, nlx2 = lx2, nly2 = ly2;
25432 ntx0 = tx0/z0, nty0 = ty0/z0,
25433 ntx1 = tx1/z1, nty1 = ty1/z1,
25434 ntx2 = tx2/z2, nty2 = ty2/z2,
25435 nz0 = 1/z0, nz1 = 1/z1, nz2 = 1/z2;
25436 if (ny0>ny1)
cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1,nlx0,nlx1,nly0,nly1,nz0,nz1);
25437 if (ny0>ny2)
cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2,nlx0,nlx2,nly0,nly2,nz0,nz2);
25438 if (ny1>ny2)
cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2,nlx1,nlx2,nly1,nly2,nz1,nz2);
25439 if (ny0>=
dimy() || ny2<0)
return *
this;
25441 ptxl = (ntx1 - ntx0)/(ny1 - ny0),
25442 ptxr = (ntx2 - ntx0)/(ny2 - ny0),
25443 ptxn = (ntx2 - ntx1)/(ny2 - ny1),
25444 ptyl = (nty1 - nty0)/(ny1 - ny0),
25445 ptyr = (nty2 - nty0)/(ny2 - ny0),
25446 ptyn = (nty2 - nty1)/(ny2 - ny1),
25447 pzl = (nz1 - nz0)/(ny1 - ny0),
25448 pzr = (nz2 - nz0)/(ny2 - ny0),
25449 pzn = (nz2 - nz1)/(ny2 - ny1),
25450 zr = ny0>=0?nz0:(nz0 - ny0*(nz2 - nz0)/(ny2 - ny0)),
25451 txr = ny0>=0?ntx0:(ntx0 - ny0*(ntx2 - ntx0)/(ny2 - ny0)),
25452 tyr = ny0>=0?nty0:(nty0 - ny0*(nty2 - nty0)/(ny2 - ny0)),
25453 zl = ny1>=0?(ny0>=0?nz0:(nz0 - ny0*(nz1 - nz0)/(ny1 - ny0))):(pzl=pzn,(nz1 - ny1*(nz2 - nz1)/(ny2 - ny1))),
25454 txl = ny1>=0?(ny0>=0?ntx0:(ntx0 - ny0*(ntx1 - ntx0)/(ny1 - ny0))):(ptxl=ptxn,(ntx1 - ny1*(ntx2 - ntx1)/(ny2 - ny1))),
25455 tyl = ny1>=0?(ny0>=0?nty0:(nty0 - ny0*(nty1 - nty0)/(ny1 - ny0))):(ptyl=ptyn,(nty1 - ny1*(nty2 - nty1)/(ny2 - ny1)));
25457 nx0,ny0,nlx0,nly0,nx1,ny1,nlx1,nly1,nx2,ny2,nlx2,nly2) {
25458 if (
y==ny1) { zl = nz1; txl = ntx1; tyl = nty1; pzl = pzn; ptxl = ptxn; ptyl = ptyn; }
25460 xleft = xleft0, xright = xright0,
25461 lxleft = lxleft0, lxright = lxright0,
25462 lyleft = lyleft0, lyright = lyright0;
25464 zleft = zl, zright = zr,
25465 txleft = txl, txright = txr,
25466 tyleft = tyl, tyright = tyr;
25467 if (xright<xleft)
cimg::swap(xleft,xright,zleft,zright,txleft,txright,tyleft,tyright,lxleft,lxright,lyleft,lyright);
25469 dx = xright - xleft,
25470 dlx = lxright>lxleft?lxright - lxleft:lxleft - lxright,
25471 dly = lyright>lyleft?lyright - lyleft:lyleft - lyright,
25472 rlx = dx?(lxright - lxleft)/dx:0,
25473 rly = dx?(lyright - lyleft)/dx:0,
25474 slx = lxright>lxleft?1:-1,
25475 sly = lyright>lyleft?1:-1,
25476 ndlx = dlx - (dx?dx*(dlx/
dx):0),
25477 ndly = dly - (dx?dx*(dly/
dx):0);
25479 pentez = (zright - zleft)/dx,
25480 pentetx = (txright - txleft)/
dx,
25481 pentety = (tyright - tyleft)/dx;
25482 int errlx = dx>>1, errly = errlx;
25483 if (xleft<0 && dx) {
25484 zleft-=xleft*(zright - zleft)/dx;
25485 lxleft-=xleft*(lxright - lxleft)/dx;
25486 lyleft-=xleft*(lyright - lyleft)/dx;
25487 txleft-=xleft*(txright - txleft)/dx;
25488 tyleft-=xleft*(tyright - tyleft)/dx;
25490 if (xleft<0) xleft = 0;
25491 if (xright>=
dimx()-1) xright =
dimx()-1;
25492 T* ptrd =
ptr(xleft,
y);
25493 float *ptrz = zbuffer.ptr(xleft,
y);
25494 if (opacity>=1)
for (
int x = xleft; x<=xright; ++
x, ++ptrz, ++ptrd) {
25497 const float invz = 1/zleft;
25498 const tl l = light(lxleft,lyleft);
25499 const tc *col = texture.ptr((
int)(txleft*invz),(
int)(tyleft*invz));
25501 *ptrd = (T)(l<1?l**col:(2-l)**col+(l-1)*maxval);
25502 ptrd+=whz; col+=twhz;
25506 zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
25507 lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0);
25508 lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0);
25509 }
else for (
int x = xleft; x<=xright; ++
x, ++ptrz, ++ptrd) {
25512 const float invz = 1/zleft;
25513 const tl l = light(lxleft,lyleft);
25514 const tc *col = texture.ptr((
int)(txleft*invz),(
int)(tyleft*invz));
25516 const T val = (T)(l<1?l**col:(2-l)**col+(l-1)*maxval);
25517 *ptrd = (T)(nopacity*val + *ptrd*copacity);
25518 ptrd+=whz; col+=twhz;
25522 zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
25523 lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0);
25524 lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0);
25526 zr+=pzr; txr+=ptxr; tyr+=ptyr; zl+=pzl; txl+=ptxl; tyl+=ptyl;
25547 const int x1,
const int y1,
const int z1,
const int v1,
25548 const T val,
const float opacity=1) {
25550 const bool bx = (x0<x1),
by = (y0<y1), bz = (z0<z1), bv = (v0<v1);
25552 nx0 = bx?x0:x1, nx1 = bx?x1:x0,
25553 ny0 =
by?y0:y1, ny1 =
by?y1:y0,
25554 nz0 = bz?z0:z1, nz1 = bz?z1:z0,
25555 nv0 = bv?v0:v1, nv1 = bv?v1:v0;
25557 lX = (1 + nx1 - nx0) + (nx1>=
dimx()?
dimx() - 1 - nx1:0) + (nx0<0?nx0:0),
25558 lY = (1 + ny1 - ny0) + (ny1>=
dimy()?
dimy() - 1 - ny1:0) + (ny0<0?ny0:0),
25559 lZ = (1 + nz1 - nz0) + (nz1>=
dimz()?
dimz() - 1 - nz1:0) + (nz0<0?nz0:0),
25560 lV = (1 + nv1 - nv0) + (nv1>=
dimv()?
dimv() - 1 - nv1:0) + (nv0<0?nv0:0);
25563 T *ptrd =
ptr(nx0<0?0:nx0,ny0<0?0:ny0,nz0<0?0:nz0,nv0<0?0:nv0);
25564 if (lX>0 && lY>0 && lZ>0 && lV>0)
25565 for (
int v = 0;
v<lV; ++
v) {
25566 for (
int z = 0;
z<lZ; ++
z) {
25567 for (
int y = 0;
y<lY; ++
y) {
25569 if (
sizeof(T)!=1) {
for (
int x = 0; x<lX; ++
x) *(ptrd++) = val; ptrd+=offX; }
25570 else { std::memset(ptrd,(
int)val,lX); ptrd+=
width; }
25571 }
else {
for (
int x = 0; x<lX; ++
x) { *ptrd = (T)(nopacity*val + *ptrd*copacity); ++ptrd; } ptrd+=offX; }
25593 template<
typename tc>
25595 const int x1,
const int y1,
const int z1,
25596 const tc *
const color,
const float opacity=1) {
25600 cimg_forV(*
this,
k)
draw_rectangle(x0,y0,z0,
k,x1,y1,z1,
k,color[
k],opacity);
25605 template<
typename tc>
25607 const int x1,
const int y1,
const int z1,
25608 const CImg<tc>& color,
const float opacity=1) {
25613 template<
typename tc>
25615 const int x1,
const int y1,
const int z1,
25616 const tc *
const color,
const float opacity,
25617 const unsigned int pattern) {
25618 return draw_line(x0,y0,z0,x1,y0,z0,color,opacity,pattern,
true).
25619 draw_line(x1,y0,z0,x1,y1,z0,color,opacity,pattern,
false).
25620 draw_line(x1,y1,z0,x0,y1,z0,color,opacity,pattern,
false).
25621 draw_line(x0,y1,z0,x0,y0,z0,color,opacity,pattern,
false).
25622 draw_line(x0,y0,z1,x1,y0,z1,color,opacity,pattern,
true).
25623 draw_line(x1,y0,z1,x1,y1,z1,color,opacity,pattern,
false).
25624 draw_line(x1,y1,z1,x0,y1,z1,color,opacity,pattern,
false).
25625 draw_line(x0,y1,z1,x0,y0,z1,color,opacity,pattern,
false).
25626 draw_line(x0,y0,z0,x0,y0,z1,color,opacity,pattern,
true).
25627 draw_line(x1,y0,z0,x1,y0,z1,color,opacity,pattern,
true).
25628 draw_line(x1,y1,z0,x1,y1,z1,color,opacity,pattern,
true).
25629 draw_line(x0,y1,z0,x0,y1,z1,color,opacity,pattern,
true);
25633 template<
typename tc>
25635 const int x1,
const int y1,
const int z1,
25636 const CImg<tc>& color,
const float opacity,
25637 const unsigned int pattern) {
25638 return draw_rectangle(x0,y0,z0,x1,y1,z1,color.data,opacity,pattern);
25652 template<
typename tc>
25654 const int x1,
const int y1,
25655 const tc *
const color,
const float opacity=1) {
25660 template<
typename tc>
25662 const int x1,
const int y1,
25663 const CImg<tc>& color,
const float opacity=1) {
25668 template<
typename tc>
25670 const int x1,
const int y1,
25671 const tc *
const color,
const float opacity,
25672 const unsigned int pattern) {
25674 if (y0==y1)
return draw_line(x0,y0,x1,y0,color,opacity,pattern,
true);
25675 if (x0==x1)
return draw_line(x0,y0,x0,y1,color,opacity,pattern,
true);
25676 const bool bx = (x0<x1),
by = (y0<y1);
25678 nx0 = bx?x0:x1, nx1 = bx?x1:x0,
25679 ny0 =
by?y0:y1, ny1 =
by?y1:y0;
25680 if (ny1==ny0+1)
return draw_line(nx0,ny0,nx1,ny0,color,opacity,pattern,
true).
25681 draw_line(nx1,ny1,nx0,ny1,color,opacity,pattern,
false);
25682 return draw_line(nx0,ny0,nx1,ny0,color,opacity,pattern,
true).
25683 draw_line(nx1,ny0+1,nx1,ny1-1,color,opacity,pattern,
false).
25684 draw_line(nx1,ny1,nx0,ny1,color,opacity,pattern,
false).
25685 draw_line(nx0,ny1-1,nx0,ny0+1,color,opacity,pattern,
false);
25689 template<
typename tc>
25691 const int x1,
const int y1,
25692 const CImg<tc>& color,
const float opacity,
25693 const unsigned int pattern) {
25698 template<
typename t,
typename tc>
25700 const tc *
const color,
const float opacity) {
25701 if (
is_empty() || !points || N<3)
return *
this;
25706 int xmin = (int)(~0U>>1), xmax = 0, ymin = (int)(~0U>>1), ymax = 0;
25707 for (
unsigned int p = 0; p<N; ++p) {
25708 const int x = (int)points(p,0),
y = (int)points(p,1);
25709 if (x<xmin) xmin =
x;
25710 if (x>xmax) xmax =
x;
25711 if (
y<ymin) ymin =
y;
25712 if (
y>ymax) ymax =
y;
25714 if (xmax<0 || xmin>=
dimx() || ymax<0 || ymin>=
dimy())
return *
this;
25716 nymin = ymin<0?0:(
unsigned int)ymin,
25717 nymax = ymax>=
dimy()?
height-1:(
unsigned int)ymax,
25718 dy = 1 + nymax - nymin;
25720 int cx = (int)points(0,0), cy = (int)points(0,1);
25721 for (
unsigned int cp = 0, p = 0; p<N; ++p) {
25722 const unsigned int np = (p!=N-1)?p+1:0, ap = (np!=N-1)?np+1:0;
25724 nx = (int)points(np,0), ny = (int)points(np,1), ay = (int)points(ap,1),
25725 y0 = cy - nymin, y1 = ny - nymin;
25727 const int countermin = ((ny<ay && cy<ny) || (ny>ay && cy>ny))?1:0;
25728 for (
int x = cx,
y = y0, _sx = 1, _sy = 1,
25729 _dx = nx>cx?nx-cx:((_sx=-1),cx-nx),
25730 _dy = y1>y0?y1-y0:((_sy=-1),y0-y1),
25731 _counter = ((_dx-=_dy?_dy*(_dx/_dy):0),_dy),
25733 _rx = _dy?(nx-cx)/_dy:0;
25734 _counter>=countermin;
25735 --_counter,
y+=_sy, x+=_rx + ((_err-=_dx)<0?_err+=_dy,_sx:0))
25736 if (y>=0 && y<(
int)
dy) X(++X(0,y),
y) = x;
25737 cp = np; cx = nx; cy = ny;
25739 const int pp = (cp?cp-1:N-1), py = (
int)points(pp,1);
25740 if ((cy>py && ay>cy) || (cy<py && ay<cy)) X(++X(0,y0),y0) = nx;
25741 if (cy!=ay) { cp = np; cx = nx; cy = ny; }
25744 for (
int y = 0;
y<(int)
dy; ++
y) {
25745 tmp.assign(X.ptr(1,
y),X(0,
y),1,1,1,
true).
sort();
25746 for (
int i = 1; i<=X(0,
y); ) {
25747 const int xb = X(i++,
y), xe = X(i++,
y);
25755 template<
typename t,
typename tc>
25757 const tc *
const color,
const float opacity=1) {
25758 if (!points.is_sameY(2))
25765 template<
typename t,
typename tc>
25767 const CImg<tc>& color,
const float opacity=1) {
25772 template<
typename t,
typename tc>
25774 const tc *
const color,
const float opacity=1) {
25775 if (points.height<2)
25782 template<
typename t,
typename tc>
25784 const CImg<tc>& color,
const float opacity=1) {
25789 template<
typename t,
typename tc>
25791 const tc *
const color,
const float opacity,
25792 const unsigned int pattern) {
25793 if (
is_empty() || !points || W<3)
return *
this;
25794 bool ninit_hatch =
true;
25800 const int x0 = (int)points(0,0), y0 = (int)points(0,1);
25801 int ox = x0, oy = y0;
25802 for (
unsigned int i = 1; i<W; ++
i) {
25803 const int x = (int)points(i,0),
y = (int)points(i,1);
25804 draw_line(ox,oy,x,
y,color,opacity,pattern,ninit_hatch);
25805 ninit_hatch =
false;
25808 draw_line(ox,oy,x0,y0,color,opacity,pattern,
false);
25811 const int x0 = (int)points(0,0), y0 = (int)points(0,1), z0 = (int)points(0,2);
25812 int ox = x0, oy = y0, oz = z0;
25813 for (
unsigned int i = 1; i<W; ++
i) {
25814 const int x = (int)points(i,0),
y = (int)points(i,1),
z = (int)points(i,2);
25815 draw_line(ox,oy,oz,x,
y,
z,color,opacity,pattern,ninit_hatch);
25816 ninit_hatch =
false;
25817 ox =
x; oy =
y; oz =
z;
25819 draw_line(ox,oy,oz,x0,y0,z0,color,opacity,pattern,
false);
25826 template<
typename t,
typename tc>
25828 const tc *
const color,
const float opacity,
25829 const unsigned int pattern) {
25835 template<
typename t,
typename tc>
25837 const CImg<tc>& color,
const float opacity,
25838 const unsigned int pattern) {
25839 return draw_polygon(points,color.data,opacity,pattern);
25843 template<
typename t,
typename tc>
25845 const tc *
const color,
const float opacity,
25846 const unsigned int pattern) {
25847 return _draw_polygon(points,points.width,points.height,color,opacity,pattern);
25851 template<
typename t,
typename tc>
25853 const CImg<tc>& color,
const float opacity,
25854 const unsigned int pattern) {
25855 return draw_polygon(points,color.data,opacity,pattern);
25868 template<
typename tc>
25870 const tc *
const color,
const float opacity=1) {
25876 if (radius<0 || x0-radius>=
dimx() || y0+radius<0 || y0-radius>=
dimy())
return *
this;
25878 for (
int f = 1-radius, ddFx = 0, ddFy = -(radius<<1), x = 0,
y = radius; x<
y; ) {
25880 const int x1 = x0-
x, x2 = x0+
x, y1 = y0-
y, y2 = y0+
y;
25885 const bool no_diag = y!=(x++);
25887 const int x1 = x0-
y, x2 = x0+
y, y1 = y0-
x, y2 = y0+
x;
25898 template<
typename tc>
25900 const CImg<tc>& color,
const float opacity=1) {
25901 return draw_circle(x0,y0,radius,color.data,opacity);
25912 template<
typename tc>
25914 const tc *
const color,
const float opacity,
25915 const unsigned int) {
25920 if (radius<0 || x0-radius>=
dimx() || y0+radius<0 || y0-radius>=
dimy())
return *
this;
25921 if (!radius)
return draw_point(x0,y0,color,opacity);
25922 draw_point(x0-radius,y0,color,opacity).draw_point(x0+radius,y0,color,opacity).
25923 draw_point(x0,y0-radius,color,opacity).draw_point(x0,y0+radius,color,opacity);
25924 if (radius==1)
return *
this;
25925 for (
int f = 1-radius, ddFx = 0, ddFy = -(radius<<1), x = 0,
y = radius; x<
y; ) {
25926 if (f>=0) { f+=(ddFy+=2); --
y; }
25927 ++
x; ++(f+=(ddFx+=2));
25929 const int x1 = x0-
y, x2 = x0+
y, y1 = y0-
x, y2 = y0+
x, x3 = x0-
x, x4 = x0+
x, y3 = y0-
y, y4 = y0+
y;
25930 draw_point(x1,y1,color,opacity).draw_point(x1,y2,color,opacity).
25931 draw_point(x2,y1,color,opacity).draw_point(x2,y2,color,opacity);
25933 draw_point(x3,y3,color,opacity).draw_point(x4,y4,color,opacity).
25934 draw_point(x4,y3,color,opacity).draw_point(x3,y4,color,opacity);
25942 template<
typename tc>
25944 const float opacity,
25945 const unsigned int pattern) {
25946 return draw_circle(x0,y0,radius,color.data,opacity,pattern);
25950 template<
typename tc>
25952 const tc *
const color,
const float opacity,
25953 const unsigned int pattern) {
25965 l1 = (float)
std::pow(rmax/(nr1>0?nr1:1e-6),2),
25966 l2 = (
float)
std::pow(rmax/(nr2>0?nr2:1e-6),2),
25967 a = l1*u*u + l2*
v*
v,
25969 c = l1*v*v + l2*u*u;
25971 yb = (int)
std::sqrt(a*rmax*rmax/(a*c-b*b)),
25972 tymin = y0 - yb - 1,
25973 tymax = y0 + yb + 1,
25974 ymin = tymin<0?0:tymin,
25976 int oxmin = 0, oxmax = 0;
25977 bool first_line =
true;
25978 for (
int y = ymin;
y<=ymax; ++
y) {
25980 Y =
y-y0 + (
y<y0?0.5f:-0.5f),
25981 delta = b*b*Y*Y-a*(c*Y*Y-rmax*rmax),
25982 sdelta = delta>0?(float)
std::sqrt(delta)/a:0.0f,
25984 fxmin = x0-0.5f-bY-sdelta,
25985 fxmax = x0+0.5f-bY+sdelta;
25986 const int xmin = (int)fxmin, xmax = (
int)fxmax;
25991 else draw_point(xmin,
y,color,opacity).draw_point(xmax,
y,color,opacity);
25992 first_line =
false;
26001 oxmin = xmin; oxmax = xmax;
26016 template<
typename tc>
26018 const tc *
const color,
const float opacity=1) {
26023 template<
typename tc>
26025 const CImg<tc>& color,
const float opacity=1) {
26026 return draw_ellipse(x0,y0,r1,r2,angle,color.data,opacity);
26037 template<
typename t,
typename tc>
26039 const tc *
const color,
const float opacity=1) {
26041 const CImg<t> &val = eig[0], &vec = eig[1];
26042 return draw_ellipse(x0,y0,val(0),val(1),vec(0,0),vec(0,1),color,opacity);
26046 template<
typename t,
typename tc>
26048 const CImg<tc>& color,
const float opacity=1) {
26064 template<
typename tc>
26066 const tc *
const color,
const float opacity,
const unsigned int pattern) {
26067 if (pattern)
_draw_ellipse(x0,y0,r1,r2,angle,color,opacity,pattern);
26072 template<
typename tc>
26074 const CImg<tc>& color,
const float opacity,
const unsigned int pattern) {
26075 return draw_ellipse(x0,y0,r1,r2,angle,color.data,opacity,pattern);
26087 template<
typename t,
typename tc>
26089 const tc *
const color,
const float opacity,
26090 const unsigned int pattern) {
26092 const CImg<t> &val = eig[0], &vec = eig[1];
26093 return draw_ellipse(x0,y0,val(0),val(1),vec(0,0),vec(0,1),color,opacity,pattern);
26097 template<
typename t,
typename tc>
26099 const CImg<tc>& color,
const float opacity,
26100 const unsigned int pattern) {
26101 return draw_ellipse(x0,y0,tensor,color.data,opacity,pattern);
26115 template<
typename t>
26117 const CImg<t>& sprite,
const float opacity=1) {
26120 throw CImgArgumentException(
"CImg<%s>::draw_image() : Specified sprite image (%u,%u,%u,%u,%p) is empty.",
26121 pixel_type(),sprite.width,sprite.height,sprite.depth,sprite.dim,sprite.data);
26123 const bool bx = (x0<0),
by = (y0<0), bz = (z0<0), bv = (v0<0);
26125 lX = sprite.dimx() - (x0 + sprite.dimx()>
dimx()?x0 + sprite.dimx() -
dimx():0) + (bx?x0:0),
26126 lY = sprite.dimy() - (y0 + sprite.dimy()>
dimy()?y0 + sprite.dimy() -
dimy():0) + (
by?y0:0),
26127 lZ = sprite.dimz() - (z0 + sprite.dimz()>
dimz()?z0 + sprite.dimz() -
dimz():0) + (bz?z0:0),
26128 lV = sprite.dimv() - (v0 + sprite.dimv()>
dimv()?v0 + sprite.dimv() -
dimv():0) + (bv?v0:0);
26130 *ptrs = sprite.data -
26132 (
by?y0*sprite.dimx():0) -
26133 (bz?z0*sprite.dimx()*sprite.dimy():0) -
26134 (bv?v0*sprite.dimx()*sprite.dimy()*sprite.dimz():0);
26136 offX =
width - lX, soffX = sprite.width - lX,
26137 offY =
width*(
height - lY), soffY = sprite.width*(sprite.height - lY),
26138 offZ =
width*
height*(
depth - lZ), soffZ = sprite.width*sprite.height*(sprite.depth - lZ);
26140 if (lX>0 && lY>0 && lZ>0 && lV>0) {
26141 T *ptrd =
ptr(x0<0?0:x0,y0<0?0:y0,z0<0?0:z0,v0<0?0:v0);
26142 for (
int v = 0;
v<lV; ++
v) {
26143 for (
int z = 0;
z<lZ; ++
z) {
26144 for (
int y = 0;
y<lY; ++
y) {
26145 if (opacity>=1)
for (
int x = 0; x<lX; ++
x) *(ptrd++) = (T)*(ptrs++);
26146 else for (
int x = 0; x<lX; ++
x) { *ptrd = (T)(nopacity*(*(ptrs++)) + *ptrd*copacity); ++ptrd; }
26147 ptrd+=offX; ptrs+=soffX;
26149 ptrd+=offY; ptrs+=soffY;
26151 ptrd+=offZ; ptrs+=soffZ;
26159 const CImg<T>& sprite,
const float opacity=1) {
26162 throw CImgArgumentException(
"CImg<%s>::draw_image() : Specified sprite image (%u,%u,%u,%u,%p) is empty.",
26163 pixel_type(),sprite.width,sprite.height,sprite.depth,sprite.dim,sprite.data);
26165 const bool bx = (x0<0),
by = (y0<0), bz = (z0<0), bv = (v0<0);
26167 lX = sprite.dimx() - (x0 + sprite.dimx()>
dimx()?x0 + sprite.dimx() -
dimx():0) + (bx?x0:0),
26168 lY = sprite.dimy() - (y0 + sprite.dimy()>
dimy()?y0 + sprite.dimy() -
dimy():0) + (
by?y0:0),
26169 lZ = sprite.dimz() - (z0 + sprite.dimz()>
dimz()?z0 + sprite.dimz() -
dimz():0) + (bz?z0:0),
26170 lV = sprite.dimv() - (v0 + sprite.dimv()>
dimv()?v0 + sprite.dimv() -
dimv():0) + (bv?v0:0);
26172 *ptrs = sprite.data -
26174 (
by?y0*sprite.dimx():0) -
26175 (bz?z0*sprite.dimx()*sprite.dimy():0) -
26176 (bv?v0*sprite.dimx()*sprite.dimy()*sprite.dimz():0);
26178 offX =
width - lX, soffX = sprite.width - lX,
26179 offY =
width*(
height - lY), soffY = sprite.width*(sprite.height - lY),
26180 offZ =
width*
height*(
depth - lZ), soffZ = sprite.width*sprite.height*(sprite.depth - lZ),
26181 slX = lX*
sizeof(T);
26183 if (lX>0 && lY>0 && lZ>0 && lV>0) {
26184 T *ptrd =
ptr(x0<0?0:x0,y0<0?0:y0,z0<0?0:z0,v0<0?0:v0);
26185 for (
int v = 0;
v<lV; ++
v) {
26186 for (
int z = 0;
z<lZ; ++
z) {
26187 if (opacity>=1)
for (
int y = 0;
y<lY; ++
y) { std::memcpy(ptrd,ptrs,slX); ptrd+=
width; ptrs+=sprite.width; }
26188 else for (
int y = 0;
y<lY; ++
y) {
26189 for (
int x = 0; x<lX; ++
x) { *ptrd = (T)(nopacity*(*(ptrs++)) + *ptrd*copacity); ++ptrd; }
26190 ptrd+=offX; ptrs+=soffX;
26192 ptrd+=offY; ptrs+=soffY;
26194 ptrd+=offZ; ptrs+=soffZ;
26201 template<
typename t>
26203 const CImg<t>& sprite,
const float opacity=1) {
26204 return draw_image(x0,y0,z0,0,sprite,opacity);
26208 template<
typename t>
26210 const CImg<t>& sprite,
const float opacity=1) {
26215 template<
typename t>
26217 const CImg<t>& sprite,
const float opacity=1) {
26222 template<
typename t>
26242 template<
typename ti,
typename tm>
26245 const float mask_valmax=1) {
26248 throw CImgArgumentException(
"CImg<%s>::draw_image() : Specified sprite image (%u,%u,%u,%u,%p) is empty.",
26249 pixel_type(),sprite.width,sprite.height,sprite.depth,sprite.dim,sprite.data);
26251 throw CImgArgumentException(
"CImg<%s>::draw_image() : Specified mask image (%u,%u,%u,%u,%p) is empty.",
26252 pixel_type(),mask.width,mask.height,mask.depth,mask.dim,mask.data);
26255 if (mask.width!=sprite.width || mask.height!=sprite.height || mask.depth!=sprite.depth)
26256 throw CImgArgumentException(
"CImg<%s>::draw_image() : Mask dimension is (%u,%u,%u,%u), while sprite is (%u,%u,%u,%u)",
26257 pixel_type(),mask.width,mask.height,mask.depth,mask.dim,sprite.width,sprite.height,sprite.depth,sprite.dim);
26258 const bool bx = (x0<0),
by = (y0<0), bz = (z0<0), bv = (v0<0);
26260 lX = sprite.dimx() - (x0 + sprite.dimx()>
dimx()?x0 + sprite.dimx() -
dimx():0) + (bx?x0:0),
26261 lY = sprite.dimy() - (y0 + sprite.dimy()>
dimy()?y0 + sprite.dimy() -
dimy():0) + (
by?y0:0),
26262 lZ = sprite.dimz() - (z0 + sprite.dimz()>
dimz()?z0 + sprite.dimz() -
dimz():0) + (bz?z0:0),
26263 lV = sprite.dimv() - (v0 + sprite.dimv()>
dimv()?v0 + sprite.dimv() -
dimv():0) + (bv?v0:0);
26265 coff = -(bx?x0:0)-(
by?y0*mask.dimx():0)-(bz?z0*mask.dimx()*mask.dimy():0)-(bv?v0*mask.dimx()*mask.dimy()*mask.dimz():0),
26266 ssize = mask.dimx()*mask.dimy()*mask.dimz();
26267 const ti *ptrs = sprite.data + coff;
26268 const tm *ptrm = mask.data + coff;
26270 offX =
width - lX, soffX = sprite.width - lX,
26271 offY =
width*(
height - lY), soffY = sprite.width*(sprite.height - lY),
26272 offZ =
width*
height*(
depth - lZ), soffZ = sprite.width*sprite.height*(sprite.depth - lZ);
26273 if (lX>0 && lY>0 && lZ>0 && lV>0) {
26274 T *ptrd =
ptr(x0<0?0:x0,y0<0?0:y0,z0<0?0:z0,v0<0?0:v0);
26275 for (
int v = 0;
v<lV; ++
v) {
26276 ptrm = mask.data + (ptrm - mask.data)%ssize;
26277 for (
int z = 0;
z<lZ; ++
z) {
26278 for (
int y = 0;
y<lY; ++
y) {
26279 for (
int x = 0; x<lX; ++
x) {
26280 const float mopacity = (float)(*(ptrm++)*opacity),
26282 *ptrd = (T)((nopacity*(*(ptrs++)) + *ptrd*copacity)/mask_valmax);
26285 ptrd+=offX; ptrs+=soffX; ptrm+=soffX;
26287 ptrd+=offY; ptrs+=soffY; ptrm+=soffY;
26289 ptrd+=offZ; ptrs+=soffZ; ptrm+=soffZ;
26296 template<
typename ti,
typename tm>
26299 const float mask_valmax=1) {
26300 return draw_image(x0,y0,z0,0,sprite,mask,opacity,mask_valmax);
26304 template<
typename ti,
typename tm>
26307 const float mask_valmax=1) {
26308 return draw_image(x0,y0,0,sprite,mask,opacity,mask_valmax);
26312 template<
typename ti,
typename tm>
26315 const float mask_valmax=1) {
26316 return draw_image(x0,0,sprite,mask,opacity,mask_valmax);
26320 template<
typename ti,
typename tm>
26322 const float mask_valmax=1) {
26323 return draw_image(0,sprite,mask,opacity,mask_valmax);
26337 template<
typename tc1,
typename tc2,
typename t>
26339 const tc1 *
const foreground_color,
const tc2 *
const background_color,
26340 const float opacity,
const CImgList<t>& font, ...) {
26341 char tmp[2048] = { 0 }; std::va_list ap; va_start(ap,font);
26342 std::vsprintf(tmp,text,ap); va_end(ap);
26343 return _draw_text(x0,y0,tmp,foreground_color,background_color,opacity,font);
26347 template<
typename tc1,
typename tc2,
typename t>
26350 const float opacity,
const CImgList<t>& font, ...) {
26351 char tmp[2048] = { 0 }; std::va_list ap; va_start(ap,font);
26352 std::vsprintf(tmp,text,ap); va_end(ap);
26353 return _draw_text(x0,y0,tmp,foreground_color,background_color,opacity,font);
26357 template<
typename tc,
typename t>
26359 const tc *
const foreground_color,
const int,
26360 const float opacity,
const CImgList<t>& font, ...) {
26361 char tmp[2048] = { 0 }; std::va_list ap; va_start(ap,font);
26362 std::vsprintf(tmp,text,ap); va_end(ap);
26363 return _draw_text(x0,y0,tmp,foreground_color,(tc*)0,opacity,font);
26367 template<
typename tc,
typename t>
26369 const int,
const tc *
const background_color,
26370 const float opacity,
const CImgList<t>& font, ...) {
26371 char tmp[2048] = { 0 }; std::va_list ap; va_start(ap,font);
26372 std::vsprintf(tmp,text,ap); va_end(ap);
26373 return _draw_text(x0,y0,tmp,(tc*)0,background_color,opacity,font);
26387 template<
typename tc1,
typename tc2>
26389 const tc1 *
const foreground_color,
const tc2 *
const background_color,
26390 const float opacity=1,
const unsigned int font_size=11, ...) {
26392 static unsigned int fsize = 0;
26393 if (fsize!=font_size) { font =
CImgList<T>::font(font_size); fsize = font_size; }
26394 char tmp[2048] = { 0 }; std::va_list ap; va_start(ap,font_size); std::vsprintf(tmp,text,ap); va_end(ap);
26395 return _draw_text(x0,y0,tmp,foreground_color,background_color,opacity,font);
26399 template<
typename tc1,
typename tc2>
26402 const float opacity=1,
const unsigned int font_size=11, ...) {
26404 static unsigned int fsize = 0;
26405 if (fsize!=font_size) { font =
CImgList<T>::font(font_size); fsize = font_size; }
26406 char tmp[2048] = { 0 }; std::va_list ap; va_start(ap,font_size); std::vsprintf(tmp,text,ap); va_end(ap);
26407 return _draw_text(x0,y0,tmp,foreground_color.data,background_color.data,opacity,font);
26411 template<
typename tc>
26413 const tc *
const foreground_color,
const int background_color=0,
26414 const float opacity=1,
const unsigned int font_size=11, ...) {
26416 static unsigned int fsize = 0;
26417 if (fsize!=font_size) { font =
CImgList<T>::font(font_size); fsize = font_size; }
26418 char tmp[2048] = { 0 }; std::va_list ap; va_start(ap,font_size); std::vsprintf(tmp,text,ap); va_end(ap);
26419 return _draw_text(x0,y0,tmp,foreground_color,(
const tc*)background_color,opacity,font);
26423 template<
typename tc>
26425 const int,
const tc *
const background_color,
26426 const float opacity=1,
const unsigned int font_size=11, ...) {
26428 static unsigned int fsize = 0;
26429 if (fsize!=font_size) { font =
CImgList<T>::font(font_size); fsize = font_size; }
26430 char tmp[2048] = { 0 }; std::va_list ap; va_start(ap,font_size); std::vsprintf(tmp,text,ap); va_end(ap);
26431 return _draw_text(x0,y0,tmp,(tc*)0,background_color,opacity,font);
26434 template<
typename tc1,
typename tc2,
typename t>
26436 const tc1 *
const foreground_color,
const tc2 *
const background_color,
26438 if (!text)
return *
this;
26442 const unsigned int text_length = std::strlen(text);
26446 int x = 0,
y = 0, w = 0;
26447 unsigned char c = 0;
26448 for (
unsigned int i = 0; i<text_length; ++
i) {
26451 case '\n' :
y+=font[
' '].height;
if (x>w) w =
x; x = 0;
break;
26452 case '\t' : x+=4*font[
' '].
width;
break;
26453 default :
if (c<font.
width) x+=font[c].
width;
26456 if (x!=0 || c==
'\n') {
26458 y+=font[
' '].height;
26460 assign(x0+w,y0+
y,1,font[
' '].dim,0);
26464 int x = x0,
y = y0;
26466 for (
unsigned int i = 0; i<text_length; ++
i) {
26467 const unsigned char c = text[
i];
26469 case '\n' : y+=font[
' '].height; x = x0;
break;
26470 case '\t' : x+=4*font[
' '].
width;
break;
26471 default :
if (c<font.
width) {
26474 if (foreground_color)
for (
unsigned int p = 0; p<letter.width*letter.height; ++p)
26475 if (
mask(p))
cimg_forV(*
this,
k) letter(p,0,0,
k) = (T)(letter(p,0,0,
k)*foreground_color[
k]);
26476 if (background_color)
for (
unsigned int p = 0; p<letter.width*letter.height; ++p)
26477 if (!
mask(p))
cimg_forV(*
this,
k) letter(p,0,0,
k) = (T)background_color[
k];
26478 if (!background_color && font.
width>=512)
draw_image(x,y,letter,mask,opacity,(T)1);
26497 template<
typename t1,
typename t2>
26499 const t2 *
const color,
const float opacity=1,
26500 const unsigned int sampling=25,
const float factor=-20,
26501 const bool arrows=
true,
const unsigned int pattern=~0U) {
26502 return draw_quiver(flow,
CImg<t2>(color,dim,1,1,1,
true),opacity,sampling,factor,arrows,pattern);
26515 template<
typename t1,
typename t2>
26517 const CImg<t2>& color,
const float opacity=1,
26518 const unsigned int sampling=25,
const float factor=-20,
26519 const bool arrows=
true,
const unsigned int pattern=~0U) {
26521 if (!flow || flow.dim!=2)
26522 throw CImgArgumentException(
"CImg<%s>::draw_quiver() : Specified flow (%u,%u,%u,%u,%p) has wrong dimensions.",
26523 pixel_type(),flow.width,flow.height,flow.depth,flow.dim,flow.data);
26527 const bool colorfield = (color.width==flow.width && color.height==flow.height && color.depth==1 && color.dim==
dim);
26532 float m, M = (float)flow.get_norm(2).maxmin(m);
26535 }
else { fact = factor; vmax = 1; }
26537 for (
unsigned int y=sampling/2;
y<
height;
y+=sampling)
26538 for (
unsigned int x=sampling/2; x<
width; x+=sampling) {
26539 const unsigned int X = x*flow.width/
width, Y =
y*flow.height/
height;
26540 float u = (float)flow(X,Y,0,0)*fact/vmax,
v = (float)flow(X,Y,0,1)*fact/vmax;
26542 const int xx = x+(int)u, yy =
y+(
int)
v;
26543 if (colorfield)
draw_arrow(x,
y,xx,yy,color.get_vector_at(X,Y).data,opacity,45,sampling/5.0f,pattern);
26544 else draw_arrow(x,
y,xx,yy,color,opacity,45,sampling/5.0f,pattern);
26546 if (colorfield)
draw_line((
int)(x-0.5*u),(
int)(
y-0.5*v),(
int)(x+0.5*u),(
int)(
y+0.5*v),color.get_vector_at(X,Y),opacity,pattern);
26547 else draw_line((
int)(x-0.5*u),(
int)(
y-0.5*v),(
int)(x+0.5*u),(
int)(
y+0.5*v),color,opacity,pattern);
26564 template<
typename t,
typename tc>
26566 const tc *
const color,
const float opacity=1,
26567 const unsigned int pattern=~0U) {
26569 int siz = (int)xvalues.size()-1;
26572 if (xvalues[0]<xvalues[siz])
draw_arrow(0,y,
width-1,y,color,opacity,30,5,pattern);
26574 const int yt = (y+14)<
dimy()?(y+3):(y-14);
26575 char txt[32] = { 0 };
26577 std::sprintf(txt,
"%g",(
double)xvalues(x));
26578 const int xi = (int)(x*(
width-1)/siz), xt = xi-(
int)std::strlen(txt)*3;
26579 draw_point(xi,y-1,color,opacity).draw_point(xi,y+1,color,opacity).
26580 draw_text(xt<0?0:xt,yt,txt,color,(tc*)0,opacity,11);
26588 template<
typename t,
typename tc>
26590 const CImg<tc>& color,
const float opacity=1,
26591 const unsigned int pattern=~0U) {
26592 return draw_axis(xvalues,y,color.data,opacity,pattern);
26596 template<
typename t,
typename tc>
26598 const tc *
const color,
const float opacity=1,
26599 const unsigned int pattern=~0U) {
26601 int siz = (int)yvalues.size()-1;
26604 if (yvalues[0]<yvalues[siz])
draw_arrow(x,0,x,
height-1,color,opacity,30,5,pattern);
26606 char txt[32] = { 0 };
26608 std::sprintf(txt,
"%g",(
double)yvalues(
y));
26610 yi = (int)(
y*(
height-1)/siz),
26612 nyi = tmp<0?0:(tmp>=
dimy()-11?
dimy()-11:tmp),
26613 xt = x-(
int)std::strlen(txt)*7;
26614 draw_point(x-1,yi,color,opacity).draw_point(x+1,yi,color,opacity);
26615 if (xt>0)
draw_text(xt,nyi,txt,color,(tc*)0,opacity,11);
26616 else draw_text(x+3,nyi,txt,color,(tc*)0,opacity,11);
26624 template<
typename t,
typename tc>
26626 const CImg<tc>& color,
const float opacity=1,
26627 const unsigned int pattern=~0U) {
26628 return draw_axis(x,yvalues,color.data,opacity,pattern);
26632 template<
typename tx,
typename ty,
typename tc>
26634 const tc *
const color,
const float opacity=1,
26635 const unsigned int patternx=~0U,
const unsigned int patterny=~0U) {
26637 const CImg<tx> nxvalues(xvalues.data,xvalues.size(),1,1,1,
true);
26638 const int sizx = (int)xvalues.size()-1, wm1 = (int)(
width)-1;
26640 float ox = (float)nxvalues[0];
26641 for (
unsigned int x = 1; x<
width; ++
x) {
26642 const float nx = (float)nxvalues._linear_atX((
float)x*sizx/wm1);
26643 if (nx*ox<=0) {
draw_axis(nx==0?x:x-1,yvalues,color,opacity,patterny);
break; }
26647 const CImg<ty> nyvalues(yvalues.data,yvalues.size(),1,1,1,
true);
26648 const int sizy = (int)yvalues.size()-1, hm1 = (int)(
height)-1;
26650 float oy = (float)nyvalues[0];
26651 for (
unsigned int y = 1;
y<
height; ++
y) {
26652 const float ny = (float)nyvalues._linear_atX((
float)
y*sizy/hm1);
26653 if (ny*oy<=0) {
draw_axis(xvalues,ny==0?
y:
y-1,color,opacity,patternx);
break; }
26662 template<
typename tx,
typename ty,
typename tc>
26664 const CImg<tc>& color,
const float opacity=1,
26665 const unsigned int patternx=~0U,
const unsigned int patterny=~0U) {
26666 return draw_axis(xvalues,yvalues,color.data,opacity,patternx,patterny);
26670 template<
typename tc>
26672 const tc *
const color,
const float opacity=1,
26673 const int subdivisionx=-60,
const int subdivisiony=-60,
26674 const float precisionx=0,
const float precisiony=0,
26675 const unsigned int patternx=~0U,
const unsigned int patterny=~0U) {
26683 color,opacity,patternx,patterny);
26689 template<
typename tc>
26691 const CImg<tc>& color,
const float opacity=1,
26692 const int subdivisionx=-60,
const int subdivisiony=-60,
26693 const float precisionx=0,
const float precisiony=0,
26694 const unsigned int patternx=~0U,
const unsigned int patterny=~0U) {
26695 return draw_axis(x0,x1,y0,y1,color.data,opacity,subdivisionx,subdivisiony,precisionx,precisiony,patternx,patterny);
26699 template<
typename tx,
typename ty,
typename tc>
26701 const tc *
const color,
const float opacity=1,
26702 const unsigned int patternx=~0U,
const unsigned int patterny=~0U) {
26705 const int xi = (int)xvalues[x];
26709 const int yi = (int)yvalues[
y];
26717 template<
typename tx,
typename ty,
typename tc>
26719 const CImg<tc>& color,
const float opacity=1,
26720 const unsigned int patternx=~0U,
const unsigned int patterny=~0U) {
26721 return draw_grid(xvalues,yvalues,color.data,opacity,patternx,patterny);
26725 template<
typename tc>
26727 const float offsetx,
const float offsety,
26728 const bool invertx,
const bool inverty,
26729 const tc *
const color,
const float opacity=1,
26730 const unsigned int patternx=~0U,
const unsigned int patterny=~0U) {
26733 const float dx = deltax>0?deltax:
width*-deltax/100;
26734 const unsigned int nx = (
unsigned int)(
width/dx);
26741 const float dy = deltay>0?deltay:
height*-deltay/100;
26742 const unsigned int ny = (
unsigned int)(
height/dy);
26747 return draw_grid(seqx,seqy,color,opacity,patternx,patterny);
26751 template<
typename tc>
26753 const float offsetx,
const float offsety,
26754 const bool invertx,
const bool inverty,
26755 const CImg<tc>& color,
const float opacity=1,
26756 const unsigned int patternx=~0U,
const unsigned int patterny=~0U) {
26757 return draw_grid(deltax,deltay,offsetx,offsety,invertx,inverty,color.data,opacity,patternx,patterny);
26787 template<
typename t,
typename tc>
26789 const tc *
const color,
const float opacity=1,
26790 const unsigned int plot_type=1,
const int vertex_type=1,
26791 const double ymin=0,
const double ymax=0,
const bool expand=
false,
26792 const unsigned int pattern=~0U) {
26794 const unsigned int siz = data.size();
26798 tc *color1 = 0, *color2 = 0;
26799 if (plot_type==3) {
26800 color1 =
new tc[
dim]; color2 =
new tc[
dim];
26801 cimg_forV(*
this,
k) { color1[
k] = (tc)(color[
k]*0.6f); color2[
k] = (tc)(color[
k]*0.3f); }
26804 double m = ymin, M = ymax;
26805 if (ymin==ymax) m = (double)data.maxmin(M);
26806 if (m==M) { --m; ++M; }
26807 const float ca = (float)(M-m)/(
height-1);
26808 bool init_hatch =
true;
26809 const unsigned int xp = expand?1:0;
26812 switch (plot_type%4) {
26814 int oX = 0, oY = (int)((data[0]-m)/ca);
26815 for (
unsigned int off = 1; off<siz; ++off) {
26817 X = (int)(off*
width/(siz-xp)),
26818 Y = (
int)((data[off]-m)/ca);
26819 draw_line(oX,oY,X,Y,color,opacity,pattern,init_hatch);
26821 init_hatch =
false;
26825 const CImg<t> ndata(data.data,siz,1,1,1,
true);
26826 int oY = (int)((data[0]-m)/ca);
26828 const int Y = (int)((ndata._cubic_atX((
float)x*(ndata.width-xp)/
width)-m)/ca);
26829 if (x>0)
draw_line(x,oY,x+1,Y,color,opacity,pattern,init_hatch);
26830 init_hatch =
false;
26835 const int Y0 = (int)(-m/ca);
26839 X = (off+1)*
width/siz-1,
26840 Y = (
int)((data[off]-m)/ca);
26843 draw_line(oX,Y0,X,Y0,Y<=Y0?color2:color,opacity).
26845 draw_line(oX,Y,X,Y,Y<=Y0?color:color2,opacity);
26853 switch (vertex_type%8) {
26856 const int X = off*
width/(siz-xp), Y = (
int)((data[off]-m)/ca);
26862 const int X = off*
width/(siz-xp), Y = (
int)((data[off]-m)/ca);
26863 draw_line(X-3,Y,X+3,Y,color,opacity).draw_line(X,Y-3,X,Y+3,color,opacity);
26868 const int X = off*
width/(siz-xp), Y = (
int)((data[off]-m)/ca);
26869 draw_line(X-3,Y-3,X+3,Y+3,color,opacity).draw_line(X-3,Y+3,X+3,Y-3,color,opacity);
26874 const int X = off*
width/(siz-xp), Y = (
int)((data[off]-m)/ca);
26880 const int X = off*
width/(siz-xp), Y = (
int)((data[off]-m)/ca);
26886 const int X = off*
width/(siz-xp), Y = (
int)((data[off]-m)/ca);
26892 const int X = off*
width/(siz-xp), Y = (
int)((data[off]-m)/ca);
26902 if (color1)
delete[] color1;
if (color2)
delete[] color2;
26907 template<
typename t,
typename tc>
26909 const CImg<tc>& color,
const float opacity=1,
26910 const unsigned int plot_type=1,
const unsigned int vertex_type=1,
26911 const double ymin=0,
const double ymax=0,
const bool expand=
false,
26912 const unsigned int pattern=~0U) {
26913 return draw_graph(data,color.data,opacity,plot_type,vertex_type,ymin,ymax,expand,pattern);
26928 template<
typename tc,
typename t>
26930 const tc *
const color,
const float opacity,
26931 CImg<t>& region,
const float sigma=0,
26932 const bool high_connexity=
false) {
26934 #define _cimg_draw_fill_test(x,y,z,res) if (region(x,y,z)) res = false; else { \
26936 const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(x,y,z) + siz; \
26937 for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } \
26938 region(x,y,z) = (t)(res?1:noregion); \
26941 #define _cimg_draw_fill_set(x,y,z) { \
26942 const tc *col = color; \
26943 T *ptrd = ptr(x,y,z); \
26944 if (opacity>=1) cimg_forV(*this,k) { *ptrd = (T)*(col++); ptrd+=whz; } \
26945 else cimg_forV(*this,k) { *ptrd = (T)(*(col++)*nopacity + *ptrd*copacity); ptrd+=whz; } \
26948 #define _cimg_draw_fill_insert(x,y,z) { \
26949 if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); \
26950 unsigned int *ptrr = remaining.ptr(0,posr1); \
26951 *(ptrr++) = x; *(ptrr++) = y; *(ptrr++) = z; ++posr1; \
26954 #define _cimg_draw_fill_test_neighbor(x,y,z,cond) if (cond) { \
26955 const unsigned int tx = x, ty = y, tz = z; \
26956 _cimg_draw_fill_test(tx,ty,tz,res); if (res) _cimg_draw_fill_insert(tx,ty,tz); \
26963 if (x>=0 && x<
dimx() && y>=0 && y<
dimy() && z>=0 && z<
dimz()) {
26966 const bool threed = depth>1;
26969 remaining(0,0) =
x; remaining(1,0) =
y; remaining(2,0) =
z;
26970 unsigned int posr0 = 0, posr1 = 1;
26971 region(x,y,z) = (t)1;
26972 const t noregion = ((t)1==(t)2)?(t)0:(t)(-1);
26974 const unsigned int *pcurr = remaining.
ptr(0,posr0++), xc = *(pcurr++), yc = *(pcurr++), zc = *(pcurr++);
26975 if (posr0>=512) { remaining.
translate(0,-(
int)posr0); posr1-=posr0; posr0 = 0; }
26977 unsigned int nxc = xc;
26997 unsigned int nyc = yc;
27019 unsigned int nzc = zc;
27041 }
while (posr1>posr0);
27043 const unsigned int *pcurr = remaining.
ptr(0,posr0++), xc = *(pcurr++), yc = *(pcurr++);
27044 if (posr0>=512) { remaining.
translate(0,-(
int)posr0); posr1-=posr0; posr0 = 0; }
27046 unsigned int nxc = xc;
27051 if (high_connexity) {
27066 if (high_connexity) {
27074 unsigned int nyc = yc;
27081 if (high_connexity) {
27096 if (high_connexity) {
27104 }
while (posr1>posr0);
27111 template<
typename tc,
typename t>
27113 const CImg<tc>& color,
const float opacity,
27114 CImg<t>& region,
const float sigma=0,
const bool high_connexity=
false) {
27115 return draw_fill(x,y,z,color.data,opacity,region,sigma,high_connexity);
27127 template<
typename tc>
27129 const tc *
const color,
const float opacity=1,
27130 const float sigma=0,
const bool high_connexity=
false) {
27132 return draw_fill(x,y,z,color,opacity,tmp,sigma,high_connexity);
27136 template<
typename tc>
27138 const CImg<tc>& color,
const float opacity=1,
27139 const float sigma=0,
const bool high_connexity=
false) {
27140 return draw_fill(x,y,z,color.data,opacity,sigma,high_connexity);
27151 template<
typename tc>
27153 const tc *
const color,
const float opacity=1,
27154 const float sigma=0,
const bool high_connexity=
false) {
27156 return draw_fill(x,y,0,color,opacity,tmp,sigma,high_connexity);
27160 template<
typename tc>
27162 const CImg<tc>& color,
const float opacity=1,
27163 const float sigma=0,
const bool high_connexity=
false) {
27164 return draw_fill(x,y,color.data,opacity,sigma,high_connexity);
27178 const float alpha=1,
const float beta=1,
27179 const float opacity=1) {
27182 int nx0 = x0, nx1 = x1, ny0 = y0, ny1 = y1;
27185 if (nx0<0) nx0 = 0;
27187 if (ny0<0) ny0 = 0;
27189 const int xc = (nx0+nx1)/2, yc = (ny0+ny1)/2,
dx = (xc-nx0),
dy = (yc-ny0);
27195 val0 = (
Tfloat)((*
this)(nx0,ny0,0,
k)), val1 = (
Tfloat)((*
this)(nx1,ny0,0,
k)),
27196 val2 = (
Tfloat)((*
this)(nx0,ny1,0,
k)), val3 = (
Tfloat)((*
this)(nx1,ny1,0,
k));
27197 (*this)(xc,ny0,0,
k) = (T)((val0+val1)/2);
27198 (*this)(xc,ny1,0,
k) = (T)((val2+val3)/2);
27199 (*this)(nx0,yc,0,
k) = (T)((val0+val2)/2);
27200 (*this)(nx1,yc,0,
k) = (T)((val1+val3)/2);
27203 (
Tfloat)((*
this)(nx1,ny0,0,
k)) +
27204 (
Tfloat)((*
this)(nx1,ny1,0,
k)) +
27205 (
Tfloat)((*
this)(nx0,ny1,0,
k))) +
27208 (*this)(xc,yc,0,
k) = (T)val;
27211 val0 = (
Tfloat)((*
this)(nx0,ny0,0,
k)), val1 = (
Tfloat)((*
this)(nx1,ny0,0,
k)),
27212 val2 = (
Tfloat)((*
this)(nx0,ny1,0,
k)), val3 = (
Tfloat)((*
this)(nx1,ny1,0,
k));
27213 (*this)(xc,ny0,0,
k) = (T)(((val0+val1)*nopacity + copacity*(*
this)(xc,ny0,0,
k))/2);
27214 (*this)(xc,ny1,0,
k) = (T)(((val2+val3)*nopacity + copacity*(*
this)(xc,ny1,0,
k))/2);
27215 (*this)(nx0,yc,0,
k) = (T)(((val0+val2)*nopacity + copacity*(*
this)(nx0,yc,0,
k))/2);
27216 (*this)(nx1,yc,0,
k) = (T)(((val1+val3)*nopacity + copacity*(*
this)(nx1,yc,0,
k))/2);
27219 (
Tfloat)((*
this)(nx1,ny0,0,
k)) +
27220 (
Tfloat)((*
this)(nx1,ny1,0,
k)) +
27221 (
Tfloat)((*
this)(nx0,ny1,0,
k))) +
27222 dc*
cimg::grand())*nopacity + copacity*(*
this)(xc,yc,0,
k));
27224 (*this)(xc,yc,0,
k) = (T)val;
27227 if (xc!=nx0 || yc!=ny0) {
27244 const float opacity=1) {
27249 template<
typename tc>
27251 const CImg<tc>& color_palette,
const float opacity=1,
27252 const double z0r=-2,
const double z0i=-2,
const double z1r=2,
const double z1i=2,
27253 const unsigned int itermax=255,
27254 const bool normalized_iteration=
false,
27255 const bool julia_set=
false,
27256 const double paramr=0,
const double parami=0) {
27259 if (color_palette) palette.assign(color_palette.data,color_palette.size()/color_palette.dim,1,1,color_palette.dim,
true);
27260 if (palette && palette.dim!=dim)
27261 throw CImgArgumentException(
"CImg<%s>::draw_mandelbrot() : Specified color palette (%u,%u,%u,%u,%p) is not \n"
27262 "compatible with instance image (%u,%u,%u,%u,%p).",
27263 pixel_type(),color_palette.width,color_palette.height,color_palette.depth,color_palette.dim,
27266 unsigned int iter = 0;
27268 const double x = z0r + p*(z1r-z0r)/
width,
y = z0i +
q*(z1i-z0i)/
height;
27269 double zr, zi, cr, ci;
27270 if (julia_set) { zr =
x; zi =
y; cr = paramr; ci = parami; }
27271 else { zr = paramr; zi = parami; cr =
x; ci =
y; }
27272 for (iter=1; zr*zr + zi*zi<=4 && iter<=itermax; ++iter) {
27273 const double temp = zr*zr - zi*zi + cr;
27277 if (iter>itermax) {
27279 if (opacity>=1)
cimg_forV(*
this,
k) (*this)(p,
q,0,
k) = (T)palette(0,
k);
27280 else cimg_forV(*
this,
k) (*this)(p,
q,0,
k) = (T)(palette(0,
k)*nopacity + (*this)(p,
q,0,
k)*copacity);
27282 if (opacity>=1)
cimg_forV(*
this,
k) (*this)(p,
q,0,
k) = (T)0;
27283 else cimg_forV(*
this,
k) (*this)(p,
q,0,
k) = (T)((*this)(p,
q,0,
k)*copacity);
27285 }
else if (normalized_iteration) {
27290 if (opacity>=1)
cimg_forV(*
this,
k) (*this)(p,
q,0,
k) = (T)palette._linear_atX(niter,
k);
27291 else cimg_forV(*
this,
k) (*this)(p,
q,0,
k) = (T)(palette._linear_atX(niter,
k)*nopacity + (*this)(p,
q,0,
k)*copacity);
27293 if (opacity>=1)
cimg_forV(*
this,
k) (*this)(p,
q,0,
k) = (T)niter;
27294 else cimg_forV(*
this,
k) (*this)(p,
q,0,
k) = (T)(niter*nopacity + (*this)(p,
q,0,
k)*copacity);
27298 if (opacity>=1)
cimg_forV(*
this,
k) (*this)(p,
q,0,
k) = (T)palette._atX(iter,
k);
27299 else cimg_forV(*
this,
k) (*this)(p,
q,0,
k) = (T)(palette(iter,
k)*nopacity + (*this)(p,
q,0,
k)*copacity);
27301 if (opacity>=1)
cimg_forV(*
this,
k) (*this)(p,
q,0,
k) = (T)iter;
27302 else cimg_forV(*
this,
k) (*this)(p,
q,0,
k) = (T)(iter*nopacity + (*this)(p,
q,0,
k)*copacity);
27310 template<
typename tc>
27312 const double z0r=-2,
const double z0i=-2,
const double z1r=2,
const double z1i=2,
27313 const unsigned int itermax=255,
27314 const bool normalized_iteration=
false,
27315 const bool julia_set=
false,
27316 const double paramr=0,
const double parami=0) {
27317 return draw_mandelbrot(0,0,
width-1,
height-1,color_palette,opacity,z0r,z0i,z1r,z1i,itermax,normalized_iteration,julia_set,paramr,parami);
27327 template<
typename tc>
27329 const tc *
const color,
const float opacity=1) {
27334 const float sigma2 = 2*sigma*sigma, nopacity =
cimg::abs(opacity), copacity = 1 -
cimg::max(opacity,0);
27336 const tc *col = color;
27338 const float dx = (x - xc), val = (
float)
std::exp(-dx*dx/sigma2);
27339 T *ptrd =
ptr(x,0,0,0);
27340 if (opacity>=1)
cimg_forV(*
this,
k) { *ptrd = (T)(val*(*col++)); ptrd+=whz; }
27341 else cimg_forV(*
this,
k) { *ptrd = (T)(nopacity*val*(*col++) + *ptrd*copacity); ptrd+=whz; }
27348 template<
typename tc>
27350 const CImg<tc>& color,
const float opacity=1) {
27362 template<
typename t,
typename tc>
27364 const tc *
const color,
const float opacity=1) {
27367 if (tensor.width!=2 || tensor.height!=2 || tensor.depth!=1 || tensor.dim!=1)
27368 throw CImgArgumentException(
"CImg<%s>::draw_gaussian() : Tensor parameter (%u,%u,%u,%u,%p) is not a 2x2 matrix.",
27369 pixel_type(),tensor.width,tensor.height,tensor.depth,tensor.dim,tensor.data);
27373 const CImg<tfloat> invT = tensor.get_invert(), invT2 = (invT*invT)/(-2.0);
27374 const tfloat a = invT2(0,0), b = 2*invT2(1,0), c = invT2(1,1);
27377 const tc *col = color;
27382 const float val = (float)
std::exp(a*dx*dx + b*dx*dy + c*dy*dy);
27383 T *ptrd =
ptr(x,
y,0,0);
27384 if (opacity>=1)
cimg_forV(*
this,
k) { *ptrd = (T)(val*(*col++)); ptrd+=whz; }
27385 else cimg_forV(*
this,
k) { *ptrd = (T)(nopacity*val*(*col++) + *ptrd*copacity); ptrd+=whz; }
27395 template<
typename t,
typename tc>
27397 const CImg<tc>& color,
const float opacity=1) {
27402 template<
typename tc>
27404 const tc *
const color,
const float opacity=1) {
27406 a = r1*ru*ru + r2*rv*rv,
27408 c = r1*rv*rv + r2*ru*ru;
27414 template<
typename tc>
27416 const CImg<tc>& color,
const float opacity=1) {
27417 return draw_gaussian(xc,yc,r1,r2,ru,rv,color.data,opacity);
27428 template<
typename tc>
27430 const tc *
const color,
const float opacity=1) {
27435 template<
typename tc>
27437 const CImg<tc>& color,
const float opacity=1) {
27450 template<
typename t,
typename tc>
27452 const tc *
const color,
const float opacity=1) {
27455 if (tensor.width!=3 || tensor.height!=3 || tensor.depth!=1 || tensor.dim!=1)
27456 throw CImgArgumentException(
"CImg<%s>::draw_gaussian() : Tensor parameter (%u,%u,%u,%u,%p) is not a 3x3 matrix.",
27457 pixel_type(),tensor.width,tensor.height,tensor.depth,tensor.dim,tensor.data);
27458 const CImg<tfloat> invT = tensor.get_invert(), invT2 = (invT*invT)/(-2.0);
27459 const tfloat a = invT(0,0), b = 2*invT(1,0), c = 2*invT(2,0),
d = invT(1,1), e = 2*invT(2,1), f = invT(2,2);
27462 const tc *col = color;
27465 dx = (x - xc),
dy = (
y - yc), dz = (
z - zc),
27466 val = (
float)
std::exp(a*dx*dx + b*dx*
dy + c*dx*dz +
d*
dy*
dy + e*
dy*dz + f*dz*dz);
27467 T *ptrd =
ptr(x,
y,
z,0);
27468 if (opacity>=1)
cimg_forV(*
this,
k) { *ptrd = (T)(val*(*col++)); ptrd+=whz; }
27469 else cimg_forV(*
this,
k) { *ptrd = (T)(nopacity*val*(*col++) + *ptrd*copacity); ptrd+=whz; }
27476 template<
typename t,
typename tc>
27478 const CImg<tc>& color,
const float opacity=1) {
27491 template<
typename tc>
27493 const tc *
const color,
const float opacity=1) {
27498 template<
typename tc>
27500 const CImg<tc>& color,
const float opacity=1) {
27521 template<
typename tp,
typename tf,
typename tc,
typename to>
27525 const unsigned int render_type=4,
27526 const bool double_sided=
false,
const float focale=500,
27527 const float lightx=0,
const float lighty=0,
const float lightz=-5000,
27528 const float specular_light=0.2f,
const float specular_shine=0.1f,
27530 return _draw_object3d(0,zbuffer,x0,y0,z0,vertices,primitives,colors,opacities,opacities.
width,
27531 render_type,double_sided,focale,lightx,lighty,lightz,specular_light,specular_shine);
27534 #ifdef cimg_use_board
27535 template<
typename tp,
typename tf,
typename tc,
typename to>
27537 const float x0,
const float y0,
const float z0,
27540 const unsigned int render_type=4,
27541 const bool double_sided=
false,
const float focale=500,
27542 const float lightx=0,
const float lighty=0,
const float lightz=-5000,
27543 const float specular_light=0.2f,
const float specular_shine=0.1f,
27545 return _draw_object3d((
void*)&board,zbuffer,x0,y0,z0,vertices,primitives,colors,opacities,opacities.
width,
27546 render_type,double_sided,focale,lightx,lighty,lightz,specular_light,specular_shine);
27549 template<
typename tp,
typename tf,
typename tc,
typename to>
27553 const unsigned int render_type=4,
27554 const bool double_sided=
false,
const float focale=500,
27555 const float lightx=0,
const float lighty=0,
const float lightz=-5000,
27556 const float specular_light=0.2f,
const float specular_shine=0.1f,
27558 return _draw_object3d(0,zbuffer,x0,y0,z0,vertices,primitives,colors,opacities,opacities.size(),
27559 render_type,double_sided,focale,lightx,lighty,lightz,specular_light,specular_shine);
27562 #ifdef cimg_use_board
27563 template<
typename tp,
typename tf,
typename tc,
typename to>
27565 const float x0,
const float y0,
const float z0,
27568 const unsigned int render_type=4,
27569 const bool double_sided=
false,
const float focale=500,
27570 const float lightx=0,
const float lighty=0,
const float lightz=-5000,
27571 const float specular_light=0.2f,
const float specular_shine=0.1f,
27573 return _draw_object3d((
void*)&board,zbuffer,x0,y0,z0,vertices,primitives,colors,opacities,opacities.size(),
27574 render_type,double_sided,focale,lightx,lighty,lightz,specular_light,specular_shine);
27579 template<
typename tp,
typename tf,
typename tc>
27583 const unsigned int render_type=4,
27584 const bool double_sided=
false,
const float focale=500,
27585 const float lightx=0,
const float lighty=0,
const float lightz=-5000,
27586 const float specular_light=0.2f,
const float specular_shine=0.1f,
27589 return draw_object3d(x0,y0,z0,vertices,primitives,colors,opacities,
27590 render_type,double_sided,focale,lightx,lighty,lightz,specular_light,specular_shine,zbuffer);
27593 #ifdef cimg_use_board
27594 template<
typename tp,
typename tf,
typename tc,
typename to>
27596 const float x0,
const float y0,
const float z0,
27599 const unsigned int render_type=4,
27600 const bool double_sided=
false,
const float focale=500,
27601 const float lightx=0,
const float lighty=0,
const float lightz=-5000,
27602 const float specular_light=0.2f,
const float specular_shine=0.1f,
27605 return draw_object3d(x0,y0,z0,vertices,primitives,colors,opacities,
27606 render_type,double_sided,focale,lightx,lighty,lightz,specular_light,specular_shine,zbuffer);
27610 template<
typename tc,
typename to>
27612 const int nx0,
const int ny0,
const CImg<T>& sprite,
const float opac) {
27613 if (n_primitive<nb_opacities && opacities[n_primitive].
is_sameXY(color))
27614 draw_image(nx0,ny0,sprite,opacities[n_primitive].
get_resize(sprite.width,sprite.height,1,sprite.dim,1));
27618 template<
typename tc,
typename to>
27620 const int nx0,
const int ny0,
const CImg<T>& sprite,
const float opac) {
27624 template<
typename tp,
typename tf,
typename tc,
typename to>
27626 const float X,
const float Y,
const float Z,
27630 const to& opacities,
const unsigned int nb_opacities,
27631 const unsigned int render_type,
27632 const bool double_sided,
const float focale,
27633 const float lightx,
const float lighty,
const float lightz,
27634 const float specular_light,
const float specular_shine) {
27635 if (
is_empty() || !vertices || !primitives)
return *
this;
27636 vertices.is_object3d(primitives,
false,
true);
27637 #ifndef cimg_use_board
27638 if (pboard)
return *
this;
27641 nspec = 1.0f-(specular_light<0.0f?0.0f:(specular_light>1.0f?1.0f:specular_light)),
27642 nspec2 = 1.0f+(specular_shine<0.0f?0.0f:specular_shine),
27644 nsl2 = (1-2*nsl1*nspec),
27645 nsl3 = nspec2-nsl1-nsl2;
27649 if (render_type==5) {
27650 if (colors.
width>primitives.
width) light_texture.assign(colors[primitives.
width])/=255;
27652 static float olightx = 0, olighty = 0, olightz = 0, ospecular_shine = 0;
27653 if (!light_texture || lightx!=olightx || lighty!=olighty || lightz!=olightz || specular_shine!=ospecular_shine) {
27654 light_texture.assign(512,512);
27655 const float white[] = { 1 },
27656 dlx = lightx-X, dly = lighty-Y, dlz = lightz-Z,
27657 nl = (float)
std::sqrt(dlx*dlx+dly*dly+dlz*dlz),
27658 nlx = light_texture.width/2*(1+dlx/nl),
27659 nly = light_texture.height/2*(1+dly/nl);
27660 light_texture.draw_gaussian(nlx,nly,light_texture.width/3.0f,white);
27662 const float factor = light_texture(x,
y);
27663 if (factor>nspec) light_texture(x,
y) =
cimg::min(2,nsl1*factor*factor+nsl2*factor+nsl3);
27665 olightx = lightx; olighty = lighty; olightz = lightz; ospecular_shine = specular_shine;
27674 x = (float)vertices(l,0),
27675 y = (float)vertices(l,1),
27676 z = (float)vertices(l,2);
27677 const float projectedz =
z + Z + focale;
27678 projections(l,1) = Y + focale*
y/projectedz;
27679 projections(l,0) = X + focale*x/projectedz;
27685 unsigned int nb_visibles = 0;
27686 const float zmin = -focale+1.5f;
27688 const CImg<tf>& primitive = primitives[l];
27689 switch (primitive.size()) {
27692 const unsigned int i0 = (
unsigned int)primitive(0);
27693 const float x0 = projections(i0,0), y0 = projections(i0,1), z0 = (float)(Z + vertices(i0,2));
27694 if (z0>zmin && x0>=0 && x0<width && y0>=0 && y0<
height) {
27695 visibles(nb_visibles) = (
unsigned int)l;
27696 zrange(nb_visibles++) = z0;
27701 i0 = (
unsigned int)primitive(0),
27702 i1 = (
unsigned int)primitive(1),
27703 i2 = (
unsigned int)primitive(2);
27704 const float x0 = projections(i0,0), y0 = projections(i0,1), z0 = (float)(Z + vertices(i0,2));
27706 if (i2) radius = (int)(i2*focale/(z0+focale));
27708 const float x1 = projections(i1,0), y1 = projections(i1,1);
27709 const int deltax = (int)(x1-x0), deltay = (int)(y1-y0);
27710 radius = (int)
std::sqrt((
float)(deltax*deltax + deltay*deltay));
27712 if (z0>zmin && x0+radius>=0 && x0-radius<width && y0+radius>=0 && y0-radius<
height) {
27713 visibles(nb_visibles) = (
unsigned int)l;
27714 zrange(nb_visibles++) = z0;
27720 i0 = (
unsigned int)primitive(0),
27721 i1 = (
unsigned int)primitive(1);
27723 x0 = projections(i0,0), y0 = projections(i0,1), z0 = (float)(Z + vertices(i0,2)),
27724 x1 = projections(i1,0), y1 = projections(i1,1), z1 = (float)(Z + vertices(i1,2));
27725 float xm, xM, ym, yM;
27726 if (x0<x1) { xm = x0; xM = x1; }
else { xm = x1; xM = x0; }
27727 if (y0<y1) { ym = y0; yM = y1; }
else { ym = y1; yM = y0; }
27728 if (z0>zmin && z1>zmin && xM>=0 && xm<width && yM>=0 && ym<
height) {
27729 visibles(nb_visibles) = (
unsigned int)l;
27730 zrange(nb_visibles++) = 0.5f*(z0+z1);
27736 i0 = (
unsigned int)primitive(0),
27737 i1 = (
unsigned int)primitive(1),
27738 i2 = (
unsigned int)primitive(2);
27740 x0 = projections(i0,0), y0 = projections(i0,1), z0 = (float)(Z + vertices(i0,2)),
27741 x1 = projections(i1,0), y1 = projections(i1,1), z1 = (float)(Z + vertices(i1,2)),
27742 x2 = projections(i2,0), y2 = projections(i2,1), z2 = (float)(Z + vertices(i2,2));
27743 float xm, xM, ym, yM;
27744 if (x0<x1) { xm = x0; xM = x1; }
else { xm = x1; xM = x0; }
27745 if (x2<xm) xm = x2;
27746 if (x2>xM) xM = x2;
27747 if (y0<y1) { ym = y0; yM = y1; }
else { ym = y1; yM = y0; }
27748 if (y2<ym) ym = y2;
27749 if (y2>yM) yM = y2;
27750 if (z0>zmin && z1>zmin && z2>zmin && xM>=0 && xm<width && yM>=0 && ym<
height) {
27751 const float d = (x1-x0)*(y2-y0)-(x2-x0)*(y1-y0);
27752 if (double_sided || d<0) {
27753 visibles(nb_visibles) = (
unsigned int)l;
27754 zrange(nb_visibles++) = (z0+z1+z2)/3;
27761 i0 = (
unsigned int)primitive(0),
27762 i1 = (
unsigned int)primitive(1),
27763 i2 = (
unsigned int)primitive(2),
27764 i3 = (
unsigned int)primitive(3);
27766 x0 = projections(i0,0), y0 = projections(i0,1), z0 = (float)(Z + vertices(i0,2)),
27767 x1 = projections(i1,0), y1 = projections(i1,1), z1 = (float)(Z + vertices(i1,2)),
27768 x2 = projections(i2,0), y2 = projections(i2,1), z2 = (float)(Z + vertices(i2,2)),
27769 x3 = projections(i3,0), y3 = projections(i3,1), z3 = (float)(Z + vertices(i3,2));
27770 float xm, xM, ym, yM;
27771 if (x0<x1) { xm = x0; xM = x1; }
else { xm = x1; xM = x0; }
27772 if (x2<xm) xm = x2;
27773 if (x2>xM) xM = x2;
27774 if (x3<xm) xm = x3;
27775 if (x3>xM) xM = x3;
27776 if (y0<y1) { ym = y0; yM = y1; }
else { ym = y1; yM = y0; }
27777 if (y2<ym) ym = y2;
27778 if (y2>yM) yM = y2;
27779 if (y3<ym) ym = y3;
27780 if (y3>yM) yM = y3;
27781 if (z0>zmin && z1>zmin && z2>zmin && z3>zmin && xM>=0 && xm<width && yM>=0 && ym<
height) {
27782 const float d = (x1 - x0)*(y2 - y0) - (x2 - x0)*(y1 - y0);
27783 if (double_sided || d<0) {
27784 visibles(nb_visibles) = (
unsigned int)l;
27785 zrange(nb_visibles++) = (z0 + z1 + z2 + z3)/4;
27790 throw CImgArgumentException(
"CImg<%s>::draw_object3d() : Primitive %u is invalid (size = %u, can be 1,2,3,4,5,6,9 or 12)",
27795 if (nb_visibles<=0)
return *
this;
27797 CImg<floatT>(zrange.data,nb_visibles,1,1,1,
true).
sort(permutations,
false);
27801 switch (render_type) {
27803 lightprops.assign(nb_visibles);
27805 const CImg<tf>& primitive = primitives(visibles(permutations(l)));
27806 const unsigned int psize = primitive.size();
27807 if (psize==3 || psize==4 || psize==9 || psize==12) {
27809 i0 = (
unsigned int)primitive(0),
27810 i1 = (
unsigned int)primitive(1),
27811 i2 = (
unsigned int)primitive(2);
27813 x0 = (float)vertices(i0,0), y0 = (float)vertices(i0,1), z0 = (float)vertices(i0,2),
27814 x1 = (float)vertices(i1,0), y1 = (float)vertices(i1,1), z1 = (float)vertices(i1,2),
27815 x2 = (float)vertices(i2,0), y2 = (float)vertices(i2,1), z2 = (float)vertices(i2,2),
27816 dx1 = x1 - x0, dy1 = y1 - y0, dz1 = z1 - z0,
27817 dx2 = x2 - x0, dy2 = y2 - y0, dz2 = z2 - z0,
27818 nx = dy1*dz2 - dz1*dy2,
27819 ny = dz1*dx2 - dx1*dz2,
27820 nz = dx1*dy2 - dy1*dx2,
27822 lx = X + (x0 + x1 + x2)/3 - lightx,
27823 ly = Y + (y0 + y1 + y2)/3 - lighty,
27824 lz = Z + (z0 + z1 + z2)/3 - lightz,
27825 nl = (
float)
std::sqrt(1e-5f + lx*lx + ly*ly + lz*lz),
27827 lightprops[l] = factor<=nspec?factor:(nsl1*factor*factor + nsl2*factor + nsl3);
27828 }
else lightprops[l] = 1;
27834 CImg<floatT> vertices_normals(vertices.width,3,1,1,0);
27835 for (
unsigned int l = 0; l<nb_visibles; ++l) {
27836 const CImg<tf>& primitive = primitives[visibles(l)];
27837 const unsigned int psize = primitive.size();
27839 triangle_flag = (psize==3) || (psize==9),
27840 rectangle_flag = (psize==4) || (psize==12);
27841 if (triangle_flag || rectangle_flag) {
27843 i0 = (
unsigned int)primitive(0),
27844 i1 = (
unsigned int)primitive(1),
27845 i2 = (
unsigned int)primitive(2),
27846 i3 = rectangle_flag?(
unsigned int)primitive(3):0;
27848 x0 = (float)vertices(i0,0), y0 = (float)vertices(i0,1), z0 = (float)vertices(i0,2),
27849 x1 = (float)vertices(i1,0), y1 = (float)vertices(i1,1), z1 = (float)vertices(i1,2),
27850 x2 = (float)vertices(i2,0), y2 = (float)vertices(i2,1), z2 = (float)vertices(i2,2),
27851 dx1 = x1 - x0, dy1 = y1 - y0, dz1 = z1 - z0,
27852 dx2 = x2 - x0, dy2 = y2 - y0, dz2 = z2 - z0,
27853 nnx = dy1*dz2 - dz1*dy2,
27854 nny = dz1*dx2 - dx1*dz2,
27855 nnz = dx1*dy2 - dy1*dx2,
27856 norm = 1e-5f + (float)
std::sqrt(nnx*nnx + nny*nny + nnz*nnz),
27860 vertices_normals(i0,0)+=nx; vertices_normals(i0,1)+=ny; vertices_normals(i0,2)+=nz;
27861 vertices_normals(i1,0)+=nx; vertices_normals(i1,1)+=ny; vertices_normals(i1,2)+=nz;
27862 vertices_normals(i2,0)+=nx; vertices_normals(i2,1)+=ny; vertices_normals(i2,2)+=nz;
27863 if (rectangle_flag) { vertices_normals(i3,0)+=nx; vertices_normals(i3,1)+=ny; vertices_normals(i3,2)+=nz; }
27867 if (double_sided)
cimg_forX(vertices_normals,p)
if (vertices_normals(p,2)>0) {
27868 vertices_normals(p,0) = -vertices_normals(p,0);
27869 vertices_normals(p,1) = -vertices_normals(p,1);
27870 vertices_normals(p,2) = -vertices_normals(p,2);
27873 if (render_type==4) {
27874 lightprops.assign(vertices.width);
27877 nx = vertices_normals(ll,0),
27878 ny = vertices_normals(ll,1),
27879 nz = vertices_normals(ll,2),
27881 lx = (float)(X + vertices(ll,0) - lightx),
27882 ly = (
float)(Y + vertices(ll,1) - lighty),
27883 lz = (
float)(Z + vertices(ll,2) - lightz),
27884 nl = (
float)
std::sqrt(1e-5f + lx*lx + ly*ly + lz*lz),
27886 lightprops[ll] = factor<=nspec?factor:(nsl1*factor*factor + nsl2*factor + nsl3);
27890 lw2 = light_texture.width/2 - 1,
27891 lh2 = light_texture.height/2 - 1;
27892 lightprops.assign(vertices.width,2);
27895 nx = vertices_normals(ll,0),
27896 ny = vertices_normals(ll,1),
27897 nz = vertices_normals(ll,2),
27901 lightprops(ll,0) = lw2*(1 + nnx);
27902 lightprops(ll,1) = lh2*(1 + nny);
27909 const CImg<tc> default_color(1,dim,1,1,(tc)200);
27910 for (
unsigned int l = 0; l<nb_visibles; ++l) {
27911 const unsigned int n_primitive = visibles(permutations(l));
27912 const CImg<tf>& primitive = primitives[n_primitive];
27913 const CImg<tc>& color = n_primitive<colors.
width?colors[n_primitive]:default_color;
27914 const float opac = n_primitive<nb_opacities?opacities(n_primitive,0):1.0f;
27915 #ifdef cimg_use_board
27916 LibBoard::Board &board = *(LibBoard::Board*)pboard;
27919 switch (primitive.size()) {
27921 const unsigned int n0 = (
unsigned int)primitive[0];
27922 const int x0 = (int)projections(n0,0), y0 = (int)projections(n0,1);
27923 if (color.size()==
dim) {
27925 #ifdef cimg_use_board
27927 board.setPenColorRGBi(color[0],color[1],color[2],(
unsigned char)(opac*255));
27928 board.fillCircle((
float)x0,
dimy()-(
float)y0,0);
27932 const float z = Z + vertices(n0,2);
27934 factor = (int)(focale*100/(z+focale)),
27935 sw = color.width*factor/200,
27936 sh = color.height*factor/200,
27937 nx0 = x0 - sw, ny0 = y0 - sh;
27938 if (x0+sw>=0 && nx0<
dimx() && y0+sh>=0 && ny0<
dimy()) {
27939 const CImg<T> sprite = color.get_resize(-factor,-factor,1,-100,render_type<=3?1:3);
27940 __draw_object3d(n_primitive,nb_opacities,opacities,color,nx0,ny0,sprite,opac);
27941 #ifdef cimg_use_board
27943 board.setPenColorRGBi(128,128,128);
27944 board.setFillColor(LibBoard::Color::None);
27945 board.drawRectangle((
float)nx0,
dimy()-(
float)ny0,sw,sh);
27953 n0 = (
unsigned int)primitive[0],
27954 n1 = (
unsigned int)primitive[1];
27956 x0 = (int)projections(n0,0), y0 = (int)projections(n0,1),
27957 x1 = (int)projections(n1,0), y1 = (int)projections(n1,1);
27959 z0 = vertices(n0,2) + Z + focale,
27960 z1 = vertices(n1,2) + Z + focale;
27962 if (zbuffer)
draw_line(zbuffer,x0,y0,z0,x1,y1,z1,color,opac);
27963 else draw_line(x0,y0,x1,y1,color,opac);
27964 #ifdef cimg_use_board
27966 board.setPenColorRGBi(color[0],color[1],color[2],(
unsigned char)(opac*255));
27967 board.drawLine((
float)x0,
dimy()-(
float)y0,x1,
dimy()-(
float)y1);
27971 draw_point(x0,y0,color,opac).draw_point(x1,y1,color,opac);
27972 #ifdef cimg_use_board
27974 board.setPenColorRGBi(color[0],color[1],color[2],(
unsigned char)(opac*255));
27975 board.drawCircle((
float)x0,
dimy()-(
float)y0,0);
27976 board.drawCircle((
float)x1,
dimy()-(
float)y1,0);
27983 n0 = (
unsigned int)primitive[0],
27984 n1 = (
unsigned int)primitive[1],
27985 n2 = (
unsigned int)primitive[2];
27987 x0 = (int)projections(n0,0), y0 = (int)projections(n0,1);
27989 if (n2) radius = (int)(n2*focale/(Z + vertices(n0,2) + focale));
27992 x1 = (int)projections(n1,0), y1 = (int)projections(n1,1),
27993 deltax = x1-x0, deltay = y1-y0;
27994 radius = (int)
std::sqrt((
float)(deltax*deltax + deltay*deltay));
27996 switch (render_type) {
27999 #ifdef cimg_use_board
28001 board.setPenColorRGBi(color[0],color[1],color[2],(
unsigned char)(opac*255));
28002 board.fillCircle((
float)x0,
dimy()-(
float)y0,0);
28008 #ifdef cimg_use_board
28010 board.setPenColorRGBi(color[0],color[1],color[2],(
unsigned char)(opac*255));
28011 board.setFillColor(LibBoard::Color::None);
28012 board.drawCircle((
float)x0,
dimy()-(
float)y0,(
float)radius);
28018 #ifdef cimg_use_board
28020 board.setPenColorRGBi(color[0],color[1],color[2],(
unsigned char)(opac*255));
28021 board.fillCircle((
float)x0,
dimy()-(
float)y0,(
float)radius);
28029 n0 = (
unsigned int)primitive[0],
28030 n1 = (
unsigned int)primitive[1],
28031 tx0 = (
unsigned int)primitive[2],
28032 ty0 = (
unsigned int)primitive[3],
28033 tx1 = (
unsigned int)primitive[4],
28034 ty1 = (
unsigned int)primitive[5];
28036 x0 = (int)projections(n0,0), y0 = (int)projections(n0,1),
28037 x1 = (int)projections(n1,0), y1 = (int)projections(n1,1);
28039 z0 = vertices(n0,2) + Z + focale,
28040 z1 = vertices(n1,2) + Z + focale;
28042 if (zbuffer)
draw_line(zbuffer,x0,y0,z0,x1,y1,z1,color,tx0,ty0,tx1,ty1,opac);
28043 else draw_line(x0,y0,x1,y1,color,tx0,ty0,tx1,ty1,opac);
28044 #ifdef cimg_use_board
28046 board.setPenColorRGBi(128,128,128,(
unsigned char)(opac*255));
28047 board.drawLine((
float)x0,
dimy()-(
float)y0,(
float)x1,
dimy()-(
float)y1);
28051 draw_point(x0,y0,color.get_vector_at(tx0,ty0),opac).
28052 draw_point(x1,y1,color.get_vector_at(tx1,ty1),opac);
28053 #ifdef cimg_use_board
28055 board.setPenColorRGBi(128,128,128,(
unsigned char)(opac*255));
28056 board.drawCircle((
float)x0,
dimy()-(
float)y0,0);
28057 board.drawCircle((
float)x1,
dimy()-(
float)y1,0);
28064 n0 = (
unsigned int)primitive[0],
28065 n1 = (
unsigned int)primitive[1],
28066 n2 = (
unsigned int)primitive[2];
28068 x0 = (int)projections(n0,0), y0 = (int)projections(n0,1),
28069 x1 = (int)projections(n1,0), y1 = (int)projections(n1,1),
28070 x2 = (int)projections(n2,0), y2 = (int)projections(n2,1);
28072 z0 = vertices(n0,2) + Z + focale,
28073 z1 = vertices(n1,2) + Z + focale,
28074 z2 = vertices(n2,2) + Z + focale;
28075 switch (render_type) {
28077 draw_point(x0,y0,color,opac).draw_point(x1,y1,color,opac).draw_point(x2,y2,color,opac);
28078 #ifdef cimg_use_board
28080 board.setPenColorRGBi(color[0],color[1],color[2],(
unsigned char)(opac*255));
28081 board.drawCircle((
float)x0,
dimy()-(
float)y0,0);
28082 board.drawCircle((
float)x1,
dimy()-(
float)y1,0);
28083 board.drawCircle((
float)x2,
dimy()-(
float)y2,0);
28089 draw_line(zbuffer,x0,y0,z0,x1,y1,z1,color,opac).draw_line(zbuffer,x0,y0,z0,x2,y2,z2,color,opac).
28090 draw_line(zbuffer,x1,y1,z1,x2,y2,z2,color,opac);
28092 draw_line(x0,y0,x1,y1,color,opac).draw_line(x0,y0,x2,y2,color,opac).
28094 #ifdef cimg_use_board
28096 board.setPenColorRGBi(color[0],color[1],color[2],(
unsigned char)(opac*255));
28097 board.drawLine((
float)x0,
dimy()-(
float)y0,(
float)x1,
dimy()-(
float)y1);
28098 board.drawLine((
float)x0,
dimy()-(
float)y0,(
float)x2,
dimy()-(
float)y2);
28099 board.drawLine((
float)x1,
dimy()-(
float)y1,(
float)x2,
dimy()-(
float)y2);
28104 if (zbuffer)
draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,opac);
28106 #ifdef cimg_use_board
28108 board.setPenColorRGBi(color[0],color[1],color[2],(
unsigned char)(opac*255));
28109 board.fillTriangle((
float)x0,
dimy()-(
float)y0,(
float)x1,
dimy()-(
float)y1,(
float)x2,
dimy()-(
float)y2);
28114 if (zbuffer)
draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color.data,opac,lightprops(l));
28115 else _draw_triangle(x0,y0,x1,y1,x2,y2,color.data,opac,lightprops(l));
28116 #ifdef cimg_use_board
28118 const float lp =
cimg::min(lightprops(l),1);
28119 board.setPenColorRGBi((
unsigned char)(color[0]*lp),
28120 (
unsigned char)(color[1]*lp),
28121 (
unsigned char)(color[2]*lp),
28122 (
unsigned char)(opac*255));
28123 board.fillTriangle((
float)x0,
dimy()-(
float)y0,(
float)x1,
dimy()-(
float)y1,(
float)x2,
dimy()-(
float)y2);
28128 if (zbuffer)
draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,lightprops(n0),lightprops(n1),lightprops(n2),opac);
28129 else draw_triangle(x0,y0,x1,y1,x2,y2,color,lightprops(n0),lightprops(n1),lightprops(n2),opac);
28130 #ifdef cimg_use_board
28132 board.setPenColorRGBi((
unsigned char)(color[0]),
28133 (
unsigned char)(color[1]),
28134 (
unsigned char)(color[2]),
28135 (
unsigned char)(opac*255));
28136 board.fillGouraudTriangle((
float)x0,
dimy()-(
float)y0,lightprops(n0),
28137 (
float)x1,
dimy()-(
float)y1,lightprops(n1),
28138 (
float)x2,
dimy()-(
float)y2,lightprops(n2));
28144 lx0 = (
unsigned int)lightprops(n0,0), ly0 = (
unsigned int)lightprops(n0,1),
28145 lx1 = (
unsigned int)lightprops(n1,0), ly1 = (
unsigned int)lightprops(n1,1),
28146 lx2 = (
unsigned int)lightprops(n2,0), ly2 = (
unsigned int)lightprops(n2,1);
28147 if (zbuffer)
draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,light_texture,lx0,ly0,lx1,ly1,lx2,ly2,opac);
28148 else draw_triangle(x0,y0,x1,y1,x2,y2,color,light_texture,lx0,ly0,lx1,ly1,lx2,ly2,opac);
28149 #ifdef cimg_use_board
28152 l0 = light_texture((
int)(light_texture.dimx()/2*(1+lightprops(n0,0))), (int)(light_texture.dimy()/2*(1+lightprops(n0,1)))),
28153 l1 = light_texture((
int)(light_texture.dimx()/2*(1+lightprops(n1,0))), (int)(light_texture.dimy()/2*(1+lightprops(n1,1)))),
28154 l2 = light_texture((
int)(light_texture.dimx()/2*(1+lightprops(n2,0))), (int)(light_texture.dimy()/2*(1+lightprops(n2,1))));
28155 board.setPenColorRGBi((
unsigned char)(color[0]),
28156 (
unsigned char)(color[1]),
28157 (
unsigned char)(color[2]),
28158 (
unsigned char)(opac*255));
28159 board.fillGouraudTriangle((
float)x0,
dimy()-(
float)y0,l0,
28160 (
float)x1,
dimy()-(
float)y1,l1,
28161 (
float)x2,
dimy()-(
float)y2,l2);
28169 n0 = (
unsigned int)primitive[0],
28170 n1 = (
unsigned int)primitive[1],
28171 n2 = (
unsigned int)primitive[2],
28172 n3 = (
unsigned int)primitive[3];
28174 x0 = (int)projections(n0,0), y0 = (int)projections(n0,1),
28175 x1 = (int)projections(n1,0), y1 = (int)projections(n1,1),
28176 x2 = (int)projections(n2,0), y2 = (int)projections(n2,1),
28177 x3 = (int)projections(n3,0), y3 = (int)projections(n3,1);
28179 z0 = vertices(n0,2) + Z + focale,
28180 z1 = vertices(n1,2) + Z + focale,
28181 z2 = vertices(n2,2) + Z + focale,
28182 z3 = vertices(n3,2) + Z + focale;
28183 switch (render_type) {
28185 draw_point(x0,y0,color,opac).draw_point(x1,y1,color,opac).
28186 draw_point(x2,y2,color,opac).draw_point(x3,y3,color,opac);
28187 #ifdef cimg_use_board
28189 board.setPenColorRGBi(color[0],color[1],color[2],(
unsigned char)(opac*255));
28190 board.drawCircle((
float)x0,
dimy()-(
float)y0,0);
28191 board.drawCircle((
float)x1,
dimy()-(
float)y1,0);
28192 board.drawCircle((
float)x2,
dimy()-(
float)y2,0);
28193 board.drawCircle((
float)x3,
dimy()-(
float)y3,0);
28199 draw_line(zbuffer,x0,y0,z0,x1,y1,z1,color,opac).draw_line(zbuffer,x1,y1,z1,x2,y2,z2,color,opac).
28200 draw_line(zbuffer,x2,y2,z2,x3,y3,z3,color,opac).draw_line(zbuffer,x3,y3,z3,x0,y0,z0,color,opac);
28202 draw_line(x0,y0,x1,y1,color,opac).draw_line(x1,y1,x2,y2,color,opac).
28203 draw_line(x2,y2,x3,y3,color,opac).draw_line(x3,y3,x0,y0,color,opac);
28204 #ifdef cimg_use_board
28206 board.setPenColorRGBi(color[0],color[1],color[2],(
unsigned char)(opac*255));
28207 board.drawLine((
float)x0,
dimy()-(
float)y0,(
float)x1,
dimy()-(
float)y1);
28208 board.drawLine((
float)x1,
dimy()-(
float)y1,(
float)x2,
dimy()-(
float)y2);
28209 board.drawLine((
float)x2,
dimy()-(
float)y2,(
float)x3,
dimy()-(
float)y3);
28210 board.drawLine((
float)x3,
dimy()-(
float)y3,(
float)x0,
dimy()-(
float)y0);
28216 draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,opac).draw_triangle(zbuffer,x0,y0,z0,x2,y2,z2,x3,y3,z3,color,opac);
28218 draw_triangle(x0,y0,x1,y1,x2,y2,color,opac).draw_triangle(x0,y0,x2,y2,x3,y3,color,opac);
28219 #ifdef cimg_use_board
28221 board.setPenColorRGBi(color[0],color[1],color[2],(
unsigned char)(opac*255));
28222 board.fillTriangle((
float)x0,
dimy()-(
float)y0,(
float)x1,
dimy()-(
float)y1,(
float)x2,
dimy()-(
float)y2);
28223 board.fillTriangle((
float)x0,
dimy()-(
float)y0,(
float)x2,
dimy()-(
float)y2,(
float)x3,
dimy()-(
float)y3);
28229 draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color.data,opac,lightprops(l)).
28230 draw_triangle(zbuffer,x0,y0,z0,x2,y2,z2,x3,y3,z3,color.data,opac,lightprops(l));
28232 _draw_triangle(x0,y0,x1,y1,x2,y2,color.data,opac,lightprops(l)).
28233 _draw_triangle(x0,y0,x2,y2,x3,y3,color.data,opac,lightprops(l));
28234 #ifdef cimg_use_board
28236 const float lp =
cimg::min(lightprops(l),1);
28237 board.setPenColorRGBi((
unsigned char)(color[0]*lp),
28238 (
unsigned char)(color[1]*lp),
28239 (
unsigned char)(color[2]*lp),(
unsigned char)(opac*255));
28240 board.fillTriangle((
float)x0,
dimy()-(
float)y0,(
float)x1,
dimy()-(
float)y1,(
float)x2,
dimy()-(
float)y2);
28241 board.fillTriangle((
float)x0,
dimy()-(
float)y0,(
float)x2,
dimy()-(
float)y2,(
float)x3,
dimy()-(
float)y3);
28247 lightprop0 = lightprops(n0), lightprop1 = lightprops(n1),
28248 lightprop2 = lightprops(n2), lightprop3 = lightprops(n3);
28250 draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,lightprop0,lightprop1,lightprop2,opac).
28251 draw_triangle(zbuffer,x0,y0,z0,x2,y2,z2,x3,y3,z3,color,lightprop0,lightprop2,lightprop3,opac);
28253 draw_triangle(x0,y0,x1,y1,x2,y2,color,lightprop0,lightprop1,lightprop2,opac).
28254 draw_triangle(x0,y0,x2,y2,x3,y3,color,lightprop0,lightprop2,lightprop3,opac);
28255 #ifdef cimg_use_board
28257 board.setPenColorRGBi((
unsigned char)(color[0]),
28258 (
unsigned char)(color[1]),
28259 (
unsigned char)(color[2]),
28260 (
unsigned char)(opac*255));
28261 board.fillGouraudTriangle((
float)x0,
dimy()-(
float)y0,lightprop0,
28262 (
float)x1,
dimy()-(
float)y1,lightprop1,
28263 (
float)x2,
dimy()-(
float)y2,lightprop2);
28264 board.fillGouraudTriangle((
float)x0,
dimy()-(
float)y0,lightprop0,
28265 (
float)x2,
dimy()-(
float)y2,lightprop2,
28266 (
float)x3,
dimy()-(
float)y3,lightprop3);
28272 lx0 = (
unsigned int)lightprops(n0,0), ly0 = (
unsigned int)lightprops(n0,1),
28273 lx1 = (
unsigned int)lightprops(n1,0), ly1 = (
unsigned int)lightprops(n1,1),
28274 lx2 = (
unsigned int)lightprops(n2,0), ly2 = (
unsigned int)lightprops(n2,1),
28275 lx3 = (
unsigned int)lightprops(n3,0), ly3 = (
unsigned int)lightprops(n3,1);
28277 draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,light_texture,lx0,ly0,lx1,ly1,lx2,ly2,opac).
28278 draw_triangle(zbuffer,x0,y0,z0,x2,y2,z2,x3,y3,z3,color,light_texture,lx0,ly0,lx2,ly2,lx3,ly3,opac);
28280 draw_triangle(x0,y0,x1,y1,x2,y2,color,light_texture,lx0,ly0,lx1,ly1,lx2,ly2,opac).
28281 draw_triangle(x0,y0,x2,y2,x3,y3,color,light_texture,lx0,ly0,lx2,ly2,lx3,ly3,opac);
28282 #ifdef cimg_use_board
28285 l0 = light_texture((
int)(light_texture.dimx()/2*(1+lx0)), (int)(light_texture.dimy()/2*(1+ly0))),
28286 l1 = light_texture((
int)(light_texture.dimx()/2*(1+lx1)), (int)(light_texture.dimy()/2*(1+ly1))),
28287 l2 = light_texture((
int)(light_texture.dimx()/2*(1+lx2)), (int)(light_texture.dimy()/2*(1+ly2))),
28288 l3 = light_texture((
int)(light_texture.dimx()/2*(1+lx3)), (int)(light_texture.dimy()/2*(1+ly3)));
28289 board.setPenColorRGBi((
unsigned char)(color[0]),
28290 (
unsigned char)(color[1]),
28291 (
unsigned char)(color[2]),
28292 (
unsigned char)(opac*255));
28293 board.fillGouraudTriangle((
float)x0,
dimy()-(
float)y0,l0,
28294 (
float)x1,
dimy()-(
float)y1,l1,
28295 (
float)x2,
dimy()-(
float)y2,l2);
28296 board.fillGouraudTriangle((
float)x0,
dimy()-(
float)y0,l0,
28297 (
float)x2,
dimy()-(
float)y2,l2,
28298 (
float)x3,
dimy()-(
float)y3,l3);
28306 n0 = (
unsigned int)primitive[0],
28307 n1 = (
unsigned int)primitive[1],
28308 n2 = (
unsigned int)primitive[2],
28309 tx0 = (
unsigned int)primitive[3],
28310 ty0 = (
unsigned int)primitive[4],
28311 tx1 = (
unsigned int)primitive[5],
28312 ty1 = (
unsigned int)primitive[6],
28313 tx2 = (
unsigned int)primitive[7],
28314 ty2 = (
unsigned int)primitive[8];
28316 x0 = (int)projections(n0,0), y0 = (int)projections(n0,1),
28317 x1 = (int)projections(n1,0), y1 = (int)projections(n1,1),
28318 x2 = (int)projections(n2,0), y2 = (int)projections(n2,1);
28320 z0 = vertices(n0,2) + Z + focale,
28321 z1 = vertices(n1,2) + Z + focale,
28322 z2 = vertices(n2,2) + Z + focale;
28323 switch (render_type) {
28325 draw_point(x0,y0,color.get_vector_at(tx0,ty0),opac).
28326 draw_point(x1,y1,color.get_vector_at(tx1,ty1),opac).
28327 draw_point(x2,y2,color.get_vector_at(tx2,ty2),opac);
28328 #ifdef cimg_use_board
28330 board.setPenColorRGBi(128,128,128,(
unsigned char)(opac*255));
28331 board.drawCircle((
float)x0,
dimy()-(
float)y0,0);
28332 board.drawCircle((
float)x1,
dimy()-(
float)y1,0);
28333 board.drawCircle((
float)x2,
dimy()-(
float)y2,0);
28339 draw_line(zbuffer,x0,y0,z0,x1,y1,z1,color,tx0,ty0,tx1,ty1,opac).
28340 draw_line(zbuffer,x0,y0,z0,x2,y2,z2,color,tx0,ty0,tx2,ty2,opac).
28341 draw_line(zbuffer,x1,y1,z1,x2,y2,z2,color,tx1,ty1,tx2,ty2,opac);
28343 draw_line(x0,y0,z0,x1,y1,z1,color,tx0,ty0,tx1,ty1,opac).
28344 draw_line(x0,y0,z0,x2,y2,z2,color,tx0,ty0,tx2,ty2,opac).
28345 draw_line(x1,y1,z1,x2,y2,z2,color,tx1,ty1,tx2,ty2,opac);
28346 #ifdef cimg_use_board
28348 board.setPenColorRGBi(128,128,128,(
unsigned char)(opac*255));
28349 board.drawLine((
float)x0,
dimy()-(
float)y0,(
float)x1,
dimy()-(
float)y1);
28350 board.drawLine((
float)x0,
dimy()-(
float)y0,(
float)x2,
dimy()-(
float)y2);
28351 board.drawLine((
float)x1,
dimy()-(
float)y1,(
float)x2,
dimy()-(
float)y2);
28356 if (zbuffer)
draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opac);
28357 else draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opac);
28358 #ifdef cimg_use_board
28360 board.setPenColorRGBi(128,128,128,(
unsigned char)(opac*255));
28361 board.fillTriangle((
float)x0,
dimy()-(
float)y0,(
float)x1,
dimy()-(
float)y1,(
float)x2,
dimy()-(
float)y2);
28366 if (zbuffer)
draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opac,lightprops(l));
28367 else draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opac,lightprops(l));
28368 #ifdef cimg_use_board
28370 const float lp =
cimg::min(lightprops(l),1);
28371 board.setPenColorRGBi((
unsigned char)(128*lp),
28372 (
unsigned char)(128*lp),
28373 (
unsigned char)(128*lp),
28374 (
unsigned char)(opac*255));
28375 board.fillTriangle((
float)x0,
dimy()-(
float)y0,(
float)x1,
dimy()-(
float)y1,(
float)x2,
dimy()-(
float)y2);
28381 draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,lightprops(n0),lightprops(n1),lightprops(n2),opac);
28383 draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,lightprops(n0),lightprops(n1),lightprops(n2),opac);
28384 #ifdef cimg_use_board
28386 board.setPenColorRGBi(128,128,128,(
unsigned char)(opac*255));
28387 board.fillGouraudTriangle((
float)x0,
dimy()-(
float)y0,lightprops(n0),
28388 (
float)x1,
dimy()-(
float)y1,lightprops(n1),
28389 (
float)x2,
dimy()-(
float)y2,lightprops(n2));
28395 draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,light_texture,
28396 (
unsigned int)lightprops(n0,0), (
unsigned int)lightprops(n0,1),
28397 (
unsigned int)lightprops(n1,0), (
unsigned int)lightprops(n1,1),
28398 (
unsigned int)lightprops(n2,0), (
unsigned int)lightprops(n2,1),
28401 draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,light_texture,
28402 (
unsigned int)lightprops(n0,0), (
unsigned int)lightprops(n0,1),
28403 (
unsigned int)lightprops(n1,0), (
unsigned int)lightprops(n1,1),
28404 (
unsigned int)lightprops(n2,0), (
unsigned int)lightprops(n2,1),
28406 #ifdef cimg_use_board
28409 l0 = light_texture((
int)(light_texture.dimx()/2*(1+lightprops(n0,0))), (int)(light_texture.dimy()/2*(1+lightprops(n0,1)))),
28410 l1 = light_texture((
int)(light_texture.dimx()/2*(1+lightprops(n1,0))), (int)(light_texture.dimy()/2*(1+lightprops(n1,1)))),
28411 l2 = light_texture((
int)(light_texture.dimx()/2*(1+lightprops(n2,0))), (int)(light_texture.dimy()/2*(1+lightprops(n2,1))));
28412 board.setPenColorRGBi(128,128,128,(
unsigned char)(opac*255));
28413 board.fillGouraudTriangle((
float)x0,
dimy()-(
float)y0,l0,(
float)x1,
dimy()-(
float)y1,l1,(
float)x2,
dimy()-(
float)y2,l2);
28421 n0 = (
unsigned int)primitive[0],
28422 n1 = (
unsigned int)primitive[1],
28423 n2 = (
unsigned int)primitive[2],
28424 n3 = (
unsigned int)primitive[3],
28425 tx0 = (
unsigned int)primitive[4],
28426 ty0 = (
unsigned int)primitive[5],
28427 tx1 = (
unsigned int)primitive[6],
28428 ty1 = (
unsigned int)primitive[7],
28429 tx2 = (
unsigned int)primitive[8],
28430 ty2 = (
unsigned int)primitive[9],
28431 tx3 = (
unsigned int)primitive[10],
28432 ty3 = (
unsigned int)primitive[11];
28434 x0 = (int)projections(n0,0), y0 = (int)projections(n0,1),
28435 x1 = (int)projections(n1,0), y1 = (int)projections(n1,1),
28436 x2 = (int)projections(n2,0), y2 = (int)projections(n2,1),
28437 x3 = (int)projections(n3,0), y3 = (int)projections(n3,1);
28439 z0 = vertices(n0,2) + Z + focale,
28440 z1 = vertices(n1,2) + Z + focale,
28441 z2 = vertices(n2,2) + Z + focale,
28442 z3 = vertices(n3,2) + Z + focale;
28444 switch (render_type) {
28446 draw_point(x0,y0,color.get_vector_at(tx0,ty0),opac).
28447 draw_point(x1,y1,color.get_vector_at(tx1,ty1),opac).
28448 draw_point(x2,y2,color.get_vector_at(tx2,ty2),opac).
28449 draw_point(x3,y3,color.get_vector_at(tx3,ty3),opac);
28450 #ifdef cimg_use_board
28452 board.setPenColorRGBi(128,128,128,(
unsigned char)(opac*255));
28453 board.drawCircle((
float)x0,
dimy()-(
float)y0,0);
28454 board.drawCircle((
float)x1,
dimy()-(
float)y1,0);
28455 board.drawCircle((
float)x2,
dimy()-(
float)y2,0);
28456 board.drawCircle((
float)x3,
dimy()-(
float)y3,0);
28462 draw_line(zbuffer,x0,y0,z0,x1,y1,z1,color,tx0,ty0,tx1,ty1,opac).
28463 draw_line(zbuffer,x1,y1,z1,x2,y2,z2,color,tx1,ty1,tx2,ty2,opac).
28464 draw_line(zbuffer,x2,y2,z2,x3,y3,z3,color,tx2,ty2,tx3,ty3,opac).
28465 draw_line(zbuffer,x3,y3,z3,x0,y0,z0,color,tx3,ty3,tx0,ty0,opac);
28467 draw_line(x0,y0,z0,x1,y1,z1,color,tx0,ty0,tx1,ty1,opac).
28468 draw_line(x1,y1,z1,x2,y2,z2,color,tx1,ty1,tx2,ty2,opac).
28469 draw_line(x2,y2,z2,x3,y3,z3,color,tx2,ty2,tx3,ty3,opac).
28470 draw_line(x3,y3,z3,x0,y0,z0,color,tx3,ty3,tx0,ty0,opac);
28471 #ifdef cimg_use_board
28473 board.setPenColorRGBi(128,128,128,(
unsigned char)(opac*255));
28474 board.drawLine((
float)x0,
dimy()-(
float)y0,(
float)x1,
dimy()-(
float)y1);
28475 board.drawLine((
float)x1,
dimy()-(
float)y1,(
float)x2,
dimy()-(
float)y2);
28476 board.drawLine((
float)x2,
dimy()-(
float)y2,(
float)x3,
dimy()-(
float)y3);
28477 board.drawLine((
float)x3,
dimy()-(
float)y3,(
float)x0,
dimy()-(
float)y0);
28483 draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opac).
28484 draw_triangle(zbuffer,x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,opac);
28486 draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opac).
28487 draw_triangle(x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,opac);
28488 #ifdef cimg_use_board
28490 board.setPenColorRGBi(128,128,128,(
unsigned char)(opac*255));
28491 board.fillTriangle((
float)x0,
dimy()-(
float)y0,(
float)x1,
dimy()-(
float)y1,(
float)x2,
dimy()-(
float)y2);
28492 board.fillTriangle((
float)x0,
dimy()-(
float)y0,(
float)x2,
dimy()-(
float)y2,(
float)x3,
dimy()-(
float)y3);
28498 draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opac,lightprops(l)).
28499 draw_triangle(zbuffer,x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,opac,lightprops(l));
28501 draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opac,lightprops(l)).
28502 draw_triangle(x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,opac,lightprops(l));
28503 #ifdef cimg_use_board
28505 const float lp =
cimg::min(lightprops(l),1);
28506 board.setPenColorRGBi((
unsigned char)(128*lp),
28507 (
unsigned char)(128*lp),
28508 (
unsigned char)(128*lp),
28509 (
unsigned char)(opac*255));
28510 board.fillTriangle((
float)x0,
dimy()-(
float)y0,(
float)x1,
dimy()-(
float)y1,(
float)x2,
dimy()-(
float)y2);
28511 board.fillTriangle((
float)x0,
dimy()-(
float)y0,(
float)x2,
dimy()-(
float)y2,(
float)x3,
dimy()-(
float)y3);
28517 lightprop0 = lightprops(n0), lightprop1 = lightprops(n1),
28518 lightprop2 = lightprops(n2), lightprop3 = lightprops(n3);
28520 draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,lightprop0,lightprop1,lightprop2,opac).
28521 draw_triangle(zbuffer,x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,lightprop0,lightprop2,lightprop3,opac);
28523 draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,lightprop0,lightprop1,lightprop2,opac).
28524 draw_triangle(x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,lightprop0,lightprop2,lightprop3,opac);
28525 #ifdef cimg_use_board
28527 board.setPenColorRGBi(128,128,128,(
unsigned char)(opac*255));
28528 board.fillGouraudTriangle((
float)x0,
dimy()-(
float)y0,lightprop0,
28529 (
float)x1,
dimy()-(
float)y1,lightprop1,
28530 (
float)x2,
dimy()-(
float)y2,lightprop2);
28531 board.fillGouraudTriangle((
float)x0,
dimy()-(
float)y0,lightprop0,
28532 (
float)x2,
dimy()-(
float)y2,lightprop2,
28533 (
float)x3,
dimy()-(
float)y3,lightprop3);
28539 lx0 = (
unsigned int)lightprops(n0,0), ly0 = (
unsigned int)lightprops(n0,1),
28540 lx1 = (
unsigned int)lightprops(n1,0), ly1 = (
unsigned int)lightprops(n1,1),
28541 lx2 = (
unsigned int)lightprops(n2,0), ly2 = (
unsigned int)lightprops(n2,1),
28542 lx3 = (
unsigned int)lightprops(n3,0), ly3 = (
unsigned int)lightprops(n3,1);
28544 draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,light_texture,lx0,ly0,lx1,ly1,lx2,ly2,opac).
28545 draw_triangle(zbuffer,x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,light_texture,lx0,ly0,lx2,ly2,lx3,ly3,opac);
28547 draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,light_texture,lx0,ly0,lx1,ly1,lx2,ly2,opac).
28548 draw_triangle(x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,light_texture,lx0,ly0,lx2,ly2,lx3,ly3,opac);
28549 #ifdef cimg_use_board
28552 l0 = light_texture((
int)(light_texture.dimx()/2*(1+lx0)), (int)(light_texture.dimy()/2*(1+ly0))),
28553 l1 = light_texture((
int)(light_texture.dimx()/2*(1+lx1)), (int)(light_texture.dimy()/2*(1+ly1))),
28554 l2 = light_texture((
int)(light_texture.dimx()/2*(1+lx2)), (int)(light_texture.dimy()/2*(1+ly2))),
28555 l3 = light_texture((
int)(light_texture.dimx()/2*(1+lx3)), (int)(light_texture.dimy()/2*(1+ly3)));
28556 board.setPenColorRGBi(128,128,128,(
unsigned char)(opac*255));
28557 board.fillGouraudTriangle((
float)x0,
dimy()-(
float)y0,l0,
28558 (
float)x1,
dimy()-(
float)y1,l1,
28559 (
float)x2,
dimy()-(
float)y2,l2);
28560 board.fillGouraudTriangle((
float)x0,
dimy()-(
float)y0,l0,
28561 (
float)x2,
dimy()-(
float)y2,l2,
28562 (
float)x3,
dimy()-(
float)y3,l3);
28589 const int select_type=2,
unsigned int *
const XYZ=0,
28590 const unsigned char *
const color=0) {
28591 return get_select(disp,select_type,XYZ,color).transfer_to(*
this);
28596 const int select_type=2,
unsigned int *
const XYZ=0,
28597 const unsigned char *
const color=0) {
28598 return get_select(title,select_type,XYZ,color).transfer_to(*
this);
28603 const int select_type=2,
unsigned int *
const XYZ=0,
28604 const unsigned char *
const color=0)
const {
28605 return _get_select(disp,0,select_type,XYZ,color,0,0,0);
28610 const int select_type=2,
unsigned int *
const XYZ=0,
28611 const unsigned char *
const color=0)
const {
28613 return _get_select(disp,title,select_type,XYZ,color,0,0,0);
28617 const int coords_type,
unsigned int *
const XYZ,
28618 const unsigned char *
const color,
28619 const int origX,
const int origY,
const int origZ)
const {
28624 char ntitle[64] = { 0 };
if (!title) { std::sprintf(ntitle,
"CImg<%s>",
pixel_type()); }
28630 hatch = 0x55555555;
28636 unsigned char foreground_color[] = { 255,255,105 }, background_color[] = { 0,0,0 };
28637 if (color) std::memcpy(foreground_color,color,
sizeof(
unsigned char)*
cimg::min(3,
dimv()));
28639 int area = 0, clicked_area = 0, phase = 0,
28641 X1 =-1, Y1 = -1, Z1 = -1,
28642 X = -1, Y = -1, Z = -1,
28643 oX = X, oY = Y, oZ = Z;
28644 unsigned int old_button = 0,
key = 0;
28646 bool shape_selected =
false, text_down =
false;
28648 char text[1024] = { 0 };
28653 oX = X; oY = Y; oZ = Z;
28658 if (mX<
dimx() && mY<
dimy()) { area = 1; X = mX; Y = mY; Z = phase?Z1:Z0; }
28659 if (mX<
dimx() && mY>=
dimy()) { area = 2; X = mX; Z = mY-
height; Y = phase?Y1:Y0; }
28660 if (mX>=
dimx() && mY<
dimy()) { area = 3; Y = mY; Z = mX-
width; X = phase?X1:X0; }
28662 switch (
key = disp.
key) {
28673 disp.
key =
key = 0; visu0.assign();
28677 disp.
key =
key = 0; visu0.assign();
28681 disp.
key =
key = 0; visu0.assign();
28684 static unsigned int snap_number = 0;
28685 char filename[32] = { 0 };
28688 std::sprintf(filename,
"CImg_%.4u.bmp",snap_number++);
28692 visu.draw_text(2,2,
"Saving snapshot...",foreground_color,background_color,0.8f,11).display(disp);
28693 visu0.save(filename);
28694 visu.draw_text(2,2,
"Snapshot '%s' saved.",foreground_color,background_color,0.8f,11,filename).display(disp);
28699 static unsigned int snap_number = 0;
28700 char filename[32] = { 0 };
28703 std::sprintf(filename,
"CImg_%.4u.cimg",snap_number++);
28706 visu.draw_text(2,2,
"Saving instance...",foreground_color,background_color,0.8f,11).display(disp);
28708 visu.draw_text(2,2,
"Instance '%s' saved.",foreground_color,background_color,0.8f,11,filename).display(disp);
28713 if (!area) mx = my = X = Y = Z = -1;
28715 if (disp.
button&1 && phase<2) { X1 = X; Y1 = Y; Z1 = Z; }
28716 if (!(disp.
button&1) && phase>=2) {
28717 switch (clicked_area) {
28718 case 1 : Z1 = Z;
break;
28719 case 2 : Y1 = Y;
break;
28720 case 3 : X1 = X;
break;
28723 if (disp.
button&2) {
if (phase) { X1 = X; Y1 = Y; Z1 = Z; }
else { X0 = X; Y0 = Y; Z0 = Z; } }
28724 if (disp.
button&4) { oX = X = X0; oY = Y = Y0; oZ = Z = Z0; phase = 0; visu.assign(); }
28728 case 1 :
if (phase) Z = (Z1+=disp.
wheel);
else Z = (Z0+=disp.
wheel);
break;
28729 case 2 :
if (phase) Y = (Y1+=disp.
wheel);
else Y = (Y0+=disp.
wheel);
break;
28730 case 3 :
if (phase) X = (X1+=disp.
wheel);
else X = (X0+=disp.
wheel);
break;
28735 if ((disp.
button&1)!=old_button) {
28737 case 0 : X0 = X1 = X; Y0 = Y1 = Y; Z0 = Z1 = Z; clicked_area = area;
break;
28738 case 1 : X1 = X; Y1 = Y; Z1 = Z;
break;
28740 old_button = disp.
button&1;
28742 if (
depth>1 && (X!=oX || Y!=oY || Z!=oZ)) visu0.assign();
28746 if (!coords_type) shape_selected = phase?
true:
false;
28748 if (
depth>1) shape_selected = (phase==3)?
true:
false;
28749 else shape_selected = (phase==2)?
true:
false;
28753 if (X0<0) X0 = 0;
if (X0>=
dimx()) X0 =
dimx()-1;
if (Y0<0) Y0 = 0;
if (Y0>=
dimy()) Y0 =
dimy()-1;
28754 if (Z0<0) Z0 = 0;
if (Z0>=
dimz()) Z0 =
dimz()-1;
28755 if (X1<1) X1 = 0;
if (X1>=
dimx()) X1 =
dimx()-1;
if (Y1<0) Y1 = 0;
if (Y1>=
dimy()) Y1 =
dimy()-1;
28756 if (Z1<0) Z1 = 0;
if (Z1>=
dimz()) Z1 =
dimz()-1;
28759 if (oX!=X || oY!=Y || oZ!=Z || !visu0) {
28764 tmp = tmp0.get_channels(0,
cimg::min(2U,dim-1));
28766 switch (old_normalization) {
28767 case 0 : visu0 = tmp;
break;
28772 visu0.assign(tmp.width,tmp.height,1,tmp.dim);
28773 unsigned char *ptrd = visu0.end();
28774 cimg_for(tmp,ptrs,
Tuchar) *(--ptrd) = (
unsigned char)((*ptrs-m)*255.0f/(M-m));
28776 default : visu0 = tmp.normalize(0,255);
28778 visu0.resize(disp);
28782 if (visu.mean()<200) {
28783 foreground_color[0] = foreground_color[1] = foreground_color[2] = 255;
28784 background_color[0] = background_color[1] = background_color[2] = 0;
28786 foreground_color[0] = foreground_color[1] = foreground_color[2] = 0;
28787 background_color[0] = background_color[1] = background_color[2] = 255;
28792 if (phase)
switch (coords_type) {
28799 visu.draw_arrow(x0,y0,x1,y1,foreground_color,0.6f,30,5,hatch);
28806 visu.draw_arrow(zx0,y0,zx1,y1,foreground_color,0.6f,30,5,hatch).
28807 draw_arrow(x0,zy0,x1,zy1,foreground_color,0.6f,30,5,hatch);
28814 visu.draw_rectangle(x0,y0,x1,y1,foreground_color,0.2f).draw_rectangle(x0,y0,x1,y1,foreground_color,0.6f,hatch);
28821 visu.draw_rectangle(zx0,y0,zx1,y1,foreground_color,0.2f).draw_rectangle(zx0,y0,zx1,y1,foreground_color,0.6f,hatch);
28822 visu.draw_rectangle(x0,zy0,x1,zy1,foreground_color,0.2f).draw_rectangle(x0,zy0,x1,zy1,foreground_color,0.6f,hatch);
28831 visu.draw_ellipse(x0,y0,(
float)(x1-x0),(
float)(y1-y0),0,foreground_color,0.2f).
28832 draw_ellipse(x0,y0,(
float)(x1-x0),(
float)(y1-y0),0,foreground_color,0.6f,hatch);
28839 visu.draw_ellipse(zx0,y0,(
float)(zx1-zx0),(
float)(y1-y0),0,foreground_color,0.2f).
28840 draw_ellipse(zx0,y0,(
float)(zx1-zx0),(
float)(y1-y0),0,foreground_color,0.6f,hatch).
28841 draw_ellipse(x0,zy0,(
float)(x1-x0),(
float)(zy1-zy0),0,foreground_color,0.2f).
28842 draw_ellipse(x0,zy0,(
float)(x1-x0),(
float)(zy1-zy0),0,foreground_color,0.6f,hatch);
28851 if (x1-x0>=4 && y1-y0>=4) visu.draw_rectangle(x0,y0,x1,y1,foreground_color,0.4f,~0U);
28854 if (my<12) text_down =
true;
28855 if (my>=visu.dimy()-11) text_down =
false;
28856 if (!coords_type || !phase) {
28857 if (X>=0 && Y>=0 && Z>=0 && X<
dimx() && Y<
dimy() && Z<
dimz()) {
28858 if (
depth>1) std::sprintf(text,
"Point (%d,%d,%d) = [ ",origX+X,origY+Y,origZ+Z);
28859 else std::sprintf(text,
"Point (%d,%d) = [ ",origX+X,origY+Y);
28860 char *ctext = text + std::strlen(text), *
const ltext = text + 512;
28861 for (
unsigned int k = 0;
k<dim && ctext<ltext; ++
k) {
28863 ctext = text + std::strlen(text);
28864 *(ctext++) =
' '; *ctext = 0;
28866 std::sprintf(text + std::strlen(text),
"]");
28868 }
else switch (coords_type) {
28870 const double dX = (double)(X0 - X1), dY = (double)(Y0 - Y1), dZ = (double)(Z0 - Z1),
norm =
std::sqrt(dX*dX+dY*dY+dZ*dZ);
28871 if (
depth>1) std::sprintf(text,
"Vect (%d,%d,%d)-(%d,%d,%d), Norm = %g",
28872 origX+X0,origY+Y0,origZ+Z0,origX+X1,origY+Y1,origZ+Z1,
norm);
28873 else std::sprintf(text,
"Vect (%d,%d)-(%d,%d), Norm = %g",
28874 origX+X0,origY+Y0,origX+X1,origY+Y1,
norm);
28877 if (
depth>1) std::sprintf(text,
"Box (%d,%d,%d)-(%d,%d,%d), Size = (%d,%d,%d)",
28878 origX+(X0<X1?X0:X1),origY+(Y0<Y1?Y0:Y1),origZ+(Z0<Z1?Z0:Z1),
28879 origX+(X0<X1?X1:X0),origY+(Y0<Y1?Y1:Y0),origZ+(Z0<Z1?Z1:Z0),
28881 else std::sprintf(text,
"Box (%d,%d)-(%d,%d), Size = (%d,%d)",
28882 origX+(X0<X1?X0:X1),origY+(Y0<Y1?Y0:Y1),origX+(X0<X1?X1:X0),origY+(Y0<Y1?Y1:Y0),
28886 if (
depth>1) std::sprintf(text,
"Ellipse (%d,%d,%d)-(%d,%d,%d), Radii = (%d,%d,%d)",
28887 origX+X0,origY+Y0,origZ+Z0,origX+X1,origY+Y1,origZ+Z1,
28889 else std::sprintf(text,
"Ellipse (%d,%d)-(%d,%d), Radii = (%d,%d)",
28893 if (phase || (mx>=0 && my>=0)) visu.draw_text(0,text_down?visu.dimy()-11:0,text,foreground_color,background_color,0.7f,11);
28895 }
else if (!shape_selected) disp.
wait();
28901 if (XYZ) { XYZ[0] = (
unsigned int)X0; XYZ[1] = (
unsigned int)Y0; XYZ[2] = (
unsigned int)Z0; }
28902 if (shape_selected) {
28903 if (coords_type==2) {
28908 if (X1<0 || Y1<0 || Z1<0) X0 = Y0 = Z0 = X1 = Y1 = Z1 = -1;
28909 switch (coords_type) {
28911 case 2 : res[3] = X1; res[4] = Y1; res[5] = Z1;
28912 default : res[0] = X0; res[1] = Y0; res[2] = Z0;
28924 const unsigned int plot_type=1,
const unsigned int vertex_type=1,
28925 const char *
const labelx=0,
const double xmin=0,
const double xmax=0,
28926 const char *
const labely=0,
const double ymin=0,
const double ymax=0)
const {
28928 throw CImgInstanceException(
"CImg<%s>::display_graph() : Instance image (%u,%u,%u,%u,%p) is empty.",
28931 if (!disp) {
char ntitle[64] = { 0 }; std::sprintf(ntitle,
"CImg<%s>",
pixel_type()); disp.
assign(640,480,ntitle,0); }
28933 double nymin = ymin, nymax = ymax, nxmin = xmin, nxmax = xmax;
28935 if (nymin==nymax) { --nymin; ++nymax; }
28936 if (nxmin==nxmax && nxmin==0) { nxmin = 0; nxmax = siz - 1.0; }
28938 const unsigned char black[] = { 0,0,0 }, white[] = { 255,255,255 }, gray[] = { 220,220,220 };
28939 const unsigned char gray2[] = { 110,110,110 }, ngray[] = { 35,35,35 };
28940 static unsigned int odimv = 0;
28945 if (dim==1) { palette[0] = palette[1] = 120; palette[2] = 200; }
28947 palette(0,0) = 220; palette(1,0) = 10; palette(2,0) = 10;
28948 if (dim>1) { palette(0,1) = 10; palette(1,1) = 220; palette(2,1) = 10; }
28949 if (dim>2) { palette(0,2) = 10; palette(1,2) = 10; palette(2,2) = 220; }
28955 int x0 = -1, x1 = -1, y0 = -1, y1 = -1, omouse_x = -2, omouse_y = -2;
28956 char message[1024] = { 0 };
28957 unsigned int okey = 0, obutton = 0;
28960 for (
bool selected =
false; !selected && !disp.
is_closed && !okey && !disp.
wheel; ) {
28962 const unsigned int key = disp.
key, button = disp.
button;
28966 visu0.assign(disp.
dimx(),disp.
dimy(),1,3,220);
28967 const int gdimx = disp.
dimx() - 32, gdimy = disp.
dimy() - 32;
28968 if (gdimx>0 && gdimy>0) {
28969 graph.assign(gdimx,gdimy,1,3,255);
28970 graph.draw_grid(-10,-10,0,0,
false,
true,black,0.2f,0x33333333,0x33333333);
28972 plot_type,vertex_type,nymax,nymin,
false);
28974 axes.assign(gdimx,gdimy,1,1,0);
28982 axes.draw_axis(seqx,seqy,white);
28983 if (nymin>0) axes.draw_axis(seqx,gdimy-1,gray);
28984 if (nymax<0) axes.draw_axis(seqx,0,gray);
28985 if (nxmin>0) axes.draw_axis(0,seqy,gray);
28986 if (nxmax<0) axes.draw_axis(gdimx-1,seqy,gray);
28991 else cimg_forV(graph,
k) graph(x,
y,
k) = (
unsigned char)(2*graph(x,
y,
k)/3);
28993 else if (Ipc || Inc || Icp || Icn || Ipp || Inn || Ipn || Inp)
cimg_forV(graph,
k) graph(x,
y,
k) = (graph(x,
y,
k)+255)/2;
28995 visu0.draw_image(16,16,graph);
28996 visu0.draw_line(15,15,16+gdimx,15,gray2).draw_line(16+gdimx,15,16+gdimx,16+gdimy,gray2).
28997 draw_line(16+gdimx,16+gdimy,15,16+gdimy,white).draw_line(15,16+gdimy,15,15,white);
28998 }
else graph.assign();
28999 text.assign().draw_text(0,0,labelx?labelx:
"X-axis",white,ngray,1);
29000 visu0.draw_image((visu0.dimx()-text.dimx())/2,visu0.dimy()-14,~text);
29001 text.assign().draw_text(0,0,labely?labely:
"Y-axis",white,ngray,1).rotate(-90);
29002 visu0.draw_image(2,(visu0.dimy()-text.dimy())/2,~text);
29008 visu.assign(visu0);
29009 if (graph && x0>=0 && x1>=0) {
29011 nx0 = x0<=x1?x0:x1,
29012 nx1 = x0<=x1?x1:x0,
29013 ny0 = y0<=y1?y0:y1,
29014 ny1 = y0<=y1?y1:y0,
29015 sx0 = 16 + nx0*(visu.dimx()-32)/whz,
29016 sx1 = 15 + (nx1+1)*(visu.dimx()-32)/whz,
29020 if (y0>=0 && y1>=0)
29021 visu.draw_rectangle(sx0,sy0,sx1,sy1,gray,0.5f).draw_rectangle(sx0,sy0,sx1,sy1,black,0.5f,0xCCCCCCCCU);
29022 else visu.draw_rectangle(sx0,0,sx1,visu.dimy()-17,gray,0.5f).
29023 draw_line(sx0,16,sx0,visu.dimy()-17,black,0.5f,0xCCCCCCCCU).
29024 draw_line(sx1,16,sx1,visu.dimy()-17,black,0.5f,0xCCCCCCCCU);
29026 if (mouse_x>=16 && mouse_y>=16 && mouse_x<visu.dimx()-16 && mouse_y<visu.dimy()-16) {
29027 if (graph) visu.draw_line(mouse_x,16,mouse_x,visu.dimy()-17,black,0.5f,0x55555555U);
29028 const unsigned x = (mouse_x-16)*whz/(disp.
dimx()-32);
29029 const double cx = nxmin + x*(nxmax-nxmin)/whz;
29031 std::sprintf(message,
"Value[%g] = ( %g %g %g ... %g %g %g )",cx,
29032 (
double)(*
this)(x,0,0,0),(
double)(*
this)(x,0,0,1),(
double)(*
this)(x,0,0,2),
29033 (
double)(*
this)(x,0,0,dim-4),(
double)(*
this)(x,0,0,dim-3),(
double)(*
this)(x,0,0,dim-1));
29035 std::sprintf(message,
"Value[%g] = ( ",cx);
29036 cimg_forV(*
this,
k) std::sprintf(message+std::strlen(message),
"%g ",(
double)(*
this)(x,0,0,
k));
29037 std::sprintf(message+std::strlen(message),
")");
29039 if (x0>=0 && x1>=0) {
29041 nx0 = x0<=x1?x0:x1,
29042 nx1 = x0<=x1?x1:x0,
29043 ny0 = y0<=y1?y0:y1,
29044 ny1 = y0<=y1?y1:y0;
29046 cx0 = nxmin + nx0*(nxmax-nxmin)/(visu.dimx()-32),
29047 cx1 = nxmin + nx1*(nxmax-nxmin)/(visu.dimx()-32),
29048 cy0 = nymax - ny0*(nymax-nymin)/(visu.dimy()-32),
29049 cy1 = nymax - ny1*(nymax-nymin)/(visu.dimy()-32);
29050 if (y0>=0 && y1>=0)
29051 std::sprintf(message+std::strlen(message),
" - Range ( %g, %g ) - ( %g, %g )",cx0,cy0,cx1,cy1);
29053 std::sprintf(message+std::strlen(message),
" - Range [ %g - %g ]",cx0,cx1);
29055 text.assign().draw_text(0,0,message,white,ngray,1);
29056 visu.draw_image((visu.dimx()-text.dimx())/2,2,~text);
29058 visu.display(disp);
29062 switch (okey = key) {
29067 disp.
key = okey = 0;
29071 disp.
key = okey = 0;
29075 disp.
key = okey = 0;
29079 disp.
key = okey = 0;
29082 static unsigned int snap_number = 0;
29083 if (visu || visu0) {
29085 char filename[32] = { 0 };
29088 std::sprintf(filename,
"CImg_%.4u.bmp",snap_number++);
29091 (+screen).
draw_text(2,2,
"Saving BMP snapshot...",black,gray,1,11).display(disp);
29092 screen.save(filename);
29093 screen.draw_text(2,2,
"Snapshot '%s' saved.",black,gray,1,11,filename).display(disp);
29095 disp.
key = okey = 0;
29100 if (obutton!=button || omouse_x!=mouse_x || omouse_y!=mouse_y) {
29104 mx = (mouse_x-16)*(
int)whz/(disp.
dimx()-32),
29105 cx = mx<0?0:(mx>=(
int)whz?whz-1:mx),
29107 cy = my<=0?0:(my>=(disp.
dimy()-32)?(disp.
dimy()-32):my);
29108 if (button&1) {
if (!obutton) { x0 = cx; y0 = -1; }
else { x1 = cx; y1 = -1; }}
29109 else if (button&2) {
if (!obutton) { x0 = cx; y0 = cy; }
else { x1 = cx; y1 = cy; }}
29110 else if (obutton) { x1 = cx; y1 = y1>=0?cy:-1; selected =
true; }
29111 }
else if (!button && obutton) selected =
true;
29112 obutton = button; omouse_x = mouse_x; omouse_y = mouse_y;
29115 if (visu && visu0) disp.
wait();
29139 #ifdef cimg_load_plugin
29140 cimg_load_plugin(filename);
29142 #ifdef cimg_load_plugin1
29143 cimg_load_plugin1(filename);
29145 #ifdef cimg_load_plugin2
29146 cimg_load_plugin2(filename);
29148 #ifdef cimg_load_plugin3
29149 cimg_load_plugin3(filename);
29151 #ifdef cimg_load_plugin4
29152 cimg_load_plugin4(filename);
29154 #ifdef cimg_load_plugin5
29155 cimg_load_plugin5(filename);
29157 #ifdef cimg_load_plugin6
29158 cimg_load_plugin6(filename);
29160 #ifdef cimg_load_plugin7
29161 cimg_load_plugin7(filename);
29163 #ifdef cimg_load_plugin8
29164 cimg_load_plugin8(filename);
29284 if (!filename && !file)
29287 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"rb");
29288 char line[256] = { 0 };
29289 int err = std::fscanf(nfile,
"%255[^\n]",line);
29290 unsigned int off,
dx = 0,
dy = 1, dz = 1, dv = 1;
29291 std::sscanf(line,
"%u%*c%u%*c%u%*c%u",&dx,&
dy,&dz,&dv);
29292 err = std::fscanf(nfile,
"%*[^0-9.eE+-]");
29293 if (!dx || !
dy || !dz || !dv) {
29295 throw CImgIOException(
"CImg<%s>::load_ascii() : File '%s', invalid .ASC header, specified image dimensions are (%u,%u,%u,%u).",
29296 pixel_type(),filename?filename:
"(FILE*)",dx,
dy,dz,dv);
29299 const unsigned int siz =
size();
29302 for (err = 1, off = 0; off<siz && err==1; ++off) {
29303 err = std::fscanf(nfile,
"%lf%*[^0-9.eE+-]",&val);
29307 cimg::warn(
"CImg<%s>::load_ascii() : File '%s', only %u/%u values read.",
29308 pixel_type(),filename?filename:
"(FILE*)",off-1,siz);
29332 if (!filename && !file)
29335 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"r");
29336 char delimiter[256] = { 0 }, tmp[256] = { 0 };
29337 unsigned int cdx = 0,
dx = 0,
dy = 0;
29341 while ((err = std::fscanf(nfile,
"%lf%255[^0-9.+-]",&val,delimiter))>0) {
29342 if (err>0) (*this)(cdx++,
dy) = (T)val;
29345 if (!std::sscanf(delimiter,
"%255[^\n]%c",tmp,&c) || c==
'\n') {
29351 if (cdx && err==1) {
dx = cdx; ++
dy; }
29380 if (!filename && !file)
29383 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"rb");
29384 unsigned char header[64] = { 0 };
29386 if (header[0]!=
'B' || header[1]!=
'M') {
29388 throw CImgIOException(
"CImg<%s>::load_bmp() : Invalid valid BMP file (filename '%s').",
29395 file_size = header[0x02] + (header[0x03]<<8) + (header[0x04]<<16) + (header[0x05]<<24),
29396 offset = header[0x0A] + (header[0x0B]<<8) + (header[0x0C]<<16) + (header[0x0D]<<24),
29397 dx = header[0x12] + (header[0x13]<<8) + (header[0x14]<<16) + (header[0x15]<<24),
29398 dy = header[0x16] + (header[0x17]<<8) + (header[0x18]<<16) + (header[0x19]<<24),
29399 compression = header[0x1E] + (header[0x1F]<<8) + (header[0x20]<<16) + (header[0x21]<<24),
29400 nb_colors = header[0x2E] + (header[0x2F]<<8) + (header[0x30]<<16) + (header[0x31]<<24),
29401 bpp = header[0x1C] + (header[0x1D]<<8),
29404 dx_bytes = (bpp==1)?(
dx/8+(
dx%8?1:0)):((bpp==4)?(
dx/2+(
dx%2?1:0)):(
dx*bpp/8)),
29405 align = (4-dx_bytes%4)%4,
29408 if (bpp<16) {
if (!nb_colors) nb_colors=1<<bpp; }
else nb_colors = 0;
29409 if (nb_colors) { palette =
new int[nb_colors];
cimg::fread(palette,nb_colors,nfile); }
29410 const int xoffset =
offset-54-4*nb_colors;
29411 if (xoffset>0) std::fseek(nfile,xoffset,SEEK_CUR);
29412 unsigned char *buffer =
new unsigned char[buf_size], *ptrs = buffer;
29420 throw CImgIOException(
"CImg<%s>::load_bmp() : Not able to read a compressed BMP file using a *FILE input",
29429 for (
int y =
dimy()-1;
y>=0; --
y) {
29430 unsigned char mask = 0x80, val = 0;
29432 if (mask==0x80) val = *(ptrs++);
29433 const unsigned char *col = (
unsigned char*)(palette+(val&mask?1:0));
29434 (*this)(
x,
y,2) = (T)*(col++);
29435 (*this)(
x,
y,1) = (T)*(col++);
29436 (*this)(
x,
y,0) = (T)*(col++);
29441 for (
int y =
dimy()-1;
y>=0; --
y) {
29442 unsigned char mask = 0xF0, val = 0;
29444 if (mask==0xF0) val = *(ptrs++);
29445 const unsigned char color = (
unsigned char)((mask<16)?(val&
mask):((val&mask)>>4));
29446 unsigned char *col = (
unsigned char*)(palette+color);
29447 (*this)(
x,
y,2) = (T)*(col++);
29448 (*this)(
x,
y,1) = (T)*(col++);
29449 (*this)(
x,
y,0) = (T)*(col++);
29455 const unsigned char *col = (
unsigned char*)(palette+*(ptrs++));
29456 (*this)(
x,
y,2) = (T)*(col++);
29457 (*this)(
x,
y,1) = (T)*(col++);
29458 (*this)(
x,
y,0) = (T)*(col++);
29463 const unsigned char c1 = *(ptrs++), c2 = *(ptrs++);
29464 const unsigned short col = (
unsigned short)(c1|(c2<<8));
29465 (*this)(
x,
y,2) = (T)(col&0x1F);
29466 (*this)(
x,
y,1) = (T)((col>>5)&0x1F);
29467 (*this)(
x,
y,0) = (T)((col>>10)&0x1F);
29472 (*this)(
x,
y,2) = (T)*(ptrs++);
29473 (*this)(
x,
y,1) = (T)*(ptrs++);
29474 (*this)(
x,
y,0) = (T)*(ptrs++);
29479 (*this)(
x,
y,2) = (T)*(ptrs++);
29480 (*this)(
x,
y,1) = (T)*(ptrs++);
29481 (*this)(
x,
y,0) = (T)*(ptrs++);
29486 if (palette)
delete[] palette;
29511 if (!filename && !file)
29514 #ifndef cimg_use_jpeg
29516 throw CImgIOException(
"CImg<%s>::load_jpeg() : File '(FILE*)' cannot be read without using libjpeg.",
29520 struct jpeg_decompress_struct cinfo;
29521 struct jpeg_error_mgr jerr;
29522 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"rb");
29524 cinfo.err = jpeg_std_error(&jerr);
29525 jpeg_create_decompress(&cinfo);
29526 jpeg_stdio_src(&cinfo,nfile);
29527 jpeg_read_header(&cinfo,
TRUE);
29528 jpeg_start_decompress(&cinfo);
29530 if (cinfo.output_components!=1 && cinfo.output_components!=3 && cinfo.output_components!=4) {
29531 cimg::warn(
"CImg<%s>::load_jpeg() : Don't know how to read image '%s' with libpeg, trying ImageMagick's convert",
29536 throw CImgIOException(
"CImg<%s>::load_jpeg() : Cannot read JPEG image '%s' using a *FILE input.",
29541 const unsigned int row_stride = cinfo.output_width * cinfo.output_components;
29542 unsigned char *buf =
new unsigned char[cinfo.output_width*cinfo.output_height*cinfo.output_components], *buf2 = buf;
29543 JSAMPROW row_pointer[1];
29544 while (cinfo.output_scanline < cinfo.output_height) {
29545 row_pointer[0] = &buf[cinfo.output_scanline*row_stride];
29546 jpeg_read_scanlines(&cinfo,row_pointer,1);
29548 jpeg_finish_decompress(&cinfo);
29549 jpeg_destroy_decompress(&cinfo);
29552 assign(cinfo.output_width,cinfo.output_height,1,cinfo.output_components);
29559 T *ptr_r =
ptr(0,0,0,0), *ptr_g =
ptr(0,0,0,1), *ptr_b =
ptr(0,0,0,2);
29561 *(ptr_r++) = (T)*(buf2++);
29562 *(ptr_g++) = (T)*(buf2++);
29563 *(ptr_b++) = (T)*(buf2++);
29567 T *ptr_r =
ptr(0,0,0,0), *ptr_g =
ptr(0,0,0,1),
29568 *ptr_b =
ptr(0,0,0,2), *ptr_a =
ptr(0,0,0,3);
29570 *(ptr_r++) = (T)*(buf2++);
29571 *(ptr_g++) = (T)*(buf2++);
29572 *(ptr_b++) = (T)*(buf2++);
29573 *(ptr_a++) = (T)*(buf2++);
29589 #ifdef cimg_use_magick
29590 Magick::Image image(filename);
29591 const unsigned int W = image.size().width(), H = image.size().height();
29592 switch (image.type()) {
29593 case Magick::PaletteMatteType :
29594 case Magick::TrueColorMatteType :
29595 case Magick::ColorSeparationType : {
29597 T *rdata =
ptr(0,0,0,0), *gdata =
ptr(0,0,0,1), *bdata =
ptr(0,0,0,2), *adata =
ptr(0,0,0,3);
29598 Magick::PixelPacket *pixels = image.getPixels(0,0,W,H);
29599 for (
unsigned int off = W*H; off; --off) {
29600 *(rdata++) = (T)(pixels->red);
29601 *(gdata++) = (T)(pixels->green);
29602 *(bdata++) = (T)(pixels->blue);
29603 *(adata++) = (T)(pixels->opacity);
29607 case Magick::PaletteType :
29608 case Magick::TrueColorType : {
29610 T *rdata =
ptr(0,0,0,0), *gdata =
ptr(0,0,0,1), *bdata =
ptr(0,0,0,2);
29611 Magick::PixelPacket *pixels = image.getPixels(0,0,W,H);
29612 for (
unsigned int off = W*H; off; --off) {
29613 *(rdata++) = (T)(pixels->red);
29614 *(gdata++) = (T)(pixels->green);
29615 *(bdata++) = (T)(pixels->blue);
29619 case Magick::GrayscaleMatteType : {
29621 T *
data =
ptr(0,0,0,0), *adata =
ptr(0,0,0,1);
29622 Magick::PixelPacket *pixels = image.getPixels(0,0,W,H);
29623 for (
unsigned int off = W*H; off; --off) {
29624 *(data++) = (T)(pixels->red);
29625 *(adata++) = (T)(pixels->opacity);
29632 Magick::PixelPacket *pixels = image.getPixels(0,0,W,H);
29633 for (
unsigned int off = W*H; off; --off) {
29634 *(data++) = (T)(pixels->red);
29640 throw CImgIOException(
"CImg<%s>::load_magick() : File '%s', Magick++ library has not been linked.",
29670 if (!filename && !file)
29673 #ifndef cimg_use_png
29675 throw CImgIOException(
"CImg<%s>::load_png() : File '(FILE*)' cannot be read without using libpng.",
29680 const char *
volatile nfilename = filename;
29681 std::FILE *
volatile nfile = file?file:
cimg::fopen(nfilename,
"rb");
29683 unsigned char pngCheck[8] = { 0 };
29685 if (png_sig_cmp(pngCheck,0,8)) {
29687 throw CImgIOException(
"CImg<%s>::load_png() : File '%s' is not a valid PNG file.",
29688 pixel_type(),nfilename?nfilename:
"(FILE*)");
29692 png_voidp user_error_ptr = 0;
29693 png_error_ptr user_error_fn = 0, user_warning_fn = 0;
29694 png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,user_error_ptr,user_error_fn,user_warning_fn);
29697 throw CImgIOException(
"CImg<%s>::load_png() : File '%s', trouble initializing 'png_ptr' data structure.",
29698 pixel_type(),nfilename?nfilename:
"(FILE*)");
29700 png_infop info_ptr = png_create_info_struct(png_ptr);
29703 png_destroy_read_struct(&png_ptr,(png_infopp)0,(png_infopp)0);
29704 throw CImgIOException(
"CImg<%s>::load_png() : File '%s', trouble initializing 'info_ptr' data structure.",
29705 pixel_type(),nfilename?nfilename:
"(FILE*)");
29707 png_infop end_info = png_create_info_struct(png_ptr);
29710 png_destroy_read_struct(&png_ptr,&info_ptr,(png_infopp)0);
29711 throw CImgIOException(
"CImg<%s>::load_png() : File '%s', trouble initializing 'end_info' data structure.",
29712 pixel_type(),nfilename?nfilename:
"(FILE*)");
29716 if (setjmp(png_jmpbuf(png_ptr))) {
29718 png_destroy_read_struct(&png_ptr, &end_info, (png_infopp)0);
29719 throw CImgIOException(
"CImg<%s>::load_png() : File '%s', unknown fatal error.",
29720 pixel_type(),nfilename?nfilename:
"(FILE*)");
29722 png_init_io(png_ptr, nfile);
29723 png_set_sig_bytes(png_ptr, 8);
29726 png_read_info(png_ptr,info_ptr);
29728 int bit_depth, color_type, interlace_type;
29729 png_get_IHDR(png_ptr,info_ptr,&W,&H,&bit_depth,&color_type,&interlace_type,int_p_NULL,int_p_NULL);
29730 int new_bit_depth = bit_depth;
29731 int new_color_type = color_type;
29734 if (new_color_type == PNG_COLOR_TYPE_PALETTE){
29735 png_set_palette_to_rgb(png_ptr);
29736 new_color_type -= PNG_COLOR_MASK_PALETTE;
29739 if (new_color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8){
29740 png_set_gray_1_2_4_to_8(png_ptr);
29743 if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
29744 png_set_tRNS_to_alpha(png_ptr);
29745 if (new_color_type == PNG_COLOR_TYPE_GRAY || new_color_type == PNG_COLOR_TYPE_GRAY_ALPHA){
29746 png_set_gray_to_rgb(png_ptr);
29747 new_color_type |= PNG_COLOR_MASK_COLOR;
29749 if (new_color_type == PNG_COLOR_TYPE_RGB)
29750 png_set_filler(png_ptr, 0xffffU, PNG_FILLER_AFTER);
29751 png_read_update_info(png_ptr,info_ptr);
29752 if (!(new_bit_depth==8 || new_bit_depth==16)) {
29754 png_destroy_read_struct(&png_ptr, &end_info, (png_infopp)0);
29755 throw CImgIOException(
"CImg<%s>::load_png() : File '%s', wrong bit coding (bit_depth=%u)",
29756 pixel_type(),nfilename?nfilename:
"(FILE*)",new_bit_depth);
29758 const int byte_depth = new_bit_depth>>3;
29761 png_bytep *imgData =
new png_bytep[H];
29762 for (
unsigned int row = 0; row<H; ++row) imgData[row] =
new png_byte[byte_depth*4*W];
29763 png_read_image(png_ptr,imgData);
29764 png_read_end(png_ptr,end_info);
29767 if (!(new_color_type==PNG_COLOR_TYPE_RGB || new_color_type==PNG_COLOR_TYPE_RGB_ALPHA)) {
29769 png_destroy_read_struct(&png_ptr,&end_info,(png_infopp)0);
29770 throw CImgIOException(
"CImg<%s>::load_png() : File '%s', wrong color coding (new_color_type=%u)",
29771 pixel_type(),nfilename?nfilename:
"(FILE*)",new_color_type);
29773 const bool no_alpha_channel = (new_color_type==PNG_COLOR_TYPE_RGB);
29774 assign(W,H,1,no_alpha_channel?3:4);
29775 T *ptr1 =
ptr(0,0,0,0), *ptr2 =
ptr(0,0,0,1), *ptr3 =
ptr(0,0,0,2), *ptr4 =
ptr(0,0,0,3);
29776 switch (new_bit_depth) {
29779 const unsigned char *ptrs = (
unsigned char*)imgData[
y];
29781 *(ptr1++) = (T)*(ptrs++);
29782 *(ptr2++) = (T)*(ptrs++);
29783 *(ptr3++) = (T)*(ptrs++);
29784 if (no_alpha_channel) ++ptrs;
else *(ptr4++) = (T)*(ptrs++);
29790 const unsigned short *ptrs = (
unsigned short*)(imgData[
y]);
29793 *(ptr1++) = (T)*(ptrs++);
29794 *(ptr2++) = (T)*(ptrs++);
29795 *(ptr3++) = (T)*(ptrs++);
29796 if (no_alpha_channel) ++ptrs;
else *(ptr4++) = (T)*(ptrs++);
29801 png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
29830 if (!filename && !file)
29833 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"rb");
29834 unsigned int ppm_type, W, H, colormax = 255;
29835 char item[1024] = { 0 };
29836 int err, rval, gval, bval;
29837 const int cimg_iobuffer = 12*1024*1024;
29838 while ((err=std::fscanf(nfile,
"%1023[^\n]",item))!=EOF && (item[0]==
'#' || !err)) std::fgetc(nfile);
29839 if (std::sscanf(item,
" P%u",&ppm_type)!=1) {
29841 throw CImgIOException(
"CImg<%s>::load_pnm() : File '%s', PNM header 'P?' not found.",
29844 while ((err=std::fscanf(nfile,
" %1023[^\n]",item))!=EOF && (item[0]==
'#' || !err)) std::fgetc(nfile);
29845 if ((err=std::sscanf(item,
" %u %u %u",&W,&H,&colormax))<2) {
29847 throw CImgIOException(
"CImg<%s>::load_pnm() : File '%s', WIDTH and HEIGHT fields are not defined in PNM header.",
29851 while ((err=std::fscanf(nfile,
" %1023[^\n]",item))!=EOF && (item[0]==
'#' || !err)) std::fgetc(nfile);
29852 if (std::sscanf(item,
"%u",&colormax)!=1)
29853 cimg::warn(
"CImg<%s>::load_pnm() : File '%s', COLORMAX field is not defined in PNM header.",
29859 switch (ppm_type) {
29863 cimg_foroff(*
this,off) {
if (std::fscanf(nfile,
"%d",&rval)>0) *(rdata++) = (T)rval;
else break; }
29867 T *rdata =
ptr(0,0,0,0), *gdata =
ptr(0,0,0,1), *bdata =
ptr(0,0,0,2);
29869 if (std::fscanf(nfile,
"%d %d %d",&rval,&gval,&bval)==3) { *(rdata++) = (T)rval; *(gdata++) = (T)gval; *(bdata++) = (T)bval; }
29874 if (colormax<256) {
29877 T *ptrd =
ptr(0,0,0,0);
29878 for (
int toread = (
int)
size(); toread>0; ) {
29879 raw.assign(
cimg::min(toread,cimg_iobuffer));
29882 const unsigned char *ptrs = raw.data;
29883 for (
unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++);
29888 T *ptrd =
ptr(0,0,0,0);
29889 for (
int toread = (
int)
size(); toread>0; ) {
29890 raw.assign(
cimg::min(toread,cimg_iobuffer/2));
29894 const unsigned short *ptrs = raw.data;
29895 for (
unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++);
29900 if (colormax<256) {
29904 *ptr_r =
ptr(0,0,0,0),
29905 *ptr_g =
ptr(0,0,0,1),
29906 *ptr_b =
ptr(0,0,0,2);
29907 for (
int toread = (
int)
size(); toread>0; ) {
29908 raw.assign(
cimg::min(toread,cimg_iobuffer));
29911 const unsigned char *ptrs = raw.data;
29912 for (
unsigned int off = raw.width/3; off; --off) {
29913 *(ptr_r++) = (T)*(ptrs++);
29914 *(ptr_g++) = (T)*(ptrs++);
29915 *(ptr_b++) = (T)*(ptrs++);
29922 *ptr_r =
ptr(0,0,0,0),
29923 *ptr_g =
ptr(0,0,0,1),
29924 *ptr_b =
ptr(0,0,0,2);
29925 for (
int toread = (
int)
size(); toread>0; ) {
29926 raw.assign(
cimg::min(toread,cimg_iobuffer/2));
29930 const unsigned short *ptrs = raw.data;
29931 for (
unsigned int off = raw.width/3; off; --off) {
29932 *(ptr_r++) = (T)*(ptrs++);
29933 *(ptr_g++) = (T)*(ptrs++);
29934 *(ptr_b++) = (T)*(ptrs++);
29941 throw CImgIOException(
"CImg<%s>::load_pnm() : File '%s', PPM type 'P%d' not supported.",
29942 pixel_type(),filename?filename:
"(FILE*)",ppm_type);
29949 CImg<T>&
load_rgb(
const char *
const filename,
const unsigned int dimw,
const unsigned int dimh=1) {
29950 return _load_rgb(0,filename,dimw,dimh);
29958 CImg<T>&
load_rgb(std::FILE *
const file,
const unsigned int dimw,
const unsigned int dimh=1) {
29966 CImg<T>&
_load_rgb(std::FILE *
const file,
const char *
const filename,
const unsigned int dimw,
const unsigned int dimh) {
29967 if (!filename && !file)
29970 if (!dimw || !dimh)
return assign();
29971 const int cimg_iobuffer = 12*1024*1024;
29972 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"rb");
29976 *ptr_r =
ptr(0,0,0,0),
29977 *ptr_g =
ptr(0,0,0,1),
29978 *ptr_b =
ptr(0,0,0,2);
29979 for (
int toread = (
int)
size(); toread>0; ) {
29980 raw.assign(
cimg::min(toread,cimg_iobuffer));
29983 const unsigned char *ptrs = raw.data;
29984 for (
unsigned int off = raw.width/3; off; --off) {
29985 *(ptr_r++) = (T)*(ptrs++);
29986 *(ptr_g++) = (T)*(ptrs++);
29987 *(ptr_b++) = (T)*(ptrs++);
29995 CImg<T>&
load_rgba(
const char *
const filename,
const unsigned int dimw,
const unsigned int dimh=1) {
30012 CImg<T>&
_load_rgba(std::FILE *
const file,
const char *
const filename,
const unsigned int dimw,
const unsigned int dimh) {
30013 if (!filename && !file)
30016 if (!dimw || !dimh)
return assign();
30017 const int cimg_iobuffer = 12*1024*1024;
30018 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"rb");
30022 *ptr_r =
ptr(0,0,0,0),
30023 *ptr_g =
ptr(0,0,0,1),
30024 *ptr_b =
ptr(0,0,0,2),
30025 *ptr_a =
ptr(0,0,0,3);
30026 for (
int toread = (
int)
size(); toread>0; ) {
30027 raw.assign(
cimg::min(toread,cimg_iobuffer));
30030 const unsigned char *ptrs = raw.data;
30031 for (
unsigned int off = raw.width/4; off; --off) {
30032 *(ptr_r++) = (T)*(ptrs++);
30033 *(ptr_g++) = (T)*(ptrs++);
30034 *(ptr_b++) = (T)*(ptrs++);
30035 *(ptr_a++) = (T)*(ptrs++);
30044 const unsigned int first_frame=0,
const unsigned int last_frame=~0U,
30045 const unsigned int step_frame=1) {
30050 nfirst_frame = first_frame<last_frame?first_frame:last_frame,
30051 nstep_frame = step_frame?step_frame:1;
30052 unsigned int nlast_frame = first_frame<last_frame?last_frame:first_frame;
30054 #ifndef cimg_use_tiff
30055 if (nfirst_frame || nlast_frame!=~0U || nstep_frame>1)
30056 throw CImgArgumentException(
"CImg<%s>::load_tiff() : File '%s', reading sub-images from a tiff file requires the use of libtiff.\n"
30057 "('cimg_use_tiff' must be defined).",
30061 TIFF *tif = TIFFOpen(filename,
"r");
30063 unsigned int nb_images = 0;
30064 do ++nb_images;
while (TIFFReadDirectory(tif));
30065 if (nfirst_frame>=nb_images || (nlast_frame!=~0U && nlast_frame>=nb_images))
30066 cimg::warn(
"CImg<%s>::load_tiff() : File '%s' contains %u image(s), specified frame range is [%u,%u] (step %u).",
30067 pixel_type(),filename,nb_images,nfirst_frame,nlast_frame,nstep_frame);
30068 if (nfirst_frame>=nb_images)
return assign();
30069 if (nlast_frame>=nb_images) nlast_frame = nb_images-1;
30070 TIFFSetDirectory(tif,0);
30072 for (
unsigned int l = nfirst_frame; l<=nlast_frame; l+=nstep_frame) {
30073 frame._load_tiff(tif,l);
30074 if (l==nfirst_frame)
assign(frame.width,frame.height,1+(nlast_frame-nfirst_frame)/nstep_frame,frame.dim);
30075 if (frame.width>
width || frame.height>
height || frame.dim>dim)
30077 draw_image(0,0,(l-nfirst_frame)/nstep_frame,frame);
30080 }
else throw CImgException(
"CImg<%s>::load_tiff() : File '%s' cannot be opened.",
30087 const unsigned int first_frame=0,
const unsigned int last_frame=~0U,
30088 const unsigned int step_frame=1) {
30093 #ifdef cimg_use_tiff
30094 CImg<T>& _load_tiff(TIFF *tif,
const unsigned int directory) {
30095 if (!TIFFSetDirectory(tif,directory))
return assign();
30096 uint16 samplesperpixel, bitspersample;
30098 const char *
const filename = TIFFFileName(tif);
30099 TIFFGetField(tif,TIFFTAG_IMAGEWIDTH,&nx);
30100 TIFFGetField(tif,TIFFTAG_IMAGELENGTH,&ny);
30101 TIFFGetField(tif,TIFFTAG_SAMPLESPERPIXEL,&samplesperpixel);
30102 if (samplesperpixel!=1 && samplesperpixel!=3 && samplesperpixel!=4) {
30103 cimg::warn(
"CImg<%s>::load_tiff() : File '%s', unknow value for tag : TIFFTAG_SAMPLESPERPIXEL, will force it to 1.",
30105 samplesperpixel = 1;
30107 TIFFGetFieldDefaulted(tif,TIFFTAG_BITSPERSAMPLE,&bitspersample);
30108 assign(nx,ny,1,samplesperpixel);
30109 if (bitspersample!=8 || !(samplesperpixel==3 || samplesperpixel==4)) {
30110 uint16 photo, config;
30111 TIFFGetField(tif,TIFFTAG_PLANARCONFIG,&config);
30112 TIFFGetField(tif,TIFFTAG_PHOTOMETRIC,&photo);
30113 if (TIFFIsTiled(tif)) {
30115 TIFFGetField(tif,TIFFTAG_TILEWIDTH,&tw);
30116 TIFFGetField(tif,TIFFTAG_TILELENGTH,&th);
30117 if (config==PLANARCONFIG_CONTIG)
switch (bitspersample) {
30119 unsigned char *buf = (
unsigned char*)_TIFFmalloc(TIFFTileSize(tif));
30121 for (
unsigned int row = 0; row<ny; row+=th)
30122 for (
unsigned int col = 0; col<nx; col+=tw) {
30123 if (TIFFReadTile(tif,buf,col,row,0,0)<0) {
30124 _TIFFfree(buf); TIFFClose(tif);
30125 throw CImgException(
"CImg<%s>::load_tiff() : File '%s', an error occure while reading a tile.",
30128 unsigned char *
ptr = buf;
30129 for (
unsigned int rr = row; rr<
cimg::min((
unsigned int)(row+th),(
unsigned int)ny); ++rr)
30130 for (
unsigned int cc = col; cc<
cimg::min((
unsigned int)(col+tw),(
unsigned int)nx); ++cc)
30131 for (
unsigned int vv = 0; vv<samplesperpixel; ++vv)
30132 (*
this)(cc,rr,vv) = (T)(float)(ptr[(rr-row)*th*samplesperpixel + (cc-col)*samplesperpixel + vv]);
30139 unsigned short *buf = (
unsigned short*)_TIFFmalloc(TIFFTileSize(tif));
30141 for (
unsigned int row = 0; row<ny; row+=th)
30142 for (
unsigned int col = 0; col<nx; col+=tw) {
30143 if (TIFFReadTile(tif,buf,col,row,0,0)<0) {
30144 _TIFFfree(buf); TIFFClose(tif);
30145 throw CImgException(
"CImg<%s>::load_tiff() : File '%s', an error occure while reading a tile.",
30148 unsigned short *ptr = buf;
30149 for (
unsigned int rr = row; rr<
cimg::min((
unsigned int)(row+th),(
unsigned int)ny); ++rr)
30150 for (
unsigned int cc = col; cc<
cimg::min((
unsigned int)(col+tw),(
unsigned int)nx); ++cc)
30151 for (
unsigned int vv = 0; vv<samplesperpixel; ++vv)
30152 (*
this)(cc,rr,vv) = (T)(float)(ptr[(rr-row)*th*samplesperpixel + (cc-col)*samplesperpixel + vv]);
30159 float *buf = (
float*)_TIFFmalloc(TIFFTileSize(tif));
30161 for (
unsigned int row = 0; row<ny; row+=th)
30162 for (
unsigned int col = 0; col<nx; col+=tw) {
30163 if (TIFFReadTile(tif,buf,col,row,0,0)<0) {
30164 _TIFFfree(buf); TIFFClose(tif);
30165 throw CImgException(
"CImg<%s>::load_tiff() : File '%s', an error occure while reading a tile.",
30169 for (
unsigned int rr = row; rr<
cimg::min((
unsigned int)(row+th),(
unsigned int)ny); ++rr)
30170 for (
unsigned int cc = col; cc<
cimg::min((
unsigned int)(col+tw),(
unsigned int)nx); ++cc)
30171 for (
unsigned int vv = 0; vv<samplesperpixel; ++vv)
30172 (*
this)(cc,rr,vv) = (T)(float)(ptr[(rr-row)*th*samplesperpixel + (cc-col)*samplesperpixel + vv]);
30178 }
else switch (bitspersample) {
30180 unsigned char *buf = (
unsigned char*)_TIFFmalloc(TIFFTileSize(tif));
30182 for (
unsigned int vv = 0; vv<samplesperpixel; ++vv)
30183 for (
unsigned int row = 0; row<ny; row+=th)
30184 for (
unsigned int col = 0; col<nx; col+=tw) {
30185 if (TIFFReadTile(tif,buf,col,row,0,vv)<0) {
30186 _TIFFfree(buf); TIFFClose(tif);
30187 throw CImgException(
"CImg<%s>::load_tiff() : File '%s', an error occure while reading a tile.",
30190 unsigned char *ptr = buf;
30191 for (
unsigned int rr = row; rr<
cimg::min((
unsigned int)(row+th),(
unsigned int)ny); ++rr)
30192 for (
unsigned int cc = col; cc<
cimg::min((
unsigned int)(col+tw),(
unsigned int)nx); ++cc)
30193 (*
this)(cc,rr,vv) = (T)(float)*(ptr++);
30200 unsigned short *buf = (
unsigned short*)_TIFFmalloc(TIFFTileSize(tif));
30202 for (
unsigned int vv = 0; vv<samplesperpixel; ++vv)
30203 for (
unsigned int row = 0; row<ny; row+=th)
30204 for (
unsigned int col = 0; col<nx; col+=tw) {
30205 if (TIFFReadTile(tif,buf,col,row,0,vv)<0) {
30206 _TIFFfree(buf); TIFFClose(tif);
30207 throw CImgException(
"CImg<%s>::load_tiff() : File '%s', an error occure while reading a tile.",
30210 unsigned short *ptr = buf;
30211 for (
unsigned int rr = row; rr<
cimg::min((
unsigned int)(row+th),(
unsigned int)ny); ++rr)
30212 for (
unsigned int cc = col; cc<
cimg::min((
unsigned int)(col+tw),(
unsigned int)nx); ++cc)
30213 (*
this)(cc,rr,vv) = (T)(float)*(ptr++);
30220 float *buf = (
float*)_TIFFmalloc(TIFFTileSize(tif));
30222 for (
unsigned int vv = 0; vv<samplesperpixel; ++vv)
30223 for (
unsigned int row = 0; row<ny; row+=th)
30224 for (
unsigned int col = 0; col<nx; col+=tw) {
30225 if (TIFFReadTile(tif,buf,col,row,0,vv)<0) {
30226 _TIFFfree(buf); TIFFClose(tif);
30227 throw CImgException(
"CImg<%s>::load_tiff() : File '%s', an error occure while reading a tile.",
30231 for (
unsigned int rr = row; rr<
cimg::min((
unsigned int)(row+th),(
unsigned int)ny); ++rr)
30232 for (
unsigned int cc = col; cc<
cimg::min((
unsigned int)(col+tw),(
unsigned int)nx); ++cc)
30233 (*
this)(cc,rr,vv) = (T)(float)*(ptr++);
30241 if (config==PLANARCONFIG_CONTIG)
switch (bitspersample) {
30243 unsigned char *buf = (
unsigned char*)_TIFFmalloc(TIFFStripSize(tif));
30245 uint32 row, rowsperstrip = (uint32)-1;
30246 TIFFGetField(tif,TIFFTAG_ROWSPERSTRIP,&rowsperstrip);
30247 for (row = 0; row<ny; row+= rowsperstrip) {
30248 uint32
nrow = (row+rowsperstrip>ny?ny-row:rowsperstrip);
30249 tstrip_t strip = TIFFComputeStrip(tif, row, 0);
30250 if ((TIFFReadEncodedStrip(tif,strip,buf,-1))<0) {
30251 _TIFFfree(buf); TIFFClose(tif);
30252 throw CImgException(
"CImg<%s>::load_tiff() : File '%s', an error occure while reading a strip.",
30255 unsigned char *ptr = buf;
30256 for (
unsigned int rr = 0; rr<
nrow; ++rr)
30257 for (
unsigned int cc = 0; cc<nx; ++cc)
30258 for (
unsigned int vv = 0; vv<samplesperpixel; ++vv) (*
this)(cc,row+rr,vv) = (T)(float)*(ptr++);
30264 unsigned short *buf = (
unsigned short*)_TIFFmalloc(TIFFStripSize(tif));
30266 uint32 row, rowsperstrip = (uint32)-1;
30267 TIFFGetField(tif,TIFFTAG_ROWSPERSTRIP,&rowsperstrip);
30268 for (row = 0; row<ny; row+= rowsperstrip) {
30269 uint32 nrow = (row+rowsperstrip>ny?ny-row:rowsperstrip);
30270 tstrip_t strip = TIFFComputeStrip(tif, row, 0);
30271 if ((TIFFReadEncodedStrip(tif,strip,buf,-1))<0) {
30272 _TIFFfree(buf); TIFFClose(tif);
30273 throw CImgException(
"CImg<%s>::load_tiff() : File '%s', error while reading a strip.",
30276 unsigned short *ptr = buf;
30277 for (
unsigned int rr = 0; rr<
nrow; ++rr)
30278 for (
unsigned int cc = 0; cc<nx; ++cc)
30279 for (
unsigned int vv = 0; vv<samplesperpixel; ++vv) (*
this)(cc,row+rr,vv) = (T)(float)*(ptr++);
30285 float *buf = (
float*)_TIFFmalloc(TIFFStripSize(tif));
30287 uint32 row, rowsperstrip = (uint32)-1;
30288 TIFFGetField(tif,TIFFTAG_ROWSPERSTRIP,&rowsperstrip);
30289 for (row = 0; row<ny; row+= rowsperstrip) {
30290 uint32 nrow = (row+rowsperstrip>ny?ny-row:rowsperstrip);
30291 tstrip_t strip = TIFFComputeStrip(tif, row, 0);
30292 if ((TIFFReadEncodedStrip(tif,strip,buf,-1))<0) {
30293 _TIFFfree(buf); TIFFClose(tif);
30294 throw CImgException(
"CImg<%s>::load_tiff() : File '%s', error while reading a strip.",
30298 for (
unsigned int rr = 0; rr<
nrow; ++rr)
30299 for (
unsigned int cc = 0; cc<nx; ++cc)
30300 for (
unsigned int vv = 0; vv<samplesperpixel; ++vv) (*
this)(cc,row+rr,vv) = (T)(float)*(ptr++);
30305 }
else switch (bitspersample){
30307 unsigned char *buf = (
unsigned char*)_TIFFmalloc(TIFFStripSize(tif));
30309 uint32 row, rowsperstrip = (uint32)-1;
30310 TIFFGetField(tif,TIFFTAG_ROWSPERSTRIP,&rowsperstrip);
30311 for (
unsigned int vv = 0; vv<samplesperpixel; ++vv)
30312 for (row = 0; row<ny; row+= rowsperstrip) {
30313 uint32 nrow = (row+rowsperstrip>ny?ny-row:rowsperstrip);
30314 tstrip_t strip = TIFFComputeStrip(tif, row, vv);
30315 if ((TIFFReadEncodedStrip(tif,strip,buf,-1))<0) {
30316 _TIFFfree(buf); TIFFClose(tif);
30317 throw CImgException(
"CImg<%s>::load_tiff() : File '%s', an error occure while reading a strip.",
30320 unsigned char *ptr = buf;
30321 for (
unsigned int rr = 0;rr<
nrow; ++rr)
30322 for (
unsigned int cc = 0; cc<nx; ++cc)
30323 (*
this)(cc,row+rr,vv) = (T)(float)*(ptr++);
30329 unsigned short *buf = (
unsigned short*)_TIFFmalloc(TIFFStripSize(tif));
30331 uint32 row, rowsperstrip = (uint32)-1;
30332 TIFFGetField(tif,TIFFTAG_ROWSPERSTRIP,&rowsperstrip);
30333 for (
unsigned int vv = 0; vv<samplesperpixel; ++vv)
30334 for (row = 0; row<ny; row+= rowsperstrip) {
30335 uint32 nrow = (row+rowsperstrip>ny?ny-row:rowsperstrip);
30336 tstrip_t strip = TIFFComputeStrip(tif, row, vv);
30337 if ((TIFFReadEncodedStrip(tif,strip,buf,-1))<0) {
30338 _TIFFfree(buf); TIFFClose(tif);
30339 throw CImgException(
"CImg<%s>::load_tiff() : File '%s', error while reading a strip.",
30342 unsigned short *ptr = buf;
30343 for (
unsigned int rr = 0; rr<
nrow; ++rr)
30344 for (
unsigned int cc = 0; cc<nx; ++cc)
30345 (*
this)(cc,row+rr,vv) = (T)(float)*(ptr++);
30351 float *buf = (
float*)_TIFFmalloc(TIFFStripSize(tif));
30353 uint32 row, rowsperstrip = (uint32)-1;
30354 TIFFGetField(tif,TIFFTAG_ROWSPERSTRIP,&rowsperstrip);
30355 for (
unsigned int vv = 0; vv<samplesperpixel; ++vv)
30356 for (row = 0; row<ny; row+= rowsperstrip) {
30357 uint32 nrow = (row+rowsperstrip>ny?ny-row:rowsperstrip);
30358 tstrip_t strip = TIFFComputeStrip(tif, row, vv);
30359 if ((TIFFReadEncodedStrip(tif,strip,buf,-1))<0) {
30360 _TIFFfree(buf); TIFFClose(tif);
30361 throw CImgException(
"CImg<%s>::load_tiff() : File '%s', error while reading a strip.",
30365 for (
unsigned int rr = 0; rr<
nrow; ++rr)
for (
unsigned int cc = 0; cc<nx; ++cc)
30366 (*
this)(cc,row+rr,vv) = (T)(float)*(ptr++);
30374 uint32* raster = (uint32*)_TIFFmalloc(nx * ny *
sizeof (uint32));
30376 _TIFFfree(raster); TIFFClose(tif);
30377 throw CImgException(
"CImg<%s>::load_tiff() : File '%s', not enough memory for buffer allocation.",
30380 TIFFReadRGBAImage(tif,nx,ny,raster,0);
30381 switch (samplesperpixel) {
30383 cimg_forXY(*
this,x,
y) (*this)(
x,
y) = (T)(float)((raster[nx*(ny-1-
y)+
x]+ 128) / 257);
30387 (*this)(
x,
y,0) = (T)(float)TIFFGetR(raster[nx*(ny-1-y)+
x]);
30388 (*this)(
x,
y,1) = (T)(float)TIFFGetG(raster[nx*(ny-1-y)+
x]);
30389 (*this)(
x,
y,2) = (T)(float)TIFFGetB(raster[nx*(ny-1-y)+
x]);
30394 (*this)(
x,
y,0) = (T)(float)TIFFGetR(raster[nx*(ny-1-y)+
x]);
30395 (*this)(
x,
y,1) = (T)(float)TIFFGetG(raster[nx*(ny-1-y)+
x]);
30396 (*this)(
x,
y,2) = (T)(float)TIFFGetB(raster[nx*(ny-1-y)+
x]);
30397 (*this)(
x,
y,3) = (T)(float)TIFFGetA(raster[nx*(ny-1-y)+
x]);
30426 if (!filename && !file)
30429 std::FILE *nfile_header = 0, *nfile = 0;
30431 char body[1024] = { 0 };
30435 std::sprintf(body+std::strlen(body),
".img");
30439 std::sprintf(body+std::strlen(body),
".hdr");
30441 }
else nfile_header = nfile =
cimg::fopen(filename,
"rb");
30442 }
else nfile_header = nfile = file;
30443 if (!nfile || !nfile_header)
30444 throw CImgIOException(
"CImg<%s>::load_analyze() : File '%s', not recognized as an Analyze7.5 or NIFTI file.",
30448 bool endian =
false;
30449 unsigned int header_size;
30452 throw CImgIOException(
"CImg<%s>::load_analyze() : File '%s', zero-sized header found.",
30455 unsigned char *header =
new unsigned char[header_size];
30456 cimg::fread(header+4,header_size-4,nfile_header);
30457 if (!file && nfile_header!=nfile)
cimg::fclose(nfile_header);
30465 unsigned short *dim = (
unsigned short*)(header+40),
dimx = 1,
dimy = 1,
dimz = 1,
dimv = 1;
30467 cimg::warn(
"CImg<%s>::load_analyze() : File '%s', tells that image has zero dimensions.",
30470 cimg::warn(
"CImg<%s>::load_analyze() : File '%s', number of image dimension is %u, reading only the 4 first dimensions",
30471 pixel_type(),filename?filename:
"(FILE*)",dim[0]);
30472 if (dim[0]>=1)
dimx = dim[1];
30473 if (dim[0]>=2)
dimy = dim[2];
30474 if (dim[0]>=3)
dimz = dim[3];
30475 if (dim[0]>=4)
dimv = dim[4];
30476 float scalefactor = *(
float*)(header+112);
if (scalefactor==0) scalefactor=1;
30477 const unsigned short datatype = *(
short*)(header+70);
30479 const float *vsize = (
float*)(header+76);
30480 voxsize[0] = vsize[1]; voxsize[1] = vsize[2]; voxsize[2] = vsize[3];
30486 switch (datatype) {
30523 throw CImgIOException(
"CImg<%s>::load_analyze() : File '%s', cannot read images with 'datatype = %d'",
30524 pixel_type(),filename?filename:
"(FILE*)",datatype);
30556 const unsigned int n0,
const unsigned int n1,
30557 const unsigned int x0,
const unsigned int y0,
const unsigned int z0,
const unsigned int v0,
30558 const unsigned int x1,
const unsigned int y1,
const unsigned int z1,
const unsigned int v1,
30559 const char axis=
'z',
const char align=
'p') {
30561 list.
load_cimg(filename,n0,n1,x0,y0,z0,v0,x1,y1,z1,v1);
30567 const unsigned int n0,
const unsigned int n1,
30568 const unsigned int x0,
const unsigned int y0,
const unsigned int z0,
const unsigned int v0,
30569 const unsigned int x1,
const unsigned int y1,
const unsigned int z1,
const unsigned int v1,
30570 const char axis=
'z',
const char align=
'p') {
30571 return CImg<T>().
load_cimg(filename,n0,n1,x0,y0,z0,v0,x1,y1,z1,v1,axis,align);
30576 const unsigned int n0,
const unsigned int n1,
30577 const unsigned int x0,
const unsigned int y0,
const unsigned int z0,
const unsigned int v0,
30578 const unsigned int x1,
const unsigned int y1,
const unsigned int z1,
const unsigned int v1,
30579 const char axis=
'z',
const char align=
'p') {
30581 list.
load_cimg(file,n0,n1,x0,y0,z0,v0,x1,y1,z1,v1);
30587 const unsigned int n0,
const unsigned int n1,
30588 const unsigned int x0,
const unsigned int y0,
const unsigned int z0,
const unsigned int v0,
30589 const unsigned int x1,
const unsigned int y1,
const unsigned int z1,
const unsigned int v1,
30590 const char axis=
'z',
const char align=
'p') {
30591 return CImg<T>().
load_cimg(file,n0,n1,x0,y0,z0,v0,x1,y1,z1,v1,axis,align);
30614 char item[1024] = { 0 }, tmp1[64] = { 0 }, tmp2[64] = { 0 };
30615 out[0] = std::fscanf(file,
"%63s",item);
30616 out[0] = out[1] = out[2] = out[3] = out[5] = 1; out[4] = out[6] = out[7] = -1;
30618 throw CImgIOException(
"CImg<%s>::load_inr() : File does not appear to be a valid INR file.\n"
30619 "(INRIMAGE-4 identifier not found)",
30621 while (std::fscanf(file,
" %63[^\n]%*c",item)!=EOF && std::strncmp(item,
"##}",3)) {
30622 std::sscanf(item,
" XDIM%*[^0-9]%d",out);
30623 std::sscanf(item,
" YDIM%*[^0-9]%d",out+1);
30624 std::sscanf(item,
" ZDIM%*[^0-9]%d",out+2);
30625 std::sscanf(item,
" VDIM%*[^0-9]%d",out+3);
30626 std::sscanf(item,
" PIXSIZE%*[^0-9]%d",out+6);
30628 std::sscanf(item,
" VX%*[^0-9.+-]%f",voxsize);
30629 std::sscanf(item,
" VY%*[^0-9.+-]%f",voxsize+1);
30630 std::sscanf(item,
" VZ%*[^0-9.+-]%f",voxsize+2);
30632 if (std::sscanf(item,
" CPU%*[ =]%s",tmp1)) out[7]=
cimg::strncasecmp(tmp1,
"sun",3)?0:1;
30633 switch (std::sscanf(item,
" TYPE%*[ =]%s %s",tmp1,tmp2)) {
30635 case 2 : out[5] =
cimg::strncasecmp(tmp1,
"unsigned",8)?1:0; std::strcpy(tmp1,tmp2);
30640 if (out[4]>=0)
break;
30642 throw CImgIOException(
"cimg::inr_header_read() : Invalid TYPE '%s'",tmp2);
30645 if(out[0]<0 || out[1]<0 || out[2]<0 || out[3]<0)
30646 throw CImgIOException(
"CImg<%s>::load_inr() : Bad dimensions in .inr file = ( %d , %d , %d , %d )",
30648 if(out[4]<0 || out[5]<0)
30649 throw CImgIOException(
"CImg<%s>::load_inr() : TYPE is not fully defined",
30652 throw CImgIOException(
"CImg<%s>::load_inr() : PIXSIZE is not fully defined",
30655 throw CImgIOException(
"CImg<%s>::load_inr() : Big/Little Endian coding type is not defined",
30660 #define _cimg_load_inr_case(Tf,sign,pixsize,Ts) \
30661 if (!loaded && fopt[6]==pixsize && fopt[4]==Tf && fopt[5]==sign) { \
30662 Ts *xval, *val = new Ts[fopt[0]*fopt[3]]; \
30663 cimg_forYZ(*this,y,z) { \
30664 cimg::fread(val,fopt[0]*fopt[3],nfile); \
30665 if (fopt[7]!=endian) cimg::invert_endianness(val,fopt[0]*fopt[3]); \
30666 xval = val; cimg_forX(*this,x) cimg_forV(*this,k) (*this)(x,y,z,k) = (T)*(xval++); \
30672 if (!filename && !file)
30675 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"rb");
30677 bool loaded =
false;
30678 if (voxsize) voxsize[0]=voxsize[1]=voxsize[2]=1;
30680 assign(fopt[0],fopt[1],fopt[2],fopt[3]);
30693 throw CImgIOException(
"CImg<%s>::load_inr() : File '%s', cannot read images of the type specified in the file",
30719 #define __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,ndim,stype) \
30720 cimg::fread(dims,nbdim,nfile); \
30721 if (endian) cimg::invert_endianness(dims,nbdim); \
30722 assign(nwidth,nheight,ndepth,ndim); \
30723 const unsigned int siz = size(); \
30724 stype *buffer = new stype[siz]; \
30725 cimg::fread(buffer,siz,nfile); \
30726 if (endian) cimg::invert_endianness(buffer,siz); \
30728 cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++); \
30732 #define _cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype1,stype2,stype3,ltype) { \
30733 if (sizeof(stype1)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype1); } \
30734 else if (sizeof(stype2)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype2); } \
30735 else if (sizeof(stype3)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype3); } \
30736 else throw CImgIOException("CImg<%s>::load_pandore() : File '%s' cannot be read, datatype not supported on this architecture.", \
30737 pixel_type(),filename?filename:"(FILE*)"); }
30739 if (!filename && !file)
30742 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"rb");
30743 typedef unsigned char uchar;
30744 typedef unsigned short ushort;
30745 typedef unsigned int uint;
30746 typedef unsigned long ulong;
30747 char header[32] = { 0 };
30751 throw CImgIOException(
"CImg<%s>::load_pandore() : File '%s' is not a valid PANDORE file, "
30752 "(PANDORE identifier not found).",
30755 unsigned int imageid, dims[8] = { 0 };
30757 const bool endian = (imageid>255);
30775 const unsigned siz =
size();
30777 unsigned char *buffer =
new unsigned char[siz];
30780 cimg_foroff(*
this,off) *(ptrd++) = (T)*(buffer++);
30784 if (dims[2]<65536) {
30785 unsigned short *buffer =
new unsigned short[siz];
30789 cimg_foroff(*
this,off) *(ptrd++) = (T)*(buffer++);
30793 unsigned int *buffer =
new unsigned int[siz];
30797 cimg_foroff(*
this,off) *(ptrd++) = (T)*(buffer++);
30807 assign(dims[2],dims[1],1,1);
30808 const unsigned int siz =
size();
30810 unsigned char *buffer =
new unsigned char[siz];
30813 cimg_foroff(*
this,off) *(ptrd++) = (T)*(buffer++);
30817 if (dims[3]<65536) {
30818 unsigned short *buffer =
new unsigned short[siz];
30822 cimg_foroff(*
this,off) *(ptrd++) = (T)*(buffer++);
30826 unsigned long *buffer =
new unsigned long[siz];
30830 cimg_foroff(*
this,off) *(ptrd++) = (T)*(buffer++);
30840 assign(dims[3],dims[2],dims[1],1);
30841 const unsigned int siz =
size();
30843 unsigned char *buffer =
new unsigned char[siz];
30846 cimg_foroff(*
this,off) *(ptrd++) = (T)*(buffer++);
30850 if (dims[4]<65536) {
30851 unsigned short *buffer =
new unsigned short[siz];
30855 cimg_foroff(*
this,off) *(ptrd++) = (T)*(buffer++);
30859 unsigned int *buffer =
new unsigned int[siz];
30863 cimg_foroff(*
this,off) *(ptrd++) = (T)*(buffer++);
30889 int ptbuf[4] = { 0 };
30892 assign(1); (*this)(0) = (T)ptbuf[0];
30895 int ptbuf[4] = { 0 };
30898 assign(2); (*this)(0) = (T)ptbuf[1]; (*this)(1) = (T)ptbuf[0];
30901 int ptbuf[4] = { 0 };
30904 assign(3); (*this)(0) = (T)ptbuf[2]; (*this)(1) = (T)ptbuf[1]; (*this)(2) = (T)ptbuf[0];
30908 throw CImgIOException(
"CImg<%s>::load_pandore() : File '%s', cannot read images with ID_type = %u",
30909 pixel_type(),filename?filename:
"(FILE*)",imageid);
30929 const unsigned int sizex,
const unsigned int sizey=1,
30930 const unsigned int sizez=1,
const unsigned int sizev=1,
30936 const unsigned int sizex,
const unsigned int sizey=1,
30937 const unsigned int sizez=1,
const unsigned int sizev=1,
30944 const unsigned int sizex,
const unsigned int sizey=1,
30945 const unsigned int sizez=1,
const unsigned int sizev=1,
30951 const unsigned int sizex,
const unsigned int sizey=1,
30952 const unsigned int sizez=1,
const unsigned int sizev=1,
30958 const unsigned int sizex,
const unsigned int sizey,
30959 const unsigned int sizez,
const unsigned int sizev,
30961 if (!filename && !file)
30964 assign(sizex,sizey,sizez,sizev,0);
30965 const unsigned int siz =
size();
30967 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"rb");
30968 if (!multiplexed) {
30985 CImg<T>&
load_ffmpeg(
const char *
const filename,
const unsigned int first_frame=0,
const unsigned int last_frame=~0U,
30986 const unsigned int step_frame=1,
const bool pixel_format=
true,
const bool resume=
false,
30987 const char axis=
'z',
const char align=
'p') {
30988 return get_load_ffmpeg(filename,first_frame,last_frame,step_frame,pixel_format,resume,axis,align).transfer_to(*
this);
30992 const unsigned int step_frame=1,
const bool pixel_format=
true,
const bool resume=
false,
30993 const char axis=
'z',
const char align=
'p') {
30994 return CImgList<T>().
load_ffmpeg(filename,first_frame,last_frame,step_frame,pixel_format,resume).get_append(axis,align);
30999 const unsigned int sizex,
const unsigned int sizey=1,
31000 const unsigned int first_frame=0,
const unsigned int last_frame=~0U,
31001 const unsigned int step_frame=1,
const bool yuv2rgb=
true,
const char axis=
'z',
const char align=
'p') {
31002 return get_load_yuv(filename,sizex,sizey,first_frame,last_frame,step_frame,yuv2rgb,axis,align).transfer_to(*
this);
31006 const unsigned int sizex,
const unsigned int sizey=1,
31007 const unsigned int first_frame=0,
const unsigned int last_frame=~0U,
31008 const unsigned int step_frame=1,
const bool yuv2rgb=
true,
const char axis=
'z',
const char align=
'p') {
31009 return CImgList<T>().
load_yuv(filename,sizex,sizey,first_frame,last_frame,step_frame,yuv2rgb).get_append(axis,align);
31014 const unsigned int sizex,
const unsigned int sizey=1,
31015 const unsigned int first_frame=0,
const unsigned int last_frame=~0U,
31016 const unsigned int step_frame=1,
const bool yuv2rgb=
true,
const char axis=
'z',
const char align=
'p') {
31017 return get_load_yuv(file,sizex,sizey,first_frame,last_frame,step_frame,yuv2rgb,axis,align).transfer_to(*
this);
31021 const unsigned int sizex,
const unsigned int sizey=1,
31022 const unsigned int first_frame=0,
const unsigned int last_frame=~0U,
31023 const unsigned int step_frame=1,
const bool yuv2rgb=
true,
const char axis=
'z',
const char align=
'p') {
31024 return CImgList<T>().
load_yuv(file,sizex,sizey,first_frame,last_frame,step_frame,yuv2rgb).get_append(axis,align);
31028 template<
typename tf,
typename tc>
31030 return _load_off(0,filename,primitives,colors);
31033 template<
typename tf,
typename tc>
31039 template<
typename tf,
typename tc>
31041 return _load_off(file,0,primitives,colors);
31044 template<
typename tf,
typename tc>
31049 template<
typename tf,
typename tc>
31052 if (!filename && !file)
31055 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"r");
31056 unsigned int nb_points = 0, nb_primitives = 0, nb_read = 0;
31057 char line[256] = { 0 };
31061 do { err = std::fscanf(nfile,
"%255[^\n] ",line); }
while (!err || (err==1 && line[0]==
'#'));
31064 throw CImgIOException(
"CImg<%s>::load_off() : File '%s', keyword 'OFF' not found.",
31067 do { err = std::fscanf(nfile,
"%255[^\n] ",line); }
while (!err || (err==1 && line[0]==
'#'));
31068 if ((err = std::sscanf(line,
"%u%u%*[^\n] ",&nb_points,&nb_primitives))!=2) {
31070 throw CImgIOException(
"CImg<%s>::load_off() : File '%s', invalid vertices/primitives numbers.",
31076 float X = 0, Y = 0, Z = 0;
31078 do { err = std::fscanf(nfile,
"%255[^\n] ",line); }
while (!err || (err==1 && line[0]==
'#'));
31079 if ((err = std::sscanf(line,
"%f%f%f%*[^\n] ",&X,&Y,&Z))!=3) {
31081 throw CImgIOException(
"CImg<%s>::load_off() : File '%s', cannot read point %u/%u.\n",
31082 pixel_type(),filename?filename:
"(FILE*)",l+1,nb_points);
31084 (*this)(l,0) = (T)X; (*this)(l,1) = (T)Y; (*this)(l,2) = (T)Z;
31090 bool stopflag =
false;
31091 while (!stopflag) {
31092 float c0 = 0.7f, c1 = 0.7f, c2 = 0.7f;
31093 unsigned int prim = 0, i0 = 0, i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
31095 if ((err = std::fscanf(nfile,
"%u",&prim))!=1) stopflag=
true;
31100 if ((err = std::fscanf(nfile,
"%u%255[^\n] ",&i0,line))<2) {
31101 cimg::warn(
"CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.",
31102 pixel_type(),filename?filename:
"(FILE*)",nb_read,nb_primitives);
31103 err = std::fscanf(nfile,
"%*[^\n] ");
31105 err = std::sscanf(line,
"%f%f%f",&c0,&c1,&c2);
31107 CImg<tc>::vector((tc)(c0*255),(tc)(c1*255),(tc)(c2*255)).transfer_to(colors);
31111 if ((err = std::fscanf(nfile,
"%u%u%255[^\n] ",&i0,&i1,line))<2) {
31112 cimg::warn(
"CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.",
31113 pixel_type(),filename?filename:
"(FILE*)",nb_read,nb_primitives);
31114 err = std::fscanf(nfile,
"%*[^\n] ");
31116 err = std::sscanf(line,
"%f%f%f",&c0,&c1,&c2);
31118 CImg<tc>::vector((tc)(c0*255),(tc)(c1*255),(tc)(c2*255)).transfer_to(colors);
31122 if ((err = std::fscanf(nfile,
"%u%u%u%255[^\n] ",&i0,&i1,&i2,line))<3) {
31123 cimg::warn(
"CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.",
31124 pixel_type(),filename?filename:
"(FILE*)",nb_read,nb_primitives);
31125 err = std::fscanf(nfile,
"%*[^\n] ");
31127 err = std::sscanf(line,
"%f%f%f",&c0,&c1,&c2);
31129 CImg<tc>::vector((tc)(c0*255),(tc)(c1*255),(tc)(c2*255)).transfer_to(colors);
31133 if ((err = std::fscanf(nfile,
"%u%u%u%u%255[^\n] ",&i0,&i1,&i2,&i3,line))<4) {
31134 cimg::warn(
"CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.",
31135 pixel_type(),filename?filename:
"(FILE*)",nb_read,nb_primitives);
31136 err = std::fscanf(nfile,
"%*[^\n] ");
31138 err = std::sscanf(line,
"%f%f%f",&c0,&c1,&c2);
31140 CImg<tc>::vector((tc)(c0*255),(tc)(c1*255),(tc)(c2*255),(tc)(c2*255)).transfer_to(colors);
31144 if ((err = std::fscanf(nfile,
"%u%u%u%u%u%255[^\n] ",&i0,&i1,&i2,&i3,&i4,line))<5) {
31145 cimg::warn(
"CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.",
31146 pixel_type(),filename?filename:
"(FILE*)",nb_read,nb_primitives);
31147 err = std::fscanf(nfile,
"%*[^\n] ");
31149 err = std::sscanf(line,
"%f%f%f",&c0,&c1,&c2);
31157 if ((err = std::fscanf(nfile,
"%u%u%u%u%u%u%255[^\n] ",&i0,&i1,&i2,&i3,&i4,&i5,line))<6) {
31158 cimg::warn(
"CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.",
31159 pixel_type(),filename?filename:
"(FILE*)",nb_read,nb_primitives);
31160 err = std::fscanf(nfile,
"%*[^\n] ");
31162 err = std::sscanf(line,
"%f%f%f",&c0,&c1,&c2);
31170 if ((err = std::fscanf(nfile,
"%u%u%u%u%u%u%u%255[^\n] ",&i0,&i1,&i2,&i3,&i4,&i5,&i6,line))<7) {
31171 cimg::warn(
"CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.",
31172 pixel_type(),filename?filename:
"(FILE*)",nb_read,nb_primitives);
31173 err = std::fscanf(nfile,
"%*[^\n] ");
31175 err = std::sscanf(line,
"%f%f%f",&c0,&c1,&c2);
31180 ++(++nb_primitives);
31184 if ((err = std::fscanf(nfile,
"%u%u%u%u%u%u%u%u%255[^\n] ",&i0,&i1,&i2,&i3,&i4,&i5,&i6,&i7,line))<7) {
31185 cimg::warn(
"CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.",
31186 pixel_type(),filename?filename:
"(FILE*)",nb_read,nb_primitives);
31187 err = std::fscanf(nfile,
"%*[^\n] ");
31189 err = std::sscanf(line,
"%f%f%f",&c0,&c1,&c2);
31194 ++(++nb_primitives);
31198 cimg::warn(
"CImg<%s>::load_off() : File '%s', invalid primitive %u/%u (%u vertices).",
31199 pixel_type(),filename?filename:
"(FILE*)",nb_read,nb_primitives,prim);
31200 err = std::fscanf(nfile,
"%*[^\n] ");
31205 if (primitives.
width!=nb_primitives)
31206 cimg::warn(
"CImg<%s>::load_off() : File '%s', read only %u primitives instead of %u as claimed in the header.",
31207 pixel_type(),filename?filename:
"(FILE*)",primitives.
width,nb_primitives);
31223 throw CImgArgumentException(
"CImg<%s>::load_graphicsmagick_external() : Cannot load (null) filename.",
31225 char command[1024] = { 0 }, filetmp[512] = { 0 };
31226 std::FILE *file = 0;
31229 file = popen(command,
"r");
31230 if (file) {
load_pnm(file); pclose(file);
return *
this; }
31240 throw CImgIOException(
"CImg<%s>::load_graphicsmagick_external() : Failed to open image '%s'.\n\n"
31241 "Path of 'GraphicsMagick's gm' : \"%s\"\n"
31242 "Path of temporary filename : \"%s\"",
31246 std::remove(filetmp);
31257 throw CImgIOException(
"CImg<%s>::load_gzip_external() : Cannot load (null) filename.",
31259 char command[1024] = { 0 }, filetmp[512] = { 0 }, body[512] = { 0 };
31263 std::FILE *file = 0;
31274 std::sprintf(command,
"%s -c \"%s\" > %s",
cimg::gunzip_path(),filename,filetmp);
31278 throw CImgIOException(
"CImg<%s>::load_gzip_external() : File '%s' cannot be opened.",
31282 std::remove(filetmp);
31293 throw CImgArgumentException(
"CImg<%s>::load_imagemagick_external() : Cannot load (null) filename.",
31295 char command[1024] = { 0 }, filetmp[512] = { 0 };
31296 std::FILE *file = 0;
31299 file = popen(command,
"r");
31300 if (file) {
load_pnm(file); pclose(file);
return *
this; }
31310 throw CImgIOException(
"CImg<%s>::load_imagemagick_external() : Failed to open image '%s'.\n\n"
31311 "Path of 'ImageMagick's convert' : \"%s\"\n"
31312 "Path of temporary filename : \"%s\"",
31316 std::remove(filetmp);
31329 char command[1024] = { 0 }, filetmp[512] = { 0 }, body[512] = { 0 };
31331 std::FILE *file = 0;
31336 std::sprintf(command,
"%s -w -c anlz -o %s -f %s",
cimg::medcon_path(),filetmp,filename);
31339 std::sprintf(command,
"m000-%s.hdr",body);
31342 throw CImgIOException(
"CImg<%s>::load_medcon_external() : Failed to open image '%s'.\n\n"
31343 "Path of 'medcon' : \"%s\"\n"
31344 "Path of temporary filename : \"%s\"",
31348 std::remove(command);
31349 std::sprintf(command,
"m000-%s.img",body);
31350 std::remove(command);
31363 char command[1024] = { 0 }, filetmp[512] = { 0 };
31364 std::FILE *file = 0;
31367 file = popen(command,
"r");
31368 if (file) {
load_pnm(file); pclose(file);
return *
this; }
31374 std::sprintf(command,
"%s -4 -c \"%s\" > %s",
cimg::dcraw_path(),filename,filetmp);
31378 throw CImgIOException(
"CImg<%s>::load_dcraw_external() : Failed to open image '%s'.\n\n"
31379 "Path of 'dcraw' : \"%s\"\n"
31380 "Path of temporary filename : \"%s\"",
31384 std::remove(filetmp);
31411 throw CImgIOException(
"CImg<%s>::load_other() : File '%s' cannot be opened.",
31432 const CImg<T>&
print(
const char *title=0,
const bool display_stats=
true)
const {
31433 int xm = 0, ym = 0, zm = 0, vm = 0, xM = 0, yM = 0, zM = 0, vM = 0;
31435 if (!
is_empty() && display_stats) {
31437 xm = (int)st[4]; ym = (int)st[5], zm = (
int)st[6], vm = (int)st[7];
31438 xM = (int)st[8]; yM = (int)st[9], zM = (
int)st[10], vM = (int)st[11];
31440 const unsigned int siz =
size(), msiz = siz*
sizeof(T), siz1 = siz-1;
31441 const unsigned int mdisp = msiz<8*1024?0:(msiz<8*1024*1024?1:2), width1 =
width-1;
31442 char ntitle[64] = { 0 };
31443 if (!title) std::sprintf(ntitle,
"CImg<%s>",
pixel_type());
31444 std::fprintf(
cimg_stdout,
"%s: this = %p, size = (%u,%u,%u,%u) [%u %s], data = (%s*)%p..%p (%s) = [ ",
31446 mdisp==0?msiz:(mdisp==1?(msiz>>10):(msiz>>20)),
31447 mdisp==0?
"b":(mdisp==1?
"Kb":
"Mb"),
31452 if (off!=siz1) std::fprintf(
cimg_stdout,
"%s",off%
width==width1?
" ; ":
" ");
31453 if (off==7 && siz>16) { off = siz1-8;
if (off!=7) std::fprintf(
cimg_stdout,
"... "); }
31456 std::fprintf(
cimg_stdout,
" ], min = %g, max = %g, mean = %g, std = %g, coords(min) = (%u,%u,%u,%u), coords(max) = (%u,%u,%u,%u).\n",
31457 st[0],st[1],st[2],
std::sqrt(st[3]),xm,ym,zm,vm,xM,yM,zM,vM);
31470 return _display(disp,0,display_info);
31476 return _display(disp,title,display_info);
31483 unsigned int oldw = 0, oldh = 0, XYZ[3],
key = 0, mkey = 0;
31484 int x0 = 0, y0 = 0, z0 = 0, x1 =
dimx()-1, y1 =
dimy()-1, z1 =
dimz()-1;
31485 float frametiming = 5;
31487 char ntitle[256] = { 0 };
31492 std::strncpy(ntitle,disp.
title,255);
31493 if (display_info)
print(ntitle);
31496 for (
bool reset_view =
true, resize_disp =
false; !key && !disp.
is_closed; ) {
31498 XYZ[0] = (x0 + x1)/2; XYZ[1] = (y0 + y1)/2; XYZ[2] = (z0 + z1)/2;
31501 reset_view =
false;
31503 if (!x0 && !y0 && !z0 && x1==
dimx()-1 && y1==
dimy()-1 && z1==
dimz()-1) zoom.assign();
31504 else zoom =
get_crop(x0,y0,z0,x1,y1,z1);
31507 dx = 1 + x1 - x0,
dy = 1 + y1 - y0, dz = 1 + z1 - z0,
31508 tw = dx + (dz>1?dz:0), th = dy + (dz>1?dz:0);
31511 ttw = tw*disp.
width/oldw, tth = th*disp.
height/oldh,
31515 resize_disp =
false;
31517 oldw = tw; oldh = th;
31520 go_up =
false, go_down =
false, go_left =
false, go_right =
false,
31521 go_inc =
false, go_dec =
false, go_in =
false, go_out =
false,
31522 go_in_center =
false;
31523 const CImg<T>& visu = zoom?zoom:*
this;
31524 const CImg<intT> selection = visu._get_select(disp,0,2,XYZ,0,x0,y0,z0);
31526 if (disp.
is_keyCTRLLEFT) {
if (!mkey || mkey==1) go_out = !(go_in = disp.
wheel>0); go_in_center =
false; mkey = 1; }
31527 else if (disp.
is_keySHIFTLEFT) {
if (!mkey || mkey==2) go_right = !(go_left = disp.
wheel>0); mkey = 2; }
31528 else if (disp.
is_keyALT ||
depth==1) {
if (!mkey || mkey==3) go_down = !(go_up = disp.
wheel>0); mkey = 3; }
31533 sx0 = selection(0), sy0 = selection(1), sz0 = selection(2),
31534 sx1 = selection(3), sy1 = selection(4), sz1 = selection(5);
31535 if (sx0>=0 && sy0>=0 && sz0>=0 && sx1>=0 && sy1>=0 && sz1>=0) {
31536 x1 = x0 + sx1; y1 = y0 + sy1; z1 = z0 + sz1; x0+=sx0; y0+=sy0; z0+=sz0;
31537 if (sx0==sx1 && sy0==sy1 && sz0==sz1) reset_view =
true;
31538 resize_disp =
true;
31539 }
else switch (key = disp.
key) {
31543 w1 = visu.width*disp.
width/(visu.width+(visu.depth>1?visu.depth:0)),
31544 h1 = visu.height*disp.
height/(visu.height+(visu.depth>1?visu.depth:0));
31546 for (
unsigned int timer = 0; !key && !disp.
is_closed && !disp.
button; ) {
31549 visu.get_slice(XYZ[2]).display(disp.
set_title(
"%s | z=%d",ntitle,XYZ[2]));
31550 if (++XYZ[2]>=visu.depth) XYZ[2] = 0;
31552 if (++timer>(
unsigned int)frametiming) timer = 0;
31554 switch (key = disp.
key) {
31561 disp.
key = key = 0;
31565 disp.
key = key = 0;
31569 disp.
key = key = 0;
31575 frametiming = frametiming<1?1:(frametiming>39?39:frametiming);
31579 w2 = (visu.width + (visu.depth>1?visu.depth:0))*disp.
width/visu.width,
31580 h2 = (visu.height + (visu.depth>1?visu.depth:0))*disp.
height/visu.height;
31585 case cimg::keyPADADD : go_in =
true; go_in_center =
true; key = 0;
break;
31591 case cimg::keyPAD7 : go_up = go_left =
true; key = 0;
break;
31592 case cimg::keyPAD9 : go_up = go_right =
true; key = 0;
break;
31593 case cimg::keyPAD1 : go_down = go_left =
true; key = 0;
break;
31594 case cimg::keyPAD3 : go_down = go_right =
true; key = 0;
break;
31604 int X = XYZ[0], Y = XYZ[1], Z = XYZ[2];
31605 if (mX<
dimx() && mY<
dimy()) { X = x0 + mX*(1+x1-x0)/
width; Y = y0 + mY*(1+y1-y0)/
height; Z = XYZ[2]; }
31608 if (x1-x0>4) { x0 = X - 7*(X-x0)/8; x1 = X + 7*(x1-X)/8; }
31609 if (y1-y0>4) { y0 = Y - 7*(Y-y0)/8; y1 = Y + 7*(y1-Y)/8; }
31610 if (z1-z0>4) { z0 = Z - 7*(Z-z0)/8; z1 = Z + 7*(z1-Z)/8; }
31614 deltax = (x1-x0)/8, deltay = (y1-y0)/8, deltaz = (z1-z0)/8,
31615 ndeltax = deltax?deltax:(
width>1?1:0),
31616 ndeltay = deltay?deltay:(
height>1?1:0),
31617 ndeltaz = deltaz?deltaz:(
depth>1?1:0);
31618 x0-=ndeltax; y0-=ndeltay; z0-=ndeltaz;
31619 x1+=ndeltax; y1+=ndeltay; z1+=ndeltaz;
31620 if (x0<0) { x1-=x0; x0 = 0;
if (x1>=
dimx()) x1 =
dimx()-1; }
31621 if (y0<0) { y1-=y0; y0 = 0;
if (y1>=
dimy()) y1 =
dimy()-1; }
31622 if (z0<0) { z1-=z0; z0 = 0;
if (z1>=
dimz()) z1 =
dimz()-1; }
31623 if (x1>=
dimx()) { x0-=(x1-
dimx()+1); x1 =
dimx()-1;
if (x0<0) x0 = 0; }
31624 if (y1>=
dimy()) { y0-=(y1-
dimy()+1); y1 =
dimy()-1;
if (y0<0) y0 = 0; }
31625 if (z1>=
dimz()) { z0-=(z1-
dimz()+1); z1 =
dimz()-1;
if (z0<0) z0 = 0; }
31628 const int delta = (x1-x0)/5, ndelta = delta?delta:(
width>1?1:0);
31629 if (x0-ndelta>=0) { x0-=ndelta; x1-=ndelta; }
31630 else { x1-=x0; x0 = 0; }
31633 const int delta = (x1-x0)/5, ndelta = delta?delta:(
width>1?1:0);
31634 if (x1+ndelta<
dimx()) { x0+=ndelta; x1+=ndelta; }
31635 else { x0+=(
dimx()-1-x1); x1 =
dimx()-1; }
31638 const int delta = (y1-y0)/5, ndelta = delta?delta:(
height>1?1:0);
31639 if (y0-ndelta>=0) { y0-=ndelta; y1-=ndelta; }
31640 else { y1-=y0; y0 = 0; }
31643 const int delta = (y1-y0)/5, ndelta = delta?delta:(
height>1?1:0);
31644 if (y1+ndelta<
dimy()) { y0+=ndelta; y1+=ndelta; }
31645 else { y0+=(
dimy()-1-y1); y1 =
dimy()-1; }
31648 const int delta = (z1-z0)/5, ndelta = delta?delta:(
depth>1?1:0);
31649 if (z0-ndelta>=0) { z0-=ndelta; z1-=ndelta; }
31650 else { z1-=z0; z0 = 0; }
31653 const int delta = (z1-z0)/5, ndelta = delta?delta:(
depth>1?1:0);
31654 if (z1+ndelta<
dimz()) { z0+=ndelta; z1+=ndelta; }
31663 template<
typename tp,
typename tf,
typename tc,
typename to>
31668 const to& opacities,
31669 const bool centering=
true,
31670 const int render_static=4,
const int render_motion=1,
31671 const bool double_sided=
true,
const float focale=500,
31672 const float specular_light=0.2f,
const float specular_shine=0.1f,
31673 const bool display_axes=
true,
float *
const pose_matrix=0)
const {
31674 return _display_object3d(disp,0,vertices,primitives,colors,opacities,centering,render_static,
31675 render_motion,double_sided,focale,specular_light,specular_shine,
31676 display_axes,pose_matrix);
31680 template<
typename tp,
typename tf,
typename tc,
typename to>
31685 const to& opacities,
31686 const bool centering=
true,
31687 const int render_static=4,
const int render_motion=1,
31688 const bool double_sided=
true,
const float focale=500,
31689 const float specular_light=0.2f,
const float specular_shine=0.1f,
31690 const bool display_axes=
true,
float *
const pose_matrix=0)
const {
31692 return _display_object3d(disp,title,vertices,primitives,colors,opacities,centering,render_static,
31693 render_motion,double_sided,focale,specular_light,specular_shine,
31694 display_axes,pose_matrix);
31698 template<
typename tp,
typename tf,
typename tc>
31703 const bool centering=
true,
31704 const int render_static=4,
const int render_motion=1,
31705 const bool double_sided=
true,
const float focale=500,
31706 const float specular_light=0.2f,
const float specular_shine=0.1f,
31707 const bool display_axes=
true,
float *
const pose_matrix=0)
const {
31709 render_static,render_motion,double_sided,focale,specular_light,specular_shine,
31710 display_axes,pose_matrix);
31714 template<
typename tp,
typename tf,
typename tc>
31719 const bool centering=
true,
31720 const int render_static=4,
const int render_motion=1,
31721 const bool double_sided=
true,
const float focale=500,
31722 const float specular_light=0.2f,
const float specular_shine=0.1f,
31723 const bool display_axes=
true,
float *
const pose_matrix=0)
const {
31725 render_static,render_motion,double_sided,focale,specular_light,specular_shine,
31726 display_axes,pose_matrix);
31730 template<
typename tp,
typename tf>
31734 const bool centering=
true,
31735 const int render_static=4,
const int render_motion=1,
31736 const bool double_sided=
true,
const float focale=500,
31737 const float specular_light=0.2f,
const float specular_shine=0.1f,
31738 const bool display_axes=
true,
float *
const pose_matrix=0)
const {
31740 render_static,render_motion,double_sided,focale,specular_light,specular_shine,
31741 display_axes,pose_matrix);
31745 template<
typename tp,
typename tf>
31749 const bool centering=
true,
31750 const int render_static=4,
const int render_motion=1,
31751 const bool double_sided=
true,
const float focale=500,
31752 const float specular_light=0.2f,
const float specular_shine=0.1f,
31753 const bool display_axes=
true,
float *
const pose_matrix=0)
const {
31755 render_static,render_motion,double_sided,focale,specular_light,specular_shine,
31756 display_axes,pose_matrix);
31760 template<
typename tp>
31763 const bool centering=
true,
31764 const int render_static=4,
const int render_motion=1,
31765 const bool double_sided=
true,
const float focale=500,
31766 const float specular_light=0.2f,
const float specular_shine=0.1f,
31767 const bool display_axes=
true,
float *
const pose_matrix=0)
const {
31769 render_static,render_motion,double_sided,focale,specular_light,specular_shine,
31770 display_axes,pose_matrix);
31774 template<
typename tp>
31777 const bool centering=
true,
31778 const int render_static=4,
const int render_motion=1,
31779 const bool double_sided=
true,
const float focale=500,
31780 const float specular_light=0.2f,
const float specular_shine=0.1f,
31781 const bool display_axes=
true,
float *
const pose_matrix=0)
const {
31783 render_static,render_motion,double_sided,focale,specular_light,specular_shine,
31784 display_axes,pose_matrix);
31787 template<
typename tp,
typename tf,
typename tc,
typename to>
31792 const to& opacities,
31793 const bool centering,
31794 const int render_static,
const int render_motion,
31795 const bool double_sided,
const float focale,
31796 const float specular_light,
const float specular_shine,
31797 const bool display_axes,
float *
const pose_matrix)
const {
31803 render_static,render_motion,double_sided,focale,specular_light,specular_shine,
31804 display_axes,pose_matrix);
31807 render_static,render_motion,double_sided,focale,specular_light,specular_shine,
31808 display_axes,pose_matrix);
31810 vertices.is_object3d(primitives,
true,
true);
31811 if (vertices.width && !primitives) {
31814 return _display_object3d(disp,title,vertices,nprimitives,colors,opacities,centering,
31815 render_static,render_motion,double_sided,focale,specular_light,specular_shine,
31816 display_axes,pose_matrix);
31819 char ntitle[256] = { 0 };
31820 if (!title) { std::sprintf(ntitle,
"CImg<%s> (%u vertices, %u primitives)",
pixel_type(),vertices.width,primitives.
width); }
31830 pose, rot_mat, zbuffer(disp.
width,disp.
height,1,1,0),
31832 rotated_vertices(vertices.width,3),
31833 bbox_vertices, rotated_bbox_vertices,
31834 axes_vertices, rotated_axes_vertices,
31835 bbox_opacities, axes_opacities;
31837 CImgList<T> bbox_colors, bbox_colors2, axes_colors;
31838 float dx = 0,
dy = 0, dz = 0, ratio = 1;
31840 T minval = (T)0, maxval = (T)255;
31842 minval = colors.
minmax(maxval);
31843 if (minval==maxval) { minval = (T)0; maxval = (T)255; }
31845 unsigned int ns_width = 0, ns_height = 0;
31846 const float meanval = (float)
mean();
31847 bool color_model =
true;
31850 background_color(1,1,1,dim,color_model?minval:maxval),
31851 foreground_color(1,1,1,dim,color_model?maxval:minval);
31855 const float x = (float)vertices(i,0), y = (float)vertices(i,1),
z = (float)vertices(i,2);
31863 const float delta =
cimg::max(xM-xm,yM-ym,zM-zm);
31865 if (display_axes) {
31866 rotated_axes_vertices = axes_vertices.assign(7,3,1,1,
31870 axes_opacities.assign(3,1,1,1,1);
31871 axes_colors.
assign(3,dim,1,1,1,foreground_color[0]);
31872 axes_primitives.
assign(3,1,2,1,1, 0,1, 0,2, 0,3);
31877 bool init =
true, clicked =
false, redraw =
true;
31878 unsigned int key = 0;
31879 int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
31887 dx = 0.5f*(xM + xm);
dy = 0.5f*(yM + ym); dz = 0.5f*(zM + zm);
31890 centered_vertices(l,0) = (float)((vertices(l,0) - dx)*ratio);
31891 centered_vertices(l,1) = (float)((vertices(l,1) -
dy)*ratio);
31892 centered_vertices(l,2) = (float)((vertices(l,2) - dz)*ratio);
31896 if (render_static<0 || render_motion<0) {
31897 rotated_bbox_vertices = bbox_vertices.assign(8,3,1,1,
31898 xm,xM,xM,xm,xm,xM,xM,xm,
31899 ym,ym,yM,yM,ym,ym,yM,yM,
31900 zm,zm,zm,zm,zM,zM,zM,zM);
31901 bbox_primitives.
assign(6,1,4,1,1, 0,3,2,1, 4,5,6,7, 1,2,6,5, 0,4,7,3, 0,1,5,4, 2,3,7,6);
31902 bbox_colors.
assign(6,dim,1,1,1,background_color[0]);
31903 bbox_colors2.
assign(6,dim,1,1,1,foreground_color[0]);
31904 bbox_opacities.assign(bbox_colors.
width,1,1,1,0.3f);
31908 if (pose_matrix) pose =
CImg<floatT>(pose_matrix,4,4,1,1,
false);
31918 r00 = pose(0,0), r10 = pose(1,0), r20 = pose(2,0), r30 = pose(3,0),
31919 r01 = pose(0,1), r11 = pose(1,1), r21 = pose(2,1), r31 = pose(3,1),
31920 r02 = pose(0,2), r12 = pose(1,2), r22 = pose(2,2), r32 = pose(3,2);
31921 if ((clicked && render_motion>=0) || (!clicked && render_static>=0)) {
31922 if (centering)
cimg_forX(centered_vertices,l) {
31923 const float x = centered_vertices(l,0), y = centered_vertices(l,1),
z = centered_vertices(l,2);
31924 rotated_vertices(l,0) = r00*x + r10*y + r20*
z + r30;
31925 rotated_vertices(l,1) = r01*x + r11*y + r21*
z + r31;
31926 rotated_vertices(l,2) = r02*x + r12*y + r22*
z + r32;
31929 x = (float)vertices(l,0),
31930 y = (float)vertices(l,1),
31931 z = (float)vertices(l,2);
31932 rotated_vertices(l,0) = r00*x + r10*y + r20*
z + r30;
31933 rotated_vertices(l,1) = r01*x + r11*y + r21*
z + r31;
31934 rotated_vertices(l,2) = r02*x + r12*y + r22*
z + r32;
31937 if (!centering)
cimg_forX(bbox_vertices,l) {
31938 const float x = bbox_vertices(l,0), y = bbox_vertices(l,1),
z = bbox_vertices(l,2);
31939 rotated_bbox_vertices(l,0) = r00*x + r10*y + r20*
z + r30;
31940 rotated_bbox_vertices(l,1) = r01*x + r11*y + r21*
z + r31;
31941 rotated_bbox_vertices(l,2) = r02*x + r12*y + r22*
z + r32;
31943 const float x = (bbox_vertices(l,0) -
dx)*ratio, y = (bbox_vertices(l,1) -
dy)*ratio,
z = (bbox_vertices(l,2) - dz)*ratio;
31944 rotated_bbox_vertices(l,0) = r00*x + r10*y + r20*
z + r30;
31945 rotated_bbox_vertices(l,1) = r01*x + r11*y + r21*
z + r31;
31946 rotated_bbox_vertices(l,2) = r02*x + r12*y + r22*
z + r32;
31952 if ((clicked && render_motion<0) || (!clicked && render_static<0))
31953 visu.draw_object3d(visu.width/2.0f,visu.height/2.0f,0,rotated_bbox_vertices,bbox_primitives,bbox_colors,bbox_opacities,2,
false,focale).
31954 draw_object3d(visu.width/2.0f,visu.height/2.0f,0,rotated_bbox_vertices,bbox_primitives,bbox_colors2,1,
false,focale);
31955 else visu.draw_object3d(visu.width/2.0f,visu.height/2.0f,0,
31956 rotated_vertices,primitives,ncolors,opacities,clicked?render_motion:render_static,
31957 double_sided,focale,visu.dimx()/2.0f,visu.dimy()/2.0f,-5000,specular_light,specular_shine,
31961 if (display_axes) {
31962 const float Xaxes = 25, Yaxes = visu.height - 35.0f;
31964 const float x = axes_vertices(l,0), y = axes_vertices(l,1),
z = axes_vertices(l,2);
31965 rotated_axes_vertices(l,0) = r00*x + r10*y + r20*
z;
31966 rotated_axes_vertices(l,1) = r01*x + r11*y + r21*
z;
31967 rotated_axes_vertices(l,2) = r02*x + r12*y + r22*
z;
31969 axes_opacities(0,0) = (rotated_axes_vertices(1,2)>0)?0.5f:1.0f;
31970 axes_opacities(1,0) = (rotated_axes_vertices(2,2)>0)?0.5f:1.0f;
31971 axes_opacities(2,0) = (rotated_axes_vertices(3,2)>0)?0.5f:1.0f;
31972 visu.draw_object3d(Xaxes,Yaxes,0,rotated_axes_vertices,axes_primitives,axes_colors,axes_opacities,1,
false,focale).
31973 draw_text((
int)(Xaxes+rotated_axes_vertices(4,0)),
31974 (
int)(Yaxes+rotated_axes_vertices(4,1)),
31975 "X",axes_colors[0].
data,0,axes_opacities(0,0),11).
31976 draw_text((
int)(Xaxes+rotated_axes_vertices(5,0)),
31977 (
int)(Yaxes+rotated_axes_vertices(5,1)),
31978 "Y",axes_colors[1].data,0,axes_opacities(1,0),11).
31979 draw_text((
int)(Xaxes+rotated_axes_vertices(6,0)),
31980 (
int)(Yaxes+rotated_axes_vertices(6,1)),
31981 "Z",axes_colors[2].data,0,axes_opacities(2,0),11);
31983 visu.display(disp);
31984 if (!clicked || render_motion==render_static) redraw =
false;
31991 if (!clicked) { x0 = x1 = disp.
mouse_x; y0 = y1 = disp.
mouse_y;
if (!disp.
wheel) clicked =
true; }
31997 u0 = (float)(x0-disp.
dimx()/2),
31998 v0 = (
float)(y0-disp.
dimy()/2),
31999 u1 = (
float)(x1-disp.
dimx()/2),
32000 v1 = (
float)(y1-disp.
dimy()/2),
32003 nu0 = n0>R?(u0*R/n0):u0,
32004 nv0 = n0>R?(v0*R/n0):v0,
32006 nu1 = n1>R?(u1*R/n1):u1,
32007 nv1 = n1>R?(v1*R/n1):v1,
32009 u = nv0*nw1-nw0*nv1,
32010 v = nw0*nu1-nu0*nw1,
32011 w = nv0*nu1-nu0*nv1,
32015 rot_mat *= pose.get_crop(0,0,2,2);
32016 pose.draw_image(rot_mat);
32019 if (disp.
button&2) { pose(3,2)+=(y1-y0); x0 = x1; y0 = y1; }
32021 if (disp.
button&4) { pose(3,0)+=(x1-x0); pose(3,1)+=(y1-y0); x0 = x1; y0 = y1; }
32023 }
else if (clicked) { x0 = x1; y0 = y1; clicked =
false; redraw =
true; }
32025 switch (key = disp.
key) {
32030 disp.
key = key = 0;
32034 disp.
key = key = 0;
32038 disp.
key = key = 0;
32041 if (!ns_width || !ns_height ||
32048 ns_width = (
unsigned int)disp.
width; ns_height = disp.
height;
32052 disp.
key = key = 0;
32055 if (zbuffer) zbuffer.assign();
32056 else zbuffer.assign(disp.
width,disp.
height,1,1,0);
32057 disp.
key = key = 0; redraw =
true;
32060 static unsigned int snap_number = 0;
32061 char filename[32] = { 0 };
32064 std::sprintf(filename,
"CImg_%.4u.bmp",snap_number++);
32067 (+visu).
draw_text(2,2,
"Saving BMP snapshot...",foreground_color,background_color,1,11).display(disp);
32068 visu.save(filename);
32069 visu.draw_text(2,2,
"Snapshot '%s' saved.",foreground_color,background_color,1,11,filename).display(disp);
32070 disp.
key = key = 0;
32073 static unsigned int snap_number = 0;
32074 char filename[32] = { 0 };
32077 std::sprintf(filename,
"CImg_%.4u.off",snap_number++);
32080 visu.draw_text(2,2,
"Saving object...",foreground_color,background_color,1,11).display(disp);
32081 vertices.save_off(filename,primitives,ncolors);
32082 visu.draw_text(2,2,
"Object '%s' saved.",foreground_color,background_color,1,11,filename).display(disp);
32083 disp.
key = key = 0;
32085 #ifdef cimg_use_board
32087 static unsigned int snap_number = 0;
32088 char filename[32] = { 0 };
32091 std::sprintf(filename,
"CImg_%.4u.eps",snap_number++);
32094 visu.draw_text(2,2,
"Saving EPS snapshot...",foreground_color,background_color,1,11).display(disp);
32095 LibBoard::Board board;
32096 (+visu).
draw_object3d(board,visu.width/2.0f,visu.height/2.0f,0,
32097 rotated_vertices,primitives,ncolors,opacities,clicked?render_motion:render_static,
32098 double_sided,focale,visu.dimx()/2.0f,visu.dimy()/2.0f,-5000,specular_light,specular_shine,
32100 board.saveEPS(filename);
32101 visu.draw_text(2,2,
"Object '%s' saved.",foreground_color,background_color,1,11,filename).display(disp);
32102 disp.
key = key = 0;
32105 static unsigned int snap_number = 0;
32106 char filename[32] = { 0 };
32109 std::sprintf(filename,
"CImg_%.4u.svg",snap_number++);
32112 visu.draw_text(2,2,
"Saving SVG snapshot...",foreground_color,background_color,1,11).display(disp);
32113 LibBoard::Board board;
32114 (+visu).
draw_object3d(board,visu.width/2.0f,visu.height/2.0f,0,
32115 rotated_vertices,primitives,ncolors,opacities,clicked?render_motion:render_static,
32116 double_sided,focale,visu.dimx()/2.0f,visu.dimy()/2.0f,-5000,specular_light,specular_shine,
32118 board.saveSVG(filename);
32119 visu.draw_text(2,2,
"Object '%s' saved.",foreground_color,background_color,1,11,filename).display(disp);
32120 disp.
key = key = 0;
32126 if (pose_matrix) std::memcpy(pose_matrix,pose.data,16*
sizeof(
float));
32134 const unsigned int plot_type=1,
const unsigned int vertex_type=1,
32135 const char *
const labelx=0,
const double xmin=0,
const double xmax=0,
32136 const char *
const labely=0,
const double ymin=0,
const double ymax=0)
const {
32138 throw CImgInstanceException(
"CImg<%s>::display_graph() : Instance image (%u,%u,%u,%u,%p) is empty.",
32141 if (!disp) {
char ntitle[64] = { 0 }; std::sprintf(ntitle,
"CImg<%s>",
pixel_type()); disp.
assign(640,480,ntitle,0); }
32143 double y0 = ymin, y1 = ymax, nxmin = xmin, nxmax = xmax;
32144 if (nxmin==nxmax) { nxmin = 0; nxmax = siz; }
32147 for (
bool reset_view =
true, resize_disp =
false; !
key && !disp.
is_closed; ) {
32148 if (reset_view) { x0 = 0; x1 =
dimx()*
dimy()*
dimz()-1; y0 = ymin; y1 = ymax; reset_view =
false; }
32152 if (y0==y1) y0 = zoom.minmax(y1);
32153 if (y0==y1) { --y0; ++y1; }
32154 const CImg<intT> selection = zoom.get_select_graph(disp,plot_type,vertex_type,
32155 labelx,nxmin + x0*(nxmax-nxmin)/siz,nxmin + (x1+1)*(nxmax-nxmin)/siz,
32159 if (selection[0]>=0 && selection[2]>=0) {
32160 x1 = x0 + selection[2];
32161 x0 += selection[0];
32162 if (x0==x1) reset_view =
true;
32163 if (selection[1]>=0 && selection[3]>=0) {
32164 y0 = y1 - selection[3]*(y1-y0)/(disp.
dimy()-32);
32165 y1 -= selection[1]*(y1-y0)/(disp.
dimy()-32);
32168 bool go_in =
false, go_out =
false, go_left =
false, go_right =
false, go_up =
false, go_down =
false;
32169 switch (
key = disp.
key) {
32182 if (disp.
wheel) go_out = !(go_in = disp.
wheel>0);
32187 mx = (mouse_x-16)*xsiz/(disp.
dimx()-32),
32188 cx = x0 + (mx<0?0:(mx>=xsiz?xsiz:mx));
32190 x0 = cx - 7*(cx-x0)/8; x1 = cx + 7*(x1-cx)/8;
32194 my = (mouse_y-16)*ysiz/(disp.
dimy()-32),
32195 cy = y1 - (my<0?0:(my>=ysiz?ysiz:my));
32196 y0 = cy - 7*(cy-y0)/8; y1 = cy + 7*(y1-cy)/8;
32197 }
else y0 = y1 = 0;
32201 const int deltax = (x1-x0)/8, ndeltax = deltax?deltax:(siz>1?1:0);
32202 x0-=ndeltax; x1+=ndeltax;
32203 if (x0<0) { x1-=x0; x0 = 0;
if (x1>=(
int)siz) x1 = (
int)siz-1; }
32204 if (x1>=(
int)siz) { x0-=(x1-siz+1); x1 = (int)siz-1;
if (x0<0) x0 = 0; }
32206 const double deltay = (y1-y0)/8, ndeltay = deltay?deltay:0.01;
32207 y0-=ndeltay; y1+=ndeltay;
32211 const int delta = (x1-x0)/5, ndelta = delta?delta:1;
32212 if (x0-ndelta>=0) { x0-=ndelta; x1-=ndelta; }
32213 else { x1-=x0; x0 = 0; }
32217 const int delta = (x1-x0)/5, ndelta = delta?delta:1;
32218 if (x1+ndelta<(
int)siz) { x0+=ndelta; x1+=ndelta; }
32219 else { x0+=(siz-1-x1); x1 = siz-1; }
32223 const double delta = (y1-y0)/10, ndelta = delta?delta:1;
32224 y0+=ndelta; y1+=ndelta;
32228 const double delta = (y1-y0)/10, ndelta = delta?delta:1;
32229 y0-=ndelta; y1-=ndelta;
32240 const unsigned int plot_type=1,
const unsigned int vertex_type=1,
32241 const char *
const labelx=0,
const double xmin=0,
const double xmax=0,
32242 const char *
const labely=0,
const double ymin=0,
const double ymax=0)
const {
32244 throw CImgInstanceException(
"CImg<%s>::display_graph() : Instance image (%u,%u,%u,%u,%p) is empty.",
32246 char ntitle[64] = { 0 };
if (!title) std::sprintf(ntitle,
"CImg<%s>",
pixel_type());
32248 return display_graph(disp,plot_type,vertex_type,labelx,xmin,xmax,labely,ymin,ymax);
32256 const CImg<T>&
save(
const char *
const filename,
const int number=-1)
const {
32258 throw CImgInstanceException(
"CImg<%s>::save() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
32261 throw CImgArgumentException(
"CImg<%s>::save() : Instance image (%u,%u,%u,%u,%p) cannot be saved as a (null) filename.",
32264 char nfilename[1024] = { 0 };
32266 #ifdef cimg_save_plugin
32267 cimg_save_plugin(fn);
32269 #ifdef cimg_save_plugin1
32270 cimg_save_plugin1(fn);
32272 #ifdef cimg_save_plugin2
32273 cimg_save_plugin2(fn);
32275 #ifdef cimg_save_plugin3
32276 cimg_save_plugin3(fn);
32278 #ifdef cimg_save_plugin4
32279 cimg_save_plugin4(fn);
32281 #ifdef cimg_save_plugin5
32282 cimg_save_plugin5(fn);
32284 #ifdef cimg_save_plugin6
32285 cimg_save_plugin6(fn);
32287 #ifdef cimg_save_plugin7
32288 cimg_save_plugin7(fn);
32290 #ifdef cimg_save_plugin8
32291 cimg_save_plugin8(fn);
32359 throw CImgInstanceException(
"CImg<%s>::save_ascii() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
32361 if (!file && !filename)
32362 throw CImgArgumentException(
"CImg<%s>::save_ascii() : Instance image (%u,%u,%u,%u,%p), specified file is (null).",
32364 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"w");
32366 const T* ptrs =
data;
32368 cimg_forX(*
this,x) std::fprintf(nfile,
"%g ",(
double)*(ptrs++));
32369 std::fputc(
'\n',nfile);
32387 if (!file && !filename)
32388 throw CImgArgumentException(
"CImg<%s>::save_cpp() : Instance image (%u,%u,%u,%u,%p), specified file is (null).",
32391 throw CImgInstanceException(
"CImg<%s>::save_cpp() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
32393 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"w");
32394 char varname[1024] = { 0 };
32395 if (filename) std::sscanf(
cimg::basename(filename),
"%1023[a-zA-Z0-9_]",varname);
32396 if (!*varname) std::sprintf(varname,
"unnamed");
32397 std::fprintf(nfile,
32398 "/* Define image '%s' of size %ux%ux%ux%u and type '%s' */\n"
32399 "%s data_%s[] = { \n ",
32401 for (
unsigned int off = 0, siz =
size()-1; off<=siz; ++off) {
32403 if (off==siz) std::fprintf(nfile,
" };\n");
32404 else if (!((off+1)%16)) std::fprintf(nfile,
",\n ");
32405 else std::fprintf(nfile,
", ");
32424 throw CImgInstanceException(
"CImg<%s>::save_dlm() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
32426 if (!file && !filename)
32427 throw CImgArgumentException(
"CImg<%s>::save_dlm() : Instance image (%u,%u,%u,%u,%p), specified file is (null).",
32430 cimg::warn(
"CImg<%s>::save_dlm() : File '%s', instance image (%u,%u,%u,%u,%p) is volumetric. Pixel values along Z will be unrolled.",
32433 cimg::warn(
"CImg<%s>::save_dlm() : File '%s', instance image (%u,%u,%u,%u,%p) is multispectral. "
32434 "Pixel values along V will be unrolled.",
32437 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"w");
32438 const T* ptrs =
data;
32440 cimg_forX(*
this,x) std::fprintf(nfile,
"%g%s",(
double)*(ptrs++),(x==
dimx()-1)?
"":
",");
32441 std::fputc(
'\n',nfile);
32460 throw CImgInstanceException(
"CImg<%s>::save_bmp() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
32462 if (!file && !filename)
32463 throw CImgArgumentException(
"CImg<%s>::save_bmp() : Instance image (%u,%u,%u,%u,%p), specified file is (null).",
32466 cimg::warn(
"CImg<%s>::save_bmp() : File '%s', instance image (%u,%u,%u,%u,%p) is volumetric. Only the first slice will be saved.",
32469 cimg::warn(
"CImg<%s>::save_bmp() : File '%s', instance image (%u,%u,%u,%u,%p) is multispectral. Only the three first channels will be saved.",
32472 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"wb");
32473 unsigned char header[54] = { 0 }, align_buf[4] = { 0 };
32475 align = (4 - (3*
width)%4)%4,
32477 file_size = 54 + buf_size;
32478 header[0] =
'B'; header[1] =
'M';
32479 header[0x02] = file_size&0xFF;
32480 header[0x03] = (file_size>>8)&0xFF;
32481 header[0x04] = (file_size>>16)&0xFF;
32482 header[0x05] = (file_size>>24)&0xFF;
32483 header[0x0A] = 0x36;
32484 header[0x0E] = 0x28;
32485 header[0x12] =
width&0xFF;
32486 header[0x13] = (
width>>8)&0xFF;
32487 header[0x14] = (
width>>16)&0xFF;
32488 header[0x15] = (
width>>24)&0xFF;
32489 header[0x16] =
height&0xFF;
32490 header[0x17] = (
height>>8)&0xFF;
32491 header[0x18] = (
height>>16)&0xFF;
32492 header[0x19] = (
height>>24)&0xFF;
32497 header[0x22] = buf_size&0xFF;
32498 header[0x23] = (buf_size>>8)&0xFF;
32499 header[0x24] = (buf_size>>16)&0xFF;
32500 header[0x25] = (buf_size>>24)&0xFF;
32501 header[0x27] = 0x1;
32502 header[0x2B] = 0x1;
32513 const unsigned char val = (
unsigned char)*(pR++);
32514 std::fputc(val,nfile); std::fputc(val,nfile); std::fputc(val,nfile);
32521 std::fputc(0,nfile);
32522 std::fputc((
unsigned char)(*(pG++)),nfile);
32523 std::fputc((
unsigned char)(*(pR++)),nfile);
32530 std::fputc((
unsigned char)(*(pB++)),nfile);
32531 std::fputc((
unsigned char)(*(pG++)),nfile);
32532 std::fputc((
unsigned char)(*(pR++)),nfile);
32554 const CImg<T>&
_save_jpeg(std::FILE *
const file,
const char *
const filename,
const unsigned int quality)
const {
32556 throw CImgInstanceException(
"CImg<%s>::save_jpeg() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
32558 if (!file && !filename)
32559 throw CImgArgumentException(
"CImg<%s>::save_jpeg() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).",
32562 cimg::warn(
"CImg<%s>::save_jpeg() : File '%s, instance image (%u,%u,%u,%u,%p) is volumetric. Only the first slice will be saved.",
32564 #ifndef cimg_use_jpeg
32565 if (!file)
return save_other(filename,quality);
32566 else throw CImgIOException(
"CImg<%s>::save_jpeg() : Cannot save a JPEG image in a *FILE output. Use libjpeg instead.",
32570 unsigned char *buf;
32571 unsigned int dimbuf = 0;
32572 J_COLOR_SPACE colortype = JCS_RGB;
32575 unsigned char *buf2 = buf =
new unsigned char[
width*
height*(dimbuf=1)];
32576 colortype = JCS_GRAYSCALE;
32577 const T *ptr_g =
data;
32578 cimg_forXY(*
this,x,y) *(buf2++) = (
unsigned char)*(ptr_g++);
32581 unsigned char *buf2 = buf =
new unsigned char[
width*
height*(dimbuf=3)];
32582 const T *ptr_r =
ptr(0,0,0,0), *ptr_g =
ptr(0,0,0,1);
32583 colortype = JCS_RGB;
32585 *(buf2++) = (
unsigned char)*(ptr_r++);
32586 *(buf2++) = (
unsigned char)*(ptr_g++);
32591 unsigned char *buf2 = buf =
new unsigned char[
width*
height*(dimbuf=3)];
32592 const T *ptr_r =
ptr(0,0,0,0), *ptr_g =
ptr(0,0,0,1), *ptr_b =
ptr(0,0,0,2);
32593 colortype = JCS_RGB;
32595 *(buf2++) = (
unsigned char)*(ptr_r++);
32596 *(buf2++) = (
unsigned char)*(ptr_g++);
32597 *(buf2++) = (
unsigned char)*(ptr_b++);
32601 unsigned char *buf2 = buf =
new unsigned char[
width*
height*(dimbuf=4)];
32602 const T *ptr_r =
ptr(0,0,0,0), *ptr_g =
ptr(0,0,0,1), *ptr_b =
ptr(0,0,0,2), *ptr_a =
ptr(0,0,0,3);
32603 colortype = JCS_CMYK;
32605 *(buf2++) = (
unsigned char)*(ptr_r++);
32606 *(buf2++) = (
unsigned char)*(ptr_g++);
32607 *(buf2++) = (
unsigned char)*(ptr_b++);
32608 *(buf2++) = (
unsigned char)*(ptr_a++);
32614 struct jpeg_compress_struct cinfo;
32615 struct jpeg_error_mgr jerr;
32616 cinfo.err = jpeg_std_error(&jerr);
32617 jpeg_create_compress(&cinfo);
32618 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"wb");
32619 jpeg_stdio_dest(&cinfo,nfile);
32620 cinfo.image_width =
width;
32621 cinfo.image_height =
height;
32622 cinfo.input_components = dimbuf;
32623 cinfo.in_color_space = colortype;
32624 jpeg_set_defaults(&cinfo);
32625 jpeg_set_quality(&cinfo,quality<100?quality:100,
TRUE);
32626 jpeg_start_compress(&cinfo,
TRUE);
32628 const unsigned int row_stride =
width*dimbuf;
32629 JSAMPROW row_pointer[1];
32630 while (cinfo.next_scanline < cinfo.image_height) {
32631 row_pointer[0] = &buf[cinfo.next_scanline*row_stride];
32632 jpeg_write_scanlines(&cinfo,row_pointer,1);
32634 jpeg_finish_compress(&cinfo);
32638 jpeg_destroy_compress(&cinfo);
32656 throw CImgInstanceException(
"CImg<%s>::save_magick() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
32659 throw CImgArgumentException(
"CImg<%s>::save_magick() : Instance image (%u,%u,%u,%u,%p), specified file is (null).",
32661 unsigned int foo = bytes_per_pixel; foo = 0;
32662 #ifdef cimg_use_magick
32663 double stmin, stmax = (double)
maxmin(stmin);
32665 cimg::warn(
"CImg<%s>::save_magick() : File '%s', instance image (%u,%u,%u,%u,%p) is volumetric. Only the first slice will be saved.",
32668 cimg::warn(
"CImg<%s>::save_magick() : File '%s', instance image (%u,%u,%u,%u,%p) is multispectral. Only the three first channels will be saved.",
32670 if (stmin<0 || (bytes_per_pixel==1 && stmax>=256) || stmax>=65536)
32671 cimg::warn(
"CImg<%s>::save_magick() : File '%s', instance image (%u,%u,%u,%u,%p) has pixel values in [%g,%g]. Probable type overflow.",
32673 Magick::Image image(Magick::Geometry(
width,
height),
"black");
32674 image.type(Magick::TrueColorType);
32675 image.depth(bytes_per_pixel?(8*bytes_per_pixel):(stmax>=256?16:8));
32677 *rdata =
ptr(0,0,0,0),
32678 *gdata = dim>1?
ptr(0,0,0,1):0,
32679 *bdata = dim>2?
ptr(0,0,0,2):0;
32680 Magick::PixelPacket *pixels = image.getPixels(0,0,
width,
height);
32683 for (
unsigned int off =
width*
height; off; --off) {
32684 pixels->red = pixels->green = pixels->blue = (Magick::Quantum)*(rdata++);
32689 for (
unsigned int off =
width*
height; off; --off) {
32690 pixels->red = (Magick::Quantum)*(rdata++);
32691 pixels->green = (Magick::Quantum)*(gdata++);
32692 pixels->blue = 0; ++pixels;
32696 for (
unsigned int off =
width*
height; off; --off) {
32697 pixels->red = (Magick::Quantum)*(rdata++);
32698 pixels->green = (Magick::Quantum)*(gdata++);
32699 pixels->blue = (Magick::Quantum)*(bdata++);
32703 image.syncPixels();
32704 image.write(filename);
32706 throw CImgIOException(
"CImg<%s>::save_magick() : File '%s', Magick++ library has not been linked.",
32714 const CImg<T>&
_save_png(std::FILE *
const file,
const char *
const filename,
const unsigned int bytes_per_pixel=0)
const {
32716 throw CImgInstanceException(
"CImg<%s>::save_png() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
32719 throw CImgArgumentException(
"CImg<%s>::save_png() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).",
32722 cimg::warn(
"CImg<%s>::save_png() : File '%s', instance image (%u,%u,%u,%u,%p) is volumetric. Only the first slice will be saved.",
32724 unsigned int foo = bytes_per_pixel; foo = 0;
32725 #ifndef cimg_use_png
32727 else throw CImgIOException(
"CImg<%s>::save_png() : Cannot save a PNG image in a *FILE output. You must use 'libpng' to do this instead.",
32730 const char *
volatile nfilename = filename;
32731 std::FILE *
volatile nfile = file?file:
cimg::fopen(nfilename,
"wb");
32733 double stmin, stmax = (double)
maxmin(stmin);
32735 cimg::warn(
"CImg<%s>::save_magick() : File '%s', instance image (%u,%u,%u,%u,%p) is volumetric. Only the first slice will be saved.",
32738 cimg::warn(
"CImg<%s>::save_magick() : File '%s', instance image (%u,%u,%u,%u,%p) is multispectral. Only the three first channels will be saved.",
32740 if (stmin<0 || (bytes_per_pixel==1 && stmax>=256) || stmax>=65536)
32741 cimg::warn(
"CImg<%s>::save_magick() : File '%s', instance image (%u,%u,%u,%u,%p) has pixel values in [%g,%g]. Probable type overflow.",
32745 png_voidp user_error_ptr = 0;
32746 png_error_ptr user_error_fn = 0, user_warning_fn = 0;
32747 png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,user_error_ptr, user_error_fn, user_warning_fn);
32750 throw CImgIOException(
"CImg<%s>::save_png() : File '%s', error when initializing 'png_ptr' data structure.",
32751 pixel_type(),nfilename?nfilename:
"(FILE*)");
32753 png_infop info_ptr = png_create_info_struct(png_ptr);
32755 png_destroy_write_struct(&png_ptr,(png_infopp)0);
32757 throw CImgIOException(
"CImg<%s>::save_png() : File '%s', error when initializing 'info_ptr' data structure.",
32758 pixel_type(),nfilename?nfilename:
"(FILE*)");
32760 if (setjmp(png_jmpbuf(png_ptr))) {
32761 png_destroy_write_struct(&png_ptr, &info_ptr);
32763 throw CImgIOException(
"CImg<%s>::save_png() : File '%s', unknown fatal error.",
32764 pixel_type(),nfilename?nfilename:
"(FILE*)");
32766 png_init_io(png_ptr, nfile);
32768 const int bit_depth = bytes_per_pixel?(bytes_per_pixel*8):(stmax>=256?16:8);
32771 case 1 : color_type = PNG_COLOR_TYPE_GRAY;
break;
32772 case 2 : color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
break;
32773 case 3 : color_type = PNG_COLOR_TYPE_RGB;
break;
32774 default : color_type = PNG_COLOR_TYPE_RGB_ALPHA;
32776 const int interlace_type = PNG_INTERLACE_NONE;
32777 const int compression_type = PNG_COMPRESSION_TYPE_DEFAULT;
32778 const int filter_method = PNG_FILTER_TYPE_DEFAULT;
32779 png_set_IHDR(png_ptr, info_ptr, width,
height, bit_depth, color_type, interlace_type,compression_type, filter_method);
32780 png_write_info(png_ptr, info_ptr);
32781 const int byte_depth = bit_depth>>3;
32782 const int numChan =
dimv()>4?4:
dimv();
32783 const int pixel_bit_depth_flag = numChan * (bit_depth-1);
32786 png_bytep *imgData =
new png_byte*[
height];
32787 for (
unsigned int row = 0; row<
height; ++row) imgData[row] =
new png_byte[byte_depth*numChan*width];
32788 const T *pC0 =
ptr(0,0,0,0);
32789 switch (pixel_bit_depth_flag) {
32792 unsigned char *ptrd = imgData[
y];
32793 cimg_forX(*
this,x) *(ptrd++) = (
unsigned char)*(pC0++);
32797 const T *pC1 =
ptr(0,0,0,1);
32799 unsigned char *ptrd = imgData[
y];
32801 *(ptrd++) = (
unsigned char)*(pC0++);
32802 *(ptrd++) = (
unsigned char)*(pC1++);
32807 const T *pC1 =
ptr(0,0,0,1), *pC2 =
ptr(0,0,0,2);
32809 unsigned char *ptrd = imgData[
y];
32811 *(ptrd++) = (
unsigned char)*(pC0++);
32812 *(ptrd++) = (
unsigned char)*(pC1++);
32813 *(ptrd++) = (
unsigned char)*(pC2++);
32818 const T *pC1 =
ptr(0,0,0,1), *pC2 =
ptr(0,0,0,2), *pC3 =
ptr(0,0,0,3);
32820 unsigned char *ptrd = imgData[
y];
32822 *(ptrd++) = (
unsigned char)*(pC0++);
32823 *(ptrd++) = (
unsigned char)*(pC1++);
32824 *(ptrd++) = (
unsigned char)*(pC2++);
32825 *(ptrd++) = (
unsigned char)*(pC3++);
32831 unsigned short *ptrd = (
unsigned short*)(imgData[y]);
32832 cimg_forX(*
this,x) *(ptrd++) = (
unsigned short)*(pC0++);
32837 const T *pC1 =
ptr(0,0,0,1);
32839 unsigned short *ptrd = (
unsigned short*)(imgData[y]);
32841 *(ptrd++) = (
unsigned short)*(pC0++);
32842 *(ptrd++) = (
unsigned short)*(pC1++);
32848 const T *pC1 =
ptr(0,0,0,1), *pC2 =
ptr(0,0,0,2);
32850 unsigned short *ptrd = (
unsigned short*)(imgData[y]);
32852 *(ptrd++) = (
unsigned short)*(pC0++);
32853 *(ptrd++) = (
unsigned short)*(pC1++);
32854 *(ptrd++) = (
unsigned short)*(pC2++);
32860 const T *pC1 =
ptr(0,0,0,1), *pC2 =
ptr(0,0,0,2), *pC3 =
ptr(0,0,0,3);
32862 unsigned short *ptrd = (
unsigned short*)(imgData[y]);
32864 *(ptrd++) = (
unsigned short)*(pC0++);
32865 *(ptrd++) = (
unsigned short)*(pC1++);
32866 *(ptrd++) = (
unsigned short)*(pC2++);
32867 *(ptrd++) = (
unsigned short)*(pC3++);
32874 throw CImgIOException(
"CImg<%s>::save_png() : File '%s', unknown fatal error.",
32875 pixel_type(),nfilename?nfilename:
"(FILE*)");
32877 png_write_image(png_ptr, imgData);
32878 png_write_end(png_ptr, info_ptr);
32879 png_destroy_write_struct(&png_ptr, &info_ptr);
32890 const CImg<T>&
save_png(
const char *
const filename,
const unsigned int bytes_per_pixel=0)
const {
32891 return _save_png(0,filename,bytes_per_pixel);
32896 return _save_png(file,0,bytes_per_pixel);
32900 const CImg<T>&
_save_pnm(std::FILE *
const file,
const char *
const filename,
const unsigned int bytes_per_pixel=0)
const {
32901 if (!file && !filename)
32902 throw CImgArgumentException(
"CImg<%s>::save_pnm() : Instance image (%u,%u,%u,%u,%p), specified file is (null).",
32905 throw CImgInstanceException(
"CImg<%s>::save_pnm() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
32907 double stmin, stmax = (double)
maxmin(stmin);
32909 cimg::warn(
"CImg<%s>::save_pnm() : File '%s', instance image (%u,%u,%u,%u,%p) is volumetric. Only the first slice will be saved.",
32912 cimg::warn(
"CImg<%s>::save_pnm() : File '%s', instance image (%u,%u,%u,%u,%p) is multispectral. Only the three first channels will be saved.",
32914 if (stmin<0 || (bytes_per_pixel==1 && stmax>=256) || stmax>=65536)
32915 cimg::warn(
"CImg<%s>::save_pnm() : File '%s', instance image (%u,%u,%u,%u,%p) has pixel values in [%g,%g]. Probable type overflow.",
32917 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"wb");
32919 *ptrR =
ptr(0,0,0,0),
32920 *ptrG = (dim>=2)?
ptr(0,0,0,1):0,
32921 *ptrB = (dim>=3)?
ptr(0,0,0,2):0;
32922 const unsigned int buf_size =
width*
height*(dim==1?1:3);
32924 std::fprintf(nfile,
"P%c\n# CREATOR: CImg Library (original size = %ux%ux%ux%u)\n%u %u\n%u\n",
32929 if (bytes_per_pixel==1 || (!bytes_per_pixel && stmax<256)) {
32930 unsigned char *ptrd =
new unsigned char[buf_size], *xptrd = ptrd;
32931 cimg_forXY(*
this,x,y) *(xptrd++) = (
unsigned char)*(ptrR++);
32935 unsigned short *ptrd =
new unsigned short[buf_size], *xptrd = ptrd;
32936 cimg_forXY(*
this,x,y) *(xptrd++) = (
unsigned short)*(ptrR++);
32943 if (bytes_per_pixel==1 || (!bytes_per_pixel && stmax<256)) {
32944 unsigned char *ptrd =
new unsigned char[buf_size], *xptrd = ptrd;
32946 *(xptrd++) = (
unsigned char)*(ptrR++);
32947 *(xptrd++) = (
unsigned char)*(ptrG++);
32953 unsigned short *ptrd =
new unsigned short[buf_size], *xptrd = ptrd;
32955 *(xptrd++) = (
unsigned short)*(ptrR++);
32956 *(xptrd++) = (
unsigned short)*(ptrG++);
32965 if (bytes_per_pixel==1 || (!bytes_per_pixel && stmax<256)) {
32966 unsigned char *ptrd =
new unsigned char[buf_size], *xptrd = ptrd;
32968 *(xptrd++) = (
unsigned char)*(ptrR++);
32969 *(xptrd++) = (
unsigned char)*(ptrG++);
32970 *(xptrd++) = (
unsigned char)*(ptrB++);
32975 unsigned short *ptrd =
new unsigned short[buf_size], *xptrd = ptrd;
32977 *(xptrd++) = (
unsigned short)*(ptrR++);
32978 *(xptrd++) = (
unsigned short)*(ptrG++);
32979 *(xptrd++) = (
unsigned short)*(ptrB++);
32992 const CImg<T>&
save_pnm(
const char *
const filename,
const unsigned int bytes_per_pixel=0)
const {
32993 return _save_pnm(0,filename,bytes_per_pixel);
32998 return _save_pnm(file,0,bytes_per_pixel);
33004 throw CImgInstanceException(
"CImg<%s>::save_rgb() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33006 if (!file && !filename)
33007 throw CImgArgumentException(
"CImg<%s>::save_rgb() : Instance image (%u,%u,%u,%u,%p), specified file is (null).",
33010 cimg::warn(
"CImg<%s>::save_rgb() : File '%s', instance image (%u,%u,%u,%u,%p) has not exactly 3 channels.",
33012 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"wb");
33014 unsigned char *buffer =
new unsigned char[3*wh], *nbuffer=buffer;
33016 *ptr1 =
ptr(0,0,0,0),
33017 *ptr2 = dim>1?
ptr(0,0,0,1):0,
33018 *ptr3 = dim>2?
ptr(0,0,0,2):0;
33021 for (
unsigned int k = 0;
k<wh; ++
k) {
33022 const unsigned char val = (
unsigned char)*(ptr1++);
33023 *(nbuffer++) = val;
33024 *(nbuffer++) = val;
33025 *(nbuffer++) = val;
33028 for (
unsigned int k = 0;
k<wh; ++
k) {
33029 *(nbuffer++) = (
unsigned char)(*(ptr1++));
33030 *(nbuffer++) = (
unsigned char)(*(ptr2++));
33034 for (
unsigned int k = 0;
k<wh; ++
k) {
33035 *(nbuffer++) = (
unsigned char)(*(ptr1++));
33036 *(nbuffer++) = (
unsigned char)(*(ptr2++));
33037 *(nbuffer++) = (
unsigned char)(*(ptr3++));
33060 throw CImgInstanceException(
"CImg<%s>::save_rgba() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33062 if (!file && !filename)
33063 throw CImgArgumentException(
"CImg<%s>::save_rgba() : Instance image (%u,%u,%u,%u,%p), specified file is (null).",
33066 cimg::warn(
"CImg<%s>::save_rgba() : File '%s, instance image (%u,%u,%u,%u,%p) has not exactly 4 channels.",
33068 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"wb");
33070 unsigned char *buffer =
new unsigned char[4*wh], *nbuffer=buffer;
33072 *ptr1 =
ptr(0,0,0,0),
33073 *ptr2 = dim>1?
ptr(0,0,0,1):0,
33074 *ptr3 = dim>2?
ptr(0,0,0,2):0,
33075 *ptr4 = dim>3?
ptr(0,0,0,3):0;
33078 for (
unsigned int k = 0;
k<wh; ++
k) {
33079 const unsigned char val = (
unsigned char)*(ptr1++);
33080 *(nbuffer++) = val;
33081 *(nbuffer++) = val;
33082 *(nbuffer++) = val;
33083 *(nbuffer++) = 255;
33086 for (
unsigned int k = 0;
k<wh; ++
k) {
33087 *(nbuffer++) = (
unsigned char)(*(ptr1++));
33088 *(nbuffer++) = (
unsigned char)(*(ptr2++));
33090 *(nbuffer++) = 255;
33093 for (
unsigned int k = 0;
k<wh; ++
k) {
33094 *(nbuffer++) = (
unsigned char)(*(ptr1++));
33095 *(nbuffer++) = (
unsigned char)(*(ptr2++));
33096 *(nbuffer++) = (
unsigned char)(*(ptr3++));
33097 *(nbuffer++) = 255;
33100 for (
unsigned int k = 0;
k<wh; ++
k) {
33101 *(nbuffer++) = (
unsigned char)(*(ptr1++));
33102 *(nbuffer++) = (
unsigned char)(*(ptr2++));
33103 *(nbuffer++) = (
unsigned char)(*(ptr3++));
33104 *(nbuffer++) = (
unsigned char)(*(ptr4++));
33125 #ifdef cimg_use_tiff
33127 #define _cimg_save_tif(types,typed) \
33128 if (!std::strcmp(types,pixel_type())) { const typed foo = (typed)0; return _save_tiff(tif,directory,foo); }
33130 template<
typename t>
33131 const CImg<T>& _save_tiff(TIFF *tif,
const unsigned int directory,
const t& pixel_t)
const {
33132 if (
is_empty() || !tif || pixel_t)
return *
this;
33133 const char *
const filename = TIFFFileName(tif);
33134 uint32 rowsperstrip = (uint32)-1;
33135 uint16 spp =
dim, bpp =
sizeof(t)*8, photometric, compression = COMPRESSION_NONE;
33136 if (spp==3 || spp==4) photometric = PHOTOMETRIC_RGB;
33137 else photometric = PHOTOMETRIC_MINISBLACK;
33138 TIFFSetDirectory(tif,directory);
33139 TIFFSetField(tif,TIFFTAG_IMAGEWIDTH,
width);
33140 TIFFSetField(tif,TIFFTAG_IMAGELENGTH,
height);
33141 TIFFSetField(tif,TIFFTAG_ORIENTATION,ORIENTATION_TOPLEFT);
33142 TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,spp);
33145 else TIFFSetField(tif,TIFFTAG_SAMPLEFORMAT,2);
33146 TIFFSetField(tif,TIFFTAG_BITSPERSAMPLE,bpp);
33147 TIFFSetField(tif,TIFFTAG_PLANARCONFIG,PLANARCONFIG_CONTIG);
33148 TIFFSetField(tif,TIFFTAG_PHOTOMETRIC,photometric);
33149 TIFFSetField(tif,TIFFTAG_COMPRESSION,compression);
33150 rowsperstrip = TIFFDefaultStripSize(tif,rowsperstrip);
33151 TIFFSetField(tif,TIFFTAG_ROWSPERSTRIP,rowsperstrip);
33152 TIFFSetField(tif,TIFFTAG_FILLORDER,FILLORDER_MSB2LSB);
33153 TIFFSetField(tif,TIFFTAG_SOFTWARE,
"CImg");
33154 t *
const buf = (t*)_TIFFmalloc(TIFFStripSize(tif));
33156 for (
unsigned int row = 0; row<
height; row+=rowsperstrip) {
33157 uint32 nrow = (row + rowsperstrip>height?height-row:rowsperstrip);
33158 tstrip_t strip = TIFFComputeStrip(tif,row,0);
33160 for (
unsigned int rr = 0; rr<
nrow; ++rr)
33161 for (
unsigned int cc = 0; cc<
width; ++cc)
33162 for (
unsigned int vv = 0; vv<spp; ++vv)
33163 buf[i++] = (t)(*this)(cc,row + rr,0,vv);
33164 if (TIFFWriteEncodedStrip(tif,strip,buf,i*
sizeof(t))<0)
33165 throw CImgException(
"CImg<%s>::save_tiff() : File '%s', an error has occured while writing a strip.",
33170 TIFFWriteDirectory(tif);
33174 const CImg<T>& _save_tiff(TIFF *tif,
const unsigned int directory)
const {
33175 typedef unsigned char uchar;
33176 typedef unsigned short ushort;
33177 typedef unsigned int uint;
33178 typedef unsigned long ulong;
33179 _cimg_save_tif(
"bool",uchar);
33180 _cimg_save_tif(
"char",
char);
33181 _cimg_save_tif(
"unsigned char",uchar);
33182 _cimg_save_tif(
"short",
short);
33183 _cimg_save_tif(
"unsigned short",ushort);
33184 _cimg_save_tif(
"int",
int);
33185 _cimg_save_tif(
"unsigned int",uint);
33186 _cimg_save_tif(
"long",
int);
33187 _cimg_save_tif(
"unsigned long",uint);
33188 _cimg_save_tif(
"float",
float);
33189 _cimg_save_tif(
"double",
float);
33190 const char *
const filename = TIFFFileName(tif);
33191 throw CImgException(
"CImg<%s>::save_tiff() : File '%s', pixel type is not supported.",
33200 throw CImgInstanceException(
"CImg<%s>::save_tiff() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33203 throw CImgArgumentException(
"CImg<%s>::save_tiff() : Specified filename is (null) for instance image (%u,%u,%u,%u,%p).",
33205 #ifdef cimg_use_tiff
33206 TIFF *tif = TIFFOpen(filename,
"w");
33210 }
else throw CImgException(
"CImg<%s>::save_tiff() : File '%s', error while opening file stream for writing.",
33221 throw CImgInstanceException(
"CImg<%s>::save_analyze() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33224 throw CImgArgumentException(
"CImg<%s>::save_analyze() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).",
33227 char header[348] = { 0 }, hname[1024] = { 0 }, iname[1024] = { 0 };
33230 std::memset(header,0,348);
33231 if (!ext[0]) { std::sprintf(hname,
"%s.hdr",filename); std::sprintf(iname,
"%s.img",filename); }
33233 std::strcpy(hname,filename); std::strcpy(iname,filename); std::sprintf(iname+std::strlen(iname)-3,
"img");
33236 std::strcpy(hname,filename); std::strcpy(iname,filename); std::sprintf(hname+std::strlen(iname)-3,
"hdr");
33239 std::strcpy(hname,filename); iname[0] = 0;
33241 ((
int*)(header))[0] = 348;
33242 std::sprintf(header+4,
"CImg");
33243 std::sprintf(header+14,
" ");
33244 ((
short*)(header+36))[0] = 4096;
33245 ((
char*)(header+38))[0] = 114;
33246 ((
short*)(header+40))[0] = 4;
33247 ((
short*)(header+40))[1] = width;
33248 ((
short*)(header+40))[2] = height;
33249 ((
short*)(header+40))[3] =
depth;
33250 ((
short*)(header+40))[4] = dim;
33263 throw CImgIOException(
"CImg<%s>::save_analyze() : Cannot save image '%s' since pixel type (%s)"
33264 "is not handled in Analyze7.5 specifications.\n",
33266 ((
short*)(header+70))[0] = datatype;
33267 ((
short*)(header+72))[0] =
sizeof(T);
33268 ((
float*)(header+112))[0] = 1;
33269 ((
float*)(header+76))[0] = 0;
33271 ((
float*)(header+76))[1] = voxsize[0];
33272 ((
float*)(header+76))[2] = voxsize[1];
33273 ((
float*)(header+76))[3] = voxsize[2];
33274 }
else ((
float*)(header+76))[1] = ((
float*)(header+76))[2] = ((
float*)(header+76))[3] = 1;
33297 const unsigned int n0,
33298 const unsigned int x0,
const unsigned int y0,
33299 const unsigned int z0,
const unsigned int v0)
const {
33306 const unsigned int n0,
33307 const unsigned int x0,
const unsigned int y0,
33308 const unsigned int z0,
const unsigned int v0)
const {
33315 const unsigned int dx,
const unsigned int dy=1,
33316 const unsigned int dz=1,
const unsigned int dv=1) {
33322 const unsigned int dx,
const unsigned int dy=1,
33323 const unsigned int dz=1,
const unsigned int dv=1) {
33328 const CImg<T>&
_save_inr(std::FILE *
const file,
const char *
const filename,
const float *
const voxsize)
const {
33330 throw CImgInstanceException(
"CImg<%s>::save_inr() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33333 throw CImgArgumentException(
"CImg<%s>::save_inr() : Instance image (%u,%u,%u,%u,%p), specified file is (null).",
33336 const char *inrtype =
"unsigned fixed\nPIXSIZE=8 bits\nSCALE=2**0";
33337 if (!
cimg::strcasecmp(
pixel_type(),
"unsigned char")) { inrtype =
"unsigned fixed\nPIXSIZE=8 bits\nSCALE=2**0"; inrpixsize = 1; }
33339 if (!
cimg::strcasecmp(
pixel_type(),
"unsigned short")) { inrtype =
"unsigned fixed\nPIXSIZE=16 bits\nSCALE=2**0";inrpixsize = 2; }
33341 if (!
cimg::strcasecmp(
pixel_type(),
"unsigned int")) { inrtype =
"unsigned fixed\nPIXSIZE=32 bits\nSCALE=2**0";inrpixsize = 4; }
33346 throw CImgIOException(
"CImg<%s>::save_inr() : Don't know how to save images of '%s'",
33348 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"wb");
33349 char header[257] = { 0 };
33350 int err = std::sprintf(header,
"#INRIMAGE-4#{\nXDIM=%u\nYDIM=%u\nZDIM=%u\nVDIM=%u\n",width,height,
depth,dim);
33351 if (voxsize) err += std::sprintf(header+err,
"VX=%g\nVY=%g\nVZ=%g\n",voxsize[0],voxsize[1],voxsize[2]);
33352 err += std::sprintf(header+err,
"TYPE=%s\nCPU=%s\n",inrtype,
cimg::endianness()?
"sun":
"decm");
33353 std::memset(header+err,
'\n',252-err);
33354 std::memcpy(header+252,
"##}\n",4);
33373 unsigned int nbdims = 0;
33374 if (
id==2 ||
id==3 ||
id==4) { dims[0] = 1; dims[1] =
width; nbdims = 2; }
33375 if (
id==5 ||
id==6 ||
id==7) { dims[0] = 1; dims[1] =
height; dims[2] =
width; nbdims=3; }
33376 if (
id==8 ||
id==9 ||
id==10) { dims[0] =
dim; dims[1] =
depth; dims[2] =
height; dims[3] =
width; nbdims = 4; }
33377 if (
id==16 ||
id==17 ||
id==18) { dims[0] = 3; dims[1] =
height; dims[2] =
width; dims[3] = colorspace; nbdims = 4; }
33378 if (
id==19 ||
id==20 ||
id==21) { dims[0] = 3; dims[1] =
depth; dims[2] =
height; dims[3] =
width; dims[4] = colorspace; nbdims = 5; }
33379 if (
id==22 ||
id==23 ||
id==25) { dims[0] =
dim; dims[1] =
width; nbdims = 2; }
33380 if (
id==26 ||
id==27 ||
id==29) { dims[0] =
dim; dims[1] =
height; dims[2] =
width; nbdims=3; }
33381 if (
id==30 ||
id==31 ||
id==33) { dims[0] =
dim; dims[1] =
depth; dims[2] =
height; dims[3] =
width; nbdims = 4; }
33386 typedef unsigned char uchar;
33387 typedef unsigned short ushort;
33388 typedef unsigned int uint;
33389 typedef unsigned long ulong;
33391 #define __cimg_save_pandore_case(dtype) \
33392 dtype *buffer = new dtype[size()]; \
33393 const T *ptrs = data; \
33394 cimg_foroff(*this,off) *(buffer++) = (dtype)(*(ptrs++)); \
33396 cimg::fwrite(buffer,size(),nfile); \
33399 #define _cimg_save_pandore_case(sy,sz,sv,stype,id) \
33400 if (!saved && (sy?(sy==height):true) && (sz?(sz==depth):true) && (sv?(sv==dim):true) && !std::strcmp(stype,pixel_type())) { \
33401 unsigned int *iheader = (unsigned int*)(header+12); \
33402 nbdims = _save_pandore_header_length((*iheader=id),dims,colorspace); \
33403 cimg::fwrite(header,36,nfile); \
33404 if (sizeof(ulong)==4) { ulong ndims[5] = { 0 }; for (int d = 0; d<5; ++d) ndims[d] = (ulong)dims[d]; cimg::fwrite(ndims,nbdims,nfile); } \
33405 else if (sizeof(uint)==4) { uint ndims[5] = { 0 }; for (int d = 0; d<5; ++d) ndims[d] = (uint)dims[d]; cimg::fwrite(ndims,nbdims,nfile); } \
33406 else if (sizeof(ushort)==4) { ushort ndims[5] = { 0 }; for (int d = 0; d<5; ++d) ndims[d] = (ushort)dims[d]; cimg::fwrite(ndims,nbdims,nfile); } \
33407 else throw CImgIOException("CImg<%s>::save_pandore() : File '%s', instance image (%u,%u,%u,%u,%p), output type is not" \
33408 "supported on this architecture.",pixel_type(),filename?filename:"(FILE*)",width,height, \
33410 if (id==2 || id==5 || id==8 || id==16 || id==19 || id==22 || id==26 || id==30) { \
33411 __cimg_save_pandore_case(uchar); \
33412 } else if (id==3 || id==6 || id==9 || id==17 || id==20 || id==23 || id==27 || id==31) { \
33413 if (sizeof(ulong)==4) { __cimg_save_pandore_case(ulong); } \
33414 else if (sizeof(uint)==4) { __cimg_save_pandore_case(uint); } \
33415 else if (sizeof(ushort)==4) { __cimg_save_pandore_case(ushort); } \
33416 else throw CImgIOException("CImg<%s>::save_pandore() : File '%s', instance image (%u,%u,%u,%u,%p), output type is not" \
33417 "supported on this architecture.",pixel_type(),filename?filename:"(FILE*)",width,height, \
33419 } else if (id==4 || id==7 || id==10 || id==18 || id==21 || id==25 || id==29 || id==33) { \
33420 if (sizeof(double)==4) { __cimg_save_pandore_case(double); } \
33421 else if (sizeof(float)==4) { __cimg_save_pandore_case(float); } \
33422 else throw CImgIOException("CImg<%s>::save_pandore() : File '%s', instance image (%u,%u,%u,%u,%p), output type is not" \
33423 "supported on this architecture.",pixel_type(),filename?filename:"(FILE*)",width,height, \
33430 throw CImgInstanceException(
"CImg<%s>::save_pandore() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33432 if (!file && !filename)
33433 throw CImgArgumentException(
"CImg<%s>::save_pandore() : Instance image (%u,%u,%u,%u,%p), specified file is (null).",
33435 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"wb");
33436 unsigned char header[36] = {
'P',
'A',
'N',
'D',
'O',
'R',
'E',
'0',
'4',0,0,0,
33437 0,0,0,0,
'C',
'I',
'm',
'g',0,0,0,0,0,
'N',
'o',
' ',
'd',
'a',
't',
'e',0,0,0,0 };
33438 unsigned int nbdims, dims[5] = { 0 };
33439 bool saved =
false;
33543 const CImg<T>&
_save_raw(std::FILE *
const file,
const char *
const filename,
const bool multiplexed)
const {
33545 throw CImgInstanceException(
"CImg<%s>::save_raw() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33547 if (!file && !filename)
33548 throw CImgArgumentException(
"CImg<%s>::save_raw() : Instance image (%u,%u,%u,%u,%p), specified file is (null).",
33550 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"wb");
33565 return _save_raw(0,filename,multiplexed);
33574 const CImg<T>&
save_ffmpeg(
const char *
const filename,
const unsigned int first_frame=0,
const unsigned int last_frame=~0U,
33575 const unsigned int fps=25)
const {
33577 throw CImgInstanceException(
"CImg<%s>::save_ffmpeg() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33580 throw CImgArgumentException(
"CImg<%s>::save_ffmpeg() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).",
33585 #ifndef cimg_use_ffmpeg
33588 get_split(
'z').save_ffmpeg(filename,first_frame,last_frame,fps);
33595 get_split(
'z').save_yuv(filename,rgb2yuv);
33606 template<
typename tf,
typename tc>
33610 throw CImgInstanceException(
"CImg<%s>::save_off() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33612 if (!file && !filename)
33615 if (height<3)
return get_resize(-100,3,1,1,0)._save_off(file,filename,primitives,colors);
33620 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"w");
33621 std::fprintf(nfile,
"OFF\n%u %u %u\n",width,primitives.
width,3*primitives.
width);
33622 cimg_forX(*
this,i) std::fprintf(nfile,
"%f %f %f\n",(
float)((*
this)(i,0)),(
float)((*
this)(i,1)),(
float)((*
this)(i,2)));
33624 const unsigned int prim = primitives[l].
size();
33625 const bool textured = (prim>4);
33626 const CImg<tc>& color = ncolors[l];
33627 const unsigned int s = textured?color.dimv():color.size();
33629 r = textured?(s>0?(float)(color.get_shared_channel(0).mean()/255.0f):1.0f):(s>0?(float)(color(0)/255.0f):1.0f),
33630 g = textured?(s>1?(float)(color.get_shared_channel(1).mean()/255.0f):r) :(s>1?(float)(color(1)/255.0f):r),
33631 b = textured?(s>2?(float)(color.get_shared_channel(2).mean()/255.0f):r) :(s>2?(float)(color(2)/255.0f):r);
33635 std::fprintf(nfile,
"1 %u %f %f %f\n",(
unsigned int)primitives(l,0),r,g,b);
33638 std::fprintf(nfile,
"2 %u %u %f %f %f\n",(
unsigned int)primitives(l,0),(
unsigned int)primitives(l,1),r,g,b);
33641 std::fprintf(nfile,
"3 %u %u %u %f %f %f\n",(
unsigned int)primitives(l,0),(
unsigned int)primitives(l,2),
33642 (
unsigned int)primitives(l,1),r,g,b);
33645 std::fprintf(nfile,
"4 %u %u %u %u %f %f %f\n",
33646 (
unsigned int)primitives(l,0),(
unsigned int)primitives(l,3),(
unsigned int)primitives(l,2),
33647 (
unsigned int)primitives(l,1),r,g,b);
33656 template<
typename tf,
typename tc>
33659 return _save_off(0,filename,primitives,colors);
33663 template<
typename tf,
typename tc>
33666 return _save_off(file,0,primitives,colors);
33671 const char *
const codec=
"mpeg2video")
const {
33673 throw CImgInstanceException(
"CImg<%s>::save_ffmpeg_external() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33676 throw CImgArgumentException(
"CImg<%s>::save_ffmpeg_external() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).",
33678 get_split(
'z').save_ffmpeg_external(filename,first_frame,last_frame,codec);
33691 throw CImgInstanceException(
"CImg<%s>::save_graphicsmagick_external() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33694 throw CImgArgumentException(
"CImg<%s>::save_graphicsmagick_external() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).",
33696 char command[1024] = { 0 }, filetmp[512] = { 0 };
33708 throw CImgIOException(
"CImg<%s>::save_graphicsmagick_external() : Failed to save image '%s'.\n\n"
33709 "Path of 'gm' : \"%s\"\n"
33710 "Path of temporary filename : \"%s\"\n",
33713 std::remove(filetmp);
33720 throw CImgIOException(
"CImg<%s>::save_gzip_external() : Cannot save (null) filename.",
33722 char command[1024] = { 0 }, filetmp[512] = { 0 }, body[512] = { 0 };
33738 std::sprintf(command,
"%s -c %s > \"%s\"",
cimg::gzip_path(),filetmp,filename);
33742 throw CImgIOException(
"CImgList<%s>::save_gzip_external() : File '%s' cannot be saved.",
33745 std::remove(filetmp);
33758 throw CImgInstanceException(
"CImg<%s>::save_imagemagick_external() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33761 throw CImgArgumentException(
"CImg<%s>::save_imagemagick_external() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).",
33763 char command[1024] = { 0 }, filetmp[512] = { 0 };
33774 throw CImgIOException(
"CImg<%s>::save_imagemagick_external() : Failed to save image '%s'.\n\n"
33775 "Path of 'convert' : \"%s\"\n"
33776 "Path of temporary filename : \"%s\"\n",
33779 std::remove(filetmp);
33786 throw CImgInstanceException(
"CImg<%s>::save_medcon_external() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33789 throw CImgArgumentException(
"CImg<%s>::save_medcon_external() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).",
33792 char command[1024] = { 0 }, filetmp[512] = { 0 }, body[512] = { 0 };
33799 std::sprintf(command,
"%s -w -c dicom -o %s -f %s",
cimg::medcon_path(),filename,filetmp);
33801 std::remove(filetmp);
33803 std::sprintf(filetmp,
"%s.img",body);
33804 std::remove(filetmp);
33805 std::sprintf(command,
"m000-%s",filename);
33809 throw CImgIOException(
"CImg<%s>::save_medcon_external() : Failed to save image '%s'.\n\n"
33810 "Path of 'medcon' : \"%s\"\n"
33811 "Path of temporary filename : \"%s\"",
33814 std::rename(command,filename);
33821 throw CImgInstanceException(
"CImg<%s>::save_other() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33824 throw CImgIOException(
"CImg<%s>::save_other() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).",
33827 bool is_saved =
true;
33841 throw CImgIOException(
"CImg<%s>::save_other() : File '%s' cannot be saved.\n"
33842 "Check you have either the ImageMagick or GraphicsMagick package installed.",
33849 static bool first_time =
true;
33850 static CImg<T> res(40,38,1,3);
33853 T *ptr1 = res.ptr(0,0,0,0), *ptr2 = res.ptr(0,0,0,1), *ptr3 = res.ptr(0,0,0,2);
33854 for (
unsigned int off = 0; off<res.width*res.height;) {
33855 const unsigned char n = *(ptrs++), r = *(ptrs++), g = *(ptrs++), b = *(ptrs++);
33856 for (
unsigned int l = 0; l<
n; ++off, ++l) { *(ptr1++) = (T)r; *(ptr2++) = (T)g; *(ptr3++) = (T)b; }
33858 first_time =
false;
33879 template<
typename T>
33930 #ifdef cimglist_plugin
33931 #include cimglist_plugin
33933 #ifdef cimglist_plugin1
33934 #include cimglist_plugin1
33936 #ifdef cimglist_plugin2
33937 #include cimglist_plugin2
33939 #ifdef cimglist_plugin3
33940 #include cimglist_plugin3
33942 #ifdef cimglist_plugin4
33943 #include cimglist_plugin4
33945 #ifdef cimglist_plugin5
33946 #include cimglist_plugin5
33948 #ifdef cimglist_plugin6
33949 #include cimglist_plugin6
33951 #ifdef cimglist_plugin7
33952 #include cimglist_plugin7
33954 #ifdef cimglist_plugin8
33955 #include cimglist_plugin8
33980 CImgList(
const unsigned int n,
const unsigned int width,
const unsigned int height=1,
33981 const unsigned int depth=1,
const unsigned int dim=1):
33988 CImgList(
const unsigned int n,
const unsigned int width,
const unsigned int height,
33989 const unsigned int depth,
const unsigned int dim,
const T val):
33996 CImgList(
const unsigned int n,
const unsigned int width,
const unsigned int height,
33997 const unsigned int depth,
const unsigned int dim,
const int val0,
const int val1, ...):
33999 #define _CImgList_stdarg(t) { \
34000 assign(n,width,height,depth,dim); \
34001 const unsigned int siz = width*height*depth*dim, nsiz = siz*n; \
34002 T *ptrd = data->data; \
34004 va_start(ap,val1); \
34005 for (unsigned int l = 0, s = 0, i = 0; i<nsiz; ++i) { \
34006 *(ptrd++) = (T)(i==0?val0:(i==1?val1:va_arg(ap,t))); \
34007 if ((++s)==siz) { ptrd = data[++l].data; s = 0; } \
34015 CImgList(
const unsigned int n,
const unsigned int width,
const unsigned int height,
34016 const unsigned int depth,
const unsigned int dim,
const double val0,
const double val1, ...):
34022 template<
typename t>
34029 template<
typename t>
34032 data[0].assign(img,shared);
34036 template<
typename t1,
typename t2>
34039 data[0].assign(img1,shared);
data[1].assign(img2,shared);
34043 template<
typename t1,
typename t2,
typename t3>
34047 data[0].assign(img1,shared);
data[1].assign(img2,shared);
data[2].assign(img3,shared);
34051 template<
typename t1,
typename t2,
typename t3,
typename t4>
34055 data[0].assign(img1,shared);
data[1].assign(img2,shared);
data[2].assign(img3,shared);
data[3].assign(img4,shared);
34059 template<
typename t1,
typename t2,
typename t3,
typename t4,
typename t5>
34061 const CImg<t5>& img5,
const bool shared=
false):
34064 data[0].assign(img1,shared);
data[1].assign(img2,shared);
data[2].assign(img3,shared);
data[3].assign(img4,shared);
34065 data[4].assign(img5,shared);
34069 template<
typename t1,
typename t2,
typename t3,
typename t4,
typename t5,
typename t6>
34074 data[0].assign(img1,shared);
data[1].assign(img2,shared);
data[2].assign(img3,shared);
data[3].assign(img4,shared);
34075 data[4].assign(img5,shared);
data[5].assign(img6,shared);
34079 template<
typename t1,
typename t2,
typename t3,
typename t4,
typename t5,
typename t6,
typename t7>
34084 data[0].assign(img1,shared);
data[1].assign(img2,shared);
data[2].assign(img3,shared);
data[3].assign(img4,shared);
34085 data[4].assign(img5,shared);
data[5].assign(img6,shared);
data[6].assign(img7,shared);
34089 template<
typename t1,
typename t2,
typename t3,
typename t4,
typename t5,
typename t6,
typename t7,
typename t8>
34094 data[0].assign(img1,shared);
data[1].assign(img2,shared);
data[2].assign(img3,shared);
data[3].assign(img4,shared);
34095 data[4].assign(img5,shared);
data[5].assign(img6,shared);
data[6].assign(img7,shared);
data[7].assign(img8,shared);
34099 template<
typename t>
34111 template<
typename t>
34161 if (allocated_width<n || allocated_width>(n<<2)) {
34172 const unsigned int depth=1,
const unsigned int dim=1) {
34180 const unsigned int depth,
const unsigned int dim,
const T val) {
34188 const unsigned int depth,
const unsigned int dim,
const int val0,
const int val1, ...) {
34195 const unsigned int depth,
const unsigned int dim,
const double val0,
const double val1, ...) {
34201 template<
typename t>
34209 template<
typename t>
34217 template<
typename t>
34220 data[0].assign(img,shared);
34225 template<
typename t1,
typename t2>
34228 data[0].assign(img1,shared);
data[1].assign(img2,shared);
34233 template<
typename t1,
typename t2,
typename t3>
34236 data[0].assign(img1,shared);
data[1].assign(img2,shared);
data[2].assign(img3,shared);
34241 template<
typename t1,
typename t2,
typename t3,
typename t4>
34243 const bool shared=
false) {
34245 data[0].assign(img1,shared);
data[1].assign(img2,shared);
data[2].assign(img3,shared);
data[3].assign(img4,shared);
34250 template<
typename t1,
typename t2,
typename t3,
typename t4,
typename t5>
34252 const CImg<t5>& img5,
const bool shared=
false) {
34254 data[0].assign(img1,shared);
data[1].assign(img2,shared);
data[2].assign(img3,shared);
data[3].assign(img4,shared);
34255 data[4].assign(img5,shared);
34260 template<
typename t1,
typename t2,
typename t3,
typename t4,
typename t5,
typename t6>
34264 data[0].assign(img1,shared);
data[1].assign(img2,shared);
data[2].assign(img3,shared);
data[3].assign(img4,shared);
34265 data[4].assign(img5,shared);
data[5].assign(img6,shared);
34270 template<
typename t1,
typename t2,
typename t3,
typename t4,
typename t5,
typename t6,
typename t7>
34274 data[0].assign(img1,shared);
data[1].assign(img2,shared);
data[2].assign(img3,shared);
data[3].assign(img4,shared);
34275 data[4].assign(img5,shared);
data[5].assign(img6,shared);
data[6].assign(img7,shared);
34280 template<
typename t1,
typename t2,
typename t3,
typename t4,
typename t5,
typename t6,
typename t7,
typename t8>
34283 const bool shared=
false) {
34285 data[0].assign(img1,shared);
data[1].assign(img2,shared);
data[2].assign(img3,shared);
data[3].assign(img4,shared);
34286 data[4].assign(img5,shared);
data[5].assign(img6,shared);
data[6].assign(img7,shared);
data[7].assign(img8,shared);
34292 return load(filename);
34301 template<
typename t>
34303 list.assign(
size());
34314 template<
typename t>
34317 const unsigned int npos = pos>list.width?list.width:pos;
34318 list.insert(width,npos);
34319 cimglist_for(*
this,l) (*this)[l].transfer_to(list.at(npos+l));
34335 return _empty.assign();
34349 cimg::warn(
"CImgList<%s>::operator[] : bad list position %u, in a list of %u images",
34360 cimg::warn(
"CImgList<%s>::operator[] : bad list position %u, in a list of %u images",
34370 return (*
this)[pos];
34374 return (*
this)[pos];
34378 T&
operator()(
const unsigned int pos,
const unsigned int x,
const unsigned int y=0,
34379 const unsigned int z=0,
const unsigned int v=0) {
34380 return (*
this)[pos](
x,
y,
z,
v);
34382 const T&
operator()(
const unsigned int pos,
const unsigned int x,
const unsigned int y=0,
34383 const unsigned int z=0,
const unsigned int v=0)
const {
34384 return (*
this)[pos](
x,
y,
z,
v);
34388 operator bool()
const {
34393 template<
typename t>
34404 template<
typename t>
34415 return assign(filename);
34428 template<
typename t>
34434 template<
typename t>
34487 cimg::warn(
"CImgList<%s>::ptr() : Asked for a pointer at position %u, outside the list range %u",
34494 const CImg<T> *
ptr(
const unsigned int l)
const {
34495 return const_cast<CImgList<T>*
>(
this)->
ptr(l);
34536 return *(
data + width - 1);
34540 return *(
data + width - 1);
34548 return data[pos<0?0:pos>=(int)width?(
int)width-1:pos];
34552 T&
atNXYZV(
const int pos,
const int x,
const int y,
const int z,
const int v,
const T out_val) {
34553 return (pos<0 || pos>=(
int)width)?(
cimg::temporary(out_val)=out_val):
data[pos].atXYZV(x,y,z,v,out_val);
34556 T
atNXYZV(
const int pos,
const int x,
const int y,
const int z,
const int v,
const T out_val)
const {
34557 return (pos<0 || pos>=(
int)width)?out_val:
data[pos].atXYZV(x,y,z,v,out_val);
34561 T&
atNXYZV(
const int pos,
const int x,
const int y,
const int z,
const int v) {
34568 T
atNXYZV(
const int pos,
const int x,
const int y,
const int z,
const int v)
const {
34575 T&
_atNXYZV(
const int pos,
const int x,
const int y,
const int z,
const int v) {
34576 return data[pos<0?0:(pos>=(int)width?(
int)width-1:pos)].atXYZV(x,y,z,v);
34579 T
_atNXYZV(
const int pos,
const int x,
const int y,
const int z,
const int v)
const {
34580 return data[pos<0?0:(pos>=(int)width?(
int)width-1:pos)].atXYZV(x,y,z,v);
34584 T&
atNXYZ(
const int pos,
const int x,
const int y,
const int z,
const int v,
const T out_val) {
34585 return (pos<0 || pos>=(
int)width)?(
cimg::temporary(out_val)=out_val):
data[pos].atXYZ(x,y,z,v,out_val);
34588 T
atNXYZ(
const int pos,
const int x,
const int y,
const int z,
const int v,
const T out_val)
const {
34589 return (pos<0 || pos>=(
int)width)?out_val:
data[pos].atXYZ(x,y,z,v,out_val);
34593 T&
atNXYZ(
const int pos,
const int x,
const int y,
const int z,
const int v=0) {
34600 T
atNXYZ(
const int pos,
const int x,
const int y,
const int z,
const int v=0)
const {
34607 T&
_atNXYZ(
const int pos,
const int x,
const int y,
const int z,
const int v=0) {
34608 return data[pos<0?0:(pos>=(int)width?(
int)width-1:pos)].atXYZ(x,y,z,
v);
34611 T
_atNXYZ(
const int pos,
const int x,
const int y,
const int z,
const int v=0)
const {
34612 return data[pos<0?0:(pos>=(int)width?(
int)width-1:pos)].atXYZ(x,y,z,
v);
34616 T&
atNXY(
const int pos,
const int x,
const int y,
const int z,
const int v,
const T out_val) {
34617 return (pos<0 || pos>=(
int)width)?(
cimg::temporary(out_val)=out_val):
data[pos].atXY(x,y,z,v,out_val);
34620 T
atNXY(
const int pos,
const int x,
const int y,
const int z,
const int v,
const T out_val)
const {
34621 return (pos<0 || pos>=(
int)width)?out_val:
data[pos].atXY(x,y,z,v,out_val);
34625 T&
atNXY(
const int pos,
const int x,
const int y,
const int z=0,
const int v=0) {
34632 T
atNXY(
const int pos,
const int x,
const int y,
const int z=0,
const int v=0)
const {
34639 T&
_atNXY(
const int pos,
const int x,
const int y,
const int z=0,
const int v=0) {
34640 return data[pos<0?0:(pos>=(int)width?(
int)width-1:pos)].atXY(x,y,
z,
v);
34643 T
_atNXY(
const int pos,
const int x,
const int y,
const int z=0,
const int v=0)
const {
34644 return data[pos<0?0:(pos>=(int)width?(
int)width-1:pos)].atXY(x,y,
z,
v);
34648 T&
atNX(
const int pos,
const int x,
const int y,
const int z,
const int v,
const T out_val) {
34649 return (pos<0 || pos>=(
int)width)?(
cimg::temporary(out_val)=out_val):
data[pos].atX(x,y,z,v,out_val);
34652 T
atNX(
const int pos,
const int x,
const int y,
const int z,
const int v,
const T out_val)
const {
34653 return (pos<0 || pos>=(
int)width)?out_val:
data[pos].atX(x,y,z,v,out_val);
34657 T&
atNX(
const int pos,
const int x,
const int y=0,
const int z=0,
const int v=0) {
34664 T
atNX(
const int pos,
const int x,
const int y=0,
const int z=0,
const int v=0)
const {
34671 T&
_atNX(
const int pos,
const int x,
const int y=0,
const int z=0,
const int v=0) {
34672 return data[pos<0?0:(pos>=(int)width?(
int)width-1:pos)].atX(x,y,
z,
v);
34675 T
_atNX(
const int pos,
const int x,
const int y=0,
const int z=0,
const int v=0)
const {
34676 return data[pos<0?0:(pos>=(int)width?(
int)width-1:pos)].atX(x,y,
z,
v);
34680 T&
atN(
const int pos,
const int x,
const int y,
const int z,
const int v,
const T out_val) {
34681 return (pos<0 || pos>=(
int)width)?(
cimg::temporary(out_val)=out_val):(*
this)(pos,
x,
y,
z,
v);
34684 T
atN(
const int pos,
const int x,
const int y,
const int z,
const int v,
const T out_val)
const {
34685 return (pos<0 || pos>=(
int)width)?out_val:(*this)(pos,
x,
y,
z,
v);
34689 T&
atN(
const int pos,
const int x=0,
const int y=0,
const int z=0,
const int v=0) {
34693 return _atN(pos,x,y,
z,
v);
34696 T
atN(
const int pos,
const int x=0,
const int y=0,
const int z=0,
const int v=0)
const {
34700 return _atN(pos,x,y,
z,
v);
34703 T&
_atN(
const int pos,
const int x=0,
const int y=0,
const int z=0,
const int v=0) {
34704 return data[pos<0?0:(pos>=(int)width?(
int)width-1:pos)](x,y,
z,
v);
34707 T
_atN(
const int pos,
const int x=0,
const int y=0,
const int z=0,
const int v=0)
const {
34708 return data[pos<0?0:(pos>=(int)width?(
int)width-1:pos)](x,y,
z,
v);
34715 for (
unsigned int l = 0; l<width-1; ++l) {
34717 item.back() = separator;
34718 item.transfer_to(items);
34720 data[width-1].value_string(separator,0).transfer_to(items);
34722 if (max_size) { res.crop(0,max_size); res(max_size) = 0; }
34735 return (!
data || !width);
34744 template<
typename t>
34746 return (width==list.width);
34751 #define _cimglist_def_is_same1(axis) \
34752 bool is_same##axis(const unsigned int val) const { \
34753 bool res = true; for (unsigned int l = 0; l<width && res; ++l) res = data[l].is_same##axis(val); return res; \
34755 bool is_sameN##axis(const unsigned int n, const unsigned int val) const { \
34756 return is_sameN(n) && is_same##axis(val); \
34759 #define _cimglist_def_is_same2(axis1,axis2) \
34760 bool is_same##axis1##axis2(const unsigned int val1, const unsigned int val2) const { \
34761 bool res = true; for (unsigned int l = 0; l<width && res; ++l) res = data[l].is_same##axis1##axis2(val1,val2); return res; \
34763 bool is_sameN##axis1##axis2(const unsigned int n, const unsigned int val1, const unsigned int val2) const { \
34764 return is_sameN(n) && is_same##axis1##axis2(val1,val2); \
34767 #define _cimglist_def_is_same3(axis1,axis2,axis3) \
34768 bool is_same##axis1##axis2##axis3(const unsigned int val1, const unsigned int val2, const unsigned int val3) const { \
34769 bool res = true; for (unsigned int l = 0; l<width && res; ++l) res = data[l].is_same##axis1##axis2##axis3(val1,val2,val3); return res; \
34771 bool is_sameN##axis1##axis2##axis3(const unsigned int n, const unsigned int val1, const unsigned int val2, const unsigned int val3) const { \
34772 return is_sameN(n) && is_same##axis1##axis2##axis3(val1,val2,val3); \
34775 #define _cimglist_def_is_same(axis) \
34776 template<typename t> bool is_same##axis(const CImg<t>& img) const { \
34777 bool res = true; for (unsigned int l = 0; l<width && res; ++l) res = data[l].is_same##axis(img); return res; \
34779 template<typename t> bool is_same##axis(const CImgList<t>& list) const { \
34780 const unsigned int lmin = cimg::min(width,list.width); \
34781 bool res = true; for (unsigned int l = 0; l<lmin && res; ++l) res = data[l].is_same##axis(list[l]); return res; \
34783 template<typename t> bool is_sameN##axis(const unsigned int n, const CImg<t>& img) const { \
34784 return (is_sameN(n) && is_same##axis(img)); \
34786 template<typename t> bool is_sameN##axis(const CImgList<t>& list) const { \
34787 return (is_sameN(list) && is_same##axis(list)); \
34814 bool is_sameXYZV(const
unsigned int dx, const
unsigned int dy, const
unsigned int dz, const
unsigned int dv)
const {
34816 for (
unsigned int l = 0; l<width && res; ++l) res =
data[l].
is_sameXYZV(dx,dy,dz,dv);
34820 bool is_sameNXYZV(
const unsigned int n,
const unsigned int dx,
const unsigned int dy,
const unsigned int dz,
const unsigned int dv)
const {
34825 bool containsNXYZV(
const int n,
const int x=0,
const int y=0,
const int z=0,
const int v=0)
const {
34827 return n>=0 && n<(int)width && x>=0 && x<
data[
n].dimx() && y>=0 && y<
data[
n].dimy() &&
z>=0 &&
z<
data[
n].dimz() &&
v>=0 &&
v<
data[
n].dimv();
34833 return n>=0 && n<(int)width;
34837 template<
typename t>
34845 template<
typename t>
34852 template<
typename t>
34859 template<
typename t>
34866 template<
typename t>
34874 unsigned int n,
x,
y,
z,
v;
34879 template<
typename t>
34882 const CImg<T> *
const ptr = &img;
34905 T *ptrmin =
data->data;
34906 T min_value = *ptrmin;
34909 cimg_for(img,ptr,T)
if ((*ptr)<min_value) min_value = *(ptrmin=
ptr);
34918 const T *ptrmin =
data->data;
34919 T min_value = *ptrmin;
34922 cimg_for(img,ptr,T)
if ((*ptr)<min_value) min_value = *(ptrmin=
ptr);
34932 T *ptrmax =
data->data;
34933 T max_value = *ptrmax;
34936 cimg_for(img,ptr,T)
if ((*ptr)>max_value) max_value = *(ptrmax=
ptr);
34945 const T *ptrmax =
data->data;
34946 T max_value = *ptrmax;
34949 cimg_for(img,ptr,T)
if ((*ptr)>max_value) max_value = *(ptrmax=
ptr);
34955 template<
typename t>
34960 T *ptrmin =
data->data;
34961 T min_value = *ptrmin, max_value = min_value;
34965 const T val = *
ptr;
34966 if (val<min_value) { min_value = val; ptrmin =
ptr; }
34967 if (val>max_value) max_value = val;
34970 max_val = (t)max_value;
34974 template<
typename t>
34979 const T *ptrmin =
data->data;
34980 T min_value = *ptrmin, max_value = min_value;
34984 const T val = *
ptr;
34985 if (val<min_value) { min_value = val; ptrmin =
ptr; }
34986 if (val>max_value) max_value = val;
34989 max_val = (t)max_value;
34994 template<
typename t>
34999 T *ptrmax =
data->data;
35000 T min_value = *ptrmax, max_value = min_value;
35004 const T val = *
ptr;
35005 if (val>max_value) { max_value = val; ptrmax =
ptr; }
35006 if (val<min_value) min_value = val;
35009 min_val = (t)min_value;
35013 template<
typename t>
35018 const T *ptrmax =
data->data;
35019 T min_value = *ptrmax, max_value = min_value;
35023 const T val = *
ptr;
35024 if (val>max_value) { max_value = val; ptrmax =
ptr; }
35025 if (val<min_value) min_value = val;
35028 min_val = (t)min_value;
35040 template<
typename t>
35042 const unsigned int npos = pos==~0U?width:pos;
35044 throw CImgArgumentException(
"CImgList<%s>::insert() : Cannot insert image (%u,%u,%u,%u,%p) at position %u in a list "
35045 "containing %u elements",
35046 pixel_type(),img.width,img.height,img.depth,img.dim,img.data,npos,width);
35048 throw CImgArgumentException(
"CImgList<%s>::insert() : Cannot insert a shared image CImg<%s> in a CImgList<%s>",
35051 if (!width || !
data) {
35056 if (npos) std::memcpy(new_data,
data,
sizeof(
CImg<T>)*npos);
35057 if (npos!=width-1) std::memcpy(new_data+npos+1,
data+npos,
sizeof(
CImg<T>)*(width-1-npos));
35062 else if (npos!=width-1) std::memmove(
data+npos+1,
data+npos,
sizeof(
CImg<T>)*(width-1-npos));
35063 data[npos].width =
data[npos].height =
data[npos].depth =
data[npos].dim = 0;
data[npos].data = 0;
35070 const unsigned int npos = pos==~0U?width:pos;
35072 throw CImgArgumentException(
"CImgList<%s>::insert() : Cannot insert at position %u into a list with %u elements",
35074 if (&img>=
data && &img<
data + width)
return insert(+img,pos,shared);
35076 if (!width || !
data) {
35078 if (shared && img) {
35079 data->width = img.width;
data->height = img.height;
data->depth = img.depth;
data->dim = img.dim;
35080 data->is_shared =
true;
data->data = img.data;
35081 }
else *
data = img;
35085 if (npos) std::memcpy(new_data,
data,
sizeof(
CImg<T>)*npos);
35086 if (npos!=width-1) std::memcpy(new_data+npos+1,
data+npos,
sizeof(
CImg<T>)*(width-1-npos));
35087 if (shared && img) {
35088 new_data[npos].width = img.width; new_data[npos].height = img.height; new_data[npos].depth = img.depth;
35089 new_data[npos].dim = img.dim; new_data[npos].is_shared =
true; new_data[npos].data = img.data;
35091 new_data[npos].width = new_data[npos].height = new_data[npos].depth = new_data[npos].dim = 0; new_data[npos].data = 0;
35092 new_data[npos] = img;
35098 if (npos!=width-1) std::memmove(
data+npos+1,
data+npos,
sizeof(
CImg<T>)*(width-1-npos));
35099 if (shared && img) {
35100 data[npos].width = img.width;
data[npos].height = img.height;
data[npos].depth = img.depth;
data[npos].dim = img.dim;
35101 data[npos].is_shared =
true;
data[npos].data = img.data;
35103 data[npos].width =
data[npos].height =
data[npos].depth =
data[npos].dim = 0;
data[npos].data = 0;
35111 template<
typename t>
35113 return (+*
this).
insert(img,pos,shared);
35119 if (!n)
return *
this;
35120 const unsigned int npos = pos==~0U?width:pos;
35121 for (
unsigned int i = 0; i<
n; ++
i)
insert(foo,npos+i);
35126 return (+*
this).
insert(n,pos);
35130 template<
typename t>
35132 if (!n)
return *
this;
35133 const unsigned int npos = pos==~0U?width:pos;
35134 insert(img,npos,shared);
35135 for (
unsigned int i = 1; i<
n; ++
i)
insert(
data[npos],npos+i,shared);
35139 template<
typename t>
35141 return (+*
this).
insert(n,img,pos,shared);
35145 template<
typename t>
35147 const unsigned int npos = pos==~0U?width:pos;
35153 template<
typename t>
35155 return (+*
this).
insert(list,pos,shared);
35159 template<
typename t>
35161 if (!n)
return *
this;
35162 const unsigned int npos = pos==~0U?width:pos;
35163 for (
unsigned int i = 0; i<
n; ++
i)
insert(list,npos,shared);
35167 template<
typename t>
35169 return (+*
this).
insert(n,list,pos,shared);
35175 npos1 = pos1<pos2?pos1:pos2,
35176 tpos2 = pos1<pos2?pos2:pos1,
35177 npos2 = tpos2<width?tpos2:width-1;
35179 cimg::warn(
"CImgList<%s>::remove() : Cannot remove images from a list (%p,%u), at positions %u->%u.",
35183 cimg::warn(
"CImgList<%s>::remove() : Cannot remove all images from a list (%p,%u), at positions %u->%u.",
35186 const unsigned int nb = 1 + npos2 - npos1;
35187 if (!(width-=nb))
return assign();
35189 if (npos1!=width) std::memmove(
data+npos1,
data+npos2+1,
sizeof(
CImg<T>)*(width - npos1));
35195 if (npos1) std::memcpy(new_data,
data,
sizeof(
CImg<T>)*npos1);
35196 if (npos1!=width) std::memcpy(new_data+npos1,
data+npos2+1,
sizeof(
CImg<T>)*(width-npos1));
35207 return (+*
this).
remove(pos1,pos2);
35212 return remove(pos,pos);
35216 return (+*
this).
remove(pos);
35221 if (width)
return remove(width-1);
35222 else cimg::warn(
"CImgList<%s>::remove() : List is empty",
35228 return (+*
this).
remove();
35233 for (
unsigned int l = 0; l<width/2; ++l) (*
this)[l].
swap((*
this)[width-1-l]);
35243 return get_images(i0,i1).transfer_to(*
this);
35247 if (i0>i1 || i1>=width)
35248 throw CImgArgumentException(
"CImgList<%s>::images() : Cannot build a sublist (%u->%u) from a list (%u,%p)",
35257 if (i0>i1 || i1>=width)
35258 throw CImgArgumentException(
"CImgList<%s>::get_shared_images() : Cannot build a sublist (%u->%u) from a list (%u,%p)",
35266 if (i0>i1 || i1>=width)
35267 throw CImgArgumentException(
"CImgList<%s>::get_shared_images() : Cannot build a sublist (%u->%u) from a list (%u,%p)",
35281 if (align!=
'p' && align!=
'c' && align!=
'n')
35282 throw CImgArgumentException(
"CImg<%s>::get_append() : Invalid alignment parameter '%c' (should be 'p','c' or 'n').",
35285 if (width==1)
return +((*this)[0]);
35286 unsigned int dx = 0,
dy = 0, dz = 0, dv = 0, pos = 0;
35291 const CImg<T>& img = (*this)[l];
35294 res.assign(dx,
dy,dz,dv,0);
35298 res.draw_image(pos,(*
this)[l]);
35299 pos+=(*this)[l].width;
35304 res.draw_image(pos,(
dy-(*
this)[l].height)/2,(dz-(*
this)[l].depth)/2,(dv-(*
this)[l].dim)/2,(*
this)[l]);
35305 pos+=(*this)[l].width;
35310 res.draw_image(pos,
dy-(*
this)[l].height,dz-(*
this)[l].depth,dv-(*
this)[l].dim,(*
this)[l]);
35311 pos+=(*this)[l].width;
35317 const CImg<T>& img = (*this)[l];
35320 res.assign(dx,
dy,dz,dv,0);
35323 cimglist_for(*
this,l) { res.draw_image(0,pos,(*
this)[l]); pos+=(*this)[l].height; }
35327 res.draw_image((dx-(*
this)[l].width)/2,pos,(dz-(*
this)[l].depth)/2,(dv-(*
this)[l].dim)/2,(*
this)[l]);
35328 pos+=(*this)[l].height;
35333 res.draw_image(dx-(*
this)[l].width,pos,dz-(*
this)[l].depth,dv-(*
this)[l].dim,(*
this)[l]);
35334 pos+=(*this)[l].height;
35340 const CImg<T>& img = (*this)[l];
35343 res.assign(dx,
dy,dz,dv,0);
35346 cimglist_for(*
this,l) { res.draw_image(0,0,pos,(*
this)[l]); pos+=(*this)[l].depth; }
35350 res.draw_image((dx-(*
this)[l].width)/2,(
dy-(*
this)[l].height)/2,pos,(dv-(*
this)[l].dim)/2,(*
this)[l]);
35351 pos+=(*this)[l].depth;
35356 res.draw_image(dx-(*
this)[l].width,
dy-(*
this)[l].height,pos,dv-(*
this)[l].dim,(*
this)[l]);
35357 pos+=(*this)[l].depth;
35363 const CImg<T>& img = (*this)[l];
35366 res.assign(dx,
dy,dz,dv,0);
35369 cimglist_for(*
this,l) { res.draw_image(0,0,0,pos,(*
this)[l]); pos+=(*this)[l].dim; }
35373 res.draw_image((dx-(*
this)[l].width)/2,(
dy-(*
this)[l].height)/2,(dz-(*
this)[l].depth)/2,pos,(*
this)[l]);
35374 pos+=(*this)[l].dim;
35379 res.draw_image(dx-(*
this)[l].width,
dy-(*
this)[l].height,dz-(*
this)[l].depth,pos,(*
this)[l]);
35380 pos+=(*this)[l].dim;
35385 throw CImgArgumentException(
"CImgList<%s>::get_append() : Invalid axis parameter '%c' (should be 'x','y','z' or 'v').",
35393 return get_split(axis,nb).transfer_to(*
this);
35403 template<
typename t>
35409 template<
typename t>
35415 template<
typename t>
35421 template<
typename t>
35428 return remove(width-1);
35438 return remove(iter-
data);
35455 #ifdef cimglist_load_plugin
35456 cimglist_load_plugin(filename);
35458 #ifdef cimglist_load_plugin1
35459 cimglist_load_plugin1(filename);
35461 #ifdef cimglist_load_plugin2
35462 cimglist_load_plugin2(filename);
35464 #ifdef cimglist_load_plugin3
35465 cimglist_load_plugin3(filename);
35467 #ifdef cimglist_load_plugin4
35468 cimglist_load_plugin4(filename);
35470 #ifdef cimglist_load_plugin5
35471 cimglist_load_plugin5(filename);
35473 #ifdef cimglist_load_plugin6
35474 cimglist_load_plugin6(filename);
35476 #ifdef cimglist_load_plugin7
35477 cimglist_load_plugin7(filename);
35479 #ifdef cimglist_load_plugin8
35480 cimglist_load_plugin8(filename);
35517 data->load(filename);
35551 #ifdef cimg_use_zlib
35552 #define _cimgz_load_cimg_case(Tss) { \
35553 Bytef *const cbuf = new Bytef[csiz]; \
35554 cimg::fread(cbuf,csiz,nfile); \
35555 raw.assign(W,H,D,V); \
35556 unsigned long destlen = (unsigned long)raw.size()*sizeof(T); \
35557 uncompress((Bytef*)raw.data,&destlen,cbuf,csiz); \
35559 const Tss *ptrs = raw.data; \
35560 for (unsigned int off = raw.size(); off; --off) *(ptrd++) = (T)*(ptrs++); \
35563 #define _cimgz_load_cimg_case(Tss) \
35564 throw CImgIOException("CImgList<%s>::load_cimg() : File '%s' contains compressed data, zlib must be used",\
35565 pixel_type(),filename?filename:"(FILE*)");
35568 #define _cimg_load_cimg_case(Ts,Tss) \
35569 if (!loaded && !cimg::strcasecmp(Ts,str_pixeltype)) { \
35570 for (unsigned int l = 0; l<N; ++l) { \
35571 j = 0; while ((i=std::fgetc(nfile))!='\n' && i>=0) tmp[j++] = (char)i; tmp[j] = 0; \
35572 W = H = D = V = 0; csiz = 0; \
35573 if ((err = std::sscanf(tmp,"%u %u %u %u #%u",&W,&H,&D,&V,&csiz))<4) \
35574 throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", \
35575 pixel_type(),filename?filename:("(FILE*)"),W,H,D,V); \
35578 CImg<T> &img = data[l]; \
35579 img.assign(W,H,D,V); \
35580 T *ptrd = img.data; \
35581 if (err==5) _cimgz_load_cimg_case(Tss) \
35582 else for (int toread = (int)img.size(); toread>0; ) { \
35583 raw.assign(cimg::min(toread,cimg_iobuffer)); \
35584 cimg::fread(raw.data,raw.width,nfile); \
35585 if (endian!=cimg::endianness()) cimg::invert_endianness(raw.data,raw.width); \
35586 toread-=raw.width; \
35587 const Tss *ptrs = raw.data; \
35588 for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); \
35595 if (!filename && !file)
35598 typedef unsigned char uchar;
35599 typedef unsigned short ushort;
35600 typedef unsigned int uint;
35601 typedef unsigned long ulong;
35602 const int cimg_iobuffer = 12*1024*1024;
35603 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"rb");
35605 char tmp[256] = { 0 }, str_pixeltype[256] = { 0 }, str_endian[256] = { 0 };
35606 unsigned int j, err, N = 0, W, H, D, V, csiz;
35608 j = 0;
while((i=std::fgetc(nfile))!=
'\n' && i!=EOF && j<256) tmp[j++] = (char)i; tmp[
j] = 0;
35609 err = std::sscanf(tmp,
"%u%*c%255[A-Za-z_]%*c%255[sA-Za-z_ ]",&N,str_pixeltype,str_endian);
35612 throw CImgIOException(
"CImgList<%s>::load_cimg() : File '%s', Unknow CImg RAW header.",
35635 throw CImgIOException(
"CImgList<%s>::load_cimg() : File '%s', cannot read images of pixels coded as '%s'.",
35636 pixel_type(),filename?filename:
"(FILE*)",str_pixeltype);
35644 const unsigned int n0,
const unsigned int n1,
35645 const unsigned int x0,
const unsigned int y0,
const unsigned int z0,
const unsigned int v0,
35646 const unsigned int x1,
const unsigned int y1,
const unsigned int z1,
const unsigned int v1) {
35647 return _load_cimg(0,filename,n0,n1,x0,y0,z0,v0,x1,y1,z1,v1);
35651 const unsigned int n0,
const unsigned int n1,
35652 const unsigned int x0,
const unsigned int y0,
const unsigned int z0,
const unsigned int v0,
35653 const unsigned int x1,
const unsigned int y1,
const unsigned int z1,
const unsigned int v1) {
35654 return CImgList<T>().
load_cimg(filename,n0,n1,x0,y0,z0,v0,x1,y1,z1,v1);
35659 const unsigned int n0,
const unsigned int n1,
35660 const unsigned int x0,
const unsigned int y0,
const unsigned int z0,
const unsigned int v0,
35661 const unsigned int x1,
const unsigned int y1,
const unsigned int z1,
const unsigned int v1) {
35662 return _load_cimg(file,0,n0,n1,x0,y0,z0,v0,x1,y1,z1,v1);
35666 const unsigned int n0,
const unsigned int n1,
35667 const unsigned int x0,
const unsigned int y0,
const unsigned int z0,
const unsigned int v0,
35668 const unsigned int x1,
const unsigned int y1,
const unsigned int z1,
const unsigned int v1) {
35669 return CImgList<T>().
load_cimg(file,n0,n1,x0,y0,z0,v0,x1,y1,z1,v1);
35673 const unsigned int n0,
const unsigned int n1,
35674 const unsigned int x0,
const unsigned int y0,
const unsigned int z0,
const unsigned int v0,
35675 const unsigned int x1,
const unsigned int y1,
const unsigned int z1,
const unsigned int v1) {
35676 #define _cimg_load_cimg_case2(Ts,Tss) \
35677 if (!loaded && !cimg::strcasecmp(Ts,str_pixeltype)) { \
35678 for (unsigned int l = 0; l<=nn1; ++l) { \
35679 j = 0; while ((i=std::fgetc(nfile))!='\n' && i>=0) tmp[j++] = (char)i; tmp[j] = 0; \
35680 W = H = D = V = 0; \
35681 if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) \
35682 throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", \
35683 pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); \
35685 if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(Tss),SEEK_CUR); \
35687 const unsigned int \
35688 nx1 = x1>=W?W-1:x1, \
35689 ny1 = y1>=H?H-1:y1, \
35690 nz1 = z1>=D?D-1:z1, \
35691 nv1 = v1>=V?V-1:v1; \
35692 CImg<Tss> raw(1 + nx1 - x0); \
35693 CImg<T> &img = data[l - n0]; \
35694 img.assign(1 + nx1 - x0,1 + ny1 - y0,1 + nz1 - z0,1 + nv1 - v0); \
35695 T *ptrd = img.data; \
35696 const unsigned int skipvb = v0*W*H*D*sizeof(Tss); \
35697 if (skipvb) std::fseek(nfile,skipvb,SEEK_CUR); \
35698 for (unsigned int v = 1 + nv1 - v0; v; --v) { \
35699 const unsigned int skipzb = z0*W*H*sizeof(Tss); \
35700 if (skipzb) std::fseek(nfile,skipzb,SEEK_CUR); \
35701 for (unsigned int z = 1 + nz1 - z0; z; --z) { \
35702 const unsigned int skipyb = y0*W*sizeof(Tss); \
35703 if (skipyb) std::fseek(nfile,skipyb,SEEK_CUR); \
35704 for (unsigned int y = 1 + ny1 - y0; y; --y) { \
35705 const unsigned int skipxb = x0*sizeof(Tss); \
35706 if (skipxb) std::fseek(nfile,skipxb,SEEK_CUR); \
35707 cimg::fread(raw.data,raw.width,nfile); \
35708 if (endian!=cimg::endianness()) cimg::invert_endianness(raw.data,raw.width); \
35709 const Tss *ptrs = raw.data; \
35710 for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); \
35711 const unsigned int skipxe = (W-1-nx1)*sizeof(Tss); \
35712 if (skipxe) std::fseek(nfile,skipxe,SEEK_CUR); \
35714 const unsigned int skipye = (H-1-ny1)*W*sizeof(Tss); \
35715 if (skipye) std::fseek(nfile,skipye,SEEK_CUR); \
35717 const unsigned int skipze = (D-1-nz1)*W*H*sizeof(Tss); \
35718 if (skipze) std::fseek(nfile,skipze,SEEK_CUR); \
35720 const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(Tss); \
35721 if (skipve) std::fseek(nfile,skipve,SEEK_CUR); \
35728 if (!filename && !file)
35731 typedef unsigned char uchar;
35732 typedef unsigned short ushort;
35733 typedef unsigned int uint;
35734 typedef unsigned long ulong;
35735 if (n1<n0 || x1<x0 || y1<y0 || z1<z0 || v1<v0)
35736 throw CImgArgumentException(
"CImgList<%s>::load_cimg() : File '%s', Bad sub-region coordinates [%u->%u] "
35737 "(%u,%u,%u,%u)->(%u,%u,%u,%u).",
35739 n0,n1,x0,y0,z0,v0,x1,y1,z1,v1);
35740 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"rb");
35742 char tmp[256] = { 0 }, str_pixeltype[256] = { 0 }, str_endian[256] = { 0 };
35743 unsigned int j, err, N, W, H, D, V;
35745 j = 0;
while((i=std::fgetc(nfile))!=
'\n' && i!=EOF && j<256) tmp[j++] = (char)i; tmp[
j] = 0;
35746 err = std::sscanf(tmp,
"%u%*c%255[A-Za-z_]%*c%255[sA-Za-z_ ]",&N,str_pixeltype,str_endian);
35749 throw CImgIOException(
"CImgList<%s>::load_cimg() : File '%s', Unknow CImg RAW header.",
35754 const unsigned int nn1 = n1>=N?N-1:n1;
35773 throw CImgIOException(
"CImgList<%s>::load_cimg() : File '%s', cannot read images of pixels coded as '%s'.",
35774 pixel_type(),filename?filename:
"(FILE*)",str_pixeltype);
35785 char body[1024] = { 0 }, filenamepar[1024] = { 0 }, filenamerec[1024] = { 0 };
35787 if (!std::strcmp(ext,
"par")) { std::strcpy(filenamepar,filename); std::sprintf(filenamerec,
"%s.rec",body); }
35788 if (!std::strcmp(ext,
"PAR")) { std::strcpy(filenamepar,filename); std::sprintf(filenamerec,
"%s.REC",body); }
35789 if (!std::strcmp(ext,
"rec")) { std::strcpy(filenamerec,filename); std::sprintf(filenamepar,
"%s.par",body); }
35790 if (!std::strcmp(ext,
"REC")) { std::strcpy(filenamerec,filename); std::sprintf(filenamepar,
"%s.PAR",body); }
35797 char line[256] = { 0 };
35798 do { err=std::fscanf(file,
"%255[^\n]%*c",line); }
while (err!=EOF && (line[0]==
'#' || line[0]==
'.'));
35800 unsigned int sn,sizex,sizey,pixsize;
35802 err = std::fscanf(file,
"%u%*u%*u%*u%*u%*u%*u%u%*u%u%u%g%g%g%*[^\n]",&sn,&pixsize,&sizex,&sizey,&ri,&rs,&ss);
35804 CImg<floatT>::vector((
float)sn,(
float)pixsize,(
float)sizex,(
float)sizey,ri,rs,ss,0).transfer_to(st_slices);
35805 unsigned int i;
for (i = 0; i<st_global.
width && sn<=st_global[
i][2]; ++
i) {}
35809 if (sizex>vec[0]) vec[0] = sizex;
35810 if (sizey>vec[1]) vec[1] = sizey;
35813 st_slices[st_slices.width-1][7] = (float)i;
35818 std::FILE *file2 =
cimg::fopen(filenamerec,
"rb");
35827 sn = (
unsigned int)vec[0]-1,
35828 pixsize = (
unsigned int)vec[1],
35829 sizex = (
unsigned int)vec[2],
35830 sizey = (
unsigned int)vec[3],
35831 imn = (
unsigned int)vec[7];
35832 const float ri = vec[4],
rs = vec[5], ss = vec[6];
35839 cimg_forXY(img,x,y) img(x,y,sn) = (T)(( buf(x,y)*rs + ri )/(rs*ss));
35846 cimg_forXY(img,x,y) img(x,y,sn) = (T)(( buf(x,y)*rs + ri )/(rs*ss));
35853 cimg_forXY(img,x,y) img(x,y,sn) = (T)(( buf(x,y)*rs + ri )/(rs*ss));
35858 throw CImgIOException(
"CImg<%s>::load_parrec() : File '%s', cannot handle image with pixsize = %d bits.",
35865 throw CImgIOException(
"CImg<%s>::load_parrec() : File '%s' does not appear to be a valid PAR-REC file.",
35876 const unsigned int sizex,
const unsigned int sizey,
35877 const unsigned int first_frame=0,
const unsigned int last_frame=~0U,
35878 const unsigned int step_frame=1,
const bool yuv2rgb=
true) {
35879 return _load_yuv(0,filename,sizex,sizey,first_frame,last_frame,step_frame,yuv2rgb);
35883 const unsigned int sizex,
const unsigned int sizey=1,
35884 const unsigned int first_frame=0,
const unsigned int last_frame=~0U,
35885 const unsigned int step_frame=1,
const bool yuv2rgb=
true) {
35886 return CImgList<T>().
load_yuv(filename,sizex,sizey,first_frame,last_frame,step_frame,yuv2rgb);
35891 const unsigned int sizex,
const unsigned int sizey,
35892 const unsigned int first_frame=0,
const unsigned int last_frame=~0U,
35893 const unsigned int step_frame=1,
const bool yuv2rgb=
true) {
35894 return _load_yuv(file,0,sizex,sizey,first_frame,last_frame,step_frame,yuv2rgb);
35898 const unsigned int sizex,
const unsigned int sizey=1,
35899 const unsigned int first_frame=0,
const unsigned int last_frame=~0U,
35900 const unsigned int step_frame=1,
const bool yuv2rgb=
true) {
35901 return CImgList<T>().
load_yuv(file,sizex,sizey,first_frame,last_frame,step_frame,yuv2rgb);
35905 const unsigned int sizex,
const unsigned int sizey,
35906 const unsigned int first_frame,
const unsigned int last_frame,
35907 const unsigned int step_frame,
const bool yuv2rgb) {
35908 if (!filename && !file)
35911 if (sizex%2 || sizey%2)
35912 throw CImgArgumentException(
"CImgList<%s>::load_yuv() : File '%s', image dimensions along X and Y must be "
35913 "even numbers (given are %ux%u)\n",
35914 pixel_type(),filename?filename:
"(FILE*)",sizex,sizey);
35915 if (!sizex || !sizey)
35916 throw CImgArgumentException(
"CImgList<%s>::load_yuv() : File '%s', given image sequence size (%u,%u) is invalid",
35917 pixel_type(),filename?filename:
"(FILE*)",sizex,sizey);
35920 nfirst_frame = first_frame<last_frame?first_frame:last_frame,
35921 nlast_frame = first_frame<last_frame?last_frame:first_frame,
35922 nstep_frame = step_frame?step_frame:1;
35924 CImg<ucharT> tmp(sizex,sizey,1,3), UV(sizex/2,sizey/2,1,2);
35925 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"rb");
35926 bool stopflag =
false;
35928 if (nfirst_frame) {
35929 err = std::fseek(nfile,nfirst_frame*(sizex*sizey + sizex*sizey/2),SEEK_CUR);
35932 throw CImgIOException(
"CImgList<%s>::load_yuv() : File '%s' doesn't contain frame number %u "
35933 "(out of range error).",
35934 pixel_type(),filename?filename:
"(FILE*)",nfirst_frame);
35937 unsigned int frame;
35938 for (frame = nfirst_frame; !stopflag && frame<=nlast_frame; frame+=nstep_frame) {
35941 err = (int)
std::fread((
void*)(tmp.data),1,(
size_t)(tmp.width*tmp.height),nfile);
35942 if (err!=(
int)(tmp.width*tmp.height)) {
35945 cimg::warn(
"CImgList<%s>::load_yuv() : File '%s' contains incomplete data,"
35946 " or given image dimensions (%u,%u) are incorrect.",
35947 pixel_type(),filename?filename:
"(FILE*)",sizex,sizey);
35951 err = (int)
std::fread((
void*)(UV.data),1,(
size_t)(UV.size()),nfile);
35952 if (err!=(
int)(UV.size())) {
35955 cimg::warn(
"CImgList<%s>::load_yuv() : File '%s' contains incomplete data,"
35956 " or given image dimensions (%u,%u) are incorrect.",
35957 pixel_type(),filename?filename:
"(FILE*)",sizex,sizey);
35960 const int x2 = x*2, y2 = y*2;
35961 tmp(x2,y2,1) = tmp(x2+1,y2,1) = tmp(x2,y2+1,1) = tmp(x2+1,y2+1,1) = UV(x,y,0);
35962 tmp(x2,y2,2) = tmp(x2+1,y2,2) = tmp(x2,y2+1,2) = tmp(x2+1,y2+1,2) = UV(x,y,1);
35964 if (yuv2rgb) tmp.YCbCrtoRGB();
35966 if (nstep_frame>1) std::fseek(nfile,(nstep_frame-1)*(sizex*sizey + sizex*sizey/2),SEEK_CUR);
35970 if (stopflag && nlast_frame!=~0U && frame!=nlast_frame)
35971 cimg::warn(
"CImgList<%s>::load_yuv() : File '%s', frame %d not reached since only %u frames were found in the file.",
35972 pixel_type(),filename?filename:
"(FILE*)",nlast_frame,frame-1,filename);
35981 const unsigned int step_frame=1,
const bool pixel_format=
true,
const bool resume=
false) {
35986 nfirst_frame = first_frame<last_frame?first_frame:last_frame,
35987 nlast_frame = first_frame<last_frame?last_frame:first_frame,
35988 nstep_frame = step_frame?step_frame:1;
35991 #ifndef cimg_use_ffmpeg
35992 if ((nfirst_frame || nlast_frame!=~0U || nstep_frame>1) || (resume && (pixel_format || !pixel_format)))
35993 throw CImgArgumentException(
"CImg<%s>::load_ffmpeg() : File '%s', reading sub-frames from a video file requires the use of ffmpeg.\n"
35994 "('cimg_use_ffmpeg' must be defined).",
35998 const unsigned int ffmpeg_pixfmt = pixel_format?PIX_FMT_RGB24:PIX_FMT_GRAY8;
35999 avcodec_register_all();
36001 static AVFormatContext *format_ctx = 0;
36002 static AVCodecContext *codec_ctx = 0;
36003 static AVCodec *codec = 0;
36004 static AVFrame *avframe = avcodec_alloc_frame(), *converted_frame = avcodec_alloc_frame();
36005 static int vstream = 0;
36008 if (!format_ctx || !codec_ctx || !codec || !avframe || !converted_frame)
36009 throw CImgArgumentException(
"CImgList<%s>::load_ffmpeg() : File '%s', cannot resume due to unallocated FFMPEG structures.",
36013 if (format_ctx) av_close_input_file(format_ctx);
36014 if (av_open_input_file(&format_ctx,filename,0,0,0)!=0)
36015 throw CImgIOException(
"CImgList<%s>::load_ffmpeg() : File '%s' cannot be opened.",
36017 if (!avframe || !converted_frame || av_find_stream_info(format_ctx)<0) {
36018 av_close_input_file(format_ctx); format_ctx = 0;
36019 cimg::warn(
"CImgList<%s>::load_ffmpeg() : File '%s', cannot retrieve stream information.\n"
36020 "Trying with external ffmpeg executable.",
36025 dump_format(format_ctx,0,0,0);
36030 if (!first_frame && !last_frame && !step_frame) {
36031 for (vstream = 0; vstream<(int)(format_ctx->nb_streams); ++vstream)
36032 if (format_ctx->streams[vstream]->codec->codec_type==CODEC_TYPE_VIDEO)
break;
36033 if (vstream==(
int)format_ctx->nb_streams)
assign();
36039 for (nb_frames = 0; av_read_frame(format_ctx,&packet)>=0; av_free_packet(&packet))
36040 if (packet.stream_index==vstream) {
36046 framew = format_ctx->streams[vstream]->codec->width,
36047 frameh = format_ctx->streams[vstream]->codec->height;
36049 num = (float)(format_ctx->streams[vstream]->r_frame_rate).num,
36050 den = (float)(format_ctx->streams[vstream]->r_frame_rate).den,
36054 (*this)[0].assign(1,4).fill((T)nb_frames,(T)framew,(T)frameh,(T)fps);
36055 (*this)[1] = (timestamps>
'y');
36057 av_close_input_file(format_ctx); format_ctx = 0;
36061 for (vstream = 0; vstream<(int)(format_ctx->nb_streams) &&
36062 format_ctx->streams[vstream]->codec->codec_type!=CODEC_TYPE_VIDEO; ) ++vstream;
36063 if (vstream==(
int)format_ctx->nb_streams) {
36064 cimg::warn(
"CImgList<%s>::load_ffmpeg() : File '%s', cannot retrieve video stream.\n"
36065 "Trying with external ffmpeg executable.",
36067 av_close_input_file(format_ctx); format_ctx = 0;
36070 codec_ctx = format_ctx->streams[vstream]->codec;
36071 codec = avcodec_find_decoder(codec_ctx->codec_id);
36073 cimg::warn(
"CImgList<%s>::load_ffmpeg() : File '%s', cannot find video codec.\n"
36074 "Trying with external ffmpeg executable.",
36078 if (avcodec_open(codec_ctx,codec)<0) {
36079 cimg::warn(
"CImgList<%s>::load_ffmpeg() : File '%s', cannot open video codec.\n"
36080 "Trying with external ffmpeg executable.",
36087 const unsigned int numBytes = avpicture_get_size(ffmpeg_pixfmt,codec_ctx->width,codec_ctx->height);
36088 uint8_t *
const buffer =
new uint8_t[numBytes];
36089 avpicture_fill((AVPicture *)converted_frame,buffer,ffmpeg_pixfmt,codec_ctx->width,codec_ctx->height);
36090 const T foo = (T)0;
36092 for (
unsigned int frame = 0, next_frame = nfirst_frame; frame<=nlast_frame && av_read_frame(format_ctx,&packet)>=0; ) {
36093 if (packet.stream_index==(
int)vstream) {
36095 avcodec_decode_video(codec_ctx,avframe,&decoded,packet.data,packet.size);
36097 if (frame==next_frame) {
36098 SwsContext *c = sws_getContext(codec_ctx->width,codec_ctx->height,codec_ctx->pix_fmt,codec_ctx->width,
36099 codec_ctx->height,ffmpeg_pixfmt,1,0,0,0);
36100 sws_scale(c,avframe->data,avframe->linesize,0,codec_ctx->height,converted_frame->data,converted_frame->linesize);
36101 if (ffmpeg_pixfmt==PIX_FMT_RGB24) {
36102 CImg<ucharT> next_image(*converted_frame->data,3,codec_ctx->width,codec_ctx->height,1,
true);
36103 next_image._get_permute_axes(
"yzvx",foo).transfer_to(*
this);
36105 CImg<ucharT> next_image(*converted_frame->data,1,codec_ctx->width,codec_ctx->height,1,
true);
36106 next_image._get_permute_axes(
"yzvx",foo).transfer_to(*
this);
36108 next_frame+=nstep_frame;
36112 av_free_packet(&packet);
36113 if (next_frame>nlast_frame)
break;
36122 const unsigned int step_frame=1,
const bool pixel_format=
true) {
36131 char command[1024] = { 0 }, filetmp[512] = { 0 }, filetmp2[512] = { 0 };
36132 std::FILE *file = 0;
36135 std::sprintf(filetmp2,
"%s_000001.ppm",filetmp);
36138 std::sprintf(filetmp2,
"%s_%%6d.ppm",filetmp);
36140 std::sprintf(command,
"%s -i \"%s\" %s >/dev/null 2>&1",
cimg::ffmpeg_path(),filename,filetmp2);
36142 std::sprintf(command,
"\"%s -i \"%s\" %s\" >NUL 2>&1",
cimg::ffmpeg_path(),filename,filetmp2);
36148 unsigned int i = 1;
36149 for (
bool stopflag =
false; !stopflag; ++
i) {
36150 std::sprintf(filetmp2,
"%s_%.6u.ppm",filetmp,i);
36152 try { img.load_pnm(filetmp2); }
36154 if (img) { img.transfer_to(*
this); std::remove(filetmp2); }
36158 throw CImgIOException(
"CImgList<%s>::load_ffmpeg_external() : Failed to open image sequence '%s'.\n"
36159 "Check the filename and if the 'ffmpeg' tool is installed on your system.",
36171 throw CImgIOException(
"CImg<%s>::load_gzip_external() : Cannot load (null) filename.",
36173 char command[1024] = { 0 }, filetmp[512] = { 0 }, body[512] = { 0 };
36177 std::FILE *file = 0;
36188 std::sprintf(command,
"%s -c \"%s\" > %s",
cimg::gunzip_path(),filename,filetmp);
36192 throw CImgIOException(
"CImg<%s>::load_gzip_external() : File '%s' cannot be opened.",
36196 std::remove(filetmp);
36205 template<
typename tf,
typename tc>
36208 return get_load_off(filename,primitives,colors).transfer_to(*
this);
36211 template<
typename tf,
typename tc>
36219 const unsigned int first_frame=0,
const unsigned int last_frame=~0U,
36220 const unsigned int step_frame=1) {
36222 nfirst_frame = first_frame<last_frame?first_frame:last_frame,
36223 nstep_frame = step_frame?step_frame:1;
36224 unsigned int nlast_frame = first_frame<last_frame?last_frame:first_frame;
36225 #ifndef cimg_use_tiff
36226 if (nfirst_frame || nlast_frame!=~0U || nstep_frame!=1)
36227 throw CImgArgumentException(
"CImgList<%s>::load_tiff() : File '%s', reading sub-images from a tiff file requires the use of libtiff.\n"
36228 "('cimg_use_tiff' must be defined).",
36232 TIFF *tif = TIFFOpen(filename,
"r");
36234 unsigned int nb_images = 0;
36235 do ++nb_images;
while (TIFFReadDirectory(tif));
36236 if (nfirst_frame>=nb_images || (nlast_frame!=~0U && nlast_frame>=nb_images))
36237 cimg::warn(
"CImgList<%s>::load_tiff() : File '%s' contains %u image(s), specified frame range is [%u,%u] (step %u).",
36238 pixel_type(),filename,nb_images,nfirst_frame,nlast_frame,nstep_frame);
36239 if (nfirst_frame>=nb_images)
return assign();
36240 if (nlast_frame>=nb_images) nlast_frame = nb_images-1;
36241 assign(1+(nlast_frame-nfirst_frame)/nstep_frame);
36242 TIFFSetDirectory(tif,0);
36244 TIFFSetWarningHandler(0);
36245 TIFFSetErrorHandler(0);
36247 cimglist_for(*
this,l)
data[l]._load_tiff(tif,nfirst_frame + l*nstep_frame);
36249 }
else throw CImgException(
"CImgList<%s>::load_tiff() : File '%s' cannot be opened.",
36256 const unsigned int first_frame=0,
const unsigned int last_frame=~0U,
36257 const unsigned int step_frame=1) {
36270 unsigned int msiz = 0;
36273 const unsigned int mdisp = msiz<8*1024?0:(msiz<8*1024*1024?1:2);
36274 char ntitle[64] = { 0 };
36275 if (!title) std::sprintf(ntitle,
"CImgList<%s>",
pixel_type());
36276 std::fprintf(
cimg_stdout,
"%s: this = %p, size = %u [%u %s], data = (CImg<%s>*)%p..%p.\n",
36277 title?title:ntitle,(
void*)
this,width,
36278 mdisp==0?msiz:(mdisp==1?(msiz>>10):(msiz>>20)),
36279 mdisp==0?
"b":(mdisp==1?
"Kb":
"Mb"),
36281 char tmp[16] = { 0 };
36283 std::sprintf(tmp,
"[%d]",ll);
36285 data[ll].print(tmp,display_stats);
36286 if (ll==3 && width>8) { ll = width-5; std::fprintf(
cimg_stdout,
" ...\n"); }
36317 const bool display_info,
const char axis=
'x',
const char align=
'p')
const {
36323 visu.display(disp,
false);
36329 const bool display_info=
true,
const char axis=
'x',
const char align=
'p')
const {
36331 char ntitle[64] = { 0 };
36332 if (!title) std::sprintf(ntitle,
"CImgList<%s>",
pixel_type());
36333 if (display_info)
print(title?title:ntitle);
36334 visu.display(title?title:ntitle,
false);
36347 throw CImgArgumentException(
"CImg<%s>::save() : Instance list (%u,%p), specified filename is (null).",
36350 char nfilename[1024] = { 0 };
36352 #ifdef cimglist_save_plugin
36353 cimglist_save_plugin(fn);
36355 #ifdef cimglist_save_plugin1
36356 cimglist_save_plugin1(fn);
36358 #ifdef cimglist_save_plugin2
36359 cimglist_save_plugin2(fn);
36361 #ifdef cimglist_save_plugin3
36362 cimglist_save_plugin3(fn);
36364 #ifdef cimglist_save_plugin4
36365 cimglist_save_plugin4(fn);
36367 #ifdef cimglist_save_plugin5
36368 cimglist_save_plugin5(fn);
36370 #ifdef cimglist_save_plugin6
36371 cimglist_save_plugin6(fn);
36373 #ifdef cimglist_save_plugin7
36374 cimglist_save_plugin7(fn);
36376 #ifdef cimglist_save_plugin8
36377 cimglist_save_plugin8(fn);
36379 #ifdef cimg_use_tiff
36414 const unsigned int fps=25)
const {
36416 throw CImgInstanceException(
"CImgList<%s>::save_ffmpeg() : File '%s', instance list (%u,%p) is empty.",
36419 throw CImgArgumentException(
"CImgList<%s>::save_ffmpeg() : Instance list (%u,%p), specified filename is (null).",
36424 const unsigned int nlast_frame = last_frame==~0U?width-1:last_frame;
36425 if (first_frame>=width || nlast_frame>=width)
36426 throw CImgArgumentException(
"CImgList<%s>::save_ffmpeg() : File '%s', specified frames [%u,%u] are out of list range (%u elements).",
36427 pixel_type(),filename,first_frame,last_frame,width);
36428 for (
unsigned int ll = first_frame; ll<=nlast_frame; ++ll)
if (!
data[ll].is_sameXYZ(
data[0]))
36429 throw CImgInstanceException(
"CImgList<%s>::save_ffmpeg() : File '%s', images of the sequence have different dimensions.",
36432 #ifndef cimg_use_ffmpeg
36435 avcodec_register_all();
36438 frame_dimx =
data[first_frame].dimx(),
36439 frame_dimy =
data[first_frame].dimy(),
36440 frame_dimv =
data[first_frame].dimv();
36441 if (frame_dimv!=1 && frame_dimv!=3)
36442 throw CImgInstanceException(
"CImgList<%s>::save_ffmpeg() : File '%s', image[0] (%u,%u,%u,%u,%p) has not 1 or 3 channels.",
36445 PixelFormat dest_pxl_fmt = PIX_FMT_YUV420P;
36446 PixelFormat src_pxl_fmt = (frame_dimv == 3)?PIX_FMT_RGB24:PIX_FMT_GRAY8;
36448 int sws_flags = SWS_FAST_BILINEAR;
36449 AVOutputFormat *fmt = 0;
36450 fmt = guess_format(0,filename,0);
36451 if (!fmt) fmt = guess_format(
"mpeg",0,0);
36453 throw CImgArgumentException(
"CImgList<%s>::save_ffmpeg() : File '%s', could not determine file format from filename.",
36456 AVFormatContext *oc = 0;
36457 oc = av_alloc_format_context();
36459 throw CImgIOException(
"CImgList<%s>::save_ffmpeg() : File '%s', failed to allocate structure for format context.",
36462 AVCodec *codec = 0;
36463 AVFrame *picture = 0;
36464 AVFrame *tmp_pict = 0;
36466 std::sprintf(oc->filename,
"%s",filename);
36469 int stream_index = 0;
36470 AVStream *video_str = 0;
36471 if (fmt->video_codec!=CODEC_ID_NONE) {
36472 video_str = av_new_stream(oc,stream_index);
36475 throw CImgIOException(
"CImgList<%s>::save_ffmpeg() : File '%s', failed to allocate video stream structure.",
36480 throw CImgIOException(
"CImgList<%s>::save_ffmpeg() : File '%s', no proper codec identified.",
36484 AVCodecContext *c = video_str->codec;
36485 c->codec_id = fmt->video_codec;
36486 c->codec_type = CODEC_TYPE_VIDEO;
36487 c->bit_rate = 400000;
36488 c->width = frame_dimx;
36489 c->height = frame_dimy;
36490 c->time_base.num = 1;
36491 c->time_base.den = fps;
36493 c->pix_fmt = dest_pxl_fmt;
36494 if (c->codec_id == CODEC_ID_MPEG2VIDEO) c->max_b_frames = 2;
36495 if (c->codec_id == CODEC_ID_MPEG1VIDEO) c->mb_decision = 2;
36497 if (av_set_parameters(oc,0)<0) {
36499 throw CImgIOException(
"CImgList<%s>::save_ffmpeg() : File '%s', parameters for avcodec not properly set.",
36504 codec = avcodec_find_encoder(c->codec_id);
36507 throw CImgIOException(
"CImgList<%s>::save_ffmpeg() : File '%s', no codec found.",
36510 if (avcodec_open(c,codec)<0)
36511 throw CImgIOException(
"CImgList<%s>::save_ffmpeg() : File '%s', failed to open codec.",
36513 tmp_pict = avcodec_alloc_frame();
36515 avcodec_close(video_str->codec);
36517 throw CImgIOException(
"CImgList<%s>::save_ffmpeg() : File '%s', failed to allocate memory for data buffer.",
36520 tmp_pict->linesize[0] = (src_pxl_fmt==PIX_FMT_RGB24)?3*frame_dimx:frame_dimx;
36521 tmp_pict->type = FF_BUFFER_TYPE_USER;
36522 int tmp_size = avpicture_get_size(src_pxl_fmt,frame_dimx,frame_dimy);
36523 uint8_t *tmp_buffer = (uint8_t*)av_malloc(tmp_size);
36526 avcodec_close(video_str->codec);
36528 throw CImgIOException(
"CImgList<%s>::save_ffmpeg() : File '%s', failed to allocate memory for data buffer.",
36533 avpicture_fill((AVPicture*)tmp_pict,tmp_buffer,src_pxl_fmt,frame_dimx,frame_dimy);
36534 picture = avcodec_alloc_frame();
36536 av_free(tmp_pict->data[0]);
36538 avcodec_close(video_str->codec);
36540 throw CImgIOException(
"CImgList<%s>::save_ffmpeg() : File '%s', failed to allocate memory for picture frame.",
36544 int size = avpicture_get_size(c->pix_fmt,frame_dimx,frame_dimy);
36545 uint8_t *buffer = (uint8_t*)av_malloc(size);
36548 av_free(tmp_pict->data[0]);
36550 avcodec_close(video_str->codec);
36552 throw CImgIOException(
"CImgList<%s>::save_ffmpeg() : File '%s', failed to allocate memory for picture frame buffer.",
36557 avpicture_fill((AVPicture*)picture,buffer,c->pix_fmt,frame_dimx,frame_dimy);
36560 if (!(fmt->flags&AVFMT_NOFILE)) {
36561 if (url_fopen(&oc->pb,filename,URL_WRONLY)<0)
36562 throw CImgIOException(
"CImgList<%s>::save_ffmpeg() : File '%s' cannot be opened.",
36566 if (av_write_header(oc)<0)
36567 throw CImgIOException(
"CImgList<%s>::save_ffmpeg() : File '%s', could not write header.",
36570 SwsContext *img_convert_context = 0;
36571 img_convert_context = sws_getContext(frame_dimx,frame_dimy,src_pxl_fmt,
36572 c->width,c->height,c->pix_fmt,sws_flags,0,0,0);
36573 if (!img_convert_context) {
36575 av_free(picture->data);
36577 av_free(tmp_pict->data[0]);
36579 avcodec_close(video_str->codec);
36581 throw CImgIOException(
"CImgList<%s>::save_ffmpeg() : File '%', failed to get conversion context.",
36584 int ret = 0, out_size;
36585 uint8_t *video_outbuf = 0;
36586 int video_outbuf_size = 1000000;
36587 video_outbuf = (uint8_t*)av_malloc(video_outbuf_size);
36588 if (!video_outbuf) {
36590 av_free(picture->data);
36592 av_free(tmp_pict->data[0]);
36594 avcodec_close(video_str->codec);
36596 throw CImgIOException(
"CImgList<%s>::save_ffmpeg() : File '%s', memory allocation error.",
36601 for (
unsigned int i = first_frame; i<=nlast_frame; ++
i) {
36603 if (src_pxl_fmt == PIX_FMT_RGB24) {
36604 red = currentIm.get_shared_channel(0);
36605 green = currentIm.get_shared_channel(1);
36606 blue = currentIm.get_shared_channel(2);
36608 tmp_pict->data[0][Y*tmp_pict->linesize[0] + 3*X] = red(X,Y);
36609 tmp_pict->data[0][Y*tmp_pict->linesize[0] + 3*X + 1] = green(X,Y);
36610 tmp_pict->data[0][Y*tmp_pict->linesize[0] + 3*X + 2] = blue(X,Y);
36613 gray = currentIm.get_shared_channel(0);
36614 cimg_forXY(currentIm,X,Y) tmp_pict->data[0][Y*tmp_pict->linesize[0] + X] = gray(X,Y);
36617 if (video_str) video_pts = (video_str->pts.val * video_str->time_base.num)/(video_str->time_base.den);
36618 else video_pts = 0.0;
36619 if (!video_str)
break;
36620 if (sws_scale(img_convert_context,tmp_pict->data,tmp_pict->linesize,0,c->height,picture->data,picture->linesize)<0)
break;
36621 out_size = avcodec_encode_video(c,video_outbuf,video_outbuf_size,picture);
36624 av_init_packet(&pkt);
36625 pkt.pts = av_rescale_q(c->coded_frame->pts,c->time_base,video_str->time_base);
36626 if (c->coded_frame->key_frame) pkt.flags|=PKT_FLAG_KEY;
36627 pkt.stream_index = video_str->index;
36628 pkt.data = video_outbuf;
36629 pkt.size = out_size;
36630 ret = av_write_frame(oc,&pkt);
36631 }
else if (out_size<0)
break;
36637 avcodec_close(video_str->codec);
36638 av_free(picture->data[0]);
36640 av_free(tmp_pict->data[0]);
36643 if (av_write_trailer(oc)<0)
36644 throw CImgIOException(
"CImgList<%s>::save_ffmpeg() : File '%s', failed to write trailer.",
36646 av_freep(&oc->streams[stream_index]->codec);
36647 av_freep(&oc->streams[stream_index]);
36648 if (!(fmt->flags&AVFMT_NOFILE)) {
36655 av_free(video_outbuf);
36663 throw CImgInstanceException(
"CImgList<%s>::save_yuv() : File '%s', instance list (%u,%p) is empty.",
36665 if (!file && !filename)
36666 throw CImgArgumentException(
"CImg<%s>::save_yuv() : Instance list (%u,%p), specified file is (null).",
36668 if ((*
this)[0].
dimx()%2 || (*
this)[0].dimy()%2)
36669 throw CImgInstanceException(
"CImgList<%s>::save_yuv() : File '%s', image dimensions must be even numbers (current are %ux%u).",
36670 pixel_type(),filename?filename:
"(FILE*)",(*
this)[0].
dimx(),(*
this)[0].dimy());
36672 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"wb");
36675 if (rgb2yuv) YCbCr.RGBtoYCbCr();
36676 cimg::fwrite(YCbCr.data,YCbCr.width*YCbCr.height,nfile);
36677 cimg::fwrite(YCbCr.get_resize(YCbCr.width/2, YCbCr.height/2,1,3,3).ptr(0,0,0,1),
36678 YCbCr.width*YCbCr.height/2,nfile);
36702 throw CImgInstanceException(
"CImgList<%s>::save_cimg() : File '%s', instance list (%u,%p) is empty.",
36704 if (!file && !filename)
36705 throw CImgArgumentException(
"CImg<%s>::save_cimg() : Instance list (%u,%p), specified file is (null).",
36707 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"wb");
36709 if (std::strstr(ptype,
"unsigned")==ptype) std::fprintf(nfile,
"%u unsigned_%s %s_endian\n",width,ptype+9,etype);
36710 else std::fprintf(nfile,
"%u %s %s_endian\n",width,ptype,etype);
36713 std::fprintf(nfile,
"%u %u %u %u",img.width,img.height,img.depth,img.dim);
36718 bool compressed =
false;
36720 #ifdef cimg_use_zlib
36721 const unsigned long siz =
sizeof(T)*ref.size();
36722 unsigned long csiz = siz + siz/100 + 16;
36723 Bytef *
const cbuf =
new Bytef[csiz];
36724 if (compress(cbuf,&csiz,(Bytef*)ref.data,siz)) {
36725 cimg::warn(
"CImgList<%s>::save_cimg() : File '%s', failed to save compressed data.\n Data will be saved uncompressed.",
36727 compressed =
false;
36729 std::fprintf(nfile,
" #%lu\n",csiz);
36735 cimg::warn(
"CImgList<%s>::save_cimg() : File '%s', cannot save compressed data unless zlib is used "
36736 "('cimg_use_zlib' must be defined).\n Data will be saved uncompressed.",
36738 compressed =
false;
36742 std::fputc(
'\n',nfile);
36745 }
else std::fputc(
'\n',nfile);
36763 const unsigned int n0,
36764 const unsigned int x0,
const unsigned int y0,
36765 const unsigned int z0,
const unsigned int v0)
const {
36766 #define _cimg_save_cimg_case(Ts,Tss) \
36767 if (!saved && !cimg::strcasecmp(Ts,str_pixeltype)) { \
36768 for (unsigned int l = 0; l<lmax; ++l) { \
36769 j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j] = 0; \
36770 W = H = D = V = 0; \
36771 if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) \
36772 throw CImgIOException("CImgList<%s>::save_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", \
36773 pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); \
36775 if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(Tss),SEEK_CUR); \
36777 const CImg<T>& img = (*this)[l - n0]; \
36778 const T *ptrs = img.data; \
36779 const unsigned int \
36780 x1 = x0 + img.width - 1, \
36781 y1 = y0 + img.height - 1, \
36782 z1 = z0 + img.depth - 1, \
36783 v1 = v0 + img.dim - 1, \
36784 nx1 = x1>=W?W-1:x1, \
36785 ny1 = y1>=H?H-1:y1, \
36786 nz1 = z1>=D?D-1:z1, \
36787 nv1 = v1>=V?V-1:v1; \
36788 CImg<Tss> raw(1+nx1-x0); \
36789 const unsigned int skipvb = v0*W*H*D*sizeof(Tss); \
36790 if (skipvb) std::fseek(nfile,skipvb,SEEK_CUR); \
36791 for (unsigned int v = 1 + nv1 - v0; v; --v) { \
36792 const unsigned int skipzb = z0*W*H*sizeof(Tss); \
36793 if (skipzb) std::fseek(nfile,skipzb,SEEK_CUR); \
36794 for (unsigned int z = 1 + nz1 - z0; z; --z) { \
36795 const unsigned int skipyb = y0*W*sizeof(Tss); \
36796 if (skipyb) std::fseek(nfile,skipyb,SEEK_CUR); \
36797 for (unsigned int y = 1 + ny1 - y0; y; --y) { \
36798 const unsigned int skipxb = x0*sizeof(Tss); \
36799 if (skipxb) std::fseek(nfile,skipxb,SEEK_CUR); \
36800 raw.assign(ptrs, raw.width); \
36802 if (endian) cimg::invert_endianness(raw.data,raw.width); \
36803 cimg::fwrite(raw.data,raw.width,nfile); \
36804 const unsigned int skipxe = (W - 1 - nx1)*sizeof(Tss); \
36805 if (skipxe) std::fseek(nfile,skipxe,SEEK_CUR); \
36807 const unsigned int skipye = (H - 1 - ny1)*W*sizeof(Tss); \
36808 if (skipye) std::fseek(nfile,skipye,SEEK_CUR); \
36810 const unsigned int skipze = (D - 1 - nz1)*W*H*sizeof(Tss); \
36811 if (skipze) std::fseek(nfile,skipze,SEEK_CUR); \
36813 const unsigned int skipve = (V - 1 - nv1)*W*H*D*sizeof(Tss); \
36814 if (skipve) std::fseek(nfile,skipve,SEEK_CUR); \
36821 throw CImgInstanceException(
"CImgList<%s>::save_cimg() : File '%s', instance list (%u,%p) is empty.",
36823 if (!file && !filename)
36824 throw CImgArgumentException(
"CImg<%s>::save_cimg() : Instance list (%u,%p), specified file is (null).",
36826 typedef unsigned char uchar;
36827 typedef unsigned short ushort;
36828 typedef unsigned int uint;
36829 typedef unsigned long ulong;
36830 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"rb+");
36832 char tmp[256] = { 0 }, str_pixeltype[256] = { 0 }, str_endian[256] = { 0 };
36833 unsigned int j, err, N, W, H, D, V;
36835 j = 0;
while((i=std::fgetc(nfile))!=
'\n' && i!=EOF && j<256) tmp[j++] = (char)i; tmp[
j] = 0;
36836 err = std::sscanf(tmp,
"%u%*c%255[A-Za-z_]%*c%255[sA-Za-z_ ]",&N,str_pixeltype,str_endian);
36839 throw CImgIOException(
"CImgList<%s>::save_cimg() : File '%s', Unknow CImg RAW header.",
36844 const unsigned int lmax =
cimg::min(N,n0+width);
36862 throw CImgIOException(
"CImgList<%s>::save_cimg() : File '%s', cannot save images of pixels coded as '%s'.",
36863 pixel_type(),filename?filename:
"(FILE*)",str_pixeltype);
36871 const unsigned int n0,
36872 const unsigned int x0,
const unsigned int y0,
36873 const unsigned int z0,
const unsigned int v0)
const {
36874 return _save_cimg(0,filename,n0,x0,y0,z0,v0);
36879 const unsigned int n0,
36880 const unsigned int x0,
const unsigned int y0,
36881 const unsigned int z0,
const unsigned int v0)
const {
36887 const unsigned int nb,
36888 const unsigned int dx,
const unsigned int dy,
36889 const unsigned int dz,
const unsigned int dv) {
36890 std::FILE *
const nfile = file?file:
cimg::fopen(filename,
"wb");
36891 const unsigned int siz = dx*dy*dz*dv*
sizeof(T);
36892 std::fprintf(nfile,
"%u %s\n",nb,
pixel_type());
36893 for (
unsigned int i=nb;
i; --
i) {
36894 std::fprintf(nfile,
"%u %u %u %u\n",dx,dy,dz,dv);
36895 for (
unsigned int off=siz; off; --off) std::fputc(0,nfile);
36902 const unsigned int nb,
36903 const unsigned int dx,
const unsigned int dy=1,
36904 const unsigned int dz=1,
const unsigned int dv=1) {
36910 const unsigned int nb,
36911 const unsigned int dx,
const unsigned int dy=1,
36912 const unsigned int dz=1,
const unsigned int dv=1) {
36917 #ifdef cimg_use_tiff
36918 const CImgList<T>& save_tiff(
const char *
const filename)
const {
36920 throw CImgInstanceException(
"CImgList<%s>::save_tiff() : File '%s', instance list (%u,%p) is empty.",
36923 throw CImgArgumentException(
"CImgList<%s>::save_tiff() : Specified filename is (null) for instance list (%u,%p).",
36925 TIFF *tif = TIFFOpen(filename,
"w");
36927 for (
unsigned int dir = 0, l = 0; l<
width; ++l) {
36928 const CImg<T>& img = (*this)[l];
36930 if (img.depth==1) img._save_tiff(tif,dir++);
36931 else cimg_forZ(img,
z) img.get_slice(
z)._save_tiff(tif,dir++);
36945 throw CImgIOException(
"CImg<%s>::save_gzip_external() : Cannot save (null) filename.",
36947 char command[1024] = { 0 }, filetmp[512] = { 0 }, body[512] = { 0 };
36963 std::sprintf(command,
"%s -c %s > \"%s\"",
cimg::gzip_path(),filetmp,filename);
36967 throw CImgIOException(
"CImgList<%s>::save_gzip_external() : File '%s' cannot be saved.",
36970 std::remove(filetmp);
36976 const char *
const codec=
"mpeg2video")
const {
36978 throw CImgInstanceException(
"CImgList<%s>::save_ffmpeg_external() : File '%s', instance list (%u,%p) is empty.",
36981 throw CImgArgumentException(
"CImgList<%s>::save_ffmpeg_external() : Instance list (%u,%p), specified filename is (null).",
36983 char command[1024] = { 0 }, filetmp[512] = { 0 }, filetmp2[512] = { 0 };
36984 std::FILE *file = 0;
36985 const unsigned int nlast_frame = last_frame==~0U?width-1:last_frame;
36986 if (first_frame>=width || nlast_frame>=width)
36987 throw CImgArgumentException(
"CImgList<%s>::save_ffmpeg_external() : File '%s', specified frames [%u,%u] are out of list range (%u elements).",
36988 pixel_type(),filename,first_frame,last_frame,width);
36989 for (
unsigned int ll = first_frame; ll<=nlast_frame; ++ll)
if (!
data[ll].is_sameXYZ(
data[0]))
36990 throw CImgInstanceException(
"CImgList<%s>::save_ffmpeg_external() : File '%s', all images of the sequence must be of the same dimension.",
36994 std::sprintf(filetmp2,
"%s_000001.ppm",filetmp);
36997 for (
unsigned int l = first_frame; l<=nlast_frame; ++l) {
36998 std::sprintf(filetmp2,
"%s_%.6u.ppm",filetmp,l+1);
36999 if (
data[l].depth>1 ||
data[l].dim!=3)
data[l].get_resize(-100,-100,1,3).save_pnm(filetmp2);
37000 else data[l].save_pnm(filetmp2);
37003 std::sprintf(command,
"ffmpeg -i %s_%%6d.ppm -vcodec %s -sameq -y \"%s\" >/dev/null 2>&1",filetmp,codec,filename);
37005 std::sprintf(command,
"\"ffmpeg -i %s_%%6d.ppm -vcodec %s -sameq -y \"%s\"\" >NUL 2>&1",filetmp,codec,filename);
37010 throw CImgIOException(
"CImg<%s>::save_ffmpeg_external() : Failed to save image sequence '%s'.\n\n",
37013 cimglist_for(*
this,lll) { std::sprintf(filetmp2,
"%s_%.6u.ppm",filetmp,lll+1); std::remove(filetmp2); }
37032 const CImg<T>& letter = (*this)[l];
37033 int xmin = letter.width, xmax = 0;
37034 cimg_forXY(letter,x,y)
if (letter(x,y)) {
if (x<xmin) xmin=
x;
if (x>xmax) xmax=
x; }
37036 else letter.get_crop(xmin,0,xmax,letter.height-1).transfer_to(res);
37038 res[
' '].resize(res[
'f'].width);
37039 res[
' '+256].resize(res[
'f'].width);
37049 if (font_width<=11) {
37053 return variable_size?nfont7x11:
font7x11;
37055 if (font_width<=13) {
37059 return variable_size?nfont10x13:
font10x13;
37061 if (font_width<=17) {
37065 return variable_size?nfont8x17:
font8x17;
37067 if (font_width<=19) {
37071 return variable_size?nfont10x19:
font10x19;
37073 if (font_width<=24) {
37077 return variable_size?nfont12x24:
font12x24;
37079 if (font_width<=32) {
37083 return variable_size?nfont16x32:
font16x32;
37085 if (font_width<=38) {
37089 return variable_size?nfont19x38:
font19x38;
37094 return variable_size?nfont29x57:
font29x57;
37098 const unsigned int paddingx,
const unsigned int paddingy,
const bool variable_size=
true) {
37100 res.insert(256);
cimglist_for_in(res,256,511,l) res[l].assign(w,h,1,1);
37101 const unsigned int *ptr =
font;
37102 unsigned int m = 0, val = 0;
37103 for (
unsigned int y = 0; y<h; ++
y)
37104 for (
unsigned int x = 0; x<256*w; ++
x) {
37105 m>>=1;
if (!m) { m = 0x80000000; val = *(ptr++); }
37107 unsigned int xm = x%w;
37108 img(xm,y,0) = img(xm,y,1) = img(xm,y,2) =
mask(xm,y,0) = (T)((val&m)?1:0);
37110 if (variable_size) res.crop_font();
37111 if (paddingx || paddingy)
cimglist_for(res,l) res[l].resize(res[l].
dimx() + paddingx,res[l].dimy() + paddingy,1,-100,0);
37118 if (width==1)
insert(1);
37119 if (width>2)
cimg::warn(
"CImgList<%s>::FFT() : Instance list (%u,%p) have more than 2 images",
37132 if (width==1)
insert(1);
37133 if (width>2)
cimg::warn(
"CImgList<%s>::FFT() : Instance list (%u,%p) have more than 2 images",
37147 const unsigned int siz = p.size();
37148 if (siz==2 || siz==3 || siz==6 || siz==9)
cimg::swap(p[0],p[1]);
37149 else if (siz==4 || siz==12)
cimg::swap(p[0],p[3],p[1],p[2]);
37189 template<
typename t>
37190 inline int dialog(
const char *title,
const char *msg,
37191 const char *button1_txt,
const char *button2_txt,
37192 const char *button3_txt,
const char *button4_txt,
37193 const char *button5_txt,
const char *button6_txt,
37194 const CImg<t>& logo,
const bool centering =
false) {
37195 #if cimg_display!=0
37196 const unsigned char
37197 black[] = { 0,0,0 }, white[] = { 255,255,255 }, gray[] = { 200,200,200 }, gray2[] = { 150,150,150 };
37208 if (!buttons.width)
37209 throw CImgArgumentException(
"cimg::dialog() : No buttons have been defined. At least one is necessary");
37211 unsigned int bw = 0, bh = 0;
37215 if (bw>128) bw=128;
37220 button.draw_rectangle(0,0,bw-1,bh-1,gray);
37221 button.draw_line(0,0,bw-1,0,white).draw_line(0,bh-1,0,0,white);
37222 button.draw_line(bw-1,0,bw-1,bh-1,black).draw_line(bw-1,bh-1,0,bh-1,black);
37223 button.draw_line(1,bh-2,bw-2,bh-2,gray2).draw_line(bw-2,bh-2,bw-2,1,gray2);
37225 sbutton.draw_rectangle(0,0,bw-1,bh-1,gray);
37226 sbutton.draw_line(0,0,bw-1,0,black).draw_line(bw-1,0,bw-1,bh-1,black);
37227 sbutton.draw_line(bw-1,bh-1,0,bh-1,black).draw_line(0,bh-1,0,0,black);
37228 sbutton.draw_line(1,1,bw-2,1,white).draw_line(1,bh-2,1,1,white);
37229 sbutton.draw_line(bw-2,1,bw-2,bh-2,black).draw_line(bw-2,bh-2,1,bh-2,black);
37230 sbutton.draw_line(2,bh-3,bw-3,bh-3,gray2).draw_line(bw-3,bh-3,bw-3,2,gray2);
37231 sbutton.draw_line(4,4,bw-5,4,black,1,0xAAAAAAAA,
true).draw_line(bw-5,4,bw-5,bh-5,black,1,0xAAAAAAAA,
false);
37232 sbutton.draw_line(bw-5,bh-5,4,bh-5,black,1,0xAAAAAAAA,
false).draw_line(4,bh-5,4,4,black,1,0xAAAAAAAA,
false);
37234 cbutton.draw_rectangle(0,0,bw-1,bh-1,black).draw_rectangle(1,1,bw-2,bh-2,gray2).draw_rectangle(2,2,bw-3,bh-3,gray);
37235 cbutton.draw_line(4,4,bw-5,4,black,1,0xAAAAAAAA,
true).draw_line(bw-5,4,bw-5,bh-5,black,1,0xAAAAAAAA,
false);
37236 cbutton.draw_line(bw-5,bh-5,4,bh-5,black,1,0xAAAAAAAA,
false).draw_line(4,bh-5,4,4,black,1,0xAAAAAAAA,
false);
37239 CImg<unsigned char>(cbutton).draw_image(1+(bw-buttons[ll].
dimx())/2,1+(bh-buttons[ll].dimy())/2,buttons[ll]).
37250 bwall = (buttons.width-1)*(12+bw) + bw,
37251 w =
cimg::max(196U,36+logo.width+canvas.width, 24+bwall),
37252 h =
cimg::max(96U,36+canvas.height+bh,36+logo.height+bh),
37253 lx = 12 + (canvas.data?0:((w-24-logo.width)/2)),
37254 ly = (h-12-bh-logo.height)/2,
37255 tx = lx+logo.width+12,
37256 ty = (h-12-bh-canvas.height)/2,
37262 draw_rectangle(0,0,w-1,h-1,gray).
37263 draw_line(0,0,w-1,0,white).
draw_line(0,h-1,0,0,white).
37264 draw_line(w-1,0,w-1,h-1,black).draw_line(w-1,h-1,0,h-1,black).
37265 draw_image(tx,ty,canvas);
37268 draw_rectangle(0,0,w-1,h-1,gray).
37269 draw_line(0,0,w-1,0,white).
draw_line(0,h-1,0,0,white).
37270 draw_line(w-1,0,w-1,h-1,black).draw_line(w-1,h-1,0,h-1,black);
37271 if (logo.data) canvas.draw_image(lx,ly,logo);
37273 unsigned int xbuttons[6] = { 0 };
37274 cimglist_for(buttons,lll) { xbuttons[lll] = bx+(bw+12)*lll; canvas.draw_image(xbuttons[lll],
by,buttons[lll]); }
37277 CImgDisplay disp(canvas,title?title:
" ",0,
false,centering?
true:
false);
37280 bool stopflag =
false, refresh =
false;
37281 int oselected = -1, oclicked = -1, selected = -1, clicked = -1;
37287 else canvas.display(disp);
37295 oclicked = clicked;
37299 disp.
mouse_x>=(
int)xbuttons[l] && disp.
mouse_x<(
int)(xbuttons[l]+bw)) {
37300 clicked = selected = l;
37303 if (clicked!=oclicked) refresh =
true;
37304 }
else if (clicked>=0) stopflag =
true;
37307 oselected = selected;
37308 switch (disp.
key) {
37309 case cimg::keyESC : selected=-1; stopflag=
true;
break;
37310 case cimg::keyENTER :
if (selected<0) selected = 0; stopflag =
true;
break;
37315 case cimg::keyARROWUP : selected = (selected+buttons.width-1)%buttons.width;
break;
37318 if (selected!=oselected) refresh =
true;
37321 if (!disp) selected = -1;
37324 std::fprintf(
cimg_stdout,
"<%s>\n\n%s\n\n",title,msg);
37325 return -1+0*(int)(button1_txt-button2_txt+button3_txt-button4_txt+button5_txt-button6_txt+logo.width+(
int)centering);
37329 inline int dialog(
const char *title,
const char *msg,
37330 const char *button1_txt,
const char *button2_txt,
const char *button3_txt,
37331 const char *button4_txt,
const char *button5_txt,
const char *button6_txt,
37332 const bool centering) {
37333 return dialog(title,msg,button1_txt,button2_txt,button3_txt,button4_txt,button5_txt,button6_txt,
37338 inline double eval(
const char *
const expression,
const double x,
const double y,
const double z,
const double v) {
37340 return empty.eval(expression,x,y,z,v);
37349 #ifdef _cimg_redefine_None
37352 #ifdef _cimg_redefine_min
37353 #define min(a,b) (((a)<(b))?(a):(b))
37355 #ifdef _cimg_redefine_max
37356 #define max(a,b) (((a)>(b))?(a):(b))
int dimx() const
Return display width.
volatile bool is_keyPAUSE
CImg< T > & min(const CImg< t > &img)
Pointwise min operator between two images.
CImg< T > & draw_triangle(CImg< floatT > &zbuffer, const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const int x2, const int y2, const float z2, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const int tx2, const int ty2, const CImg< tl > &light, const int lx0, const int ly0, const int lx1, const int ly1, const int lx2, const int ly2, const float opacity=1)
Draw a 2D Pseudo-Phong-shaded textured triangle, with z-buffering and perspective correction...
const CImgList< T > & save_yuv(std::FILE *const file, const bool rgb2yuv=true) const
Save an image sequence into a YUV file.
CImg< T > get_erode(const unsigned int n, const unsigned int cond=1) const
T & max()
Return a reference to the maximum pixel value of the instance list.
static CImg< floatT > torus3d(CImgList< tf > &primitives, const float radius1=100, const float radius2=30, const unsigned int subdivisions1=24, const unsigned int subdivisions2=12)
Create and return a 3D torus.
#define _CImgList_stdarg(t)
#define cimg_file_separator
volatile bool is_keyBACKSPACE
CImg< T > & invert_endianness()
Invert endianness of the image buffer.
CImg< T > & _draw_polygon(const t &points, const unsigned int W, const unsigned int H, const tc *const color, const float opacity, const unsigned int pattern)
static unsigned int format(const unsigned char val)
#define _cimg_fopcode1(op, i1)
CImg< T > & tensor()
Realign pixel values of the instance image as a symmetric tensor.
#define cimg_for5x5(img, x, y, z, v, I)
const unsigned char logo40x38[4576]
static CImg< floatT > isocurve3d(CImgList< tf > &primitives, const tfunc &func, const float isovalue, const float x0, const float y0, const float x1, const float y1, const int sizex=256, const int sizey=256)
Get isocurve as a 3D object.
#define _cimg_fill1(x, y, z, v, off, siz, t)
const unsigned int keyPAD3
CImg< T > & max(const CImg< t > &img)
Pointwise max operator between two images.
CImg< T > & draw_triangle(const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const CImg< tc > &color, const float opacity=1)
Draw a 2D filled colored triangle.
CImg< T > & draw_text(const int x0, const int y0, const char *const text, const tc1 *const foreground_color, const tc2 *const background_color, const float opacity, const CImgList< t > &font,...)
Draw a text.
CImg< T > & mirror(const char axis)
Mirror an image along the specified axis.
CImg< T > get_shared_channels(const unsigned int v0, const unsigned int v1)
Return a shared-memory image referencing a set of channels (v0->v1) of the instance image...
const char * gzip_path(const char *const user_path=0, const bool reinit_path=false)
Return or set path to the 'gzip' command.
cimg::superset< T, unsigned char >::type Tuchar
static CImg< T > get_load_cimg(const char *const filename, const unsigned int n0, const unsigned int n1, const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0, const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int v1, const char axis='z', const char align='p')
_cimg_math_parser(const char *const expression, const char *const funcname=0)
CImg< T > & load_off(std::FILE *const file, CImgList< tf > &primitives, CImgList< tc > &colors)
Load a 3D object from a .OFF file.
#define cimg_forXZV(img, x, z, v)
static CImg< T > get_load_raw(const char *const filename, const unsigned int sizex, const unsigned int sizey=1, const unsigned int sizez=1, const unsigned int sizev=1, const bool multiplexed=false, const bool invert_endianness=false)
const CImg< T > & _save_ascii(std::FILE *const file, const char *const filename) const
CImg< T > & draw_triangle(const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const CImg< tc1 > &color1, const CImg< tc2 > &color2, const CImg< tc3 > &color3, const float opacity=1)
static CImg< T > get_load_pnm(const char *const filename)
cimg::superset< T, float >::type Tfloat
CImg< T > & equalize(const unsigned int nb_levels, const T value_min=(T) 0, const T value_max=(T) 0)
Compute the histogram-equalized version of the instance image.
const CImg< T > & save_tiff(const char *const filename) const
Save a file in TIFF format.
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed by
T & at(const int off, const T out_val)
Read a pixel value with Dirichlet boundary conditions.
const CImg< T > & save_dlm(const char *const filename) const
Save the image as a DLM file.
unsigned int prand(const double z)
Return a random variable following a Poisson distribution of parameter z.
const CImg< T > & display_object3d(CImgDisplay &disp, const CImg< tp > &vertices, const CImgList< tf > &primitives, const bool centering=true, const int render_static=4, const int render_motion=1, const bool double_sided=true, const float focale=500, const float specular_light=0.2f, const float specular_shine=0.1f, const bool display_axes=true, float *const pose_matrix=0) const
High-level interface for displaying a 3d object.
CImgList(const unsigned int n, const unsigned int width, const unsigned int height=1, const unsigned int depth=1, const unsigned int dim=1)
Construct an image list containing n images with specified size.
const CImg< T > get_shared_line(const unsigned int y0, const unsigned int z0=0, const unsigned int v0=0) const
CImg< T > get_crop(const int x0, const int y0, const int x1, const int y1, const bool border_condition=false) const
CImgList< T > operator+() const
Operator+() (unary).
static CImg< T > get_load_inr(std::FILE *const file, float *voxsize=0)
static CImg< T > get_load_gzip_external(const char *const filename)
static CImgList< T > get_load_ffmpeg(const char *const filename, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1, const bool pixel_format=true)
T atNXY(const int pos, const int x, const int y, const int z=0, const int v=0) const
CImg< Tfloat > get_CMYKtoCMY() const
CImg< T > & append(const CImg< T > &img, const char axis='x', const char align='p')
#define _cimg_for_triangle2(img, xl, cl, xr, cr, y, x0, y0, c0, x1, y1, c1, x2, y2, c2)
CImg< T > & draw_grid(const float deltax, const float deltay, const float offsetx, const float offsety, const bool invertx, const bool inverty, const CImg< tc > &color, const float opacity=1, const unsigned int patternx=~0U, const unsigned int patterny=~0U)
Draw grid.
static CImg< T > diagonal(const T &a0, const T &a1, const T &a2, const T &a3)
Return a 4x4 diagonal matrix with specified coefficients.
CImg< T > & assign(const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const unsigned int dv=1)
In-place version of the previous constructor.
CImg< T > & _draw_polygon(const t &points, const unsigned int N, const tc *const color, const float opacity)
#define _cimg_blur_patch3d_fast(N)
CImg< T > & log10()
Compute the log10 of each each pixel value.
cimg::last< T, short >::type shortT
static unsigned int _fitscreen(const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const int dmin=128, const int dmax=-85, const bool return_last=false)
CImg< T > & operator*=(const CImg< t > &img)
Operator*=().
CImg< uintT > get_label_regions() const
CImg< T > & operator^=(const CImg< t > &img)
Operator^=().
bool is_sameV(const unsigned int dv) const
Return true if image (*this) has the specified number of channels.
CImgDisplay(const CImg< T > &img, const char *title=0, const unsigned int normalization_type=3, const bool fullscreen_flag=false, const bool closed_flag=false)
Create a display window from an image.
static unsigned int min()
int fread(T *const ptr, const unsigned int nmemb, std::FILE *stream)
Read file data, and check for possible errors.
volatile int mouse_x
X-coordinate of the mouse pointer on the display.
CImg< _cimg_Tfloat > exp(const CImg< T > &instance)
unsigned int _sleep(const unsigned int milliseconds, unsigned long &timer)
iterator begin()
Return an iterator to the first image pixel.
volatile bool is_keyAPPRIGHT
volatile bool is_keyARROWRIGHT
CImg< T > & draw_polygon(const CImgList< t > &points, const CImg< tc > &color, const float opacity=1)
Draw a filled polygon in the instance image.
This class represents a window which can display CImg images and handles mouse and keyboard events...
CImgList(const CImgList< t > &list, const bool shared)
Advanced copy constructor.
const char * gunzip_path(const char *const user_path=0, const bool reinit_path=false)
Return or set path to the 'gunzip' command.
CImgDisplay()
Create an empty display window.
CImg< floatT > get_histogram(const unsigned int nb_levels, const T value_min=(T) 0, const T value_max=(T) 0) const
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
T & atNX(const int pos, const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions for the two first coordinates (pos...
const unsigned int keyF12
CImg< T > & draw_line(CImg< floatT > &zbuffer, const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const CImg< tc > &color, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a 2D colored line, with z-buffering.
void strescape(char *const s)
Replace explicit escape sequences '' in C-strings.
bool containsN(const int n) const
Return true if the list contains the image (n).
const CImg< T > & save_cimg(std::FILE *const file, const unsigned int n0, const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0) const
Insert the image into an existing .cimg file, at specified coordinates.
Tfloat sum() const
Return the sum of all the pixel values in an image.
bool contains(const T &pixel, t &n, t &x, t &y, t &z) const
Return true if one of the image list contains the specified referenced value. If true, set coordinates (n,x,y,z).
CImg< T > & draw_rectangle(const int x0, const int y0, const int x1, const int y1, const CImg< tc > &color, const float opacity, const unsigned int pattern)
Draw a 2D outlined colored rectangle.
T atXYZV(const int x, const int y, const int z, const int v, const T out_val) const
double grand()
Return a random variable following a gaussian distribution and a standard deviation of 1...
CImg< T > & operator&=(const t val)
Operator&=().
CImg< T > & fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10, const T val11, const T val12)
Fill sequentially pixel values.
CImg< T > & operator>>=(const int n)
Operator>>=().
CImg< T > & draw_ellipse(const int x0, const int y0, const CImg< t > &tensor, const tc *const color, const float opacity, const unsigned int pattern)
Draw an outlined ellipse.
CImg< T > & draw_spline(const CImg< t > &points, const CImg< tc > &color, const float opacity=1, const bool close_set=false, const float precision=4, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a set of consecutive colored lines in the instance image.
CImg< T > & draw_triangle(CImg< floatT > &zbuffer, const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const int x2, const int y2, const float z2, const CImg< tc > &color, const CImg< tl > &light, const int lx0, const int ly0, const int lx1, const int ly1, const int lx2, const int ly2, const float opacity=1)
Draw a 2D Pseudo-Phong-shaded triangle, with z-buffering.
CImg< T > & _draw_scanline(const tc *const color, const float opacity=1)
void warn(const char *format,...)
Display a warning message.
CImg< T > get_blur_bilateral(const float sigma_s, const float sigma_r, const int bgrid_s=-33, const int bgrid_r=32, const bool interpolation_type=true) const
T & atN(const int pos, const int x=0, const int y=0, const int z=0, const int v=0)
Read a pixel value with Neumann boundary conditions for the first coordinates (pos).
volatile bool is_keySPACE
CImg< T > get_resize(const CImgDisplay &disp, const int interpolation_type=1, const int border_condition=-1, const bool center=false) const
CImg< T > resize_object3d() const
Resize a 3D object so that its max dimension if one.
CImg< T > & draw_circle(const int x0, const int y0, int radius, const CImg< tc > &color, const float opacity, const unsigned int pattern)
Draw an outlined circle.
CImg< T > & draw_line(const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a 2D textured line, with perspective correction.
static CImg< T > vector(const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8, const T &a9, const T &a10, const T &a11, const T &a12, const T &a13)
Return a vector with specified coefficients.
CImg< T > get_channels(const unsigned int v0, const unsigned int v1) const
CImgDisplay & set_title(const char *format,...)
Set the window title.
CImg< T > & sinh()
Compute the hyperbolic sine of each pixel value.
CImg< T > & solve(const CImg< t > &A)
Solve a linear system AX=B where B=*this.
const T * ptr(const unsigned int x, const unsigned int y=0, const unsigned int z=0, const unsigned int v=0) const
#define _cimg_for_triangle4(img, xl, cl, txl, tyl, xr, cr, txr, tyr, y, x0, y0, c0, tx0, ty0, x1, y1, c1, tx1, ty1, x2, y2, c2, tx2, ty2)
CImg< T > & draw_text(const int x0, const int y0, const char *const text, const tc *const foreground_color, const int, const float opacity, const CImgList< t > &font,...)
Draw a text.
CImg< _cimg_Tt > operator*(const t val) const
Operator*().
CImg< intT > _autocrop(const T value, const char axis) const
CImg< T > get_vector() const
CImg< T > & _load_rgb(std::FILE *const file, const char *const filename, const unsigned int dimw, const unsigned int dimh)
static const char * format()
CImg< T > & draw_polygon(const CImgList< t > &points, const tc *const color, const float opacity=1)
Draw a filled polygon in the instance image.
#define _cimg_fopcode5(op, i1, i2, i3, i4, i5)
CImg< Tfloat > operator%(const char *const expression) const
Operator%().
#define cimg_forX(img, x)
void swap(T &a, T &b)
Exchange values of variables a and b.
volatile bool is_keyPADMUL
CImgList< T > & insert(const unsigned int n, const CImg< t > &img, const unsigned int pos=~0U, const bool shared=false)
Insert n copies of the image img into the current image list, at position pos.
CImg< T > & draw_line(CImg< floatT > &zbuffer, const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a 2D textured line, with z-buffering and perspective correction.
volatile int window_x
X-pos of the display on the screen.
CImgDisplay & wait()
Wait for an event occuring on the current display.
const unsigned int keyCAPSLOCK
CImg< Tfloat > get_RGBtoHSV() const
CImg< T > & pow(const double p)
Compute the power by p of each pixel value.
static CImg< T > vector(const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8, const T &a9, const T &a10)
Return a vector with specified coefficients.
const CImg< T > & _save_rgb(std::FILE *const file, const char *const filename) const
float frames_per_second()
Return the frame per second rate.
Tfloat linear_atXYZ(const float fx, const float fy=0, const float fz=0, const int v=0) const
Read a pixel value using linear interpolation and Neumann boundary conditions (first three coordinate...
static CImg< T > get_load_off(const char *const filename, CImgList< tf > &primitives, CImgList< tc > &colors)
bool is_sameYZV(const unsigned int dy, const unsigned int dz, const unsigned int dv) const
Return true if image (*this) has the specified height, depth and number of channels.
CImg< T > & draw_gaussian(const float xc, const float yc, const CImg< t > &tensor, const tc *const color, const float opacity=1)
Draw an anisotropic 2D gaussian function.
CImg(const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, const T val)
Construct an image with given size (dx,dy,dz,dv) and with pixel having a default value val...
#define _cimglist_def_is_same(axis)
subroutine rs(nm, n, a, w, matz, z, fv1, fv2, ierr)
iterator begin()
Returns an iterator to the beginning of the vector (STL-compliant name).
bool is_sameXY(const CImgDisplay &disp) const
Return true if image (*this) and the display disp have same width and same height.
CImg< T > & fill(const char *const expression, const bool repeat_flag)
Fill image values according to the given expression, which can be a formula or a list of values...
CImgList(const CImg< t1 > &img1, const CImg< t2 > &img2, const CImg< t3 > &img3, const CImg< t4 > &img4, const CImg< t5 > &img5, const bool shared=false)
Construct an image list from five images.
const CImg< T > & save_other(const char *const filename, const unsigned int quality=100) const
CImg< T > & slices(const unsigned int z0, const unsigned int z1)
Get a set of slices.
bool is_sameXV(const unsigned int dx, const unsigned int dv) const
Return true if image (*this) has the specified width and number of channels.
CImg< T > get_blur_anisotropic(const float amplitude, const float sharpness=0.7f, const float anisotropy=0.3f, const float alpha=0.6f, const float sigma=1.1f, const float dl=0.8f, const float da=30, const float gauss_prec=2, const unsigned int interpolation_type=0, const unsigned int fast_approx=1) const
bool is_sameX(const CImgDisplay &disp) const
Return true if images (*this) and the display disp have same width.
CImg< T > & _load_ascii(std::FILE *const file, const char *const filename)
const CImg< T > & save_cimg(const char *const filename, const bool compress=false) const
Save the image as a .cimg file.
CImg< T > & cosh()
Compute the hyperbolic cosine of each pixel value.
CImg< T > & draw_image(const int x0, const int y0, const int z0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
const CImgList< T > get_shared_images(const unsigned int i0, const unsigned int i1) const
#define _cimg_iskey_case(k)
bool is_key(const bool remove=false)
Test if any key has been pressed.
T & atNXYZV(const int pos, const int x, const int y, const int z, const int v)
Read a pixel value with Neumann boundary conditions.
CImg< T > & _load_pandore(std::FILE *const file, const char *const filename)
static const char * string()
CImg< T > get_fill(const T val) const
CImg(const CImgDisplay &disp)
Construct an image from the content of a CImgDisplay instance.
const CImg< T > & save_cpp(std::FILE *const file) const
Save the image as a CPP source file.
Tfloat linear_atXY(const float fx, const float fy, const int z=0, const int v=0) const
Read a pixel value using linear interpolation and Neumann boundary conditions (first two coordinates)...
CImg< T > & draw_image(const int x0, const int y0, const int z0, const int v0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
static CImg< T > get_load_rgb(const char *const filename, const unsigned int dimw, const unsigned int dimh=1)
CImg< T > & index(const CImg< t > &palette, const bool dithering=false, const bool map_indexes=false)
Index multi-valued pixels of the instance image, regarding to a predefined palette.
const CImg< T > & save_rgb(std::FILE *const file) const
Save the image as a RGB file.
CImg< T > & draw_rectangle(const int x0, const int y0, const int z0, const int x1, const int y1, const int z1, const tc *const color, const float opacity=1)
Draw a 3D filled colored rectangle in the instance image, at coordinates (x0,y0,z0)-(x1,y1,z1).
const T & maxmin(t &min_val) const
#define _cimg_for_triangle3(img, xl, txl, tyl, xr, txr, tyr, y, x0, y0, tx0, ty0, x1, y1, tx1, ty1, x2, y2, tx2, ty2)
CImg< T > & operator<<=(const int n)
Operator<<=().
CImg< _cimg_Tfloat > sqrt(const CImg< T > &instance)
CImgList< T > & assign(const unsigned int n, const unsigned int width, const unsigned int height, const unsigned int depth, const unsigned int dim, const T val)
In-place version of the corresponding constructor.
CImg< T > & draw_spline(const CImgList< t > &points, const tc *const color, const float opacity=1, const bool close_set=false, const float precision=4, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a set of consecutive colored splines in the instance image.
CImg< T > get_blur_median(const unsigned int n) const
CImg< Tfloat > get_sqr() const
CImg< T > get_columns(const unsigned int x0, const unsigned int x1) const
CImg< T > & crop(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const bool border_condition=false)
Get a square region of the image.
cimg::last< T, unsigned int >::type uintT
CImg< T > & CMYtoRGB()
Convert (C,M,Y) pixels of a color image into the (R,G,B) color space.
CImgList(const CImg< t1 > &img1, const CImg< t2 > &img2, const CImg< t3 > &img3, const bool shared=false)
Construct an image list from three images.
CImg< T > & draw_point(const int x0, const int y0, const tc *const color, const float opacity=1)
Draw a 2D colored point (pixel).
_marching3d_func_float(const CImg< T > &pref)
static CImg< T > get_load_rgba(const char *const filename, const unsigned int dimw, const unsigned int dimh=1)
const unsigned int keyPAGEUP
static CImg< floatT > ellipsoid3d(CImgList< tf > &primitives, const CImg< t > &tensor, const unsigned int subdivisions=3)
Create and return a 3D ellipsoid.
CImg< Tfloat > get_blur(const float sigma, const bool cond=true) const
cimg::last< T, unsigned long >::type ulongT
CImgDisplay & toggle_fullscreen(const bool redraw=true)
Toggle fullscreen mode.
volatile bool is_keyCTRLLEFT
CImg< T > & tan()
Compute the tangent of each pixel.
CImg< T > & load_off(const char *const filename, CImgList< tf > &primitives, CImgList< tc > &colors)
Load a 3D object from a .OFF file.
CImg< T > & normalize(const T value_min, const T value_max)
Linearly normalize values of the instance image between value_min and value_max.
CImg< T > & pow(const char *const expression)
Compute the power of each pixel value.
volatile int window_y
Y-pos of the display on the screen.
#define _cimg_load_cimg_case(Ts, Tss)
const CImg< T > & save_raw(std::FILE *const file, const bool multiplexed=false) const
Save the image as a RAW file.
CImg< T > & load_dcraw_external(const char *const filename)
Load a RAW Color Camera image file, using external tool 'dcraw'.
CImgDisplay & set_mouse(const int posx, const int posy)
Move mouse pointer to a specific location.
const T ror(const T a, const unsigned int n=1)
Return a right bitwise-rotated number.
cimg::superset< T, int >::type Tint
CImgList< T > & load_yuv(const char *const filename, const unsigned int sizex, const unsigned int sizey, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1, const bool yuv2rgb=true)
Load an image sequence from a YUV file.
CImg< T > & _draw_ellipse(const int x0, const int y0, const float r1, const float r2, const float angle, const tc *const color, const float opacity, const unsigned int pattern)
CImg< T > & sin()
Compute the sinus of each pixel value.
CImgList< T > & reverse()
Reverse list order.
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
T & min()
Return a reference to the minimum pixel value of the instance image.
CImg(const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, const char *const values, const bool repeat_values)
Construct an image with given size and with specified values given in a string.
CImg< T > & label_regions()
Create a map of indexed labels counting disconnected regions with same intensities.
const_iterator end() const
CImg< T > & front()
Returns a reference to the first element (STL-compliant name).
const char * option(const char *const name, const int argc, const char *const *const argv, const char *defaut, const char *const usage=0)
CImgList< T > & operator,(const CImg< t > &img)
Operator,().
CImg< T > & draw_triangle(const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const tc *const color, const CImg< tl > &light, const int lx0, const int ly0, const int lx1, const int ly1, const int lx2, const int ly2, const float opacity=1)
Draw a 2D Pseudo-Phong-shaded triangle.
static CImg< T > diagonal(const T &a0, const T &a1)
Return a 2x2 diagonal matrix with specified coefficients.
bool is_sameV(const CImg< t > &img) const
Return true if images (*this) and img have same dim.
CImg< T > & draw_triangle(const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const CImg< tc > &color, const float brightness0, const float brightness1, const float brightness2, const float opacity=1)
Draw a 2D Gouraud-shaded colored triangle.
bool is_sameXV(const CImg< t > &img) const
Return true if images have same width and same number of channels.
CImg< T > & fill(const CImg< t > &values, const bool repeat_values=true)
Fill image values according to the values found in the specified image.
CImgDisplay & fullscreen(const bool redraw=true)
Set fullscreen mode.
T mod(const T &x, const T &m)
Return the modulo of a number.
cimg::last< T, short >::type shortT
const CImg< T > & display_object3d(const char *const title, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const bool centering=true, const int render_static=4, const int render_motion=1, const bool double_sided=true, const float focale=500, const float specular_light=0.2f, const float specular_shine=0.1f, const bool display_axes=true, float *const pose_matrix=0) const
High-level interface for displaying a 3d object.
CImg< T > & draw_spline(const CImgList< t > &points, CImg< tc > &color, const float opacity=1, const bool close_set=false, const float precision=4, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a set of consecutive colored splines in the instance image.
const char * filenamerand()
CImg< T > * ptr()
Return a pointer to the image buffer.
CImg< T > get_matrix_at(const unsigned int x=0, const unsigned int y=0, const unsigned int z=0) const
Return a new image corresponding to the square matrix located at (x,y,z) of the current vector-valued...
CImg< Tfloat > get_LabtoXYZ() const
CImgList< T > & load_parrec(const char *const filename)
Load an image list from a PAR/REC (Philips) file.
CImg(const CImg< T > &img)
void int int REAL REAL * y
static unsigned int format(const unsigned short val)
CImg< Tfloat > get_stats(const unsigned int variance_method=1) const
const CImgList< T > & display(const char *const title=0, const bool display_info=true, const char axis='x', const char align='p') const
Display the current CImgList instance in a new display window.
const unsigned int keyCTRLLEFT
CImgDisplay & show()
Show a closed display.
const unsigned int keyF11
T & atNX(const int pos, const int x, const int y=0, const int z=0, const int v=0)
Read a pixel value with Neumann boundary conditions for the two first coordinates (pos...
cimg::superset< T, long >::type Tlong
CImgList< T > & assign(const CImg< t1 > &img1, const CImg< t2 > &img2, const CImg< t3 > &img3, const CImg< t4 > &img4, const bool shared=false)
In-place version of the corresponding constructor.
T _atNXYZ(const int pos, const int x, const int y, const int z, const int v=0) const
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
bool contains(const T &pixel, t &n, t &x, t &y, t &z, t &v) const
Return true if one of the image list contains the specified referenced value. If true, set coordinates (n,x,y,z,v).
CImg< T > & assign(const T *const data_buffer, const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const unsigned int dv=1)
CImg< T > operator--(int)
Operator–() (postfix).
CImg< Tuchar > get_YUVtoRGB() const
CImgList< T > & assign(const char *const filename)
In-place version of the corresponding constructor.
static CImg< T > vector(const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8, const T &a9, const T &a10, const T &a11)
Return a vector with specified coefficients.
const CImg< T > & _save_jpeg(std::FILE *const file, const char *const filename, const unsigned int quality) const
CImgList(const CImgDisplay &disp)
Construct an image list from a display.
CImg< T > & fill(const T val0, const T val1, const T val2, const T val3, const T val4)
Fill sequentially all pixel values with values val0 and val1 and val2 and val3 and val4...
CImgList< Tfloat > get_eigen() const
CImg< T > & _draw_object3d(void *const pboard, CImg< floatT > &zbuffer, const float X, const float Y, const float Z, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const to &opacities, const unsigned int nb_opacities, const unsigned int render_type, const bool double_sided, const float focale, const float lightx, const float lighty, const float lightz, const float specular_light, const float specular_shine)
#define _cimg_exception_err(etype, disp_flag)
const CImg< T > & save_gzip_external(const char *const filename) const
Save an image as a gzipped file, using external tool 'gzip'.
static CImg< floatT > plane3d(CImgList< tf > &primitives, const float size_x=100, const float size_y=100, const unsigned int subdivisions_x=10, const unsigned int subdivisions_y=10, const bool double_sided=false)
Create and return a 3D XY-plane.
volatile unsigned int & key
Key value if pressed.
static CImgList< T > get_load_yuv(const char *const filename, const unsigned int sizex, const unsigned int sizey=1, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1, const bool yuv2rgb=true)
const CImg< T > & display_object3d(const char *const title, const CImg< tp > &vertices, const CImgList< tf > &primitives, const bool centering=true, const int render_static=4, const int render_motion=1, const bool double_sided=true, const float focale=500, const float specular_light=0.2f, const float specular_shine=0.1f, const bool display_axes=true, float *const pose_matrix=0) const
High-level interface for displaying a 3d object.
CImg< T > get_blur_bilateral(const float sigma_x, const float sigma_y, const float sigma_z, const float sigma_r, const int bgrid_x, const int bgrid_y, const int bgrid_z, const int bgrid_r, const bool interpolation_type=true) const
CImgList()
Default constructor.
const CImg< T > & display(CImgDisplay &disp, const bool display_info) const
Display an image in a window with a title title, and wait a 'is_closed' or 'keyboard' event...
CImgList(const unsigned int n, const unsigned int width, const unsigned int height, const unsigned int depth, const unsigned int dim, const T val)
Construct an image list containing n images with specified size, filled with specified value...
static const char * string()
static CImgList< T > get_load_parrec(const char *const filename)
CImg< _cimg_Tfloat > pseudoinvert(const CImg< T > &instance)
CImg< T > get_fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10, const T val11, const T val12, const T val13, const T val14) const
CImg< T > get_diagonal() const
cimg::superset< T, double >::type Tdouble
CImg< T > & draw_grid(const CImg< tx > &xvalues, const CImg< ty > &yvalues, const tc *const color, const float opacity=1, const unsigned int patternx=~0U, const unsigned int patterny=~0U)
Draw grid.
CImgList< Tfloat > get_hessian(const char *const axes=0) const
Get components of the Hessian matrix of an image.
T & temporary(const T &)
Return a reference to a temporary variable of type T.
static CImg< T > get_load_cimg(const char *const filename, const char axis='z', const char align='p')
#define _cimg_blur_patch2d(N)
const T & operator()(const unsigned int pos, const unsigned int x, const unsigned int y=0, const unsigned int z=0, const unsigned int v=0) const
CImg< T > & line(const unsigned int y0)
Get a line.
CImg< intT > get_select_graph(CImgDisplay &disp, const unsigned int plot_type=1, const unsigned int vertex_type=1, const char *const labelx=0, const double xmin=0, const double xmax=0, const char *const labely=0, const double ymin=0, const double ymax=0) const
Select sub-graph in a graph.
CImg< Tfloat > get_XYZtoxyY() const
CImg< T > & draw_line(const int x0, const int y0, const int x1, const int y1, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a 2D textured line.
bool is_sameZV(const CImg< t > &img) const
Return true if images have same depth and same number of channels.
CImg< T > & LabtoRGB()
Convert a (L,a,b) image to a (R,G,B) one.
T atXYZ(const int x, const int y, const int z, const int v, const T out_val) const
const CImg< T > & display_object3d(const char *const title, const CImg< tp > &vertices, const bool centering=true, const int render_static=4, const int render_motion=1, const bool double_sided=true, const float focale=500, const float specular_light=0.2f, const float specular_shine=0.1f, const bool display_axes=true, float *const pose_matrix=0) const
High-level interface for displaying a 3d object.
T & _atNXY(const int pos, const int x, const int y, const int z=0, const int v=0)
CImg< T > & HSLtoRGB()
Convert color pixels from (H,S,L) to (R,G,B).
CImgDisplay & normalscreen(const bool redraw=true)
Set normal screen mode.
static CImg< T > get_load_off(std::FILE *const file, CImgList< tf > &primitives, CImgList< tc > &colors)
CImg< T > & erode(const unsigned int n, const unsigned int cond=1)
Erode the image by a square structuring element of size n.
#define cimg_fitscreen(dx, dy, dz)
static int _marching3d_indice(const unsigned int edge, const CImg< t > &indices1, const CImg< t > &indices2, const unsigned int x, const unsigned int y, const unsigned int nx, const unsigned int ny)
CImg< Tfloat > operator/(const char *const expression) const
Operator/().
T & at(const int off)
Read a pixel value with Neumann boundary conditions.
CImg< T > & translate_object3d(const float tx, const float ty=0, const float tz=0)
Translate a 3D object.
CImg< T > & load_pandore(std::FILE *const file)
Load an image from a PANDORE file.
const unsigned int keyF10
CImgList< T > & assign(const CImg< t1 > &img1, const CImg< t2 > &img2, const CImg< t3 > &img3, const CImg< t4 > &img4, const CImg< t5 > &img5, const CImg< t6 > &img6, const bool shared=false)
In-place version of the corresponding constructor.
static long format(const long val)
CImg< T > & load_graphicsmagick_external(const char *const filename)
Load an image using GraphicsMagick's external tool 'gm'.
CImgList< T > & assign(const CImg< t1 > &img1, const CImg< t2 > &img2, const CImg< t3 > &img3, const CImg< t4 > &img4, const CImg< t5 > &img5, const CImg< t6 > &img6, const CImg< t7 > &img7, const CImg< t8 > &img8, const bool shared=false)
In-place version of the corresponding constructor.
static CImg< T > tensor(const T &a1, const T &a2, const T &a3)
Return a 2x2 symmetric matrix tensor with specified coefficients.
const CImgList< T > & save_yuv(const char *const filename=0, const bool rgb2yuv=true) const
Save an image sequence into a YUV file.
CImg< T > & resize_tripleXY()
Upscale an image by a factor 3x.
CImg< Tfloat > get_pow(const CImg< t > &img) const
cimg::last< T, double >::type doubleT
T _atXY(const int x, const int y, const int z=0, const int v=0) const
CImgList< T > & remove(const unsigned int pos1, const unsigned int pos2)
Remove the images from positions pos1 to pos2.
bool is_sameYV(const CImg< t > &img) const
Return true if images have same height and same number of channels.
void strclean(char *const s)
Remove useless spaces and symmetric delimiters ', " and ` from a C-string.
CImg< T > get_fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10, const T val11, const T val12) const
bool endianness()
Return the current endianness of the CPU.
CImg< T > & RGBtoxyY()
Convert a (R,G,B) image to a (x,y,Y) one.
const_iterator begin() const
Class representing an image (up to 4 dimensions wide), each pixel being of type T.
CImg< T > & operator%=(const CImg< t > &img)
Operator%=().
const unsigned int font19x38[19 *38 *256/32]
const CImg< T > & display_object3d(CImgDisplay &disp, const CImg< tp > &vertices, const bool centering=true, const int render_static=4, const int render_motion=1, const bool double_sided=true, const float focale=500, const float specular_light=0.2f, const float specular_shine=0.1f, const bool display_axes=true, float *const pose_matrix=0) const
High-level interface for displaying a 3d object.
const CImg< T > & symmetric_eigen(CImg< t > &val, CImg< t > &vec) const
Compute the eigenvalues and eigenvectors of a symmetric matrix.
const CImg< T > & _save_pnm(std::FILE *const file, const char *const filename, const unsigned int bytes_per_pixel=0) const
double round(const double x, const double y, const int rounding_type=0)
Return a rounded number.
CImg< T > get_permute_axes(const char *order) const
double eval(const char *const expression, const double x=0, const double y=0, const double z=0, const double v=0)
Evaluate math expression.
CImg< T > & load_jpeg(const char *const filename)
Load an image from a JPEG file.
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
static CImgList< T > get_load_tiff(const char *const filename, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1)
const CImg< T > get_shared_planes(const unsigned int z0, const unsigned int z1, const unsigned int v0=0) const
CImg & set_linear_atXYZ(const T &val, const float fx, const float fy=0, const float fz=0, const int v=0, const bool add=false)
Set a pixel value, with 3D float coordinates, using linear interpolation.
CImg< T > & draw_polygon(const CImgList< t > &points, const tc *const color, const float opacity, const unsigned int pattern)
Draw a polygon outline.
CImg< T > & draw_object3d(const float x0, const float y0, const float z0, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const unsigned int render_type=4, const bool double_sided=false, const float focale=500, const float lightx=0, const float lighty=0, const float lightz=-5000, const float specular_light=0.2f, const float specular_shine=0.1f, CImg< floatT > &zbuffer=cimg_library::CImg< floatT >::empty())
Draw a 3D object.
CImgList< T > get_insert(const CImgList< t > &list, const unsigned int pos=~0U, const bool shared=false) const
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
#define _cimg_draw_fill_test(x, y, z, res)
static int _marching2d_indice(const unsigned int edge, const CImg< t > &indices1, const CImg< t > &indices2, const unsigned int x, const unsigned int nx)
static const char * format()
#define _cimg_test_temporary_path(p)
const CImg< T > & save_imagemagick_external(const char *const filename, const unsigned int quality=100) const
Save the image using ImageMagick's convert.
CImg(const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const unsigned int dv=1)
Constructs a new image with given size (dx,dy,dz,dv).
char * title
Display title.
CImg< T > & draw_gaussian(const float xc, const float yc, const float sigma, const CImg< tc > &color, const float opacity=1)
Draw an isotropic 2D gaussian function.
CImg< floatT > get_distance(const T isovalue, const float sizex=1, const float sizey=1, const float sizez=1, const bool compute_sqrt=true) const
A Window object contains multiple panes and multiple data attributes.
CImg< T > & _load_off(std::FILE *const file, const char *const filename, CImgList< tf > &primitives, CImgList< tc > &colors)
unsigned int height
Height of the display.
cimg::last< T, char >::type charT
cimg::superset< T, short >::type Tshort
CImg< t > _get_permute_axes(const char *permut, const t &) const
CImgList(const CImg< t1 > &img1, const CImg< t2 > &img2, const CImg< t3 > &img3, const CImg< t4 > &img4, const CImg< t5 > &img5, const CImg< t6 > &img6, const bool shared=false)
Construct an image list from six images.
cimg::last< T, long >::type longT
Tfloat mean() const
Return the mean pixel value of the instance image.
CImg< T > get_mirror(const char axis) const
static CImg< floatT > isocurve3d(CImgList< tf > &primitives, const char *const expression, const float isovalue, const float x0, const float y0, const float x1, const float y1, const int sizex=256, const int sizey=256)
CImg< T > & load_inr(std::FILE *const file, float *const voxsize=0)
Load an image from an INRIMAGE-4 file.
CImg< T > get_shared_planes(const unsigned int z0, const unsigned int z1, const unsigned int v0=0)
Return a shared memory image referencing a set of planes (z0->z1,v0) of the instance image...
CImg< T > & load_ffmpeg_external(const char *const filename, const char axis='z', const char align='p')
Load a video sequence using FFMPEG's external tool 'ffmpeg'.
const char *const *const t_bold
CImg< T > operator-() const
Operator-() (unary).
CImg< _cimg_Tt > get_append(const CImg< T > &img, const char axis='x', const char align='p') const
CImg< T > & operator|=(const CImg< t > &img)
Operator|=().
volatile bool is_keyARROWUP
CImg< T > & operator()(const unsigned int pos)
Equivalent to CImgList<T>::operator[].
CImgIOException(const char *format,...)
CImg< T > & select(const char *const title, const int select_type=2, unsigned int *const XYZ=0, const unsigned char *const color=0)
Simple interface to select a shape from an image.
CImg< _cimg_Tt > get_max(const CImg< t > &img) const
const unsigned int keySHIFTRIGHT
static CImgList< T > get_load_cimg(std::FILE *const file, const unsigned int n0, const unsigned int n1, const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0, const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int v1)
volatile bool is_keyPADDIV
cimg::superset< T, bool >::type Tbool
#define _cimg_save_cimg_case(Ts, Tss)
static unsigned int max()
CImg< T > get_cut(const T value_min, const T value_max) const
T & atNXY(const int pos, const int x, const int y, const int z=0, const int v=0)
Read a pixel value with Neumann boundary conditions for the three first coordinates (pos...
CImg< T > operator++(int)
Operator++() (postfix).
#define _cimg_draw_fill_set(x, y, z)
CImgList< T > & _load_cimg(std::FILE *const file, const char *const filename)
CImgList< T > & assign(const CImgDisplay &disp)
In-place version of the corresponding constructor.
const CImg< T > & eigen(CImg< t > &val, CImg< t > &vec) const
Compute the eigenvalues and eigenvectors of a matrix.
CImg< Tfloat > get_atan() const
CImg< T > & fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10, const T val11)
Fill sequentially pixel values.
cimg::superset< T, long >::type Tlong
CImg< T > & blur_bilateral(const float sigma_s, const float sigma_r, const int bgrid_s=-33, const int bgrid_r=32, const bool interpolation_type=true)
Blur an image using the bilateral filter.
CImg< T > & correlate(const CImg< t > &mask, const unsigned int cond=1, const bool weighted_correl=false)
Compute the correlation of the instance image by a mask.
const unsigned int keyPADADD
const CImg< T > & save_ffmpeg(const char *const filename, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int fps=25) const
Save the image as a video sequence file, using FFMPEG library.
CImg< T > & dilate(const unsigned int n, const unsigned int cond=1)
Dilate the image by a square structuring element of size n.
CImg< T > & assign(const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, const double val0, const double val1,...)
In-place version of the previous constructor.
CImg< T > & load_other(const char *const filename)
Load an image using ImageMagick's or GraphicsMagick's executables.
#define cimg_forYZ(img, y, z)
CImg< T > & draw_triangle(const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const CImg< tc > &color, const float opacity, const unsigned int pattern)
Draw a 2D outlined colored triangle.
T _atN(const int pos, const int x=0, const int y=0, const int z=0, const int v=0) const
CImg< T > & draw_triangle(const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const tc *const color, const float opacity, const unsigned int pattern)
Draw a 2D outlined colored triangle.
CImg< T > get_fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6) const
CImg< Tfloat > get_pow(const char *const expression) const
CImgList< T > get_remove() const
cimg::last< T, float >::type floatT
CImg< T > & autocrop(const T *const color, const char *const axes="zyx")
Autocrop an image, regarding of the specified backround color.
CImg< T > * ptr(const unsigned int l)
Return a pointer to the image buffer.
void _update_iskey(const unsigned int key, const bool pressed=true)
const CImgList< T > & print(const char *title=0, const bool display_stats=true) const
Print informations about the list on the standard output.
CImg< T > & draw_rectangle(const int x0, const int y0, const int z0, const int x1, const int y1, const int z1, const CImg< tc > &color, const float opacity, const unsigned int pattern)
Draw a 3D outlined colored rectangle in the instance image.
CImgDisplay & assign(const CImgDisplay &disp)
In-place version of the previous constructor.
static const char * format()
const CImgList< T > & save_cimg(const char *const filename, const bool compress=false) const
Save an image list into a CImg file (RAW binary file + simple header)
CImg< _cimg_Tt > get_mul(const CImg< t > &img) const
CImg< T > & load_cimg(const char *const filename, const unsigned int n0, const unsigned int n1, const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0, const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int v1, const char axis='z', const char align='p')
Load a sub-image (list) from a .cimg file.
volatile bool is_keyCAPSLOCK
CImg< T > & draw_text(const int x0, const int y0, const char *const text, const int, const tc *const background_color, const float opacity=1, const unsigned int font_size=11,...)
Draw a text.
CImg< T > & draw_ellipse(const int x0, const int y0, const float r1, const float r2, const float angle, const CImg< tc > &color, const float opacity, const unsigned int pattern)
Draw an outlined ellipse.
CImg< Tfloat > get_RGBtoCMYK() const
bool is_sameXZV(const unsigned int dx, const unsigned int dz, const unsigned int dv) const
Return true if image (*this) has the specified width, height and number of channels.
CImg< T > get_quantize(const unsigned int n, const bool keep_range=true) const
CImgDisplay & resize(const bool redraw=true)
Resize a display window in its current size.
const CImg< T > & display_graph(const char *const title=0, const unsigned int plot_type=1, const unsigned int vertex_type=1, const char *const labelx=0, const double xmin=0, const double xmax=0, const char *const labely=0, const double ymin=0, const double ymax=0) const
High-level interface for displaying a graph.
CImgList(const CImg< t1 > &img1, const CImg< t2 > &img2, const CImg< t3 > &img3, const CImg< t4 > &img4, const CImg< t5 > &img5, const CImg< t6 > &img6, const CImg< t7 > &img7, const CImg< t8 > &img8, const bool shared=false)
Construct an image list from eight images.
CImgList< T > & assign(const CImgList< t > &list, const bool shared=false)
In-place version of the copy constructor.
CImg< T > & RGBtoLab()
Convert a (R,G,B) image to a (L,a,b) one.
static CImg< floatT > sphere3d(CImgList< tf > &primitives, const float radius=50, const unsigned int subdivisions=3)
Create and return a 3D sphere.
CImg< T > & draw_triangle(CImg< floatT > &zbuffer, const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const int x2, const int y2, const float z2, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const int tx2, const int ty2, const float brightness0, const float brightness1, const float brightness2, const float opacity=1)
Draw a 2D Gouraud-shaded textured triangle, with z-buffering and perspective correction.
#define _cimg_load_pandore_case(nbdim, nwidth, nheight, ndepth, dim, stype1, stype2, stype3, ltype)
CImg< T > & load_dlm(std::FILE *const file)
Load an image from a DLM file.
CImgList(const char *const filename)
Construct an image list from a filename.
const CImg< T > & save_png(std::FILE *const file, const unsigned int bytes_per_pixel=0) const
Save a file in PNG format.
static CImg< T > vector(const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5)
Return a vector with specified coefficients.
CImgList< T > & assign()
In-place version of the default constructor and default destructor.
bool is_sameX(const CImg< t > &img) const
Return true if images (*this) and img have same width.
const char * graphicsmagick_path(const char *const user_path=0, const bool reinit_path=false)
Return path of the GraphicsMagick's gm tool.
T atN(const int pos, const int x=0, const int y=0, const int z=0, const int v=0) const
CImgDisplay & move(const int posx, const int posy)
Move window.
#define _cimg_save_pandore_case(sy, sz, sv, stype, id)
unsigned int opcode(const char op, const unsigned int arg1=0, const unsigned int arg2=0, const unsigned int arg3=0, const unsigned int arg4=0, const unsigned int arg5=0)
CImg< T > & unroll(const char axis)
Unroll all images values into specified axis.
volatile bool is_keyPADSUB
CImg< T > & rotate(const float angle, const float cx, const float cy, const float zoom, const unsigned int border_conditions=3, const unsigned int interpolation=1)
Rotate an image around a center point (cx,cy).
CImg< T > get_append(const CImg< T > &img, const char axis='x', const char align='p') const
CImg< _cimg_Ttfloat > get_correlate(const CImg< t > &mask, const unsigned int cond=1, const bool weighted_correl=false) const
T atNXYZ(const int pos, const int x, const int y, const int z, const int v=0) const
const CImg< T > & save_pnm(const char *const filename, const unsigned int bytes_per_pixel=0) const
Save the image as a PNM file.
const unsigned int keyARROWLEFT
CImg< T > & draw_axis(const CImg< t > &xvalues, const int y, const CImg< tc > &color, const float opacity=1, const unsigned int pattern=~0U)
Draw a labeled horizontal axis on the instance image.
CImg< T > get_blur_anisotropic(const CImg< t > &G, const float amplitude=60, const float dl=0.8f, const float da=30, const float gauss_prec=2, const unsigned int interpolation_type=0, const unsigned int fast_approx=1) const
const T * const_iterator
Const iterator type for CImg<T>.
const double valuePI
Definition of the mathematical constant PI.
volatile unsigned int window_width
Width of the underlying window.
Tfloat magnitude(const int magnitude_type=2) const
Return the norm of the current vector/matrix. ntype = norm type (0=L2, 1=L1, -1=Linf).
CImg(const char *const filename)
Construct an image from an image file.
CImg< _cimg_Tfloat > operator*(const char *const expression, const CImg< T > &img)
CImg< T > & draw_fill(const int x, const int y, const int z, const tc *const color, const float opacity, CImg< t > ®ion, const float sigma=0, const bool high_connexity=false)
Draw a 3D filled region starting from a point (x,y,\ z) in the instance image.
CImg< T > & _load_inr(std::FILE *const file, const char *const filename, float *const voxsize)
const CImgList< T > & save_ffmpeg(const char *const filename, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int fps=25) const
Save an image sequence, using FFMPEG library.
CImg< T > & draw_quiver(const CImg< t1 > &flow, const CImg< t2 > &color, const float opacity=1, const unsigned int sampling=25, const float factor=-20, const bool arrows=true, const unsigned int pattern=~0U)
Draw a vector field in the instance image, using a colormap.
static CImg< T > vector(const T &a0, const T &a1, const T &a2)
Return a vector with specified coefficients.
volatile int wheel
Wheel state of the mouse.
CImgList(const unsigned int n, const CImg< t > &img, const bool shared=false)
Construct a list containing n copies of the image img.
CImg< T > & load_dlm(const char *const filename)
Load an image from a DLM file.
CImg< T > & acos()
Compute the arc-cosine of each pixel value.
CImg< T > & identity_matrix()
Get an identity matrix having same dimension than instance image.
static double format(const double val)
CImg< T > & load_pandore(const char *const filename)
Load an image from a PANDORE file.
static CImg< T > diagonal(const T &a0, const T &a1, const T &a2, const T &a3, const T &a4)
Return a 5x5 diagonal matrix with specified coefficients.
cimg::superset< T, bool >::type Tbool
CImg< T > & xyYtoXYZ()
Convert (x,y,Y) pixels of a color image into the (X,Y,Z)_709 color space.
CImgList< T > & operator=(const CImgDisplay &disp)
Operator=().
Tfloat linear_atX(const float fx, const int y, const int z, const int v, const T out_val) const
Read a pixel value using linear interpolation and Dirichlet boundary conditions (first coordinate)...
CImg< T > & draw_polygon(const CImgList< t > &points, const CImg< tc > &color, const float opacity, const unsigned int pattern)
Draw a polygon outline.
CImg< T > & fill(const T val)
Fill an image by a value val.
CImg< _cimg_Tt > get_erode(const CImg< t > &mask, const unsigned int cond=1, const bool weighted_erosion=false) const
#define _cimg_valign3d(i, j, k)
CImg< T > & draw_point(const CImgList< t > &points, const tc *const color, const float opacity=1)
Draw a cloud of colored points.
const CImg< T > & back() const
Return a reference to the last image (STL-compliant name).
CImg< T > & max(const char *const expression)
Pointwise max operator between an image and a string.
CImg< T > & draw_image(const int x0, const int y0, const int z0, const int v0, const CImg< ti > &sprite, const CImg< tm > &mask, const float opacity=1, const float mask_valmax=1)
Draw a sprite image in the instance image (masked version).
CImg< T > & operator--()
Operator–() (prefix).
const unsigned int keyESC
CImg< _cimg_Tt > operator-(const CImg< t > &img) const
Operator-().
CImg< T > get_crop(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const bool border_condition=false) const
CImg< T > & draw_gaussian(const float xc, const float yc, const float zc, const float sigma, const tc *const color, const float opacity=1)
Draw an isotropic 3D gaussian function.
volatile bool is_keyPAGEDOWN
bool is_sameYZV(const CImg< t > &img) const
Return true if images have same heigth, same depth and same number of channels.
static CImg< T > get_load_inr(const char *const filename, float *const voxsize=0)
CImgList< T > & FFT(const char axis, const bool invert=false)
Compute a 1-D Fast Fourier Transform, along specified axis.
static CImg< T > tensor(const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6)
Return a 3x3 symmetric matrix with specified coefficients.
CImg< T > get_shared_lines(const unsigned int y0, const unsigned int y1, const unsigned int z0=0, const unsigned int v0=0)
Return a shared-memory image referencing a set of lines of the instance image.
CImg< T > & norm(const int norm_type=2)
Compute L2-norm of each multi-valued pixel of the instance image.
CImg< Tfloat > get_max(const char *const expression) const
CImg< T > & deriche(const float sigma, const int order=0, const char axis='x', const bool cond=true)
Compute the result of the Deriche filter.
CImg< T > & draw_triangle(const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const int tx2, const int ty2, const CImg< tl > &light, const int lx0, const int ly0, const int lx1, const int ly1, const int lx2, const int ly2, const float opacity=1)
Draw a 2D Pseudo-Phong-shaded textured triangle.
~CImgDisplay()
Destructor.
CImg< T > & column(const unsigned int x0)
Get one column.
_marching2d_func(const CImg< T > &pref)
CImg< Tfloat > get_dijkstra(const unsigned int starting_node, const unsigned int ending_node=~0U) const
bool contains(const T &pixel, t &n) const
Return true if one of the image list contains the specified referenced value. If true, set coordinates (n).
T & minmax(t &max_val)
Return a reference to the minimum pixel value of the instance list.
T & _atNX(const int pos, const int x, const int y=0, const int z=0, const int v=0)
T & max()
Return a reference to the maximum pixel value of the instance image.
CImg< _cimg_Tt > operator+(const t val) const
Operator+().
#define cimg_forXYV(img, x, y, v)
static CImg< T > & empty()
Return a reference to an empty image.
int fclose(std::FILE *file)
Close a file, and check for possible errors.
#define _cimg_draw_fill_test_neighbor(x, y, z, cond)
const CImg< T > & save_inr(std::FILE *const file, const float *const voxsize=0) const
Save the image as an INRIMAGE-4 file.
cimg::superset< T, char >::type Tchar
bool is_empty() const
Return true if current image is empty.
const CImg< T > * ptr() const
CImg< T > & draw_rectangle(const int x0, const int y0, const int z0, const int x1, const int y1, const int z1, const tc *const color, const float opacity, const unsigned int pattern)
Draw a 3D outlined colored rectangle in the instance image.
const CImg< T > & _save_pandore(std::FILE *const file, const char *const filename, const unsigned int colorspace) const
CImgList< T > & insert(const CImg< T > &img, const unsigned int pos=~0U, const bool shared=false)
CImg< T > & cut(const T value_min, const T value_max)
Cut values of the instance image between value_min and value_max.
CImg< Tfloat > get_sinh() const
CImg< T > & div(const CImg< t > &img)
Pointwise division between two images.
CImg< T > & xyYtoRGB()
Convert a (x,y,Y) image to a (R,G,B) one.
CImg< T > & assign(const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, const int val0, const int val1,...)
In-place version of the previous constructor.
const CImgList< T > & _save_yuv(std::FILE *const file, const char *const filename, const bool rgb2yuv) const
CImgList< T > & transfer_to(CImgList< T > &list)
CImg< T > & fillX(const unsigned int y, const unsigned int z, const unsigned int v, const double a0,...)
bool is_sameYZ(const unsigned int dy, const unsigned int dz) const
Return true if image (*this) has the specified height and depth.
static const char * string()
const CImgList< T > & _save_cimg(std::FILE *const file, const char *const filename, const unsigned int n0, const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0) const
CImg< T > & dijkstra(const unsigned int starting_node, const unsigned int ending_node, CImg< t > &previous)
Return minimal path in a graph, using the Dijkstra algorithm.
CImg< T > get_shared()
Return a shared version of the instance image.
T * data
Pointer to the first pixel of the pixel buffer.
CImg< T > & fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8)
Fill sequentially pixel values.
CImg< T > & load_png(std::FILE *const file)
Load an image from a PNG file.
CImg< T > & set_vector_at(const CImg< t > &vec, const unsigned int x, const unsigned int y=0, const unsigned int z=0)
Set the image vec as the vector valued pixel located at (x,y,z) of the current vector-valued image...
CImg< Tfloat > get_resize_object3d(const float sx, const float sy=-100, const float sz=-100) const
bool is_key(const unsigned int key1, const unsigned int key2, const unsigned int key3, const unsigned int key4, const bool remove)
Test if a key sequence has been typed.
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
const unsigned int keyPADMUL
float operator()(const float x, const float y, const float z) const
volatile bool is_keyINSERT
CImg< T > get_fill(const T val0, const T val1) const
int window_dimy() const
Return display window height.
bool contains(const T &pixel, t &x, t &y, t &z) const
Return true if specified referenced value is inside image boundaries. If true, returns pixel coordina...
CImg< T > & operator^=(const char *const expression)
Operator^=().
CImg< T > & fillY(const unsigned int x, const unsigned int z, const unsigned int v, const int a0,...)
Fill image values along the Y-axis at the specified pixel position (x,z,v).
T atXY(const int x, const int y, const int z=0, const int v=0) const
static CImgList< T > get_load(const char *const filename)
CImg< T > & draw_image(const int x0, const int y0, const int z0, const int v0, const CImg< T > &sprite, const float opacity=1)
CImg< T > & load_analyze(const char *const filename, float *const voxsize=0)
Load an image from an ANALYZE7.5/NIFTI file.
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
CImg< T > get_fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7) const
bool is_sameN(const unsigned int n) const
Return true if list if of specified size.
cimg::superset< T, int >::type Tint
CImg< T > & draw_line(const CImgList< t > &points, const tc *const color, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a set of consecutive colored lines in the instance image.
static CImg< T > get_load_bmp(const char *const filename)
CImg< T > & load_png(const char *const filename)
Load an image from a PNG file.
#define cimg_for_outXYZV(img, x0, y0, z0, v0, x1, y1, z1, v1, x, y, z, v)
CImg< T > get_tensor_at(const unsigned int x, const unsigned int y=0, const unsigned int z=0) const
Return a new image corresponding to the diffusion tensor located at (x,y,z) of the current vector-val...
Tfloat dot(const CImg< t > &img) const
Return the dot product of the current vector/matrix with the vector/matrix img.
CImg< T > & draw_object3d(const float x0, const float y0, const float z0, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const CImg< to > &opacities, const unsigned int render_type=4, const bool double_sided=false, const float focale=500, const float lightx=0, const float lighty=0, const float lightz=-5000, const float specular_light=0.2f, const float specular_shine=0.1f, CImg< floatT > &zbuffer=cimg_library::CImg< floatT >::empty())
CImg< Tfloat > operator+(const char *const expression) const
Operator+().
CImg< T > & rand(const T val_min, const T val_max)
Fill the instance image with random values between specified range.
T & _atNXYZV(const int pos, const int x, const int y, const int z, const int v)
const T & back() const
Return a reference to the last image pixel (STL-compliant name).
CImg< Tfloat > get_normalize(const T value_min, const T value_max) const
cimg::last< T, unsigned char >::type ucharT
CImg< T > & fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5)
Fill sequentially all pixel values with values val0 and val1 and val2 and val3 and val4 and val5...
cimg::last< T, bool >::type boolT
const unsigned int keyPAD1
CImg< T > & CMYKtoRGB()
Convert a (C,M,Y,K) image to a (R,G,B) one.
bool containsNXYZV(const int n, const int x=0, const int y=0, const int z=0, const int v=0) const
Return true if the list contains the pixel (n,x,y,z,v).
CImgList< T > & operator=(const char *const filename)
Operator=().
CImgDisplay & flush()
Clear all events of the current display.
CImg< T > & fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9)
Fill sequentially pixel values.
CImg< T > & fillZ(const unsigned int x, const unsigned int y, const unsigned int v, const int a0,...)
Fill image values along the Z-axis at the specified pixel position (x,y,v).
CImg< Tfloat > get_sin() const
CImg< T > & fillV(const unsigned int x, const unsigned int y, const unsigned int z, const int a0,...)
Fill image values along the V-axis at the specified pixel position (x,y,z).
Tfloat det() const
Return the determinant of the image, viewed as a matrix.
CImg< T > & draw_triangle(CImg< floatT > &zbuffer, const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const int x2, const int y2, const float z2, const CImg< tc > &color, const float brightness0, const float brightness1, const float brightness2, const float opacity=1)
Draw a Gouraud triangle with z-buffer consideration.
CImg< T > & _load_analyze(std::FILE *const file, const char *const filename, float *const voxsize=0)
volatile bool is_resized
Resized state of the window.
const T & minmax(t &max_val) const
static CImg< T > vector(const T &a0, const T &a1)
Return a vector with specified coefficients.
CImg< floatT > get_isocurve3d(CImgList< tf > &primitives, const float isovalue, const int size_x=-100, const int size_y=-100) const
Create and return a isocurve of the instance image as a 3D object.
CImg< T > get_resize(const CImg< t > &src, const int interpolation_type=1, const int border_condition=-1, const bool center=false) const
CImgList(const CImg< t1 > &img1, const CImg< t2 > &img2, const CImg< t3 > &img3, const CImg< t4 > &img4, const CImg< t5 > &img5, const CImg< t6 > &img6, const CImg< t7 > &img7, const bool shared=false)
Construct an image list from seven images.
CImg< T > & draw_spline(const int x0, const int y0, const float u0, const float v0, const int x1, const int y1, const float u1, const float v1, const CImg< tc > &color, const float opacity=1, const float precision=4, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a cubic spline curve in the instance image.
CImg< T > get_rotate(const float angle, const float cx, const float cy, const float zoom, const unsigned int border_conditions=3, const unsigned int interpolation=1) const
CImgList< T > & assign(const unsigned int n, const unsigned int width, const unsigned int height, const unsigned int depth, const unsigned int dim, const int val0, const int val1,...)
In-place version of the corresponding constructor.
CImg< _cimg_Tfloat > tan(const CImg< T > &instance)
CImg< _cimg_Ttfloat > get_solve_tridiagonal(const CImg< t > &a, const CImg< t > &b, const CImg< t > &c) const
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
const T & operator[](const unsigned int off) const
CImg< T > & draw_triangle(const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const int x2, const int y2, const float z2, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const int tx2, const int ty2, const float brightness0, const float brightness1, const float brightness2, const float opacity=1)
Draw a 2D Gouraud-shaded textured triangle, with perspective correction.
bool is_key(const unsigned int key1, const unsigned int key2, const unsigned int key3, const unsigned int key4, const unsigned int key5, const unsigned int key6, const unsigned int key7, const unsigned int key8, const unsigned int key9, const bool remove)
Test if a key sequence has been typed.
static CImg< T > get_load_pandore(const char *const filename)
CImg< T > & noise(const double sigma, const unsigned int noise_type=0)
Add random noise to the values of the instance image.
static CImgList< T > get_load_ffmpeg_external(const char *const filename)
CImg< T > & draw_image(const int x0, const int y0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
CImg< Tfloat > get_xyYtoXYZ() const
CImg< T > & XYZtoLab()
Convert (X,Y,Z)_709 pixels of a color image into the (L*,a*,b*) color space.
static const char * format()
CImgList< T > get_insert(const unsigned int n, const unsigned int pos=~0U) const
static CImg< T > matrix(const T &a0, const T &a1, const T &a2, const T &a3)
Return a 2x2 square matrix with specified coefficients.
CImgList< T > & load_ffmpeg(const char *const filename, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1, const bool pixel_format=true, const bool resume=false)
Load an image from a video file, using ffmpeg libraries.
bool contains(const T &pixel, t &x) const
Return true if specified referenced value is inside image boundaries. If true, returns pixel coordina...
float atof(const char *const str)
Read a float number from a C-string.
CImgList(const CImgList< t > &list)
Default copy constructor.
cimg::last< T, double >::type doubleT
unsigned int size() const
Return the size of the list.
CImg< T > & load_bmp(const char *const filename)
Load an image from a BMP file.
CImgDisplay & display(const CImg< T > &img)
Display an image in a window.
bool is_key(const unsigned int key1, const unsigned int key2, const bool remove)
Test if a key sequence has been typed.
static CImg< floatT > isosurface3d(CImgList< tf > &primitives, const tfunc &func, const float isovalue, const float x0, const float y0, const float z0, const float x1, const float y1, const float z1, const int size_x=32, const int size_y=32, const int size_z=32)
Get isosurface as a 3D object.
T & atXYZ(const int x, const int y, const int z, const int v=0)
Read a pixel value with Neumann boundary conditions for the three first coordinates (x...
CImg< T > & convolve(const CImg< t > &mask, const unsigned int cond=1, const bool weighted_convol=false)
Compute the convolution of the image by a mask.
CImgDisplay & assign(const CImg< T > &img, const char *title=0, const unsigned int normalization_type=3, const bool fullscreen_flag=false, const bool closed_flag=false)
In-place version of the previous constructor.
CImg< T > & draw_graph(const CImg< t > &data, const CImg< tc > &color, const float opacity=1, const unsigned int plot_type=1, const unsigned int vertex_type=1, const double ymin=0, const double ymax=0, const bool expand=false, const unsigned int pattern=~0U)
Draw a 1D graph on the instance image.
Tfloat _linear_atXYZV(const float fx, const float fy=0, const float fz=0, const float fv=0) const
CImg< T > & operator+=(const char *const expression)
Operator+=().
CImg< _cimg_Ttfloat > get_solve(const CImg< t > &A) const
CImg< T > & draw_line(const CImg< t > &points, const CImg< tc > &color, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a set of consecutive colored lines in the instance image.
CImg< T > get_autocrop(const T value, const char *const axes="vzyx") const
CImg< T > get_line(const unsigned int y0) const
const CImg< T > * ptr(const unsigned int l) const
int strncasecmp(const char *const s1, const char *const s2, const int l)
Compare the first n characters of two C-strings, ignoring the case.
const char * temporary_path(const char *const user_path=0, const bool reinit_path=false)
Return or set path to store temporary files.
CImg & set_linear_atXY(const T &val, const float fx, const float fy=0, const int z=0, const int v=0, const bool add=false)
Set a pixel value, with 2D float coordinates, using linear interpolation.
static CImg< T > logo40x38()
static void _render_resize(const T *ptrs, const unsigned int ws, const unsigned int hs, t *ptrd, const unsigned int wd, const unsigned int hd)
volatile bool is_keyALTGR
CImg< T > & load_yuv(const char *const filename, const unsigned int sizex, const unsigned int sizey=1, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1, const bool yuv2rgb=true, const char axis='z', const char align='p')
Load an image sequence from a YUV file.
const CImg< T > & save_ffmpeg_external(const char *const filename, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const char *const codec="mpeg2video") const
Save the image as a video sequence file, using the external tool 'ffmpeg'.
CImg< T > & RGBtoCMYK()
Convert a (R,G,B) image to a (C,M,Y,K) one.
CImg< T > & edge_tensors(const float sharpness=0.7f, const float anisotropy=0.3f, const float alpha=0.6f, const float sigma=1.1f, const bool is_sqrt=false)
Get a diffusion tensor for edge-preserving anisotropic smoothing of an image.
CImgList< T > & assign(const CImg< t > &img, const bool shared=false)
In-place version of the corresponding constructor.
const unsigned int keyPAD6
CImg< T > get_noise(const double sigma, const unsigned int noise_type=0) const
double length(Vector3D *const v, int n)
#define _cimg_fopcode3(op, i1, i2, i3)
CImg< T > & assign(const CImgDisplay &disp)
In-place version of the previous constructor.
static unsigned int format(const unsigned int val)
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
CImg< T > & operator%=(const t val)
Operator%=().
CImg< T > & erode(const CImg< t > &mask, const unsigned int cond=1, const bool weighted_erosion=false)
Return the erosion of the image by a structuring element.
Class representing list of images CImg<T>.
static void save_empty_cimg(std::FILE *const file, const unsigned int nb, const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const unsigned int dv=1)
Create an empty .cimg file with specified dimensions.
const unsigned int font12x24[12 *24 *256/32]
int offset(const int x, const int y=0, const int z=0, const int v=0) const
Return the offset of the pixel coordinates (x,y,z,v) with respect to the data pointer data...
static void wait(CImgDisplay &disp1, CImgDisplay &disp2)
Wait for any event occuring either on the display disp1 or disp2.
T atNXY(const int pos, const int x, const int y, const int z, const int v, const T out_val) const
CImg< T > get_fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10) const
CImg< T > & XYZtoRGB()
Convert (X,Y,Z)_709 pixels of a color image into the (R,G,B) color space.
CImg< T > & CMYtoCMYK()
Convert color pixels from (C,M,Y) to (C,M,Y,K).
CImg< T > & draw_text(const int x0, const int y0, const char *const text, const CImg< tc1 > &foreground_color, const CImg< tc2 > &background_color, const float opacity, const CImgList< t > &font,...)
Draw a text.
CImg< Tuchar > get_CMYKtoRGB() const
CImg< T > & sharpen(const float amplitude, const bool sharpen_type=false, const float edge=1, const float alpha=0, const float sigma=0)
Sharpen image using anisotropic shock filters or inverse diffusion.
void invert_endianness(T *const buffer, const unsigned int size)
Invert endianness of a memory buffer.
T at(const int off) const
CImg< T > & draw_point(const CImg< t > &points, const CImg< tc > &color, const float opacity=1)
Draw a cloud of colored points.
CImg< T > get_fill(const char *const values, const bool repeat_values) const
CImg< Tfloat > get_sqrt() const
cimg::last< T, bool >::type boolT
CImgList< T > get_insert(const unsigned int n, const CImgList< t > &list, const unsigned int pos=~0U, const bool shared=false) const
CImgWarningException(const char *format,...)
void __draw_object3d(const unsigned int, const unsigned int, const CImg< to > &, const CImg< tc > &, const int nx0, const int ny0, const CImg< T > &sprite, const float opac)
int fwrite(const T *ptr, const unsigned int nmemb, std::FILE *stream)
Write data to a file, and check for possible errors.
CImg< T > & draw_text(const int x0, const int y0, const char *const text, const tc1 *const foreground_color, const tc2 *const background_color, const float opacity=1, const unsigned int font_size=11,...)
Draw a text.
static const char * format()
const CImg< T > get_shared() const
unsigned int & exception_mode()
Get/set the current CImg exception mode.
CImg< Tfloat > get_translate_object3d(const float tx, const float ty=0, const float tz=0) const
CImg< T > & RGBtoYUV()
Convert color pixels from (R,G,B) to (Y,U,V).
bool is_sameNXYZV(const unsigned int n, const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv) const
static const char * string()
Tfloat _linear_atXYZ(const float fx, const float fy=0, const float fz=0, const int v=0) const
CImg< _cimg_Tt > operator/(const t val) const
Operator/().
const_iterator begin() const
static CImg< T > diagonal(const T &a0, const T &a1, const T &a2)
Return a 3x3 diagonal matrix with specified coefficients.
CImg< T > & load_raw(std::FILE *const file, const unsigned int sizex, const unsigned int sizey=1, const unsigned int sizez=1, const unsigned int sizev=1, const bool multiplexed=false, const bool invert_endianness=false)
Load an image from a .RAW file.
const CImgDisplay & snapshot(CImg< T > &img) const
Take a snapshot of the display in the specified image.
T & atNXYZ(const int pos, const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions for the four first coordinates (pos...
CImg< T > & draw_spline(const CImg< t > &points, const tc *const color, const float opacity=1, const bool close_set=false, const float precision=4, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a set of consecutive colored lines in the instance image.
CImgList< T > & operator=(const CImgList< t > &list)
Operator=().
static const char * format()
const unsigned int keyEND
CImg< Tfloat > get_RGBtoXYZ() const
CImg< T > & load_inr(const char *const filename, float *const voxsize=0)
Load an image from an INRIMAGE-4 file.
bool contains(const CImg< T > &img) const
Return true if the list contains the image img.
CImg< _cimg_Tfloat > cosh(const CImg< T > &instance)
CImg< T > & operator&=(const CImg< t > &img)
Operator&=().
static CImg< T > get_load_jpeg(const char *const filename)
T atXY(const int x, const int y, const int z, const int v, const T out_val) const
CImg< T > & load_cimg(std::FILE *const file, const unsigned int n0, const unsigned int n1, const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0, const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int v1, const char axis='z', const char align='p')
Load a sub-image (list) from a non-compressed .cimg file.
CImg< Tfloat > get_asin() const
#define cimg_forXYZ(img, x, y, z)
CImg< T > & draw_triangle(const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const int tx2, const int ty2, const float opacity=1, const float brightness=1)
Draw a 2D textured triangle.
#define _cimg_median_sort(a, b)
T _atXYZV(const int x, const int y, const int z, const int v) const
T & min()
Return a reference to the minimum pixel value of the instance list.
CImg< Tfloat > get_XYZtoLab() const
static CImg< T > matrix(const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8, const T &a9, const T &a10, const T &a11, const T &a12, const T &a13, const T &a14, const T &a15)
Return a 4x4 square matrix with specified coefficients.
static CImg< T > get_load_graphicsmagick_external(const char *const filename)
const unsigned int keyALTGR
Tfloat MSE(const CImg< t > &img) const
Compute the MSE (Mean-Squared Error) between two images.
CImgList< T > & load_cimg(const char *const filename, const unsigned int n0, const unsigned int n1, const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0, const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int v1)
Load a sub-image list from a non compressed .cimg file.
static void save_empty_cimg(const char *const filename, const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const unsigned int dv=1)
Save an empty .cimg file with specified dimensions.
const unsigned int keyMENU
CImg< T > & HSVtoRGB()
Convert color pixels from (H,S,V) to (R,G,B).
CImgList< T > & assign(const unsigned int n, const unsigned int width, const unsigned int height=1, const unsigned int depth=1, const unsigned int dim=1)
In-place version of the corresponding constructor.
const CImg< T > & save_yuv(const char *const filename, const bool rgb2yuv=true) const
Save the image as a YUV video sequence file.
CImg< T > & operator*=(const t val)
Operator*=().
static void wait_all()
Wait for a window event in any CImg window.
CImgList< T > get_shared()
Return a shared instance of the list.
CImg< T > & draw_axis(const CImg< tx > &xvalues, const CImg< ty > &yvalues, const CImg< tc > &color, const float opacity=1, const unsigned int patternx=~0U, const unsigned int patterny=~0U)
Draw a labeled horizontal+vertical axis on the instance image.
CImg< T > & draw_image(const int x0, const int y0, const CImg< ti > &sprite, const CImg< tm > &mask, const float opacity=1, const float mask_valmax=1)
Draw an image.
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to ** copy
CImgList(const unsigned int n, const unsigned int width, const unsigned int height, const unsigned int depth, const unsigned int dim, const double val0, const double val1,...)
Construct an image list containing n images with specified size and specified pixel values (double ve...
CImg< T > & operator|=(const t val)
Operator|=().
static const char * pixel_type()
Return the type of the pixel values.
CImg< T > & draw_rectangle(const int x0, const int y0, const int x1, const int y1, const tc *const color, const float opacity, const unsigned int pattern)
Draw a 2D outlined colored rectangle.
const char *const *const *const t_purple
T & atNXYZ(const int pos, const int x, const int y, const int z, const int v=0)
Read a pixel value with Neumann boundary conditions for the four first coordinates (pos...
CImg< T > & load(const char *const filename)
Load an image from a file.
int dimy() const
Return display height.
CImg< Tfloat > get_cos() const
CImg< T > & translate_object3d()
Translate a 3D object so that it becomes centered.
const CImg< T > & save_cimg(std::FILE *const file, const bool compress=false) const
const CImgList< T > & save(const char *const filename, const int number=-1) const
Save an image list into a file.
T _atXYZ(const int x, const int y, const int z, const int v=0) const
T & atXY(const int x, const int y, const int z=0, const int v=0)
Read a pixel value with Neumann boundary conditions for the two first coordinates (x...
CImgList< T > & _load_cimg(std::FILE *const file, const char *const filename, const unsigned int n0, const unsigned int n1, const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0, const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int v1)
CImg< T > & blur_anisotropic(const float amplitude, const float sharpness=0.7f, const float anisotropy=0.3f, const float alpha=0.6f, const float sigma=1.1f, const float dl=0.8f, const float da=30, const float gauss_prec=2, const unsigned int interpolation_type=0, const unsigned int fast_approx=1)
Blur an image following in an anisotropic way.
CImg< _cimg_Tfloat > log(const CImg< T > &instance)
CImgDisplay & paint()
Re-paint image content in window.
CImgDisplay & assign()
In-place version of the destructor.
CImg< T > & mul(const CImg< t > &img)
Pointwise multiplication between two images.
bool is_key(const unsigned int key1, const unsigned int key2, const unsigned int key3, const unsigned int key4, const unsigned int key5, const unsigned int key6, const unsigned int key7, const unsigned int key8, const bool remove)
Test if a key sequence has been typed.
const CImg< T > & save_magick(const char *const filename, const unsigned int bytes_per_pixel=0) const
Save the image using built-in ImageMagick++ library.
static const char * format()
CImg< T > & pseudoinvert()
Compute the pseudo-inverse (Moore-Penrose) of the matrix.
bool operator==(const CImg< t > &img) const
Operator==().
const unsigned int font10x13[256 *10 *13/32]
#define cimg_get3x3(img, x, y, z, v, I)
CImg< T > & blur_median(const unsigned int n)
Apply a median filter.
bool is_sameXY(const CImg< t > &img) const
Return true if images have same width and same height.
unsigned int size() const
Return the number of image buffer elements.
_marching2d_func_float(const CImg< T > &pref)
static const char * format(const T val)
const unsigned int keyAPPLEFT
CImg< T > get_fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10, const T val11, const T val12, const T val13) const
CImg< T > operator|(const char *const expression, const CImg< T > &img)
static unsigned char max()
CImgList< t > & transfer_to(CImgList< t > &list, const unsigned int pos=~0U)
const char * medcon_path(const char *const user_path=0, const bool reinit_path=false)
Return or set path of the XMedcon tool.
CImg< T > get_sort(const bool increasing=true) const
CImg(const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, const int val0, const int val1,...)
Construct an image with given size (dx,dy,dz,dv) and with specified pixel values (int version)...
CImg< Tfloat > get_log10() const
const CImg< T > & save_off(const char *const filename, const CImgList< tf > &primitives, const CImgList< tc > &colors) const
Save OFF files.
CImg< T > & draw_spline(const CImg< tp > &points, const CImg< tt > &tangents, const tc *const color, const float opacity=1, const bool close_set=false, const float precision=4, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a set of consecutive colored splines in the instance image.
CImg< T > get_rotate(const float angle, const unsigned int border_conditions=3, const unsigned int interpolation=1) const
CImg< _cimg_Tt > operator%(const t val) const
Operator%().
const T & minmax(t &max_val) const
unsigned int width
Size of the list (number of images).
CImg< T > & operator/=(const CImg< t > &img)
Operator/=().
CImg< T > & draw_point(const int x0, const int y0, const CImg< tc > &color, const float opacity=1)
Draw a 2D colored point (pixel).
volatile unsigned int & released_key
Key value if released.
CImg< T > & min(const char *const expression)
Pointwise min operator between an image and a string.
static const char * format()
CImg< intT > _get_select(CImgDisplay &disp, const char *const title, const int coords_type, unsigned int *const XYZ, const unsigned char *const color, const int origX, const int origY, const int origZ) const
CImg< T > & assign(const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, const T val)
In-place version of the previous constructor.
bool containsXYZV(const int x, const int y=0, const int z=0, const int v=0) const
Return true if pixel (x,y,z,v) is inside image boundaries.
CImg< T > & draw_point(const int x0, const int y0, const int z0, const tc *const color, const float opacity=1)
Draw a 3D colored point (voxel).
CImg< T > get_edge_tensors(const float sharpness=0.7f, const float anisotropy=0.3f, const float alpha=0.6f, const float sigma=1.1f, const bool is_sqrt=false) const
CImg< T > & stats(const unsigned int variance_method=1)
Compute a statistics vector (min,max,mean,variance,xmin,ymin,zmin,vmin,xmax,ymax,zmax,vmax).
#define _cimg_deriche2_apply
CImg< T > & blur(const float sigma, const bool cond=true)
Return a blurred version of the image, using a Canny-Deriche filter.
CImg< T > & draw_triangle(const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const CImg< tc > &color, const CImg< tl > &light, const int lx0, const int ly0, const int lx1, const int ly1, const int lx2, const int ly2, const float opacity=1)
Draw a 2D Pseudo-Phong-shaded triangle.
cimg::superset< T, unsigned short >::type Tushort
double eval(const double x, const double y, const double z, const double v)
CImg< _cimg_Tt > operator/(const CImg< t > &img) const
Operator/().
CImg< T > & draw_image(const int x0, const int y0, const int z0, const CImg< ti > &sprite, const CImg< tm > &mask, const float opacity=1, const float mask_valmax=1)
Draw an image.
CImg< T > transpose(const CImg< T > &instance)
CImg< _cimg_Tfloat > asin(const CImg< T > &instance)
const CImg< T > & save_raw(const char *const filename, const bool multiplexed=false) const
Save the image as a RAW file.
CImg(const CImg< t > &img, const char *const dimensions, const T val)
Construct an image using dimensions of another image, and fill it with given values.
CImg< T > & transpose()
Transpose the current matrix.
CImg< T > operator^(const char *const expression, const CImg< T > &img)
CImg< T > & load_rgba(const char *const filename, const unsigned int dimw, const unsigned int dimh=1)
Load an image from a RGBA file.
cimg::last< T, unsigned short >::type ushortT
static CImg< T > get_load_parrec(const char *const filename, const char axis='v', const char align='p')
CImg< T > & assign(const CImg< t > &img, const char *const dimensions, const T val)
In-place version of the previous constructor.
T & atNXY(const int pos, const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions for the three first coordinates (pos...
CImg< T > & draw_object3d(const float x0, const float y0, const float z0, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const CImgList< to > &opacities, const unsigned int render_type=4, const bool double_sided=false, const float focale=500, const float lightx=0, const float lighty=0, const float lightz=-5000, const float specular_light=0.2f, const float specular_shine=0.1f, CImg< floatT > &zbuffer=cimg_library::CImg< floatT >::empty())
Draw a 3D object.
static const char * pixel_type()
Return a string describing the type of the image pixels in the list (template parameter T)...
bool contains(const T &pixel) const
Return true if one of the image list contains the specified referenced value.
CImg< T > & _quicksort(const int min, const int max, CImg< t > &permutations, const bool increasing)
CImg< _cimg_Tt > operator-(const t val) const
Operator-().
double F1(double x)
Simple test function fixture returns .
CImg< T > & dijkstra(const unsigned int starting_node, const unsigned int ending_node=~0U)
Return minimal path in a graph, using the Dijkstra algorithm.
static CImg< T > get_load_rgba(std::FILE *const file, const unsigned int dimw, const unsigned int dimh=1)
unsigned int width
Width of the display.
CImgList< T > operator<(const char axis) const
Operator<().
CImg< T > & normalize()
Normalize multi-valued pixels of the instance image, with respect to their L2-norm.
static CImg< T > get_load_raw(std::FILE *const file, const unsigned int sizex, const unsigned int sizey=1, const unsigned int sizez=1, const unsigned int sizev=1, const bool multiplexed=false, const bool invert_endianness=false)
CImg< Tuchar > get_RGBtoYCbCr() const
bool is_sameYV(const unsigned int dy, const unsigned int dv) const
Return true if image (*this) has the specified height and number of channels.
static CImg< T > dijkstra(const tf &distance, const unsigned int nb_nodes, const unsigned int starting_node, const unsigned int ending_node, CImg< t > &previous)
Compute minimal path in a graph, using the Dijkstra algorithm.
double F2(double x)
Simple test function fixture returns .
CImg< _cimg_Tt > operator+(const CImg< t > &img) const
Operator+().
T & atNXYZV(const int pos, const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions.
CImg< T > & vector()
Unroll all images values into a one-column vector.
T _atNX(const int pos, const int x, const int y=0, const int z=0, const int v=0) const
#define cimg_for3x3(img, x, y, z, v, I)
CImg< T > & draw_line(const int x0, const int y0, const int x1, const int y1, const CImg< tc > &color, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a 2D colored line.
CImg< Tuchar > get_xyYtoRGB() const
CImgList< _cimg_Tt > operator,(CImgList< t > &list) const
Operator,().
CImg< T > & operator-=(const t val)
Operator-=().
volatile bool is_keyDELETE
#define _cimg_gs2x_for3x3(img, x, y, z, v, I)
const unsigned int keySPACE
T & maxmin(t &min_val)
Return a reference to the minimum pixel value of the instance list.
CImg< T > & operator=(const CImgDisplay &disp)
Operator=().
CImg< T > get_slices(const unsigned int z0, const unsigned int z1) const
CImg< _cimg_Tfloat > sinh(const CImg< T > &instance)
bool is_key(const unsigned int key1, const bool remove)
Test if a key has been pressed.
CImg< T > & _LU(CImg< t > &indx, bool &d)
CImgList< T > get_insert(const unsigned int n, const CImg< t > &img, const unsigned int pos=~0U, const bool shared=false) const
CImgList< T > & _load_yuv(std::FILE *const file, const char *const filename, const unsigned int sizex, const unsigned int sizey, const unsigned int first_frame, const unsigned int last_frame, const unsigned int step_frame, const bool yuv2rgb)
static float _distance_f(const int x, const int i, const float gi2, const float fact)
CImgList< T > & operator=(const CImgList< T > &list)
CImg< T > & operator-=(const char *const expression)
Operator-=().
void int int int REAL REAL REAL * z
CImg< T > & operator=(const CImg< T > &img)
CImg< T > & crop(const int x0, const int x1, const bool border_condition=false)
Get a rectangular part of the instance image.
static void save_empty_cimg(const char *const filename, const unsigned int nb, const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const unsigned int dv=1)
Create an empty .cimg file with specified dimensions.
CImg< T > & operator+=(const t val)
Operator+=().
bool is_sameY(const unsigned int dy) const
Return true if image (*this) has the specified height.
CImg< T > & draw_spline(const int x0, const int y0, const float u0, const float v0, const int x1, const int y1, const float u1, const float v1, const tc *const color, const float opacity=1, const float precision=4, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a cubic spline curve in the instance image.
CImg< T > & load_yuv(std::FILE *const file, const unsigned int sizex, const unsigned int sizey=1, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1, const bool yuv2rgb=true, const char axis='z', const char align='p')
Load an image sequence from a YUV file.
CImg< T > & crop(const int x0, const int y0, const int x1, const int y1, const bool border_condition=false)
Get a rectangular part of the instance image.
float operator()(const float x, const float y, const float z) const
#define cimg_for_inXYZ(img, x0, y0, z0, x1, y1, z1, x, y, z)
#define cimglist_apply(list, fn)
CImgDisplay & operator=(const CImg< t > &img)
CImg< T > & draw_gaussian(const float xc, const float sigma, const CImg< tc > &color, const float opacity=1)
Draw a 1D gaussian function in the instance image.
int strcasecmp(const char *const s1, const char *const s2)
Compare two C-strings, ignoring the case.
T * iterator
Iterator type for CImg<T>.
static CImgList< T > get_load_cimg(const char *const filename)
CImg< T > & draw_spline(const CImg< tp > &points, const CImg< tt > &tangents, const CImg< tc > &color, const float opacity=1, const bool close_set=false, const float precision=4, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a set of consecutive colored splines in the instance image.
CImg< T > get_slice(const unsigned int z0) const
const unsigned int font8x17[8 *17 *256/32]
const CImg< T > & save_off(std::FILE *const file, const CImgList< tf > &primitives, const CImgList< tc > &colors) const
Save OFF files.
T & _atNXYZ(const int pos, const int x, const int y, const int z, const int v=0)
CImg< T > & fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10, const T val11, const T val12, const T val13, const T val14, const T val15)
Fill sequentially pixel values.
T & atXY(const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions for the two first coordinates (x...
const CImg< T > & save_ascii(std::FILE *const file) const
Save the image as an ASCII file (ASCII Raw + simple header).
CImg< T > & sqrt()
Compute the square root of each pixel value.
const unsigned int keyPAD9
bool is_sameYZ(const CImg< t > &img) const
Return true if images have same height and same depth.
static const char * format()
CImg< T > & assign()
In-place version of the default constructor/destructor.
const unsigned int keyENTER
CImgList< Tfloat > get_FFT(const bool invert=false) const
CImg< T > & load_bmp(std::FILE *const file)
Load an image from a BMP file.
cimg::last< T, char >::type charT
CImg< T > & permute_axes(const char *order)
Permute axes order.
static CImg< T > vector(const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8, const T &a9, const T &a10, const T &a11, const T &a12)
Return a vector with specified coefficients.
T atNXYZ(const int pos, const int x, const int y, const int z, const int v, const T out_val) const
volatile bool is_keySHIFTLEFT
#define cimg_for3XYZ(img, x, y, z)
float operator()(const float x, const float y) const
CImg< _cimg_Tfloat > cos(const CImg< T > &instance)
Tfloat linear_atXYZV(const float fx, const float fy=0, const float fz=0, const float fv=0) const
Read a pixel value using linear interpolation and Neumann boundary conditions.
CImg< t > & transfer_to(CImg< t > &img)
Transfer the content of the instance image into another one in a way that memory copies are avoided i...
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
CImg< T > & load_ascii(const char *const filename)
Load an image from an ASCII file.
char * number_filename(const char *const filename, const int number, const unsigned int n, char *const string)
Create a numbered version of a filename.
CImg< T > & draw_ellipse(const int x0, const int y0, const float r1, const float r2, const float angle, const tc *const color, const float opacity, const unsigned int pattern)
Draw an outlined ellipse.
CImgDisplay & operator=(const CImgList< t > &list)
CImgList< T > & assign(const unsigned int n, const unsigned int width, const unsigned int height, const unsigned int depth, const unsigned int dim, const double val0, const double val1,...)
In-place version of the corresponding constructor.
CImg< Tfloat > get_tan() const
void winformat_string(char *const s)
const unsigned int keyPAD2
CImg< T > & haar(const bool invert=false, const unsigned int nb_scales=1)
Compute the Haar multiscale wavelet transform.
CImg< T > get_channel(const unsigned int v0) const
static CImg< T > get_load_yuv(std::FILE *const file, const unsigned int sizex, const unsigned int sizey=1, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1, const bool yuv2rgb=true, const char axis='z', const char align='p')
static CImg< T > get_load_bmp(std::FILE *const file)
CImg< _cimg_Tfloat > invert(const CImg< T > &instance)
CImg< T > * data
Pointer to the first list element.
static int screen_dimy()
Return the height of the screen resolution.
CImg< Tfloat > get_RGBtoYUV() const
CImg< Tfloat > get_deriche(const float sigma, const int order=0, const char axis='x', const bool cond=true) const
CImg< T > operator>>(const int n) const
Operator>>().
CImg< T > & operator^=(const t val)
Operator^=().
CImg< T > get_resize_tripleXY() const
CImgList< T > get_split(const char axis, const int nb=0) const
CImg< Tfloat > get_tanh() const
static CImg< T > vector(const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8, const T &a9, const T &a10, const T &a11, const T &a12, const T &a13, const T &a14)
Return a vector with specified coefficients.
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
CImg< T > & load_analyze(std::FILE *const file, float *const voxsize=0)
Load an image from an ANALYZE7.5/NIFTI file.
CImg< T > & tanh()
Compute the hyperbolic tangent of each pixel value.
const unsigned int keyAPPRIGHT
static CImg< T > get_load_png(std::FILE *const file)
CImg< _cimg_Tt > operator%(const CImg< t > &img) const
Operator%().
CImg< T > & draw_circle(const int x0, const int y0, int radius, const tc *const color, const float opacity, const unsigned int)
Draw an outlined circle.
const unsigned int font29x57[29 *57 *256/32]
CImg< T > & draw_axis(const CImg< t > &xvalues, const int y, const tc *const color, const float opacity=1, const unsigned int pattern=~0U)
Draw a labeled horizontal axis on the instance image.
T & atN(const int pos, const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions for the first coordinates (pos).
CImg< T > & draw_fill(const int x, const int y, const int z, const CImg< tc > &color, const float opacity=1, const float sigma=0, const bool high_connexity=false)
Draw a 3D filled region starting from a point (x,y,\ z) in the instance image.
CImg< T > operator>(const char axis) const
Operator>().
volatile bool is_keyAPPLEFT
CImg< T > & draw_axis(const int x, const CImg< t > &yvalues, const CImg< tc > &color, const float opacity=1, const unsigned int pattern=~0U)
Draw a labeled vertical axis on the instance image.
const unsigned int keyHOME
const char * calling_function
static CImg< T > get_load_cimg(std::FILE *const file, const char axis='z', const char align='p')
bool is_key(const unsigned int key1, const unsigned int key2, const unsigned int key3, const unsigned int key4, const unsigned int key5, const bool remove)
Test if a key sequence has been typed.
CImg< T > get_max(const T val) const
const CImg< T > get_shared_channel(const unsigned int v0) const
CImgList< T > get_shared_images(const unsigned int i0, const unsigned int i1)
Get a shared sub-list.
CImg< T > & load_jpeg(std::FILE *const file)
Load an image from a JPEG file.
CImg< T > & resize(const int pdx, const int pdy=-100, const int pdz=-100, const int pdv=-100, const int interpolation_type=1, const int border_condition=-1, const bool center=false)
Resize an image.
bool is_sameXYZV(const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv) const
CImg< T > & select(CImgDisplay &disp, const int select_type=2, unsigned int *const XYZ=0, const unsigned char *const color=0)
Simple interface to select a shape from an image.
static const char * string()
CImgArgumentException(const char *format,...)
const CImg< T > & print(const char *title=0, const bool display_stats=true) const
Display informations about the image on the standard error output.
static const char * string()
CImgList< T > & swap(CImgList< T > &list)
Swap all fields of two CImgList instances (use with care !)
const unsigned int keyPAGEDOWN
static CImg< T > get_load_pandore(std::FILE *const file)
CImg< T > & draw_grid(const CImg< tx > &xvalues, const CImg< ty > &yvalues, const CImg< tc > &color, const float opacity=1, const unsigned int patternx=~0U, const unsigned int patterny=~0U)
Draw grid.
#define cimg_for2x2(img, x, y, z, v, I)
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
double angle(Vector_3< double > v1, Vector_3< double > v2)
Compute the angle between two vectors.
const CImgList< T > & save_gzip_external(const char *const filename) const
Save a file in TIFF format.
CImg< T > get_fill(const T val0, const T val1, const T val2) const
const CImg< T > & save_bmp(const char *const filename) const
Save the image as a BMP file.
cimg::last< T, unsigned short >::type ushortT
const CImg< T > & save_graphicsmagick_external(const char *const filename, const unsigned int quality=100) const
Save the image using GraphicsMagick's gm.
CImg< T > get_fill(const T val0, const T val1, const T val2, const T val3, const T val4) const
static CImg< T > vector(const T &a0, const T &a1, const T &a2, const T &a3)
Return a vector with specified coefficients.
T & _atXYZ(const int x, const int y, const int z, const int v=0)
CImgList< Tfloat > get_FFT(const char axis, const bool invert=false) const
Compute a 1D Fast Fourier Transform, along a specified axis.
volatile unsigned int keys[512]
CImg< _cimg_Tfloat > log10(const CImg< T > &instance)
static CImg< T > get_load_magick(const char *const filename)
CImg< charT > value_string(const char separator=',', const unsigned int max_size=0) const
Return a C-string containing the values of all images in the instance list.
double crand()
Return a random variable between [-1,1] with respect to an uniform distribution.
const char *const *const *const *const t_green
T & _atXY(const int x, const int y, const int z=0, const int v=0)
#define _cimg_create_ext_operators(typ)
const CImg< T > & display(const char *const title=0, const bool display_info=true) const
Display an image in a window with a title title, and wait a 'is_closed' or 'keyboard' event...
T & minmax(t &max_val)
Return a reference to the minimum pixel value and return also the maximum pixel value.
static const char * string()
float operator()(const float x, const float y) const
CImg< T > & haar(const char axis, const bool invert=false, const unsigned int nb_scales=1)
Compute the Haar multiscale wavelet transform (monodimensional version).
CImg< T > get_shared_plane(const unsigned int z0, const unsigned int v0=0)
Return a shared-memory image referencing one plane (z0,v0) of the instance image. ...
static CImg< T > get_load_dcraw_external(const char *const filename)
static CImg< T > get_load_analyze(const char *const filename, float *const voxsize=0)
const CImg< T > & save_dlm(std::FILE *const file) const
Save the image as a DLM file.
const CImg< T > & display_object3d(CImgDisplay &disp, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const to &opacities, const bool centering=true, const int render_static=4, const int render_motion=1, const bool double_sided=true, const float focale=500, const float specular_light=0.2f, const float specular_shine=0.1f, const bool display_axes=true, float *const pose_matrix=0) const
High-level interface for displaying a 3d object.
CImg< T > & RGBtoHSV()
Convert color pixels from (R,G,B) to (H,S,V).
static int format(const short val)
CImg< T > & load_ascii(std::FILE *const file)
Load an image from an ASCII file.
CImg< T > & assign(const t *const data_buffer, const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const unsigned int dv=1)
In-place version of the previous constructor.
CImg< T > & _draw_point(const t &points, const unsigned int W, const unsigned int H, const tc *const color, const float opacity)
static unsigned short min()
CImg< T > & draw_triangle(const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const int x2, const int y2, const float z2, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const int tx2, const int ty2, const float opacity=1, const float brightness=1)
Draw a 2D textured triangle, with perspective correction.
float operator()(const float x, const float y, const float z) const
CImg< T > & fill(const T val0, const T val1)
Fill sequentially all pixel values with values val0 and val1 respectively.
static unsigned long max()
const CImg< T > & SVD(CImg< t > &U, CImg< t > &S, CImg< t > &V, const bool sorting=true, const unsigned int max_iter=40, const float lambda=0) const
Compute the SVD of a general matrix.
static CImg< floatT > elevation3d(CImgList< tf > &primitives, const char *const expression, const float x0, const float y0, const float x1, const float y1, const int sizex=256, const int sizey=256)
CImg< Tfloat > get_acos() const
static void wait(CImgDisplay &disp1, CImgDisplay &disp2, CImgDisplay &disp3, CImgDisplay &disp4)
Wait for any event occuring either on the display disp1, disp2, disp3 or disp4.
static CImg< T > get_load_ffmpeg_external(const char *const filename, const char axis='z', const char align='p')
volatile bool is_keyESC
Current state of the corresponding key (exists for all referenced keys).
static unsigned long min()
volatile bool is_moved
Moved state of the window.
CImg< T > & fillY(const unsigned int x, const unsigned int z, const unsigned int v, const double a0,...)
CImg< T > & assign(const CImg< t > &img)
In-place version of the default copy constructor.
CImgDisplay & display(const CImgList< T > &list, const char axis='x', const char align='p')
Display an image list CImgList<T> into a display window.
CImgList< Tfloat > get_FFT(const bool invert=false) const
Compute a N-D Fast-Fourier Transform.
CImg< T > & exp()
Compute the exponential of each pixel value.
CImgList< T > & insert(const unsigned int n, const unsigned int pos=~0U)
Insert n empty images img into the current image list, at position pos.
CImg< T > & draw_gaussian(const float xc, const float yc, const float zc, const CImg< t > &tensor, const tc *const color, const float opacity=1)
Draw an anisotropic 3D gaussian function.
const CImg< T > & save_inr(const char *const filename, const float *const voxsize=0) const
Save the image as an INRIMAGE-4 file.
_marching3d_func_expr(const char *const expr)
CImg(const CImg< t > &img, const char *const dimensions)
Construct an image using dimensions of another image.
const unsigned int keySHIFTLEFT
CImg< T > & assign(const CImg< t > &img, const bool shared)
In-place version of the advanced constructor.
const CImg< T > & save_cpp(const char *const filename) const
Save the image as a CPP source file.
CImg< T > & abs()
Compute the absolute value of each pixel value.
static CImg< T > get_load(const char *const filename)
CImg< T > get_autocrop(const T *const color, const char *const axes="zyx") const
CImg< T > & cos()
Compute the cosinus of each pixel value.
const CImg< T > get_shared_plane(const unsigned int z0, const unsigned int v0=0) const
CImg< T > & _load_rgba(std::FILE *const file, const char *const filename, const unsigned int dimw, const unsigned int dimh)
static unsigned short max()
CImg< T > & matrix()
Realign pixel values of the instance image as a square matrix.
const unsigned int keyARROWUP
bool is_sameXZV(const CImg< t > &img) const
Return true if images have same width, same depth and same number of channels.
CImg< intT > get_select(CImgDisplay &disp, const int select_type=2, unsigned int *const XYZ=0, const unsigned char *const color=0) const
Simple interface to select a shape from an image.
#define _cimg_blur_patch3d(N)
CImg< T > & displacement_field(const CImg< T > &target, const float smooth=0.1f, const float precision=0.1f, const unsigned int nb_scales=0, const unsigned int itermax=1000, const bool backward=true)
Estimate a displacement field between instance image and given target image.
CImg< T > & fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6)
Fill sequentially pixel values.
CImg< T > & draw_ellipse(const int x0, const int y0, const float r1, const float r2, const float angle, const CImg< tc > &color, const float opacity=1)
Draw a filled ellipse.
const CImgList< T > & save_cimg(std::FILE *file, const bool compress=false) const
Save an image list into a CImg file (RAW binary file + simple header)
CImg< Tfloat > get_haar(const char axis, const bool invert=false, const unsigned int nb_scales=1) const
CImg< T > & draw_triangle(CImg< floatT > &zbuffer, const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const int x2, const int y2, const float z2, const tc *const color, const CImg< tl > &light, const int lx0, const int ly0, const int lx1, const int ly1, const int lx2, const int ly2, const float opacity=1)
Draw a 2D Pseudo-Phong-shaded triangle, with z-buffering.
static CImg< T > get_load_dlm(std::FILE *const file)
#define cimg_foroff(img, off)
CImgDisplay & show_mouse()
Show mouse pointer.
volatile bool is_keyENTER
T _at(const int off) const
CImg< T > get_fill(const T val0, const T val1, const T val2, const T val3) const
CImg< T > get_matrix() const
T atN(const int pos, const int x, const int y, const int z, const int v, const T out_val) const
CImgList< T > get_remove(const unsigned int pos1, const unsigned int pos2) const
static CImg< Tuchar > default_LUT256()
Return a default indexed color palette with 256 (R,G,B) entries.
superset< t1, typename superset< t2, t3 >::type >::type type
CImg< _cimg_Tfloat > atan(const CImg< T > &instance)
CImg< T > & draw_point(const int x0, const int y0, const int z0, const CImg< tc > &color, const float opacity=1)
Draw a 3D colored point (voxel).
CImgList< T > get_remove(const unsigned int pos) const
CImgList< T > & FFT(const bool invert=false)
Compute a N-D Fast Fourier Transform.
unsigned int compile(char *const ss, char *const se)
CImgDisplay(const CImgDisplay &disp)
Create a display window by copying another one.
bool is_object3d(const CImgList< tf > &primitives, const bool check_primitives=true, const bool throw_exception=false, const char *const calling_function=0) const
Return true if the couple (instance,primitives) stands for a valid 3D object.
CImg< T > & fill(const T val0, const T val1, const T val2)
Fill sequentially all pixel values with values val0 and val1 and val2.
CImg< T > get_threshold(const T value, const bool soft_threshold=false, const bool strict_threshold=false) const
CImgList< T > & load_ffmpeg_external(const char *const filename)
Load an image from a video file (MPEG,AVI) using the external tool 'ffmpeg'.
CImg< _cimg_Tt > get_cross(const CImg< t > &img) const
CImgList< T > & images(const unsigned int i0, const unsigned int i1)
Get a sub-list.
CImg< T > & draw_triangle(CImg< floatT > &zbuffer, const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const int x2, const int y2, const float z2, const tc *const color, const float brightness0, const float brightness1, const float brightness2, const float opacity=1)
Draw a 2D Gouraud-shaded colored triangle, with z-buffering.
const unsigned int keyARROWRIGHT
T & _atX(const int x, const int y=0, const int z=0, const int v=0)
CImg< T > & draw_triangle(const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const tc *const color, const float opacity=1)
Draw a 2D filled colored triangle.
CImgList< T > & assign(const CImg< t1 > &img1, const CImg< t2 > &img2, const CImg< t3 > &img3, const bool shared=false)
In-place version of the corresponding constructor.
CImg< T > & load_rgb(std::FILE *const file, const unsigned int dimw, const unsigned int dimh=1)
Load an image from a RGB file.
CImgList< T > get_crop_font() const
CImg< T > & draw_triangle(const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const tc1 *const color1, const tc2 *const color2, const tc3 *const color3, const float opacity=1)
Draw a colored triangle with interpolated colors.
CImg< T > operator|(const t val) const
Operator|().
const CImg< T > get_shared_channels(const unsigned int v0, const unsigned int v1) const
T sign(const T x)
Return the sign of a number.
#define cimg_for3XY(img, x, y)
CImgList< T > get_split(const T value, const bool keep_values, const bool shared, const char axis='y') const
const CImg< T > & save_rgba(const char *const filename) const
Save the image as a RGBA file.
volatile bool is_keySHIFTRIGHT
CImg< Tfloat > get_RGBtoCMY() const
static const char * format()
const CImg< T > & save(const char *const filename, const int number=-1) const
Save the image as a file.
static CImg< T > vector(const T &a0, const T &a1, const T &a2, const T &a3, const T &a4)
Return a vector with specified coefficients.
CImg< T > & draw_spline(const CImgList< tp > &points, const CImgList< tt > &tangents, const CImg< tc > &color, const float opacity=1, const bool close_set=false, const float precision=4, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a set of consecutive colored splines in the instance image.
int window_dimx() const
Return display window width.
CImg< T > & draw_spline(const int x0, const int y0, const float u0, const float v0, const int x1, const int y1, const float u1, const float v1, const CImg< t > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const float opacity=1, const float precision=4, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a cubic spline curve in the instance image.
#define cimg_forXY(img, x, y)
CImg< T > & LabtoXYZ()
Convert (L,a,b) pixels of a color image into the (X,Y,Z) color space.
CImg< T > & blur_anisotropic(const CImg< t > &G, const float amplitude=60, const float dl=0.8f, const float da=30, const float gauss_prec=2, const unsigned int interpolation_type=0, const unsigned int fast_approx=1)
Blur the image anisotropically following a field of diffusion tensors.
const CImg< T > & save_png(const char *const filename, const unsigned int bytes_per_pixel=0) const
Save a file in PNG format.
T & maxmin(t &min_val)
Return a reference to the maximum pixel value and return also the minimum pixel value.
CImg()
Default constructor.
const unsigned int keyPAD7
CImgList(const unsigned int n, const unsigned int width, const unsigned int height, const unsigned int depth, const unsigned int dim, const int val0, const int val1,...)
Construct an image list containing n images with specified size and specified pixel values (int versi...
bool is_sameXYZV(const CImg< t > &img) const
Return true if images (*this) and img have same width, same height, same depth and same number of cha...
static void save_empty_cimg(std::FILE *const file, const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const unsigned int dv=1)
Save an empty .cimg file with specified dimensions.
CImg< T > & cross(const CImg< t > &img)
Compute the cross product between two 3d vectors.
CImgList< T > & pop_back()
Remove last element of the list (STL-compliant name).
#define _cimg_fopcode2(op, i1, i2)
CImgList< T > & assign(const unsigned int n, const CImg< t > &img, const bool shared=false)
In-place version of the corresponding constructor.
CImg< T > operator&(const t val) const
Operator&().
const T rol(const T a, const unsigned int n=1)
Return a left bitwise-rotated number.
const unsigned int font16x32[16 *32 *256/32]
CImgList< T > & split(const char axis, const int nb=0)
Return a list where each image has been split along the specified axis.
CImg< T > & draw_gaussian(const float xc, const float yc, const float zc, const float sigma, const CImg< tc > &color, const float opacity=1)
Draw an isotropic 3D gaussian function.
#define cimglist_for(list, l)
CImg< T > & draw_text(const int x0, const int y0, const char *const text, const int, const tc *const background_color, const float opacity, const CImgList< t > &font,...)
Draw a text.
CImg< Tfloat > get_displacement_field(const CImg< T > &target, const float smoothness=0.1f, const float precision=0.1f, const unsigned int nb_scales=0, const unsigned int itermax=1000, const bool backward=true) const
CImg< T > & draw_plasma(const int x0, const int y0, const int x1, const int y1, const float alpha=1, const float beta=1, const float opacity=1)
Draw a plasma random texture.
CImgList< T > get_split(const char axis, const int nb=0) const
Split image into a list.
CImg< T > & operator/=(const char *const expression)
Operator/=().
CImg< T > & YCbCrtoRGB()
Convert color pixels from (R,G,B) to (Y,Cb,Cr)_8.
CImg< T > & load_pnm(const char *const filename)
Load an image from a PNM file.
CImg< T > & load_ffmpeg(const char *const filename, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1, const bool pixel_format=true, const bool resume=false, const char axis='z', const char align='p')
Load a video sequence using FFMPEG av's libraries.
CImg< T > & resize(const CImgDisplay &disp, const int interpolation_type=1, const int border_condition=-1, const bool center=false)
Resize an image.
const CImg< T > & _display(CImgDisplay &disp, const char *const title, const bool display_info) const
CImg< Tfloat > get_pseudoinvert() const
static CImgList< T > & empty()
Return a reference to an empty list.
CImg< T > get_resize_doubleXY() const
T atX(const int x, const int y, const int z, const int v, const T out_val) const
static CImgList< T > _font(const unsigned int *const font, const unsigned int w, const unsigned int h, const unsigned int paddingx, const unsigned int paddingy, const bool variable_size=true)
CImg< T > & operator-=(const CImg< t > &img)
Operator-=().
bool is_sameZ(const CImg< t > &img) const
Return true if images (*this) and img have same depth.
T & atX(const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions for the first coordinates (x).
const unsigned int keyPAD4
const unsigned int keyPADSUB
std::vector< std::vector< bool > > mask
Masks the points that are shared (true) share (false) not shared.
int system(const char *const command, const char *const module_name=0)
CImg< _cimg_Ttfloat > get_convolve(const CImg< t > &mask, const unsigned int cond=1, const bool weighted_convol=false) const
static CImg< Tuchar > rainbow_LUT256()
Return a rainbow indexed color palette with 256 (R,G,B) entries.
CImgList< T > & load(const char *const filename)
Load an image list from a file.
CImg< T > & load_medcon_external(const char *const filename)
Load a DICOM image file, using XMedcon's external tool 'medcon'.
CImg< T > get_resize_halfXY() const
CImg< Tfloat > get_abs() const
CImg< T > & draw_text(const int x0, const int y0, const char *const text, const tc *const foreground_color, const int background_color=0, const float opacity=1, const unsigned int font_size=11,...)
Draw a text.
const CImg< T > & save_jpeg(std::FILE *const file, const unsigned int quality=100) const
Save a file in JPEG format.
CImgList< T > & load_cimg(const char *const filename)
Load an image list from a .cimg file.
CImg< T > & blur_bilateral(const float sigma_x, const float sigma_y, const float sigma_z, const float sigma_r, const int bgrid_x, const int bgrid_y, const int bgrid_z, const int bgrid_r, const bool interpolation_type=true)
Blur an image using the bilateral filter.
CImg< T > get_invert_endianness() const
bool contains(const T &pixel, t &n, t &x) const
Return true if one of the image list contains the specified referenced value. If true, set coordinates (n,x).
CImg< T > & _solve(const CImg< t > &A, const CImg< ti > &indx)
static unsigned long format(const unsigned long val)
CImgDisplay(const unsigned int dimw, const unsigned int dimh, const char *title=0, const unsigned int normalization_type=3, const bool fullscreen_flag=false, const bool closed_flag=false)
Create a display window with a specified size pwidth x height.
CImg< T > get_vector_at(const unsigned int x, const unsigned int y=0, const unsigned int z=0) const
Return a new image corresponding to the vector located at (x,y,z) of the current vector-valued image...
static CImg< T > vector(const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8)
Return a vector with specified coefficients.
#define cimg_for(img, ptr, T_ptr)
CImg< T > & CMYKtoCMY()
Convert (C,M,Y,K) pixels of a color image into the (C,M,Y) color space.
CImg< T > get_append(const char axis, const char align='p') const
Return a single image which is the concatenation of all images of the current CImgList instance...
CImg< T > & draw_plasma(const float alpha=1, const float beta=1, const float opacity=1)
Draw a plasma random texture.
const T & front() const
Return reference to the first image pixel (STL-compliant name).
CImg< T > & draw_image(const CImg< ti > &sprite, const CImg< tm > &mask, const float opacity=1, const float mask_valmax=1)
Draw an image.
double _pythagore(double a, double b)
CImg< T > & BayertoRGB(const unsigned int interpolation_type=3)
Convert a Bayer-coded image to a (R,G,B) color image.
char message[16384]
Message associated with the error that thrown the exception.
CImgList< T > & load_cimg(std::FILE *const file)
Load an image list from a .cimg file.
CImg< T > & draw_circle(const int x0, const int y0, int radius, const tc *const color, const float opacity=1)
Draw a filled circle.
CImg< T > & draw_ellipse(const int x0, const int y0, const float r1, const float r2, const float angle, const tc *const color, const float opacity=1)
Draw a filled ellipse.
CImg< T > & draw_spline(const CImgList< tp > &points, const CImgList< tt > &tangents, const tc *const color, const float opacity=1, const bool close_set=false, const float precision=4, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a set of consecutive colored splines in the instance image.
volatile int mouse_y
Y-coordinate of the mouse pointer on the display.
static CImg< floatT > cone3d(CImgList< tf > &primitives, const float radius=50, const float size_z=100, const unsigned int subdivisions=24)
Create and return a 3D cone.
#define _CImg_stdarg(img, a0, a1, N, t)
T & operator()(const unsigned int pos, const unsigned int x, const unsigned int y=0, const unsigned int z=0, const unsigned int v=0)
Return a reference to (x,y,z,v) pixel of the pos-th image of the list.
CImg< T > & draw_rectangle(const int x0, const int y0, const int z0, const int x1, const int y1, const int z1, const CImg< tc > &color, const float opacity=1)
Draw a 3D filled colored rectangle in the instance image, at coordinates (x0,y0,z0)-(x1,y1,z1).
CImg< T > & operator/=(const t val)
Operator/=().
CImg< T > & draw_line(const int x0, const int y0, const int z0, const int x1, const int y1, const int z1, const tc *const color, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a 3D colored line.
const unsigned int font7x11[7 *11 *256/32]
CImgList< T > & push_front(const CImg< t > &img)
Insert image img at the front of the list (STL-compliant name).
CImg< T > & draw_axis(const int x, const CImg< t > &yvalues, const tc *const color, const float opacity=1, const unsigned int pattern=~0U)
Draw a labeled vertical axis on the instance image.
CImg< T > get_sharpen(const float amplitude, const bool sharpen_type=false, const float edge=1, const float alpha=0, const float sigma=0) const
CImg< T > & _draw_scanline(const int x0, const int x1, const int y, const tc *const color, const float opacity=1, const float brightness=1, const bool init=false)
static double format(const float val)
CImg< T > & load_parrec(const char *const filename, const char axis='v', const char align='p')
Load an image from a PAR-REC (Philips) file.
CImg< T > & RGBtoCMY()
Convert color pixels from (R,G,B) to (C,M,Y).
const CImgList< T > & _save_cimg(std::FILE *const file, const char *const filename, const bool compression) const
Save an image list into a .cimg file.
CImg< T > & draw_line(const int x0, const int y0, const int z0, const int x1, const int y1, const int z1, const CImg< tc > &color, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a 3D colored line.
cimg::superset< T, float >::type Tfloat
Tfloat _linear_atXY(const float fx, const float fy, const int z=0, const int v=0) const
static CImg< T > identity_matrix(const unsigned int N)
Return a NxN identity matrix.
const CImg< T > & display_object3d(CImgDisplay &disp, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const bool centering=true, const int render_static=4, const int render_motion=1, const bool double_sided=true, const float focale=500, const float specular_light=0.2f, const float specular_shine=0.1f, const bool display_axes=true, float *const pose_matrix=0) const
High-level interface for displaying a 3d object.
Tfloat _cubic_atXY(const float fx, const float fy, const int z=0, const int v=0) const
CImg< t > get_map(const CImg< t > &palette) const
CImg< Tfloat > get_blur(const float sigmax, const float sigmay, const float sigmaz, const bool cond=true) const
CImg< T > & draw_fill(const int x, const int y, const int z, const tc *const color, const float opacity=1, const float sigma=0, const bool high_connexity=false)
Draw a 3D filled region starting from a point (x,y,\ z) in the instance image.
const CImg< T > & save_jpeg(const char *const filename, const unsigned int quality=100) const
Save a file in JPEG format.
T abs(const T a)
Return the absolute value of a number.
CImg< T > & autocrop(const CImg< t > &color, const char *const axes="zyx")
Autocrop an image, regarding of the specified backround color.
CImg< T > & sort(const bool increasing=true)
Sort image values.
CImg(const CImg< T > &img, const bool shared)
CImg(const CImg< t > &img)
Default copy constructor.
#define cimg_strescape(ci, co)
CImg< Tuchar > get_YCbCrtoRGB() const
CImgDisplay & close()
Close a visible display.
volatile bool is_keyPAGEUP
CImg< Tuchar > get_CMYtoRGB() const
Tfloat trace() const
Return the trace of the image, viewed as a matrix.
CImg< Tuchar > get_XYZtoRGB() const
static CImgList< T > get_load_yuv(std::FILE *const file, const unsigned int sizex, const unsigned int sizey=1, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1, const bool yuv2rgb=true)
static CImg< Tuchar > contrast_LUT256()
Return a contrasted indexed color palette with 256 (R,G,B) entries.
static CImg< T > dijkstra(const tf &distance, const unsigned int nb_nodes, const unsigned int starting_node, const unsigned int ending_node=~0U)
Return minimal path in a graph, using the Dijkstra algorithm.
static CImg< T > get_load_other(const char *const filename)
CImg< T > & load_pnm(std::FILE *const file)
Load an image from a PNM file.
static void FFT(CImg< T > &real, CImg< T > &imag, const bool invert=false)
Compute a N-D Fast Fourier Transform.
#define cimg_forV(img, v)
bool is_sameZ(const unsigned int dz) const
Return true if image (*this) has the specified depth.
static const char * string()
const unsigned int keyPAD0
T _atNXY(const int pos, const int x, const int y, const int z=0, const int v=0) const
int window_posx() const
Return X-coordinate of the window.
CImg< T > & draw_grid(const float deltax, const float deltay, const float offsetx, const float offsety, const bool invertx, const bool inverty, const tc *const color, const float opacity=1, const unsigned int patternx=~0U, const unsigned int patterny=~0U)
Draw grid.
CImg< T > & _draw_spline(const tp &points, const unsigned int W, const unsigned int H, const tc *const color, const float opacity, const bool close_set, const float precision, const unsigned int pattern, const bool init_hatch)
static void _load_inr_header(std::FILE *file, int out[8], float *const voxsize)
CImgList(const CImg< t1 > &img1, const CImg< t2 > &img2, const CImg< t3 > &img3, const CImg< t4 > &img4, const bool shared=false)
Construct an image list from four images.
CImg< T > & warp(const CImg< t > &warp, const bool relative=false, const bool interpolation=true, const unsigned int border_conditions=0)
Warp an image.
static CImgList< T > get_load_cimg(const char *const filename, const unsigned int n0, const unsigned int n1, const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0, const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int v1)
CImg< T > & RGBtoHSI()
Convert color pixels from (R,G,B) to (H,S,I).
cimg::last< T, long >::type longT
static int screen_dimx()
Return the width of the screen resolution.
CImg< T > get_crop(const int x0, const int y0, const int z0, const int x1, const int y1, const int z1, const bool border_condition=false) const
CImgList< T > & clear()
In-place version of the default constructor.
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
CImg< T > & draw_rectangle(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const T val, const float opacity=1)
Draw a 4D filled rectangle in the instance image, at coordinates (x0,y0,z0,v0)-(x1,y1,z1,v1).
const CImg< T > & save_ascii(const char *const filename) const
Save the image as an ASCII file (ASCII Raw + simple header).
CImg< T > & append_object3d(CImgList< tf > &primitives, const CImg< tp > &obj_vertices, const CImgList< tff > &obj_primitives)
Append a 3D object to another one.
const CImgList< T > get_shared() const
Return a shared instance of the list.
CImg< Tfloat > get_log() const
CImg< T > & draw_image(const CImg< t > &sprite, const float opacity=1)
Draw an image.
const CImg< T > & save_rgba(std::FILE *const file) const
Save the image as a RGBA file.
CImg< Tuchar > get_BayertoRGB(const unsigned int interpolation_type=3) const
CImgList< T > get_images(const unsigned int i0, const unsigned int i1) const
static CImg< T > diagonal(const T &a0)
Return a 1x1 diagonal matrix with specified coefficients.
char uncase(const char x)
Remove the 'case' of an ASCII character.
CImg< T > & lines(const unsigned int y0, const unsigned int y1)
Get a set of lines.
CImg< T > & draw_gaussian(const float xc, const float yc, const float zc, const CImg< t > &tensor, const CImg< tc > &color, const float opacity=1)
Draw an anisotropic 3D gaussian function.
const char * file_type(std::FILE *const file, const char *const filename)
Try to guess the image format of a filename, using its magick numbers.
T & atXYZV(const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions.
CImg< T > & draw_point(const CImg< t > &points, const tc *const color, const float opacity=1)
Draw a cloud of colored points.
CImg< T > get_fill(const CImg< t > &values, const bool repeat_values=true) const
CImg< T > get_shared_points(const unsigned int x0, const unsigned int x1, const unsigned int y0=0, const unsigned int z0=0, const unsigned int v0=0)
Get a shared-memory image referencing a set of points of the instance image.
CImg< T > & load_rgb(const char *const filename, const unsigned int dimw, const unsigned int dimh=1)
Load an image from a RGB file.
CImgList< T > & load_off(const char *const filename, CImgList< tf > &primitives, CImgList< tc > &colors)
Load a 3D object from a .OFF file.
#define _cimg_blur_patch2d_fast(N)
const CImg< T > & save_pandore(const char *const filename, const unsigned int colorspace=0) const
Save the image as a PANDORE-5 file.
static CImgDisplay & empty()
Return a reference to an empty display.
CImgDisplay(const CImgList< T > &list, const char *title=0, const unsigned int normalization_type=3, const bool fullscreen_flag=false, const bool closed_flag=false)
Create a display window from an image list.
CImgList(const CImg< t1 > &img1, const CImg< t2 > &img2, const bool shared=false)
Construct an image list from two images.
CImg< T > & resize_doubleXY()
Upscale an image by a factor 2x.
const T & operator()(const unsigned int x, const unsigned int y=0, const unsigned int z=0, const unsigned int v=0) const
CImg< T > get_crop(const int x0, const int x1, const bool border_condition=false) const
CImg< T > & sqr()
Compute the square value of each pixel.
bool is_sameXY(const unsigned int dx, const unsigned int dy) const
Return true if image (*this) has the specified width and height.
CImg< T > * iterator
Define a CImgList<T>::iterator.
CImg< T > & draw_axis(const CImg< tx > &xvalues, const CImg< ty > &yvalues, const tc *const color, const float opacity=1, const unsigned int patternx=~0U, const unsigned int patterny=~0U)
Draw a labeled horizontal+vertical axis on the instance image.
const CImg< T > & _save_rgba(std::FILE *const file, const char *const filename) const
#define cimg_for4x4(img, x, y, z, v, I)
CImgList< T > & insert(const CImgList< t > &list, const unsigned int pos=~0U, const bool shared=false)
Insert a copy of the image list list into the current image list, starting from position pos...
CImgDisplay & render(const CImg< T > &img)
Render image buffer into GDI native image format.
CImg< T > & assign(const char *const filename)
In-place version of the previous constructor.
Tfloat linear_atXYZ(const float fx, const float fy, const float fz, const int v, const T out_val) const
Read a pixel value using linear interpolation and Dirichlet boundary conditions (first three coordina...
CImg< T > get_resize(const int pdx, const int pdy=-100, const int pdz=-100, const int pdv=-100, const int interpolation_type=1, const int border_condition=-1, const bool center=false) const
CImgList< T > & load_tiff(const char *const filename, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1)
Load a TIFF file.
cimg::superset< T, short >::type Tshort
CImg< _cimg_Tfloat > sin(const CImg< T > &instance)
CImg< T > & fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10, const T val11, const T val12, const T val13)
Fill sequentially pixel values.
CImg< T > & threshold(const T value, const bool soft_threshold=false, const bool strict_threshold=false)
Threshold values of the instance image.
CImg(const T *const data_buffer, const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const unsigned int dv=1, const bool shared=false)
CImgList< T > get_insert(const CImg< t > &img, const unsigned int pos=~0U, const bool shared=false) const
static CImg< T > get_load_yuv(const char *const filename, const unsigned int sizex, const unsigned int sizey=1, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1, const bool yuv2rgb=true, const char axis='z', const char align='p')
CImg< Tuchar > get_HSVtoRGB() const
static CImg< T > get_load_analyze(std::FILE *const file, float *const voxsize=0)
CImg< floatT > get_isosurface3d(CImgList< tf > &primitives, const float isovalue, const int size_x=-100, const int size_y=-100, const int size_z=-100) const
Create and return a isosurface of the instance image as a 3D object.
CImgList< T > & reverse_object3d()
Invert primitives orientation of a 3D object.
CImg< T > & map(const CImg< t > &palette)
Map predefined palette on the scalar (indexed) instance image.
CImg< T > & fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10)
Fill sequentially pixel values.
CImg< Tuchar > get_HSLtoRGB() const
const char * split_filename(const char *const filename, char *const body=0)
Split a filename into two strings 'body' and 'extension'.
#define _cimglist_def_is_same3(axis1, axis2, axis3)
CImg< T > & _load_raw(std::FILE *const file, const char *const filename, const unsigned int sizex, const unsigned int sizey, const unsigned int sizez, const unsigned int sizev, const bool multiplexed, const bool invert_endianness)
const CImg< T > & save_bmp(std::FILE *const file) const
Save the image as a BMP file.
const CImg< T > & _save_dlm(std::FILE *const file, const char *const filename) const
CImg< T > & sort(CImg< t > &permutations, const bool increasing=true)
Sort values of a vector and get permutations.
Tfloat linear_atXYZV(const float fx, const float fy, const float fz, const float fv, const T out_val) const
Read a pixel value using linear interpolation and Dirichlet boundary conditions.
T & _atXYZV(const int x, const int y, const int z, const int v)
bool contains(const T &pixel, t &x, t &y, t &z, t &v) const
Return true if specified referenced value is inside image boundaries. If true, returns pixel coordina...
static const char * format()
volatile bool is_keyPADADD
cimg::superset< T, char >::type Tchar
CImg< T > & blur(const float sigmax, const float sigmay, const float sigmaz, const bool cond=true)
Return a blurred version of the image, using a Canny-Deriche filter.
CImgList< _cimg_Tt > operator,(const CImg< t > &img) const
Operator,().
CImg< charT > value_string(const char separator=',', const unsigned int max_size=0) const
Return a C-string containing the values of the instance image.
CImg< T > & set_tensor_at(const CImg< t > &ten, const unsigned int x=0, const unsigned int y=0, const unsigned int z=0)
Set the image vec as the tensor valued pixel located at (x,y,z) of the current vector-valued image...
bool strpare(char *const s, const char delimiter=' ', const bool symmetric=false)
Remove useless delimiters on the borders of a C-string.
CImg< T > get_projections2d(const unsigned int x0, const unsigned int y0, const unsigned int z0, const int dx=-100, const int dy=-100, const int dz=-100) const
CImg< intT > get_select(const char *const title, const int select_type=2, unsigned int *const XYZ=0, const unsigned char *const color=0) const
Simple interface to select a shape from an image.
CImg< T > get_unroll(const char axis) const
CImg< T > & round(const float x, const int rounding_type=0)
Compute image with rounded pixel values.
CImg< T > get_identity_matrix() const
static CImg< T > get_load_ffmpeg(const char *const filename, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1, const bool pixel_format=true, const bool resume=false, const char axis='z', const char align='p')
Tfloat PSNR(const CImg< t > &img, const Tfloat valmax=(Tfloat) 255) const
Compute the PSNR between two images.
CImgList< T > & assign(const CImg< t1 > &img1, const CImg< t2 > &img2, const CImg< t3 > &img3, const CImg< t4 > &img4, const CImg< t5 > &img5, const CImg< t6 > &img6, const CImg< t7 > &img7, const bool shared=false)
In-place version of the corresponding constructor.
CImg< T > operator&(const char *const expression, const CImg< T > &img)
T * ptr()
Return a pointer to the pixel buffer.
const CImg< T > & _save_raw(std::FILE *const file, const char *const filename, const bool multiplexed) const
CImgException(const char *format,...)
CImgList< Tfloat > get_gradient(const char *const axes=0, const int scheme=3) const
Compute the list of images, corresponding to the XY-gradients of an image.
const unsigned int keyINSERT
CImg< T > & columns(const unsigned int x0, const unsigned int x1)
Get a set of columns.
bool is_sameXZ(const unsigned int dx, const unsigned int dz) const
Return true if image (*this) has the specified width and depth.
CImg< T > & assign(const CImg< t > &img, const char *const dimensions, const char *const values, const bool repeat_values)
In-place version of the previous constructor.
const char * imagemagick_path(const char *const user_path=0, const bool reinit_path=false)
Return or set path to the ImageMagick's convert tool.
unsigned int wait(const unsigned int milliseconds)
Wait for a certain number of milliseconds since the last call.
bool is_sameY(const CImg< t > &img) const
Return true if images (*this) and img have same height.
T atNXYZV(const int pos, const int x, const int y, const int z, const int v) const
CImg< T > & fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7)
Fill sequentially pixel values.
CImg< T > & at(const int pos)
Read an image in specified position.
CImgList< T > & erase(const iterator iter)
Remove the element pointed by iterator iter (STL-compliant name).
CImgList< T > & transfer_to(CImgList< t > &list)
Transfer the content of the instance image list into another one.
const CImg< T > & _save_bmp(std::FILE *const file, const char *const filename) const
unsigned long time()
Get the value of a system timer with a millisecond precision.
CImg< T > & resize(const CImg< t > &src, const int interpolation_type=1, const int border_condition=-1, const bool center=false)
Resize an image.
CImg(const CImg< t > &img, const bool shared)
Advanced copy constructor.
CImg< T > & projections2d(const unsigned int x0, const unsigned int y0, const unsigned int z0, const int dx=-100, const int dy=-100, const int dz=-100)
Return a 2D representation of a 3D image, with three slices.
CImg< T > & _draw_line(const t &points, const unsigned int W, const unsigned int H, const tc *const color, const float opacity, const unsigned int pattern, const bool init_hatch)
T _atNXYZV(const int pos, const int x, const int y, const int z, const int v) const
bool is_fullscreen
Fullscreen state of the display.
bool is_sameXYZ(const CImg< t > &img) const
Return true if images have same width, same height and same depth.
static CImg< floatT > box3d(CImgList< tf > &primitives, const float size_x=200, const float size_y=100, const float size_z=100)
Create and return a 3D box object.
unsigned int normalization
Normalization type used for the display.
CImg< T > operator<<(const int n) const
Operator<<().
const CImg< T > & save_pandore(std::FILE *const file, const unsigned int colorspace=0) const
Save the image as a PANDORE-5 file.
Tfloat cubic_atXY(const float fx, const float fy, const int z=0, const int v=0) const
Read a pixel value using cubic interpolation and Neumann boundary conditions.
T atNX(const int pos, const int x, const int y=0, const int z=0, const int v=0) const
iterator end()
Returns an iterator just past the last element (STL-compliant name).
T at(const int off, const T out_val) const
static CImg< T > get_load_jpeg(std::FILE *const file)
CImg< T > & draw_graph(const CImg< t > &data, const tc *const color, const float opacity=1, const unsigned int plot_type=1, const int vertex_type=1, const double ymin=0, const double ymax=0, const bool expand=false, const unsigned int pattern=~0U)
Draw a 1D graph on the instance image.
static CImg< T > matrix(const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8)
Return a 3x3 square matrix with specified coefficients.
T _atX(const int x, const int y=0, const int z=0, const int v=0) const
CImgDisplay & operator=(const CImgDisplay &disp)
Operator=().
int window_posy() const
Return Y-coordinate of the window.
static CImg< T > rotation_matrix(const float x, const float y, const float z, const float w, const bool quaternion_data=false)
Return a 3x3 rotation matrix along the (x,y,z)-axis with an angle w.
const CImg< T > & save_medcon_external(const char *const filename) const
Save an image as a Dicom file (need '(X)Medcon' : http://xmedcon.sourceforge.net ) ...
static CImg< T > get_load_ascii(const char *const filename)
CImg< T > & draw_quiver(const CImg< t1 > &flow, const t2 *const color, const float opacity=1, const unsigned int sampling=25, const float factor=-20, const bool arrows=true, const unsigned int pattern=~0U)
Draw a vector field in the instance image, using a colormap.
static const char * format()
CImg< T > & _load_png(std::FILE *const file, const char *const filename)
CImg< T > & append(const CImg< t > &img, const char axis='x', const char align='p')
Append an image.
CImg< T > & clear()
In-place version of the default constructor (STL-compliant name).
T atNXYZV(const int pos, const int x, const int y, const int z, const int v, const T out_val) const
CImg< T > & _draw_triangle(const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const tc *const color, const float opacity, const float brightness)
#define cimg_forZV(img, z, v)
#define cimg_forXYZV(img, x, y, z, v)
volatile unsigned int window_height
Height of the underlying window.
const unsigned int keyPAD5
CImg< Tuchar > get_LabtoRGB() const
CImg< T > & _load_bmp(std::FILE *const file, const char *const filename)
volatile bool is_event
Event state of the window.
CImg< T > & draw_point(const CImgList< t > &points, const CImg< tc > &color, const float opacity=1)
Draw a cloud of colored points.
const CImg< T > & save_cimg(const char *const filename, const unsigned int n0, const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0) const
Insert the image into an existing .cimg file, at specified coordinates.
CImg< typename cimg::superset< t, unsigned int >::type > get_index(const CImg< t > &palette, const bool dithering=false, const bool map_indexes=true) const
T sqr(const T val)
Return the square of a number.
CImg< T > & draw_image(const int x0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
CImgDisplay & resize(const int width, const int height, const bool redraw=true)
Resize window.
CImg< T > & transfer_to(CImg< T > &img)
CImg< T > & operator=(const T val)
Operator=().
bool is_empty() const
Return true if list is empty.
const CImg< T > & display_graph(CImgDisplay &disp, const unsigned int plot_type=1, const unsigned int vertex_type=1, const char *const labelx=0, const double xmin=0, const double xmax=0, const char *const labely=0, const double ymin=0, const double ymax=0) const
High-level interface for displaying a graph.
CImg< T > & draw_gaussian(const int xc, const int yc, const float r1, const float r2, const float ru, const float rv, const tc *const color, const float opacity=1)
Draw an anisotropic 2D gaussian function.
CImg< T > get_fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9) const
Tfloat cubic_atXY(const float fx, const float fy, const int z, const int v, const T out_val) const
Read a pixel value using cubic interpolation and Dirichlet boundary conditions.
Tfloat _linear_atX(const float fx, const int y=0, const int z=0, const int v=0) const
CImg< T > & draw_rectangle(const int x0, const int y0, const int x1, const int y1, const tc *const color, const float opacity=1)
Draw a 2D filled colored rectangle in the instance image, at coordinates (x0,y0)-(x1,y1).
CImgList< Tfloat > get_SVD(const bool sorting=true, const unsigned int max_iter=40, const float lambda=0) const
CImg< T > get_column(const unsigned int x0) const
CImgList< T > & push_back(const CImgList< t > &list)
Insert list list at the end of the current list (STL-compliant name).
const CImg< T > & save_pnm(std::FILE *const file, const unsigned int bytes_per_pixel=0) const
Save the image as a PNM file.
CImg< T > & draw_gaussian(const float xc, const float yc, const float sigma, const tc *const color, const float opacity=1)
Draw an isotropic 2D gaussian function.
#define cimg_for3x3x3(img, x, y, z, v, I)
CImg< T > & draw_triangle(const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const int x2, const int y2, const float z2, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const int tx2, const int ty2, const CImg< tl > &light, const int lx0, const int ly0, const int lx1, const int ly1, const int lx2, const int ly2, const float opacity=1)
Draw a 2D Pseudo-Phong-shaded textured triangle, with perspective correction.
CImg< T > & draw_line(const CImg< t > &points, const tc *const color, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a set of consecutive colored lines in the instance image.
CImgList< T > & assign(const CImg< t1 > &img1, const CImg< t2 > &img2, const CImg< t3 > &img3, const CImg< t4 > &img4, const CImg< t5 > &img5, const bool shared=false)
In-place version of the corresponding constructor.
#define _cimg_for_triangle1(img, xl, xr, y, x0, y0, x1, y1, x2, y2)
CImg< _cimg_Tt > get_dilate(const CImg< t > &mask, const unsigned int cond=1, const bool weighted_dilatation=false) const
CImg< T > & draw_fill(const int x, const int y, const tc *const color, const float opacity=1, const float sigma=0, const bool high_connexity=false)
Draw a 2D filled region starting from a point (x,y) in the instance image.
CImg< T > operator^(const t val) const
Operator^().
#define cimg_forZ(img, z)
CImg< T > get_shared_channel(const unsigned int v0)
Return a shared-memory image referencing one channel v0 of the instance image.
CImg< T > get_fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5) const
static CImg< T > get_load_tiff(const char *const filename, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1)
CImg< _cimg_Tfloat > abs(const CImg< T > &instance)
CImg< T > & draw_mandelbrot(const int x0, const int y0, const int x1, const int y1, const CImg< tc > &color_palette, const float opacity=1, const double z0r=-2, const double z0i=-2, const double z1r=2, const double z1i=2, const unsigned int itermax=255, const bool normalized_iteration=false, const bool julia_set=false, const double paramr=0, const double parami=0)
Draw a quadratic Mandelbrot or Julia fractal set, computed using the Escape Time Algorithm.
CImg< T > & slice(const unsigned int z0)
Get a slice.
CImg< T > & invert(const bool use_LU=true)
Invert the current matrix.
void sleep(const unsigned int milliseconds)
Sleep for a certain numbers of milliseconds.
CImg< T > operator+() const
Operator+() (unary).
CImg< T > & draw_spline(const int x0, const int y0, const int z0, const float u0, const float v0, const float w0, const int x1, const int y1, const int z1, const float u1, const float v1, const float w1, const tc *const color, const float opacity=1, const float precision=4, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a cubic spline curve in the instance image (for volumetric images).
cimg::last< T, int >::type intT
cimg::superset< T, double >::type Tdouble
CImgDisplay & resize(const CImg< T > &img, const bool redraw=true)
Resize a display window with the size of an image.
T median() const
Return the median value of the image.
CImg< T > & draw_triangle(CImg< floatT > &zbuffer, const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const int x2, const int y2, const float z2, const tc *const color, const float opacity=1, const float brightness=1)
Draw a 2D filled colored triangle, with z-buffering.
CImg< T > & XYZtoxyY()
Convert (X,Y,Z)_709 pixels of a color image into the (x,y,Y) color space.
static CImg< T > vector(const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8, const T &a9, const T &a10, const T &a11, const T &a12, const T &a13, const T &a14, const T &a15)
Return a vector with specified coefficients.
CImg< T > & translate(const int deltax, const int deltay=0, const int deltaz=0, const int deltav=0, const int border_condition=0)
Translate the image.
CImg< T > & _load_pnm(std::FILE *const file, const char *const filename)
CImg< T > & fillV(const unsigned int x, const unsigned int y, const unsigned int z, const double a0,...)
CImg< T > & max(const T val)
Pointwise max operator between an image and a value.
CImg(const t *const data_buffer, const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const unsigned int dv=1, const bool shared=false)
Construct an image from a raw memory buffer.
static CImg< T > get_load_rgb(std::FILE *const file, const unsigned int dimw, const unsigned int dimh=1)
CImgList< T > & operator,(const CImgList< t > &list)
Operator,().
#define _cimg_load_cimg_case2(Ts, Tss)
CImg< T > & histogram(const unsigned int nb_levels, const T value_min=(T) 0, const T value_max=(T) 0)
Compute the histogram of the instance image.
CImg< Tfloat > get_norm(const int norm_type=2) const
bool is_empty() const
Return true is display is empty.
CImg< T > & distance(const T isovalue, const float sizex=1, const float sizey=1, const float sizez=1, const bool compute_sqrt=true)
Compute the Euclidean distance map to a shape of specified isovalue.
CImgDisplay & resize(const CImgDisplay &disp, const bool redraw=true)
Resize a display window using the size of the given display disp.
cimg::superset< T, unsigned int >::type Tuint
static CImg< T > vector(const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6)
Return a vector with specified coefficients.
bool is_sameN(const CImgList< t > &list) const
Return true if list if of specified size.
const CImgList< T > & display(CImgDisplay &disp, const bool display_info, const char axis='x', const char align='p') const
Display the current CImgList instance in a new display window.
bool is_key(const unsigned int key1, const unsigned int key2, const unsigned int key3, const unsigned int key4, const unsigned int key5, const unsigned int key6, const unsigned int key7, const bool remove)
Test if a key sequence has been typed.
static CImg< T > matrix(const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8, const T &a9, const T &a10, const T &a11, const T &a12, const T &a13, const T &a14, const T &a15, const T &a16, const T &a17, const T &a18, const T &a19, const T &a20, const T &a21, const T &a22, const T &a23, const T &a24)
Return a 5x5 square matrix with specified coefficients.
CImg< T > & fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10, const T val11, const T val12, const T val13, const T val14)
Fill sequentially pixel values.
#define _cimg_load_inr_case(Tf, sign, pixsize, Ts)
T atXYZ(const int x, const int y, const int z, const int v=0) const
const CImg< T > & operator[](const unsigned int pos) const
static void _save_empty_cimg(std::FILE *const file, const char *const filename, const unsigned int nb, const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv)
volatile bool is_closed
Closed state of the window.
CImgList< T > & assign(const CImg< t1 > &img1, const CImg< t2 > &img2, const bool shared=false)
In-place version of the corresponding constructor.
volatile unsigned int buttons[512]
Button state of the mouse.
const CImg< T > & _save_cpp(std::FILE *const file, const char *const filename) const
CImg< T > get_warp(const CImg< t > &warp, const bool relative=false, const bool interpolation=true, const unsigned int border_conditions=0) const
T minmod(const T a, const T b)
Return the minmod of two numbers.
const unsigned int keyALT
CImg< T > & draw_axis(const float x0, const float x1, const float y0, const float y1, const tc *const color, const float opacity=1, const int subdivisionx=-60, const int subdivisiony=-60, const float precisionx=0, const float precisiony=0, const unsigned int patternx=~0U, const unsigned int patterny=~0U)
Draw a labeled horizontal+vertical axis on the instance image.
#define cimg_forY(img, y)
T * ptr(const unsigned int x, const unsigned int y=0, const unsigned int z=0, const unsigned int v=0)
Return a pointer to the pixel value located at (x,y,z,v).
Tfloat linear_atXY(const float fx, const float fy, const int z, const int v, const T out_val) const
Read a pixel value using linear interpolation and Dirichlet boundary conditions (first two coordinate...
CImg< T > get_autocrop(const CImg< t > &color, const char *const axes="zyx") const
CImg< _cimg_Tt > operator*(const CImg< t > &img) const
Operator*().
CImg< T > & channels(const unsigned int v0, const unsigned int v1)
Get a set of channels.
CImg< T > & _load_jpeg(std::FILE *const file, const char *const filename)
const unsigned int keyPADDIV
#define _cimglist_def_is_same1(axis)
const unsigned int keyTAB
CImg< T > & assign(const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, const char *const values, const bool repeat_values)
In-place version of the corresponding constructor.
CImg< Tfloat > get_HSItoRGB() const
CImg< Tfloat > get_cosh() const
CImg< T > & operator*=(const char *const expression)
Operator*=().
static CImg< floatT > elevation3d(CImgList< tf > &primitives, const tfunc &func, const float x0, const float y0, const float x1, const float y1, const int size_x=256, const int size_y=256)
Get elevation3d of a function.
CImg< T > get_equalize(const unsigned int nblevels, const T val_min=(T) 0, const T val_max=(T) 0) const
double rand()
Return a random variable between [0,1] with respect to an uniform distribution.
CImg< T > & draw_polygon(const CImg< t > &points, const CImg< tc > &color, const float opacity=1)
Draw a filled polygon in the instance image.
cimg::last< T, unsigned int >::type uintT
const CImg< T > get_shared_points(const unsigned int x0, const unsigned int x1, const unsigned int y0=0, const unsigned int z0=0, const unsigned int v0=0) const
CImg< T > get_transpose() const
CImg< T > & load_raw(const char *const filename, const unsigned int sizex, const unsigned int sizey=1, const unsigned int sizez=1, const unsigned int sizev=1, const bool multiplexed=false, const bool invert_endianness=false)
Load an image from a .RAW file.
CImg< _cimg_Tfloat > acos(const CImg< T > &instance)
bool is_sameXYZV(const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv) const
Return true if image (*this) has the specified width, height, depth and number of channels...
bool is_sameXYZ(const unsigned int dx, const unsigned int dy, const unsigned int dz) const
Return true if image (*this) has the specified width, height and depth.
volatile unsigned int & button
CImg< Tfloat > get_RGBtoHSI() const
CImgDisplay & hide_mouse()
Hide mouse pointer.
CImg< T > & draw_arrow(const int x0, const int y0, const int x1, const int y1, const tc *const color, const float opacity=1, const float angle=30, const float length=-10, const unsigned int pattern=~0U)
Draw a colored arrow in the instance image.
CImg< T > get_shared_line(const unsigned int y0, const unsigned int z0=0, const unsigned int v0=0)
Return a shared-memory image referencing one particular line (y0,z0,v0) of the instance image...
CImgList< T > & insert(const CImg< t > &img, const unsigned int pos=~0U, const bool shared=false)
Insert a copy of the image img into the current image list, at position pos.
CImg< Tfloat > get_invert(const bool use_LU=true) const
CImg< T > get_fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10, const T val11) const
static CImg< floatT > isosurface3d(CImgList< tf > &primitives, const char *const expression, const float isovalue, const float x0, const float y0, const float z0, const float x1, const float y1, const float z1, const int dx=32, const int dy=32, const int dz=32)
const unsigned int keyBACKSPACE
CImg< T > & load_imagemagick_external(const char *const filename)
Load an image using ImageMagick's external tool 'convert'.
static CImg< T > get_load_imagemagick_external(const char *const filename)
CImgList< T > & assign(const unsigned int n)
In-place version of the corresponding constructor.
CImg< T > & fillX(const unsigned int y, const unsigned int z, const unsigned int v, const int a0,...)
Fill image values along the X-axis at the specified pixel position (y,z,v).
void __draw_object3d(const unsigned int n_primitive, const unsigned int nb_opacities, const CImgList< to > &opacities, const CImg< tc > &color, const int nx0, const int ny0, const CImg< T > &sprite, const float opac)
CImg< T > & quantize(const unsigned int nb_levels, const bool keep_range=true)
Uniformly quantize values of the instance image into nb_levels levels.
CImg< T > & draw_rectangle(const int x0, const int y0, const int x1, const int y1, const CImg< tc > &color, const float opacity=1)
Draw a 2D filled colored rectangle in the instance image, at coordinates (x0,y0)-(x1,y1).
CImg< T > & operator%=(const char *const expression)
Operator%=().
CImg< T > & fill(const T val0, const T val1, const T val2, const T val3)
Fill sequentially all pixel values with values val0 and val1 and val2 and val3.
CImgList< T > & crop_font()
Create an auto-cropped font (along the X axis) from a input font font.
const CImg< T > & operator()(const unsigned int pos) const
const unsigned int keyPAD8
CImg< T > & draw_line(const int x0, const int y0, const int x1, const int y1, const tc *const color, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a 2D colored line.
const T & maxmin(t &min_val) const
cimg::last< T, float >::type floatT
long double dist(long double *coord1, long double *coord2, int size)
cimg::last< T, unsigned long >::type ulongT
CImg< T > get_translate(const int deltax, const int deltay=0, const int deltaz=0, const int deltav=0, const int border_condition=0) const
CImg< Tfloat > get_RGBtoxyY() const
static unsigned int format(const signed char val)
CImg< T > & load_cimg(std::FILE *const file, const char axis='z', const char align='p')
Load an image (list) from a .cimg file.
const CImg< T > & save_yuv(std::FILE *const file, const bool rgb2yuv=true) const
Save the image as a YUV video sequence file.
static int _distance_sep(const int i, const int u, const int gi2, const int gu2, const float fact)
CImgList< Tfloat > get_FFT(const char axis, const bool invert=false) const
CImg< Tfloat > get_exp() const
T & atXYZ(const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions for the three first coordinates (x...
static void wait(CImgDisplay &disp1)
Wait for any event occuring on the display disp1.
CImg< T > get_fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8) const
const CImgList< T > & save_ffmpeg_external(const char *const filename, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const char *const codec="mpeg2video") const
Save an image sequence using the external tool 'ffmpeg'.
CImg< _cimg_Tt > get_min(const CImg< t > &img) const
static int format(const int val)
const CImgList< T > & save_cimg(std::FILE *const file, const unsigned int n0, const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0) const
Insert the instance image into into an existing .cimg file, at specified coordinates.
CImg< T > & fillZ(const unsigned int x, const unsigned int y, const unsigned int v, const double a0,...)
const char * ffmpeg_path(const char *const user_path=0, const bool reinit_path=false)
Return or set path to the 'ffmpeg' command.
CImg(const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, const double val0, const double val1,...)
Construct an image with given size (dx,dy,dz,dv) and with specified pixel values (double version)...
const char * argument(const unsigned int nb, const int argc, const char *const *const argv, const unsigned int nb_singles=0,...)
#define cimg_for6x6(img, x, y, z, v, I)
CImgList< T > operator<(const char axis) const
Operator<().
static CImg< floatT > cylinder3d(CImgList< tf > &primitives, const float radius=50, const float size_z=100, const unsigned int subdivisions=24)
Create and return a 3D cylinder.
static const char * format(const bool val)
CImg< T > get_rand(const T val_min, const T val_max) const
static CImg< T > sequence(const unsigned int N, const T a0, const T a1)
Return a N-numbered sequence vector from a0 to a1.
CImgDisplay & assign(const CImgList< T > &list, const char *title=0, const unsigned int normalization_type=3, const bool fullscreen_flag=false, const bool closed_flag=false)
In-place version of the previous constructor.
CImg< T > & draw_triangle(const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const tc *const color, const float brightness0, const float brightness1, const float brightness2, const float opacity=1)
Draw a 2D Gouraud-shaded colored triangle.
CImg< T > & _load_dlm(std::FILE *const file, const char *const filename)
cimg::last< T, unsigned char >::type ucharT
const unsigned int keyARROWDOWN
bool is_sameXYV(const CImg< t > &img) const
Return true if images have same width, same height and same number of channels.
static CImgList< T > get_load_cimg(std::FILE *const file)
T & operator()(const unsigned int x, const unsigned int y=0, const unsigned int z=0, const unsigned int v=0)
Fast access to pixel value for reading or writing.
CImg< T > & draw_triangle(CImg< floatT > &zbuffer, const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const int x2, const int y2, const float z2, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const int tx2, const int ty2, const float opacity=1, const float brightness=1)
Draw a 2D textured triangle, with z-buffering and perspective correction.
CImg< _cimg_Tfloat > tanh(const CImg< T > &instance)
CImg< T > & draw_gaussian(const int xc, const int yc, const float r1, const float r2, const float ru, const float rv, const CImg< tc > &color, const float opacity=1)
Draw an anisotropic 2D gaussian function.
CImg< T > & channel(const unsigned int v0)
Get a channel.
T atXYZV(const int x, const int y, const int z, const int v) const
bool operator!=(const CImg< t > &img) const
Operator!=().
CImgList< T > get_reverse() const
#define _cimglist_def_is_same2(axis1, axis2)
int dialog(const char *title, const char *msg, const char *button1_txt="OK", const char *button2_txt=0, const char *button3_txt=0, const char *button4_txt=0, const char *button5_txt=0, const char *button6_txt=0, const bool centering=false)
CImg< T > & min(const T val)
Pointwise min operator between an image and a value.
CImg< T > get_sequence(const T a0, const T a1) const
Tfloat variancemean(const unsigned int variance_method, t &mean) const
Return the variance and the mean of the image.
CImg< Tfloat > get_atan2(const CImg< t > &img) const
static CImg< T > matrix(const T &a0)
Return a 1x1 square matrix with specified coefficients.
CImgList< T > & pop_front()
Remove first element of the list (STL-compliant name).
const CImg< T > & _save_off(std::FILE *const file, const char *const filename, const CImgList< tf > &primitives, const CImgList< tc > &colors) const
CImgList< T > & load_gzip_external(const char *const filename)
Load a gzipped list, using external tool 'gunzip'.
T & atX(const int x, const int y=0, const int z=0, const int v=0)
Read a pixel value with Neumann boundary conditions for the first coordinates (x).
CImg< T > & draw_ellipse(const int x0, const int y0, const CImg< t > &tensor, const CImg< tc > &color, const float opacity=1)
Draw a filled ellipse.
CImg< T > get_dilate(const unsigned int n, const unsigned int cond=1) const
CImg< T > & set_matrix_at(const CImg< t > &mat, const unsigned int x=0, const unsigned int y=0, const unsigned int z=0)
Set the image vec as the square matrix-valued pixel located at (x,y,z) of the current vector-valued i...
CImg< Tfloat > get_pow(const double p) const
bool is_key(const unsigned int key1, const unsigned int key2, const unsigned int key3, const bool remove)
Test if a key sequence has been typed.
CImg< T > get_tensor() const
_marching3d_func(const CImg< T > &pref)
T & atXYZV(const int x, const int y, const int z, const int v)
Read a pixel value with Neumann boundary conditions.
static CImg< T > get_load_dlm(const char *const filename)
unsigned int nearest_pow2(const T x)
Return the nearest power of 2 higher than a given number.
const CImg< T > & _display_object3d(CImgDisplay &disp, const char *const title, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const to &opacities, const bool centering, const int render_static, const int render_motion, const bool double_sided, const float focale, const float specular_light, const float specular_shine, const bool display_axes, float *const pose_matrix) const
CImg< T > & atan()
Compute the arc-tangent of each pixel.
const CImg< T > & front() const
volatile bool is_keyARROWLEFT
CImg< T > & draw_polygon(const CImg< t > &points, const tc *const color, const float opacity=1)
Draw a filled polygon in the instance image.
cimg::superset< T, unsigned long >::type Tulong
CImg< T > & HSItoRGB()
Convert color pixels from (H,S,I) to (R,G,B).
bool is_key(const unsigned int *const keyseq, const unsigned int N, const bool remove=true)
Test if a key sequence has been typed.
CImgList< T > & push_back(const CImg< t > &img)
Insert image img at the end of the list (STL-compliant name).
CImg< Tfloat > operator-(const char *const expression) const
Operator-().
CImg< _cimg_Tfloat > operator/(const char *const expression, const CImg< T > &img)
const CImgList< T > & display(CImgDisplay &disp, const char axis='x', const char align='p') const
Display the current CImgList instance in an existing CImgDisplay window (by reference).
CImg< T > & draw_line(CImg< floatT > &zbuffer, const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const tc *const color, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a 2D colored line, with z-buffering.
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
bool is_sameY(const CImgDisplay &disp) const
Return true if images (*this) and the display disp have same height.
CImg< T > & draw_spline(const int x0, const int y0, const int z0, const float u0, const float v0, const float w0, const int x1, const int y1, const int z1, const float u1, const float v1, const float w1, const CImg< tc > &color, const float opacity=1, const float precision=4, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a cubic spline curve in the instance image (for volumetric images).
CImg< T > & dilate(const CImg< t > &mask, const unsigned int cond=1, const bool weighted_dilatation=false)
Dilate the image by a structuring element.
CImg< T > & draw_fill(const int x, const int y, const CImg< tc > &color, const float opacity=1, const float sigma=0, const bool high_connexity=false)
Draw a 2D filled region starting from a point (x,y) in the instance image.
const char * basename(const char *const s)
Compute the basename of a filename.
CImg< T > & assign(const t *const data_buffer, const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, const bool shared)
In-place version of the previous constructor, allowing to force the shared state of the instance imag...
#define _cimg_gs3x_for3x3(img, x, y, z, v, I)
CImg< T > & assign(const CImg< t > &img, const char *const dimensions)
In-place version of the previous constructor.
static CImg< T > vector(const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7)
Return a vector with specified coefficients.
const CImg< T > & _save_png(std::FILE *const file, const char *const filename, const unsigned int bytes_per_pixel=0) const
CImg< T > & RGBtoYCbCr()
Convert color pixels from (R,G,B) to (Y,Cb,Cr)_8.
CImg< Tfloat > get_min(const char *const expression) const
CImg< T > & draw_triangle(const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const int tx2, const int ty2, const float brightness0, const float brightness1, const float brightness2, const float opacity=1)
Draw a 2D Gouraud-shaded textured triangle.
_marching2d_func_expr(const char *const expr)
#define _cimg_valign2d(i, j)
CImg< T > & RGBtoBayer()
Convert a (R,G,B) image to a Bayer-coded representation.
static const char * string()
static const char * format()
CImg< T > & blur_patch(const float sigma_s, const float sigma_p, const unsigned int patch_size=3, const unsigned int lookup_size=4, const float smoothness=0, const bool fast_approx=true)
Blur an image in its patch-based space.
CImg< T > & pow(const CImg< t > &img)
Compute the power of each pixel value.
CImg< T > & assign(const T *const data_buffer, const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, const bool shared)
static const char * string()
const CImg< T > * const_iterator
Define a CImgList<T>::const_iterator.
static CImg< T > vector(const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8, const T &a9)
Return a vector with specified coefficients.
static CImgList< T > get_load_gzip_external(const char *const filename)
const char * dcraw_path(const char *const user_path=0, const bool reinit_path=false)
Return or set path to the 'dcraw' command.
Tfloat variance(const unsigned int variance_method=1) const
Return the variance of the image.
static CImg< T > get_load_pnm(std::FILE *const file)
CImg< T > & draw_gaussian(const float xc, const float sigma, const tc *const color, const float opacity=1)
Draw a 1D gaussian function in the instance image.
CImg< T > & diagonal()
Get a diagonal matrix, whose diagonal coefficients are the coefficients of the input image...
CImg< T > & draw_triangle(CImg< floatT > &zbuffer, const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const int x2, const int y2, const float z2, const CImg< tc > &color, const float opacity=1, const float brightness=1)
Draw a 2D filled colored triangle, with z-buffering.
CImg< Tfloat > get_CMYtoCMYK() const
CImg< T > & autocrop(const T value, const char *const axes="vzyx")
Autocrop an image, regarding of the specified backround value.
CImg< Tfloat > operator*(const char *const expression) const
Operator*().
CImgList(const CImg< t > &img, const bool shared=false)
Construct an image list from one image.
CImg< T > & load_tiff(const char *const filename, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1)
Load an image from a TIFF file.
double pow(double value, const Exponent &exp)
CImg< T > & draw_mandelbrot(const CImg< tc > &color_palette, const float opacity=1, const double z0r=-2, const double z0i=-2, const double z1r=2, const double z1i=2, const unsigned int itermax=255, const bool normalized_iteration=false, const bool julia_set=false, const double paramr=0, const double parami=0)
Draw a quadratic Mandelbrot or Julia fractal set, computed using the Escape Time Algorithm.
CImg< T > & operator=(const char *const expression)
Operator=().
CImg< T > & operator+=(const CImg< t > &img)
Operator+=().
CImg< T > & draw_axis(const float x0, const float x1, const float y0, const float y1, const CImg< tc > &color, const float opacity=1, const int subdivisionx=-60, const int subdivisiony=-60, const float precisionx=0, const float precisiony=0, const unsigned int patternx=~0U, const unsigned int patterny=~0U)
Draw a labeled horizontal+vertical axis on the instance image.
CImgList< T > get_reverse_object3d() const
const CImgList< T > & save_cimg(const char *const filename, const unsigned int n0, const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0) const
Insert the instance image into into an existing .cimg file, at specified coordinates.
cimg::superset< T, unsigned char >::type Tuchar
cimg::last< T, int >::type intT
T atNX(const int pos, const int x, const int y, const int z, const int v, const T out_val) const
#define cimglist_for_in(list, l0, l1, l)
CImgList< T > & load_cimg(std::FILE *const file, const unsigned int n0, const unsigned int n1, const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0, const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int v1)
Load a sub-image list from a non compressed .cimg file.
CImg< T > & operator++()
Operator++() (prefix).
CImg< Tfloat > get_RGBtoHSL() const
const CImg< T > & save_analyze(const char *const filename, const float *const voxsize=0) const
Save the image as an ANALYZE7.5 or NIFTI file.
CImg< T > & operator|=(const char *const expression)
Operator|=().
volatile unsigned int released_keys[512]
CImg< T > & resize_object3d(const float sx, const float sy=-100, const float sz=-100)
Resize a 3D object.
const CImg< T > & display(CImgDisplay &disp) const
Display an image into a CImgDisplay window.
CImg< Tfloat > get_normalize() const
CImg< _cimg_Tfloat > operator-(const char *const expression, const CImg< T > &img)
CImg< T > & YUVtoRGB()
Convert color pixels from (Y,U,V) to (R,G,B).
const CImg< T > & display_object3d(const char *const title, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const to &opacities, const bool centering=true, const int render_static=4, const int render_motion=1, const bool double_sided=true, const float focale=500, const float specular_light=0.2f, const float specular_shine=0.1f, const bool display_axes=true, float *const pose_matrix=0) const
High-level interface for displaying a 3d object.
CImg< T > & swap(CImg< T > &img)
Swap all fields of two images. Use with care !
CImg< T > get_min(const T val) const
const CImg< T > & save_rgb(const char *const filename) const
Save the image as a RGB file.
CImg< T > & draw_polygon(const CImg< t > &points, const tc *const color, const float opacity, const unsigned int pattern)
Draw a polygon outline.
bool contains(const CImg< T > &img, t &n) const
Return true if the list contains the image 'img'. If true, returns the position (n) of the image in t...
CImg< T > & draw_line(const CImgList< t > &points, const CImg< tc > &color, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a set of consecutive colored lines in the instance image.
static CImg< T > vector(const T &a0)
Return a vector with specified coefficients.
const CImg< T > get_shared_lines(const unsigned int y0, const unsigned int y1, const unsigned int z0=0, const unsigned int v0=0) const
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
CImg< Tfloat > get_structure_tensor(const unsigned int scheme=1) const
CImgDisplayException(const char *format,...)
CImg< T > & operator=(const CImg< t > &img)
Operator=().
static CImg< T > tensor(const T &a1)
Return a 1x1 symmetric matrix with specified coefficients.
static CImgList< T > get_load_off(const char *const filename, CImgList< tf > &primitives, CImgList< tc > &colors)
#define cimg_forXV(img, x, v)
static const char * string()
double eval(const char *const expression, const double x=0, const double y=0, const double z=0, const double v=0) const
Evaluate math expression.
#define cimg_for2x2x2(img, x, y, z, v, I)
CImgInstanceException(const char *format,...)
bool is_key(const unsigned int key1, const unsigned int key2, const unsigned int key3, const unsigned int key4, const unsigned int key5, const unsigned int key6, const bool remove)
Test if a key sequence has been typed.
const unsigned int font10x19[10 *19 *256/32]
CImgDisplay & wait(const unsigned int milliseconds)
Synchronized waiting function. Same as cimg::wait().
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
bool contains(const T &pixel) const
Return true if specified referenced value is inside the image boundaries.
CImg< T > & load_rgba(std::FILE *const file, const unsigned int dimw, const unsigned int dimh=1)
Load an image from a RGBA file.
CImg< T > & load_gzip_external(const char *const filename)
Load a gzipped image file, using external tool 'gunzip'.
Tfloat linear_atX(const float fx, const int y=0, const int z=0, const int v=0) const
Read a pixel value using linear interpolation and Neumann boundary conditions (first coordinate)...
static CImg< T > get_load_medcon_external(const char *const filename)
CImg< T > & structure_tensor(const unsigned int scheme=1)
Compute the structure tensor field of an image.
CImg< T > get_fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10, const T val11, const T val12, const T val13, const T val14, const T val15) const
void info()
Print informations about CImg environement variables.
CImg< floatT > get_elevation3d(CImgList< tf > &primitives, CImgList< tc > &colors, const CImg< te > &elevation) const
Create and return a 3D elevation of the instance image.
CImg< Tfloat > get_resize_object3d() const
CImg< T > & draw_fill(const int x, const int y, const int z, const CImg< tc > &color, const float opacity, CImg< t > ®ion, const float sigma=0, const bool high_connexity=false)
Draw a 3D filled region starting from a point (x,y,\ z) in the instance image.
CImg< T > & draw_text(const int x0, const int y0, const char *const text, const CImg< tc1 > &foreground_color, const CImg< tc2 > &background_color, const float opacity=1, const unsigned int font_size=11,...)
Draw a text.
CImg< Tfloat > get_distance_hamilton(const unsigned int nb_iter, const float band_size=0, const float precision=0.5f) const
CImg< T > get_sort(CImg< t > &permutations, const bool increasing=true) const
static void wait(CImgDisplay &disp1, CImgDisplay &disp2, CImgDisplay &disp3)
Wait for any event occuring either on the display disp1, disp2 or disp3.
CImg< T > & operator[](const unsigned int pos)
Return a reference to the i-th element of the image list.
CImg< Tfloat > get_haar(const bool invert=false, const unsigned int nb_scales=1) const
CImg< T > get_dijkstra(const unsigned int starting_node, const unsigned int ending_node, CImg< t > &previous) const
bool contains(const T &pixel, t &x, t &y) const
Return true if specified referenced value is inside image boundaries. If true, returns pixel coordina...
#define _cimg_for_triangle5(img, xl, txl, tyl, lxl, lyl, xr, txr, tyr, lxr, lyr, y, x0, y0, tx0, ty0, lx0, ly0, x1, y1, tx1, ty1, lx1, ly1, x2, y2, tx2, ty2, lx2, ly2)
CImgList(const CImgList< T > &list)
CImg< T > & draw_ellipse(const int x0, const int y0, const CImg< t > &tensor, const CImg< tc > &color, const float opacity, const unsigned int pattern)
Draw an outlined ellipse.
CImg< T > get_round(const float x, const unsigned int rounding_type=0) const
CImg< T > & solve_tridiagonal(const CImg< t > &a, const CImg< t > &b, const CImg< t > &c)
Solve a linear system AX=B where B=*this and A is a tridiagonal matrix A = [ b0,c0,0,...; a1,b1,c1,0,... ; ... ; ...,0,aN,bN ].
T kth_smallest(const unsigned int k) const
Return the kth smallest element of the image.
CImg< T > & atan2(const CImg< t > &img)
Compute the arc-tangent of each pixel.
static CImg< T > get_load_cimg(std::FILE *const file, const unsigned int n0, const unsigned int n1, const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0, const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int v1, const char axis='z', const char align='p')
unsigned int allocated_width
Allocation size of the list.
CImg< _cimg_Tt > get_div(const CImg< t > &img) const
CImg< T > & draw_gaussian(const float xc, const float yc, const CImg< t > &tensor, const CImg< tc > &color, const float opacity=1)
Draw an anisotropic 2D gaussian function.
cimg::superset< T, unsigned short >::type Tushort
CImg< T > & _draw_text(const int x0, const int y0, const char *const text, const tc1 *const foreground_color, const tc2 *const background_color, const float opacity, const CImgList< t > &font)
static const char * string()
T & operator[](const unsigned int off)
Fast access to pixel value for reading or writing, using an offset to the image pixel.
T & _atN(const int pos, const int x=0, const int y=0, const int z=0, const int v=0)
CImg< T > & draw_arrow(const int x0, const int y0, const int x1, const int y1, const CImg< tc > &color, const float opacity=1, const float angle=30, const float length=-10, const unsigned int pattern=~0U)
Draw a colored arrow in the instance image.
#define cimg_forYZV(img, y, z, v)
bool contains(const T &pixel, t &n, t &x, t &y) const
Return true if one of the image list contains the specified referenced value. If true, set coordinates (n,x,y).
bool is_sameXYV(const unsigned int dx, const unsigned int dy, const unsigned int dv) const
Return true if image (*this) has the specified width, height and depth.
static const char * string()
CImg< T > operator~() const
Operator~().
CImg< T > & crop(const int x0, const int y0, const int z0, const int x1, const int y1, const int z1, const bool border_condition=false)
Get a rectangular part of the instance image.
volatile bool is_keyCTRLRIGHT
bool is_sameZV(const unsigned int dz, const unsigned int dv) const
Return true if image (*this) has the specified depth and number of channels.
CImg< T > & load_magick(const char *const filename)
Load an image from a file, using Magick++ library.
CImg< Tfloat > get_RGBtoLab() const
cimg::superset< T, unsigned int >::type Tuint
CImg< T > & RGBtoHSL()
Convert color pixels from (R,G,B) to (H,S,L).
const unsigned int keyDELETE
CImgList< T > & operator=(const CImg< t > &img)
Operator=().
CImg< T > & draw_circle(const int x0, const int y0, int radius, const CImg< tc > &color, const float opacity=1)
Draw a filled circle.
Tfloat cubic_atX(const float fx, const int y, const int z, const int v, const T out_val) const
Read a pixel value using cubic interpolation and Dirichlet boundary conditions (first coordinates)...
CImgDisplay & assign(const unsigned int dimw, const unsigned int dimh, const char *title=0, const unsigned int normalization_type=3, const bool fullscreen_flag=false, const bool closed_flag=false)
In-place version of the previous constructor.
const unsigned int keyCTRLRIGHT
cimg::superset< T, unsigned long >::type Tulong
CImg< T > & rotate(const float angle, const unsigned int border_conditions=3, const unsigned int interpolation=1)
Rotate an image.
#define cimg_for_inXY(img, x0, y0, x1, y1, x, y)
static int format(const char val)
double eval(const CImg< t > &img, const double x, const double y, const double z, const double v)
CImgList(const unsigned int n)
Construct an image list containing n empty images.
unsigned int _save_pandore_header_length(unsigned int id, unsigned int *dims, const unsigned int colorspace) const
CImg< T > & _draw_spline(const tp &points, const tt &tangents, const unsigned int W, const unsigned int H, const tc *const color, const float opacity, const bool close_set, const float precision, const unsigned int pattern, const bool init_hatch)
const_iterator end() const
static void FFT(CImg< T > &real, CImg< T > &imag, const char axis, const bool invert=false)
Compute a 1D Fast Fourier Transform, along a specified axis.
#define cimg_forXZ(img, x, z)
bool is_sameXZ(const CImg< t > &img) const
Return true if images have same width and same depth.
CImg< T > & log()
Compute the log of each each pixel value.
static CImg< T > get_load_ascii(std::FILE *const file)
float operator()(const float x, const float y) const
CImgList< Tfloat > get_symmetric_eigen() const
CImgList< T > & load_yuv(std::FILE *const file, const unsigned int sizex, const unsigned int sizey, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1, const bool yuv2rgb=true)
Load an image sequence from a YUV file.
static unsigned char min()
volatile bool is_keyARROWDOWN
CImg< T > get_RGBtoBayer() const
static CImgList< T > font(const unsigned int font_width, const bool variable_size=true)
Return a CImg pre-defined font with desired size.
CImgList< T > & insert(const unsigned int n, const CImgList< t > &list, const unsigned int pos=~0U, const bool shared=false)
Insert n copies of the list list at position pos of the current list.
CImg< T > & draw_image(const int x0, const CImg< ti > &sprite, const CImg< tm > &mask, const float opacity=1, const float mask_valmax=1)
Draw an image.
CImg< T > get_lines(const unsigned int y0, const unsigned int y1) const
const CImg< T > & _save_inr(std::FILE *const file, const char *const filename, const float *const voxsize) const
CImg< T > & distance_hamilton(const unsigned int nb_iter, const float band_size=0, const float precision=0.5f)
Compute distance function from 0-valued isophotes by the application of an Hamilton-Jacobi PDE...
CImg< T > & draw_ellipse(const int x0, const int y0, const CImg< t > &tensor, const tc *const color, const float opacity=1)
Draw a filled ellipse.
T atX(const int x, const int y=0, const int z=0, const int v=0) const
CImg< T > & operator&=(const char *const expression)
Operator&=().
CImgList< t > & transfer_to(CImgList< t > &list, const unsigned int pos)
Tfloat _cubic_atX(const float fx, const int y=0, const int z=0, const int v=0) const
CImg< T > & load_cimg(const char *const filename, const char axis='z', const char align='p')
Load an image (list) from a .cimg file.
CImg(const CImg< t > &img, const char *const dimensions, const char *const values, const bool repeat_values)
Construct an image using dimensions of another image, and fill it with given values.
Instances of this class are thrown when errors occur during a CImg library function call...
CImg< Tfloat > get_translate_object3d() const
Tfloat cubic_atX(const float fx, const int y=0, const int z=0, const int v=0) const
Read a pixel value using cubic interpolation and Neumann boundary conditions (first coordinates)...
CImg< T > & asin()
Compute the arc-sinus of each pixel value.
superset< t1, typename superset2< t2, t3, t4 >::type >::type type
#define _cimg_get_label_test(p, q)
CImg< _cimg_Tfloat > sqr(const CImg< T > &instance)
int dimx() const
Return the size of the list.
bool is_sameX(const unsigned int dx) const
Return true if image (*this) has the specified width.
#define _cimg_fopcode0(op)
CImgList< T > & push_front(const CImgList< t > &list)
Insert list list at the front of the current list (STL-compliant name).
CImg< T > get_blur_patch(const float sigma_s, const float sigma_p, const unsigned int patch_size=3, const unsigned int lookup_size=4, const float smoothness=0, const bool fast_approx=true) const
const unsigned int keyPAUSE
CImg< T > & draw_polygon(const CImg< t > &points, const CImg< tc > &color, const float opacity, const unsigned int pattern)
Draw a polygon outline.
CImg< T > & sequence(const T a0, const T a1)
Return a N-numbered sequence vector from a0 to a1.
CImg< T > & RGBtoXYZ()
Convert color pixels from (R,G,B) to (X,Y,Z)_709.
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
int xln(const int x)
Return 1 + log_10(x).
static CImg< T > get_load_png(const char *const filename)
CImg< T > & resize_halfXY()
Half-resize an image, using a special optimized filter.