45 #include <visp3/core/vpConfig.h> 55 #include <visp3/core/vpDisplay.h> 56 #include <visp3/gui/vpDisplayX.h> 59 #include <visp3/core/vpDebug.h> 60 #include <visp3/core/vpDisplayException.h> 63 #include <visp3/core/vpMath.h> 85 :
display(NULL),
window(), Ximage(NULL), lut(), context(), screen(0), event(), pixmap(), x_color(NULL),
86 screen_depth(8), xcolor(), values(), ximage_data_init(false), RMask(0), GMask(0), BMask(0), RShift(0), GShift(0),
116 :
display(NULL),
window(), Ximage(NULL), lut(), context(), screen(0), event(), pixmap(), x_color(NULL),
117 screen_depth(8), xcolor(), values(), ximage_data_init(false), RMask(0), GMask(0), BMask(0), RShift(0), GShift(0),
121 init(I, x, y, title);
144 :
display(NULL),
window(), Ximage(NULL), lut(), context(), screen(0), event(), pixmap(), x_color(NULL),
145 screen_depth(8), xcolor(), values(), ximage_data_init(false), RMask(0), GMask(0), BMask(0), RShift(0), GShift(0),
174 :
display(NULL),
window(), Ximage(NULL), lut(), context(), screen(0), event(), pixmap(), x_color(NULL),
175 screen_depth(8), xcolor(), values(), ximage_data_init(false), RMask(0), GMask(0), BMask(0), RShift(0), GShift(0),
179 init(I, x, y, title);
204 :
display(NULL),
window(), Ximage(NULL), lut(), context(), screen(0), event(), pixmap(), x_color(NULL),
205 screen_depth(8), xcolor(), values(), ximage_data_init(false), RMask(0), GMask(0), BMask(0), RShift(0), GShift(0),
234 :
display(NULL),
window(), Ximage(NULL), lut(), context(), screen(0), event(), pixmap(), x_color(NULL),
235 screen_depth(8), xcolor(), values(), ximage_data_init(false), RMask(0), GMask(0), BMask(0), RShift(0), GShift(0),
256 if (x_color == NULL) {
274 hints.flags = USPosition;
284 vpERROR_TRACE(
"Can't connect display on server %s.\n", XDisplayName(NULL));
288 screen = DefaultScreen(
display);
289 lut = DefaultColormap(
display, screen);
290 screen_depth = (
unsigned int)DefaultDepth(
display, screen);
301 if (screen_depth == 8) {
303 xcolor.flags = DoRed | DoGreen | DoBlue;
305 for (
unsigned int i = 0; i < 256; i++) {
307 xcolor.red = 256 * i;
308 xcolor.green = 256 * i;
309 xcolor.blue = 256 * i;
310 XStoreColor(
display, lut, &xcolor);
314 XInstallColormap(
display, lut);
317 else if (screen_depth == 16) {
318 for (
unsigned int i = 0; i < 256; i++) {
320 xcolor.red = xcolor.green = xcolor.blue = 256 * i;
321 if (XAllocColor(
display, lut, &xcolor) == 0) {
322 vpERROR_TRACE(
"Can't allocate 256 colors. Only %d allocated.", i);
325 colortable[i] = xcolor.pixel;
329 XInstallColormap(
display, lut);
331 Visual *visual = DefaultVisual(
display, screen);
332 RMask = visual->red_mask;
333 GMask = visual->green_mask;
334 BMask = visual->blue_mask;
336 RShift = 15 -
getMsb(RMask);
337 GShift = 15 -
getMsb(GMask);
338 BShift = 15 -
getMsb(BMask);
344 switch (screen_depth) {
351 xcolor.red = 256 * 192;
352 xcolor.green = 256 * 192;
353 xcolor.blue = 256 * 192;
354 XStoreColor(
display, lut, &xcolor);
359 xcolor.red = 256 * 128;
360 xcolor.green = 256 * 128;
361 xcolor.blue = 256 * 128;
362 XStoreColor(
display, lut, &xcolor);
367 xcolor.red = 256 * 64;
368 xcolor.green = 256 * 64;
369 xcolor.blue = 256 * 64;
370 XStoreColor(
display, lut, &xcolor);
375 xcolor.red = 256 * 255;
376 xcolor.green = 256 * 140;
377 xcolor.blue = 256 * 140;
378 XStoreColor(
display, lut, &xcolor);
383 xcolor.red = 256 * 255;
386 XStoreColor(
display, lut, &xcolor);
391 xcolor.red = 256 * 128;
394 XStoreColor(
display, lut, &xcolor);
399 xcolor.red = 256 * 140;
400 xcolor.green = 256 * 255;
401 xcolor.blue = 256 * 140;
402 XStoreColor(
display, lut, &xcolor);
408 xcolor.green = 256 * 255;
410 XStoreColor(
display, lut, &xcolor);
416 xcolor.green = 256 * 128;
418 XStoreColor(
display, lut, &xcolor);
423 xcolor.red = 256 * 140;
424 xcolor.green = 256 * 140;
425 xcolor.blue = 256 * 255;
426 XStoreColor(
display, lut, &xcolor);
433 xcolor.blue = 256 * 255;
434 XStoreColor(
display, lut, &xcolor);
441 xcolor.blue = 256 * 128;
442 XStoreColor(
display, lut, &xcolor);
447 xcolor.red = 256 * 255;
448 xcolor.green = 256 * 255;
450 XStoreColor(
display, lut, &xcolor);
455 xcolor.red = 256 * 255;
456 xcolor.green = 256 * 165;
458 XStoreColor(
display, lut, &xcolor);
464 xcolor.green = 256 * 255;
465 xcolor.blue = 256 * 255;
466 XStoreColor(
display, lut, &xcolor);
471 xcolor.red = 256 * 128;
473 xcolor.blue = 256 * 128;
474 XStoreColor(
display, lut, &xcolor);
481 xcolor.flags = DoRed | DoGreen | DoBlue;
488 XAllocColor(
display, lut, &xcolor);
493 xcolor.red = 256 * 255;
494 xcolor.green = 256 * 255;
495 xcolor.blue = 256 * 255;
496 XAllocColor(
display, lut, &xcolor);
501 xcolor.red = 256 * 192;
502 xcolor.green = 256 * 192;
503 xcolor.blue = 256 * 192;
504 XAllocColor(
display, lut, &xcolor);
509 xcolor.red = 256 * 128;
510 xcolor.green = 256 * 128;
511 xcolor.blue = 256 * 128;
512 XAllocColor(
display, lut, &xcolor);
517 xcolor.red = 256 * 64;
518 xcolor.green = 256 * 64;
519 xcolor.blue = 256 * 64;
520 XAllocColor(
display, lut, &xcolor);
525 xcolor.red = 256 * 255;
526 xcolor.green = 256 * 140;
527 xcolor.blue = 256 * 140;
528 XAllocColor(
display, lut, &xcolor);
533 xcolor.red = 256 * 255;
536 XAllocColor(
display, lut, &xcolor);
541 xcolor.red = 256 * 128;
544 XAllocColor(
display, lut, &xcolor);
549 xcolor.red = 256 * 140;
550 xcolor.green = 256 * 255;
551 xcolor.blue = 256 * 140;
552 XAllocColor(
display, lut, &xcolor);
558 xcolor.green = 256 * 255;
560 XAllocColor(
display, lut, &xcolor);
566 xcolor.green = 256 * 128;
568 XAllocColor(
display, lut, &xcolor);
573 xcolor.red = 256 * 140;
574 xcolor.green = 256 * 140;
575 xcolor.blue = 256 * 255;
576 XAllocColor(
display, lut, &xcolor);
583 xcolor.blue = 256 * 255;
584 XAllocColor(
display, lut, &xcolor);
591 xcolor.blue = 256 * 128;
592 XAllocColor(
display, lut, &xcolor);
597 xcolor.red = 256 * 255;
598 xcolor.green = 256 * 255;
600 XAllocColor(
display, lut, &xcolor);
605 xcolor.red = 256 * 255;
606 xcolor.green = 256 * 165;
608 XAllocColor(
display, lut, &xcolor);
614 xcolor.green = 256 * 255;
615 xcolor.blue = 256 * 255;
616 XAllocColor(
display, lut, &xcolor);
621 xcolor.red = 256 * 128;
623 xcolor.blue = 256 * 128;
624 XAllocColor(
display, lut, &xcolor);
634 ExposureMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask |
635 StructureNotifyMask | PointerMotionMask);
638 values.plane_mask = AllPlanes;
639 values.fill_style = FillSolid;
640 values.foreground = WhitePixel(
display, screen);
641 values.background = BlackPixel(
display, screen);
642 context = XCreateGC(
display,
window, GCPlaneMask | GCFillStyle | GCForeground | GCBackground, &values);
644 if (context == NULL) {
661 Ximage->data = (
char *)malloc(
m_height * (
unsigned int)Ximage->bytes_per_line);
662 ximage_data_init =
true;
691 if (x_color == NULL) {
703 hints.flags = USPosition;
712 if ((
display = XOpenDisplay(NULL)) == NULL) {
713 vpERROR_TRACE(
"Can't connect display on server %s.\n", XDisplayName(NULL));
717 screen = DefaultScreen(
display);
718 lut = DefaultColormap(
display, screen);
719 screen_depth = (
unsigned int)DefaultDepth(
display, screen);
732 if (screen_depth == 8) {
734 xcolor.flags = DoRed | DoGreen | DoBlue;
736 for (
unsigned int i = 0; i < 256; i++) {
738 xcolor.red = 256 * i;
739 xcolor.green = 256 * i;
740 xcolor.blue = 256 * i;
741 XStoreColor(
display, lut, &xcolor);
745 XInstallColormap(
display, lut);
748 else if (screen_depth == 16) {
749 for (
unsigned int i = 0; i < 256; i++) {
751 xcolor.red = xcolor.green = xcolor.blue = 256 * i;
752 if (XAllocColor(
display, lut, &xcolor) == 0) {
753 vpERROR_TRACE(
"Can't allocate 256 colors. Only %d allocated.", i);
756 colortable[i] = xcolor.pixel;
759 Visual *visual = DefaultVisual(
display, screen);
760 RMask = visual->red_mask;
761 GMask = visual->green_mask;
762 BMask = visual->blue_mask;
764 RShift = 15 -
getMsb(RMask);
765 GShift = 15 -
getMsb(GMask);
766 BShift = 15 -
getMsb(BMask);
769 XInstallColormap(
display, lut);
775 switch (screen_depth) {
783 xcolor.red = 256 * 192;
784 xcolor.green = 256 * 192;
785 xcolor.blue = 256 * 192;
786 XStoreColor(
display, lut, &xcolor);
791 xcolor.red = 256 * 128;
792 xcolor.green = 256 * 128;
793 xcolor.blue = 256 * 128;
794 XStoreColor(
display, lut, &xcolor);
799 xcolor.red = 256 * 64;
800 xcolor.green = 256 * 64;
801 xcolor.blue = 256 * 64;
802 XStoreColor(
display, lut, &xcolor);
807 xcolor.red = 256 * 255;
808 xcolor.green = 256 * 140;
809 xcolor.blue = 256 * 140;
810 XStoreColor(
display, lut, &xcolor);
815 xcolor.red = 256 * 255;
818 XStoreColor(
display, lut, &xcolor);
823 xcolor.red = 256 * 128;
826 XStoreColor(
display, lut, &xcolor);
831 xcolor.red = 256 * 140;
832 xcolor.green = 256 * 255;
833 xcolor.blue = 256 * 140;
834 XStoreColor(
display, lut, &xcolor);
840 xcolor.green = 256 * 255;
842 XStoreColor(
display, lut, &xcolor);
848 xcolor.green = 256 * 128;
850 XStoreColor(
display, lut, &xcolor);
855 xcolor.red = 256 * 140;
856 xcolor.green = 256 * 140;
857 xcolor.blue = 256 * 255;
858 XStoreColor(
display, lut, &xcolor);
865 xcolor.blue = 256 * 255;
866 XStoreColor(
display, lut, &xcolor);
873 xcolor.blue = 256 * 128;
874 XStoreColor(
display, lut, &xcolor);
879 xcolor.red = 256 * 255;
880 xcolor.green = 256 * 255;
882 XStoreColor(
display, lut, &xcolor);
887 xcolor.red = 256 * 255;
888 xcolor.green = 256 * 165;
890 XStoreColor(
display, lut, &xcolor);
896 xcolor.green = 256 * 255;
897 xcolor.blue = 256 * 255;
898 XStoreColor(
display, lut, &xcolor);
903 xcolor.red = 256 * 128;
905 xcolor.blue = 256 * 128;
906 XStoreColor(
display, lut, &xcolor);
913 xcolor.flags = DoRed | DoGreen | DoBlue;
920 XAllocColor(
display, lut, &xcolor);
925 xcolor.red = 256 * 255;
926 xcolor.green = 256 * 255;
927 xcolor.blue = 256 * 255;
928 XAllocColor(
display, lut, &xcolor);
933 xcolor.red = 256 * 192;
934 xcolor.green = 256 * 192;
935 xcolor.blue = 256 * 192;
936 XAllocColor(
display, lut, &xcolor);
941 xcolor.red = 256 * 128;
942 xcolor.green = 256 * 128;
943 xcolor.blue = 256 * 128;
944 XAllocColor(
display, lut, &xcolor);
949 xcolor.red = 256 * 64;
950 xcolor.green = 256 * 64;
951 xcolor.blue = 256 * 64;
952 XAllocColor(
display, lut, &xcolor);
957 xcolor.red = 256 * 255;
958 xcolor.green = 256 * 140;
959 xcolor.blue = 256 * 140;
960 XAllocColor(
display, lut, &xcolor);
965 xcolor.red = 256 * 255;
968 XAllocColor(
display, lut, &xcolor);
973 xcolor.red = 256 * 128;
976 XAllocColor(
display, lut, &xcolor);
981 xcolor.red = 256 * 140;
982 xcolor.green = 256 * 255;
983 xcolor.blue = 256 * 140;
984 XAllocColor(
display, lut, &xcolor);
990 xcolor.green = 256 * 255;
992 XAllocColor(
display, lut, &xcolor);
998 xcolor.green = 256 * 128;
1000 XAllocColor(
display, lut, &xcolor);
1005 xcolor.red = 256 * 140;
1006 xcolor.green = 256 * 140;
1007 xcolor.blue = 256 * 255;
1008 XAllocColor(
display, lut, &xcolor);
1015 xcolor.blue = 256 * 255;
1016 XAllocColor(
display, lut, &xcolor);
1023 xcolor.blue = 256 * 128;
1024 XAllocColor(
display, lut, &xcolor);
1029 xcolor.red = 256 * 255;
1030 xcolor.green = 256 * 255;
1032 XAllocColor(
display, lut, &xcolor);
1037 xcolor.red = 256 * 255;
1038 xcolor.green = 256 * 165;
1040 XAllocColor(
display, lut, &xcolor);
1046 xcolor.green = 256 * 255;
1047 xcolor.blue = 256 * 255;
1048 XAllocColor(
display, lut, &xcolor);
1053 xcolor.red = 256 * 128;
1055 xcolor.blue = 256 * 128;
1056 XAllocColor(
display, lut, &xcolor);
1066 ExposureMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask |
1067 StructureNotifyMask | PointerMotionMask);
1070 values.plane_mask = AllPlanes;
1071 values.fill_style = FillSolid;
1072 values.foreground = WhitePixel(
display, screen);
1073 values.background = BlackPixel(
display, screen);
1074 context = XCreateGC(
display,
window, GCPlaneMask | GCFillStyle | GCForeground | GCBackground, &values);
1076 if (context == NULL) {
1093 Ximage->data = (
char *)malloc(
m_height * (
unsigned int)Ximage->bytes_per_line);
1094 ximage_data_init =
true;
1116 if (x_color == NULL) {
1135 hints.flags = USPosition;
1142 if ((
display = XOpenDisplay(NULL)) == NULL) {
1143 vpERROR_TRACE(
"Can't connect display on server %s.\n", XDisplayName(NULL));
1147 screen = DefaultScreen(
display);
1148 lut = DefaultColormap(
display, screen);
1149 screen_depth = (
unsigned int)DefaultDepth(
display, screen);
1151 vpTRACE(
"Screen depth: %d\n", screen_depth);
1162 if (screen_depth == 8) {
1164 xcolor.flags = DoRed | DoGreen | DoBlue;
1166 for (
unsigned int i = 0; i < 256; i++) {
1168 xcolor.red = 256 * i;
1169 xcolor.green = 256 * i;
1170 xcolor.blue = 256 * i;
1171 XStoreColor(
display, lut, &xcolor);
1175 XInstallColormap(
display, lut);
1178 else if (screen_depth == 16) {
1179 for (
unsigned int i = 0; i < 256; i++) {
1181 xcolor.red = xcolor.green = xcolor.blue = 256 * i;
1182 if (XAllocColor(
display, lut, &xcolor) == 0) {
1183 vpERROR_TRACE(
"Can't allocate 256 colors. Only %d allocated.", i);
1186 colortable[i] = xcolor.pixel;
1190 XInstallColormap(
display, lut);
1192 Visual *visual = DefaultVisual(
display, screen);
1193 RMask = visual->red_mask;
1194 GMask = visual->green_mask;
1195 BMask = visual->blue_mask;
1197 RShift = 15 -
getMsb(RMask);
1198 GShift = 15 -
getMsb(GMask);
1199 BShift = 15 -
getMsb(BMask);
1207 switch (screen_depth) {
1217 xcolor.red = 256 * pcolor.
R;
1218 xcolor.green = 256 * pcolor.
G;
1219 xcolor.blue = 256 * pcolor.
B;
1220 XStoreColor(
display, lut, &xcolor);
1225 xcolor.red = 256 * pcolor.
R;
1226 xcolor.green = 256 * pcolor.
G;
1227 xcolor.blue = 256 * pcolor.
B;
1228 XStoreColor(
display, lut, &xcolor);
1233 xcolor.red = 256 * pcolor.
R;
1234 xcolor.green = 256 * pcolor.
G;
1235 xcolor.blue = 256 * pcolor.
B;
1236 XStoreColor(
display, lut, &xcolor);
1241 xcolor.red = 256 * pcolor.
R;
1242 xcolor.green = 256 * pcolor.
G;
1243 xcolor.blue = 256 * pcolor.
B;
1244 XStoreColor(
display, lut, &xcolor);
1249 xcolor.red = 256 * pcolor.
R;
1250 xcolor.green = 256 * pcolor.
G;
1251 xcolor.blue = 256 * pcolor.
B;
1252 XStoreColor(
display, lut, &xcolor);
1257 xcolor.red = 256 * pcolor.
R;
1258 xcolor.green = 256 * pcolor.
G;
1259 xcolor.blue = 256 * pcolor.
B;
1260 XStoreColor(
display, lut, &xcolor);
1265 xcolor.red = 256 * pcolor.
R;
1266 xcolor.green = 256 * pcolor.
G;
1267 xcolor.blue = 256 * pcolor.
B;
1268 XStoreColor(
display, lut, &xcolor);
1273 xcolor.red = 256 * pcolor.
R;
1274 xcolor.green = 256 * pcolor.
G;
1275 xcolor.blue = 256 * pcolor.
B;
1276 XStoreColor(
display, lut, &xcolor);
1281 xcolor.red = 256 * pcolor.
R;
1282 xcolor.green = 256 * pcolor.
G;
1283 xcolor.blue = 256 * pcolor.
B;
1284 XStoreColor(
display, lut, &xcolor);
1289 xcolor.red = 256 * pcolor.
R;
1290 xcolor.green = 256 * pcolor.
G;
1291 xcolor.blue = 256 * pcolor.
B;
1292 XStoreColor(
display, lut, &xcolor);
1297 xcolor.red = 256 * pcolor.
R;
1298 xcolor.green = 256 * pcolor.
G;
1299 xcolor.blue = 256 * pcolor.
B;
1300 XStoreColor(
display, lut, &xcolor);
1305 xcolor.red = 256 * pcolor.
R;
1306 xcolor.green = 256 * pcolor.
G;
1307 xcolor.blue = 256 * pcolor.
B;
1308 XStoreColor(
display, lut, &xcolor);
1313 xcolor.red = 256 * pcolor.
R;
1314 xcolor.green = 256 * pcolor.
G;
1315 xcolor.blue = 256 * pcolor.
B;
1316 XStoreColor(
display, lut, &xcolor);
1321 xcolor.red = 256 * pcolor.
R;
1322 xcolor.green = 256 * pcolor.
G;
1323 xcolor.blue = 256 * pcolor.
B;
1324 XStoreColor(
display, lut, &xcolor);
1329 xcolor.red = 256 * pcolor.
R;
1330 xcolor.green = 256 * pcolor.
G;
1331 xcolor.blue = 256 * pcolor.
B;
1332 XStoreColor(
display, lut, &xcolor);
1337 xcolor.red = 256 * pcolor.
R;
1338 xcolor.green = 256 * pcolor.
G;
1339 xcolor.blue = 256 * pcolor.
B;
1340 XStoreColor(
display, lut, &xcolor);
1346 xcolor.flags = DoRed | DoGreen | DoBlue;
1351 xcolor.red = 256 * pcolor.
R;
1352 xcolor.green = 256 * pcolor.
G;
1353 xcolor.blue = 256 * pcolor.
B;
1354 XAllocColor(
display, lut, &xcolor);
1360 xcolor.red = 256 * pcolor.
R;
1361 xcolor.green = 256 * pcolor.
G;
1362 xcolor.blue = 256 * pcolor.
B;
1363 XAllocColor(
display, lut, &xcolor);
1369 xcolor.red = 256 * pcolor.
R;
1370 xcolor.green = 256 * pcolor.
G;
1371 xcolor.blue = 256 * pcolor.
B;
1372 XAllocColor(
display, lut, &xcolor);
1378 xcolor.red = 256 * pcolor.
R;
1379 xcolor.green = 256 * pcolor.
G;
1380 xcolor.blue = 256 * pcolor.
B;
1381 XAllocColor(
display, lut, &xcolor);
1387 xcolor.red = 256 * pcolor.
R;
1388 xcolor.green = 256 * pcolor.
G;
1389 xcolor.blue = 256 * pcolor.
B;
1390 XAllocColor(
display, lut, &xcolor);
1396 xcolor.red = 256 * pcolor.
R;
1397 xcolor.green = 256 * pcolor.
G;
1398 xcolor.blue = 256 * pcolor.
B;
1399 XAllocColor(
display, lut, &xcolor);
1405 xcolor.red = 256 * pcolor.
R;
1406 xcolor.green = 256 * pcolor.
G;
1407 xcolor.blue = 256 * pcolor.
B;
1408 XAllocColor(
display, lut, &xcolor);
1414 xcolor.red = 256 * pcolor.
R;
1415 xcolor.green = 256 * pcolor.
G;
1416 xcolor.blue = 256 * pcolor.
B;
1417 XAllocColor(
display, lut, &xcolor);
1423 xcolor.red = 256 * pcolor.
R;
1424 xcolor.green = 256 * pcolor.
G;
1425 xcolor.blue = 256 * pcolor.
B;
1426 XAllocColor(
display, lut, &xcolor);
1432 xcolor.red = 256 * pcolor.
R;
1433 xcolor.green = 256 * pcolor.
G;
1434 xcolor.blue = 256 * pcolor.
B;
1435 XAllocColor(
display, lut, &xcolor);
1441 xcolor.red = 256 * pcolor.
R;
1442 xcolor.green = 256 * pcolor.
G;
1443 xcolor.blue = 256 * pcolor.
B;
1444 XAllocColor(
display, lut, &xcolor);
1450 xcolor.red = 256 * pcolor.
R;
1451 xcolor.green = 256 * pcolor.
G;
1452 xcolor.blue = 256 * pcolor.
B;
1453 XAllocColor(
display, lut, &xcolor);
1459 xcolor.red = 256 * pcolor.
R;
1460 xcolor.green = 256 * pcolor.
G;
1461 xcolor.blue = 256 * pcolor.
B;
1462 XAllocColor(
display, lut, &xcolor);
1468 xcolor.red = 256 * pcolor.
R;
1469 xcolor.green = 256 * pcolor.
G;
1470 xcolor.blue = 256 * pcolor.
B;
1471 XAllocColor(
display, lut, &xcolor);
1477 xcolor.red = 256 * pcolor.
R;
1478 xcolor.green = 256 * pcolor.
G;
1479 xcolor.blue = 256 * pcolor.
B;
1480 XAllocColor(
display, lut, &xcolor);
1486 xcolor.red = 256 * pcolor.
R;
1487 xcolor.green = 256 * pcolor.
G;
1488 xcolor.blue = 256 * pcolor.
B;
1489 XAllocColor(
display, lut, &xcolor);
1495 xcolor.red = 256 * pcolor.
R;
1496 xcolor.green = 256 * pcolor.
G;
1497 xcolor.blue = 256 * pcolor.
B;
1498 XAllocColor(
display, lut, &xcolor);
1504 xcolor.red = 256 * pcolor.
R;
1505 xcolor.green = 256 * pcolor.
G;
1506 xcolor.blue = 256 * pcolor.
B;
1507 XAllocColor(
display, lut, &xcolor);
1517 ExposureMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask |
1518 StructureNotifyMask | PointerMotionMask);
1521 values.plane_mask = AllPlanes;
1522 values.fill_style = FillSolid;
1523 values.foreground = WhitePixel(
display, screen);
1524 values.background = BlackPixel(
display, screen);
1525 context = XCreateGC(
display,
window, GCPlaneMask | GCFillStyle | GCForeground | GCBackground, &values);
1527 if (context == NULL) {
1544 Ximage->data = (
char *)malloc(
m_height * (
unsigned int)Ximage->bytes_per_line);
1545 ximage_data_init =
true;
1571 if (!font.empty()) {
1574 stringfont = XLoadFont(
display, font.c_str());
1575 XSetFont(
display, context, stringfont);
1632 switch (screen_depth) {
1638 unsigned char *src_8 = (
unsigned char *)I.
bitmap;
1639 unsigned char *dst_8 = (
unsigned char *)Ximage->data;
1644 unsigned char nivGris = src_8[i];
1645 if (nivGris > nivGrisMax)
1654 unsigned char *dst_8 = (
unsigned char *)Ximage->data;
1656 for (
unsigned int i = 0; i <
m_height; i++) {
1657 for (
unsigned int j = 0; j <
m_width; j++) {
1659 if (nivGris > nivGrisMax)
1662 dst_8[k++] = nivGris;
1673 unsigned int bytes_per_line = (
unsigned int)Ximage->bytes_per_line;
1675 for (
unsigned int i = 0; i <
m_height; i++) {
1676 unsigned char *dst_8 = (
unsigned char *)Ximage->data + i * bytes_per_line;
1677 unsigned short *dst_16 = (
unsigned short *)dst_8;
1678 for (
unsigned int j = 0; j <
m_width; j++) {
1679 *(dst_16 + j) = (
unsigned short)colortable[I[i][j]];
1683 for (
unsigned int i = 0; i <
m_height; i++) {
1684 unsigned char *dst_8 = (
unsigned char *)Ximage->data + i * bytes_per_line;
1685 unsigned short *dst_16 = (
unsigned short *)dst_8;
1686 for (
unsigned int j = 0; j <
m_width; j++) {
1687 *(dst_16 + j) = (
unsigned short)colortable[I[i *
m_scale][j *
m_scale]];
1700 unsigned char *dst_32 = (
unsigned char *)Ximage->data;
1703 unsigned char *bitmap = I.
bitmap;
1704 unsigned char *n = I.
bitmap + size_;
1707 if (XImageByteOrder(
display) == 1) {
1709 while (bitmap < n) {
1710 unsigned char val = *(bitmap++);
1718 while (bitmap < n) {
1719 unsigned char val = *(bitmap++);
1727 if (XImageByteOrder(
display) == 1) {
1729 for (
unsigned int i = 0; i <
m_height; i++) {
1730 for (
unsigned int j = 0; j <
m_width; j++) {
1740 for (
unsigned int i = 0; i <
m_height; i++) {
1741 for (
unsigned int j = 0; j <
m_width; j++) {
1776 switch (screen_depth) {
1779 unsigned int r, g, b;
1780 unsigned int bytes_per_line = (
unsigned int)Ximage->bytes_per_line;
1783 for (
unsigned int i = 0; i <
m_height; i++) {
1784 unsigned char *dst_8 = (
unsigned char *)Ximage->data + i * bytes_per_line;
1785 unsigned short *dst_16 = (
unsigned short *)dst_8;
1786 for (
unsigned int j = 0; j <
m_width; j++) {
1791 (((r << 8) >> RShift) & RMask) | (((g << 8) >> GShift) & GMask) | (((b << 8) >> BShift) & BMask);
1796 for (
unsigned int i = 0; i <
m_height; i++) {
1797 unsigned char *dst_8 = (
unsigned char *)Ximage->data + i * bytes_per_line;
1798 unsigned short *dst_16 = (
unsigned short *)dst_8;
1799 for (
unsigned int j = 0; j <
m_width; j++) {
1805 (((r << 8) >> RShift) & RMask) | (((g << 8) >> GShift) & GMask) | (((b << 8) >> BShift) & BMask);
1821 unsigned char *dst_32 = NULL;
1822 dst_32 = (
unsigned char *)Ximage->data;
1826 if (XImageByteOrder(
display) == 1) {
1828 for (
unsigned int i = 0; i < sizeI; i++) {
1829 *(dst_32++) = bitmap->
A;
1830 *(dst_32++) = bitmap->
R;
1831 *(dst_32++) = bitmap->
G;
1832 *(dst_32++) = bitmap->
B;
1837 for (
unsigned int i = 0; i < sizeI; i++) {
1838 *(dst_32++) = bitmap->
B;
1839 *(dst_32++) = bitmap->
G;
1840 *(dst_32++) = bitmap->
R;
1841 *(dst_32++) = bitmap->
A;
1846 if (XImageByteOrder(
display) == 1) {
1848 for (
unsigned int i = 0; i <
m_height; i++) {
1849 for (
unsigned int j = 0; j <
m_width; j++) {
1851 *(dst_32++) = val.
A;
1852 *(dst_32++) = val.
R;
1853 *(dst_32++) = val.
G;
1854 *(dst_32++) = val.
B;
1859 for (
unsigned int i = 0; i <
m_height; i++) {
1860 for (
unsigned int j = 0; j <
m_width; j++) {
1862 *(dst_32++) = val.
B;
1863 *(dst_32++) = val.
G;
1864 *(dst_32++) = val.
R;
1865 *(dst_32++) = val.
A;
1878 "Unsupported depth (%d bpp) for color display", screen_depth));
1900 unsigned char *dst_32 = (
unsigned char *)Ximage->data;
1902 *(dst_32++) = *bitmap;
1903 *(dst_32++) = *bitmap;
1904 *(dst_32++) = *bitmap;
1905 *(dst_32++) = *bitmap;
1910 XPutImage(
display, pixmap, context, Ximage, 0, 0, 0, 0,
m_width, m_height);
1936 switch (screen_depth) {
1942 unsigned char *src_8 = (
unsigned char *)I.
bitmap;
1943 unsigned char *dst_8 = (
unsigned char *)Ximage->data;
1944 unsigned int iwidth = I.
getWidth();
1946 src_8 = src_8 + (int)(iP.
get_i() * iwidth + iP.
get_j());
1953 unsigned char nivGris = *(src_8 + j);
1954 if (nivGris > nivGrisMax)
1957 *(dst_8 + j) = nivGris;
1960 src_8 = src_8 + iwidth;
1970 int i_min = (std::max)((
int)ceil(iP.
get_i() /
m_scale), 0);
1971 int j_min = (std::max)((
int)ceil(iP.
get_j() /
m_scale), 0);
1975 unsigned int i_min_ = (
unsigned int)i_min;
1976 unsigned int i_max_ = (
unsigned int)i_max;
1977 unsigned int j_min_ = (
unsigned int)j_min;
1978 unsigned int j_max_ = (
unsigned int)j_max;
1980 for (
unsigned int i = i_min_; i < i_max_; i++) {
1981 unsigned char *dst_8 = (
unsigned char *)Ximage->data + i *
m_width;
1982 for (
unsigned int j = j_min_; j < j_max_; j++) {
1984 if (nivGris > nivGrisMax)
1990 XPutImage(
display, pixmap, context, Ximage, j_min, i_min, j_min, i_min, j_max_ - j_min_, i_max_ - i_min_);
1998 unsigned int bytes_per_line = (
unsigned int)Ximage->bytes_per_line;
2000 for (
unsigned int i = (
unsigned int)iP.
get_i(); i < (
unsigned int)(iP.
get_i() + h); i++) {
2001 unsigned char *dst_8 = (
unsigned char *)Ximage->data + i * bytes_per_line;
2002 unsigned short *dst_16 = (
unsigned short *)dst_8;
2003 for (
unsigned int j = (
unsigned int)iP.
get_j(); j < (
unsigned int)(iP.
get_j() + w); j++) {
2004 *(dst_16 + j) = (
unsigned short)colortable[I[i][j]];
2011 int i_min = (std::max)((
int)ceil(iP.
get_i() /
m_scale), 0);
2012 int j_min = (std::max)((
int)ceil(iP.
get_j() /
m_scale), 0);
2016 unsigned int i_min_ = (
unsigned int)i_min;
2017 unsigned int i_max_ = (
unsigned int)i_max;
2018 unsigned int j_min_ = (
unsigned int)j_min;
2019 unsigned int j_max_ = (
unsigned int)j_max;
2021 for (
unsigned int i = i_min_; i < i_max_; i++) {
2022 unsigned char *dst_8 = (
unsigned char *)Ximage->data + i * bytes_per_line;
2023 unsigned short *dst_16 = (
unsigned short *)dst_8;
2024 for (
unsigned int j = j_min_; j < j_max_; j++) {
2025 *(dst_16 + j) = (
unsigned short)colortable[I[i *
m_scale][j *
m_scale]];
2029 XPutImage(
display, pixmap, context, Ximage, j_min, i_min, j_min, i_min, j_max_ - j_min_, i_max_ - i_min_);
2039 unsigned int iwidth = I.
getWidth();
2041 unsigned char *dst_32 = (
unsigned char *)Ximage->data + (
int)(iP.
get_i() * 4 *
m_width + iP.
get_j() * 4);
2043 if (XImageByteOrder(
display) == 1) {
2049 unsigned char val = *(src_8 + j);
2051 *(dst_32 + 4 * j + 1) = val;
2052 *(dst_32 + 4 * j + 2) = val;
2053 *(dst_32 + 4 * j + 3) = val;
2056 src_8 = src_8 + iwidth;
2057 dst_32 = dst_32 + 4 *
m_width;
2066 unsigned char val = *(src_8 + j);
2067 *(dst_32 + 4 * j) = val;
2068 *(dst_32 + 4 * j + 1) = val;
2069 *(dst_32 + 4 * j + 2) = val;
2073 src_8 = src_8 + iwidth;
2074 dst_32 = dst_32 + 4 *
m_width;
2082 int i_min = (std::max)((
int)ceil(iP.
get_i() /
m_scale), 0);
2083 int j_min = (std::max)((
int)ceil(iP.
get_j() /
m_scale), 0);
2087 unsigned int i_min_ = (
unsigned int)i_min;
2088 unsigned int i_max_ = (
unsigned int)i_max;
2089 unsigned int j_min_ = (
unsigned int)j_min;
2090 unsigned int j_max_ = (
unsigned int)j_max;
2092 if (XImageByteOrder(
display) == 1) {
2094 for (
unsigned int i = i_min_; i < i_max_; i++) {
2095 unsigned char *dst_32 = (
unsigned char *)Ximage->data + (
int)(i * 4 *
m_width + j_min_ * 4);
2096 for (
unsigned int j = j_min_; j < j_max_; j++) {
2106 for (
unsigned int i = i_min_; i < i_max_; i++) {
2107 unsigned char *dst_32 = (
unsigned char *)Ximage->data + (
int)(i * 4 *
m_width + j_min_ * 4);
2108 for (
unsigned int j = j_min_; j < j_max_; j++) {
2118 XPutImage(
display, pixmap, context, Ximage, j_min, i_min, j_min, i_min, j_max_ - j_min_, i_max_ - i_min_);
2149 switch (screen_depth) {
2152 unsigned int bytes_per_line = (
unsigned int)Ximage->bytes_per_line;
2153 for (
unsigned int i = (
unsigned int)iP.
get_i(); i < (
unsigned int)(iP.
get_i() + h); i++) {
2154 unsigned char *dst_8 = (
unsigned char *)Ximage->data + i * bytes_per_line;
2155 unsigned short *dst_16 = (
unsigned short *)dst_8;
2156 for (
unsigned int j = (
unsigned int)iP.
get_j(); j < (
unsigned int)(iP.
get_j() + w); j++) {
2158 unsigned int r = val.
R;
2159 unsigned int g = val.
G;
2160 unsigned int b = val.
B;
2162 (((r << 8) >> RShift) & RMask) | (((g << 8) >> GShift) & GMask) | (((b << 8) >> BShift) & BMask);
2168 unsigned int bytes_per_line = (
unsigned int)Ximage->bytes_per_line;
2169 int i_min = (std::max)((int)ceil(iP.
get_i() /
m_scale), 0);
2170 int j_min = (std::max)((
int)ceil(iP.
get_j() /
m_scale), 0);
2174 unsigned int i_min_ = (
unsigned int)i_min;
2175 unsigned int i_max_ = (
unsigned int)i_max;
2176 unsigned int j_min_ = (
unsigned int)j_min;
2177 unsigned int j_max_ = (
unsigned int)j_max;
2179 for (
unsigned int i = i_min_; i < i_max_; i++) {
2180 unsigned char *dst_8 = (
unsigned char *)Ximage->data + i * bytes_per_line;
2181 unsigned short *dst_16 = (
unsigned short *)dst_8;
2182 for (
unsigned int j = j_min_; j < j_max_; j++) {
2184 unsigned int r = val.
R;
2185 unsigned int g = val.
G;
2186 unsigned int b = val.
B;
2188 (((r << 8) >> RShift) & RMask) | (((g << 8) >> GShift) & GMask) | (((b << 8) >> BShift) & BMask);
2191 XPutImage(
display, pixmap, context, Ximage, j_min, i_min, j_min, i_min, j_max_ - j_min_, i_max_ - i_min_);
2205 unsigned char *dst_32 = (
unsigned char *)Ximage->data;
2208 unsigned int iwidth = I.
getWidth();
2210 src_32 = src_32 + (int)(iP.
get_i() * iwidth + iP.
get_j());
2215 if (XImageByteOrder(
display) == 1) {
2220 *(dst_32 + 4 * j) = (src_32 + j)->A;
2221 *(dst_32 + 4 * j + 1) = (src_32 + j)->R;
2222 *(dst_32 + 4 * j + 2) = (src_32 + j)->G;
2223 *(dst_32 + 4 * j + 3) = (src_32 + j)->B;
2227 src_32 = src_32 + iwidth;
2228 dst_32 = dst_32 + 4 *
m_width;
2237 *(dst_32 + 4 * j) = (src_32 + j)->B;
2238 *(dst_32 + 4 * j + 1) = (src_32 + j)->G;
2239 *(dst_32 + 4 * j + 2) = (src_32 + j)->R;
2240 *(dst_32 + 4 * j + 3) = (src_32 + j)->A;
2244 src_32 = src_32 + iwidth;
2245 dst_32 = dst_32 + 4 *
m_width;
2253 int i_min = (std::max)((
int)ceil(iP.
get_i() /
m_scale), 0);
2254 int j_min = (std::max)((
int)ceil(iP.
get_j() /
m_scale), 0);
2258 unsigned int i_min_ = (
unsigned int)i_min;
2259 unsigned int i_max_ = (
unsigned int)i_max;
2260 unsigned int j_min_ = (
unsigned int)j_min;
2261 unsigned int j_max_ = (
unsigned int)j_max;
2263 if (XImageByteOrder(
display) == 1) {
2265 for (
unsigned int i = i_min_; i < i_max_; i++) {
2266 unsigned char *dst_32 = (
unsigned char *)Ximage->data + (
int)(i * 4 *
m_width + j_min_ * 4);
2267 for (
unsigned int j = j_min_; j < j_max_; j++) {
2269 *(dst_32++) = val.
A;
2270 *(dst_32++) = val.
R;
2271 *(dst_32++) = val.
G;
2272 *(dst_32++) = val.
B;
2277 for (
unsigned int i = i_min_; i < i_max_; i++) {
2278 unsigned char *dst_32 = (
unsigned char *)Ximage->data + (
int)(i * 4 *
m_width + j_min_ * 4);
2279 for (
unsigned int j = j_min_; j < j_max_; j++) {
2281 *(dst_32++) = val.
B;
2282 *(dst_32++) = val.
G;
2283 *(dst_32++) = val.
R;
2284 *(dst_32++) = val.
A;
2288 XPutImage(
display, pixmap, context, Ximage, j_min, i_min, j_min, i_min, j_max_ - j_min_, i_max_ - i_min_);
2296 "Unsupported depth (%d bpp) for color display", screen_depth));
2313 if (ximage_data_init ==
true)
2316 Ximage->data = NULL;
2317 XDestroyImage(Ximage);
2327 if (x_color != NULL) {
2378 xcolor.red = 256 * color.
R;
2379 xcolor.green = 256 * color.
G;
2380 xcolor.blue = 256 * color.
B;
2381 XAllocColor(
display, lut, &xcolor);
2382 XSetForeground(
display, context, xcolor.pixel);
2403 unsigned int h,
unsigned int thickness)
2411 if ((std::fabs(a) <= std::numeric_limits<double>::epsilon()) &&
2412 (std::fabs(b) <= std::numeric_limits<double>::epsilon())) {
2457 XSetForeground(
display, context, x_color[color.
id]);
2460 xcolor.red = 256 * color.
R;
2461 xcolor.green = 256 * color.
G;
2462 xcolor.blue = 256 * color.
B;
2463 XAllocColor(
display, lut, &xcolor);
2464 XSetForeground(
display, context, xcolor.pixel);
2483 unsigned int thickness)
2489 XSetForeground(
display, context, x_color[color.
id]);
2492 xcolor.red = 256 * color.
R;
2493 xcolor.green = 256 * color.
G;
2494 xcolor.blue = 256 * color.
B;
2495 XAllocColor(
display, lut, &xcolor);
2496 XSetForeground(
display, context, xcolor.pixel);
2499 XSetLineAttributes(
display, context, thickness, LineSolid, CapButt, JoinBevel);
2501 if (fill ==
false) {
2523 unsigned int thickness)
2526 double i = ip.
get_i();
2527 double j = ip.
get_j();
2530 ip1.
set_i(i - cross_size / 2);
2532 ip2.
set_i(i + cross_size / 2);
2537 ip1.
set_j(j - cross_size / 2);
2539 ip2.
set_j(j + cross_size / 2);
2553 unsigned int thickness)
2560 XSetForeground(
display, context, x_color[color.
id]);
2563 xcolor.red = 256 * color.
R;
2564 xcolor.green = 256 * color.
G;
2565 xcolor.blue = 256 * color.
B;
2566 XAllocColor(
display, lut, &xcolor);
2567 XSetForeground(
display, context, xcolor.pixel);
2570 XSetLineAttributes(
display, context, thickness, LineOnOffDash, CapButt, JoinBevel);
2586 unsigned int thickness)
2593 XSetForeground(
display, context, x_color[color.
id]);
2596 xcolor.red = 256 * color.
R;
2597 xcolor.green = 256 * color.
G;
2598 xcolor.blue = 256 * color.
B;
2599 XAllocColor(
display, lut, &xcolor);
2600 XSetForeground(
display, context, xcolor.pixel);
2603 XSetLineAttributes(
display, context, thickness, LineSolid, CapButt, JoinBevel);
2622 XSetForeground(
display, context, x_color[color.
id]);
2625 xcolor.red = 256 * color.
R;
2626 xcolor.green = 256 * color.
G;
2627 xcolor.blue = 256 * color.
B;
2628 XAllocColor(
display, lut, &xcolor);
2629 XSetForeground(
display, context, xcolor.pixel);
2632 if (thickness == 1) {
2636 thickness, thickness);
2658 bool fill,
unsigned int thickness)
2664 XSetForeground(
display, context, x_color[color.
id]);
2667 xcolor.red = 256 * color.
R;
2668 xcolor.green = 256 * color.
G;
2669 xcolor.blue = 256 * color.
B;
2670 XAllocColor(
display, lut, &xcolor);
2671 XSetForeground(
display, context, xcolor.pixel);
2673 XSetLineAttributes(
display, context, thickness, LineSolid, CapButt, JoinBevel);
2674 if (fill ==
false) {
2699 bool fill,
unsigned int thickness)
2705 XSetForeground(
display, context, x_color[color.
id]);
2708 xcolor.red = 256 * color.
R;
2709 xcolor.green = 256 * color.
G;
2710 xcolor.blue = 256 * color.
B;
2711 XAllocColor(
display, lut, &xcolor);
2712 XSetForeground(
display, context, xcolor.pixel);
2715 XSetLineAttributes(
display, context, thickness, LineSolid, CapButt, JoinBevel);
2721 if (fill ==
false) {
2723 XDrawRectangle(
display, pixmap, context,
2726 w > 0 ? w : 1, h > 0 ? h : 1);
2728 XFillRectangle(
display, pixmap, context,
2756 XSetForeground(
display, context, x_color[color.
id]);
2759 xcolor.red = 256 * color.
R;
2760 xcolor.green = 256 * color.
G;
2761 xcolor.blue = 256 * color.
B;
2762 XAllocColor(
display, lut, &xcolor);
2763 XSetForeground(
display, context, xcolor.pixel);
2766 XSetLineAttributes(
display, context, thickness, LineSolid, CapButt, JoinBevel);
2768 if (fill ==
false) {
2807 Window rootwin, childwin;
2808 int root_x, root_y, win_x, win_y;
2809 unsigned int modifier;
2813 XCheckMaskEvent(
display, ButtonPressMask, &event);
2814 XCheckMaskEvent(
display, ButtonReleaseMask, &event);
2815 XMaskEvent(
display, ButtonPressMask, &event);
2818 ret = XCheckMaskEvent(
display, ButtonPressMask, &event);
2823 if (XQueryPointer(
display,
window, &rootwin, &childwin, &root_x, &root_y, &win_x, &win_y, &modifier)) {
2854 Window rootwin, childwin;
2855 int root_x, root_y, win_x, win_y;
2856 unsigned int modifier;
2859 XCheckMaskEvent(
display, ButtonPressMask, &event);
2860 XCheckMaskEvent(
display, ButtonReleaseMask, &event);
2861 XMaskEvent(
display, ButtonPressMask, &event);
2864 ret = XCheckMaskEvent(
display, ButtonPressMask, &event);
2869 if (XQueryPointer(
display,
window, &rootwin, &childwin, &root_x, &root_y, &win_x, &win_y, &modifier)) {
2871 ip.
set_v((
double)event.xbutton.y * m_scale);
2905 Window rootwin, childwin;
2906 int root_x, root_y, win_x, win_y;
2907 unsigned int modifier;
2911 XCheckMaskEvent(
display, ButtonPressMask, &event);
2912 XCheckMaskEvent(
display, ButtonReleaseMask, &event);
2913 XMaskEvent(
display, ButtonPressMask, &event);
2916 ret = XCheckMaskEvent(
display, ButtonPressMask, &event);
2921 if (XQueryPointer(
display,
window, &rootwin, &childwin, &root_x, &root_y, &win_x, &win_y, &modifier)) {
2923 ip.
set_v((
double)event.xbutton.y * m_scale);
2924 switch (event.xbutton.button) {
2971 Window rootwin, childwin;
2972 int root_x, root_y, win_x, win_y;
2973 unsigned int modifier;
2977 XCheckMaskEvent(
display, ButtonPressMask, &event);
2978 XCheckMaskEvent(
display, ButtonReleaseMask, &event);
2979 XMaskEvent(
display, ButtonReleaseMask, &event);
2982 ret = XCheckMaskEvent(
display, ButtonReleaseMask, &event);
2987 if (XQueryPointer(
display,
window, &rootwin, &childwin, &root_x, &root_y, &win_x, &win_y, &modifier)) {
2989 ip.
set_v((
double)event.xbutton.y * m_scale);
2990 switch (event.xbutton.button) {
3027 unsigned char *src_32 = NULL;
3028 src_32 = (
unsigned char *)xi->data;
3030 if (screen_depth == 16) {
3031 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
3033 for (
unsigned int j = 0; j <
m_height; j++) {
3034 size_t ij_ = i_ + j;
3035 unsigned long pixel = XGetPixel(xi, (
int)j, (
int)i);
3036 I.
bitmap[ij_].
R = (((pixel & RMask) << RShift) >> 8);
3037 I.
bitmap[ij_].
G = (((pixel & GMask) << GShift) >> 8);
3038 I.
bitmap[ij_].
B = (((pixel & BMask) << BShift) >> 8);
3047 if (XImageByteOrder(
display) == 1) {
3054 I.
bitmap[i].
R = src_32[i * 4 + 1];
3055 I.
bitmap[i].
G = src_32[i * 4 + 2];
3056 I.
bitmap[i].
B = src_32[i * 4 + 3];
3061 I.
bitmap[i].
B = src_32[i * 4];
3062 I.
bitmap[i].
G = src_32[i * 4 + 1];
3063 I.
bitmap[i].
R = src_32[i * 4 + 2];
3086 if ((display_ = XOpenDisplay(NULL)) == NULL) {
3088 XDisplayName(NULL)));
3090 screen_ = DefaultScreen(display_);
3091 depth = (
unsigned int)DefaultDepth(display_, screen_);
3093 XCloseDisplay(display_);
3107 if ((display_ = XOpenDisplay(NULL)) == NULL) {
3109 XDisplayName(NULL)));
3111 screen_ = DefaultScreen(display_);
3112 w = (
unsigned int)DisplayWidth(display_, screen_);
3113 h = (
unsigned int)DisplayHeight(display_, screen_);
3115 XCloseDisplay(display_);
3123 unsigned int width, height;
3133 unsigned int width, height;
3166 XMaskEvent(
display, KeyPressMask, &event);
3169 ret = XCheckMaskEvent(
display, KeyPressMask, &event);
3205 XComposeStatus compose_status;
3211 XMaskEvent(
display, KeyPressMask, &event);
3212 XLookupString((XKeyEvent *)&event, &buffer, 1, &keysym, &compose_status);
3216 ret = XCheckMaskEvent(
display, KeyPressMask, &event);
3218 XLookupString((XKeyEvent *)&event, &buffer, 1, &keysym, &compose_status);
3245 Window rootwin, childwin;
3246 int root_x, root_y, win_x, win_y;
3247 unsigned int modifier;
3249 ret = XCheckMaskEvent(
display, PointerMotionMask, &event);
3253 if (XQueryPointer(
display,
window, &rootwin, &childwin, &root_x, &root_y, &win_x, &win_y, &modifier)) {
3255 ip.
set_v((
double)event.xbutton.y * m_scale);
3280 Window rootwin, childwin;
3281 int root_x, root_y, win_x, win_y;
3282 unsigned int modifier;
3288 if (XQueryPointer(
display,
window, &rootwin, &childwin, &root_x, &root_y, &win_x, &win_y, &modifier)) {
3290 ip.
set_v((
double)win_y * m_scale);
3306 for (i = 31; i >= 0; --i) {
3307 if (u32val & 0x80000000L)
3314 #elif !defined(VISP_BUILD_SHARED_LIBS) 3317 void dummy_vpDisplayX(){};
void clearDisplay(const vpColor &color=vpColor::white)
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="")
int m_windowYPosition
display position
unsigned int getScreenDepth()
void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
void displayRectangle(const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1)
bool getClickUp(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true)
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
unsigned char B
Blue component.
Type * bitmap
points toward the bitmap
static const vpColor black
static const vpColor darkRed
Class to define colors available for display functionnalities.
static const vpColor lightGray
void displayImage(const vpImage< unsigned char > &I)
static const vpColor darkBlue
unsigned char G
Green component.
bool m_displayHasBeenInitialized
display has been initialized
static const vpColor green
static const vpColor lightRed
bool getPointerPosition(vpImagePoint &ip)
vpWin32Window window
The window.
static const vpColor orange
unsigned int getScreenWidth()
bool getClick(bool blocking=true)
int m_windowXPosition
display position
static const vpColor cyan
static const vpColor lightGreen
void setScale(vpScaleType scaleType, unsigned int width, unsigned int height)
static double sqr(double x)
void displayCharString(const vpImagePoint &ip, const char *text, const vpColor &color=vpColor::green)
static void display(const vpImage< unsigned char > &I)
void getScreenSize(unsigned int &width, unsigned int &height)
unsigned char A
Additionnal component.
int getMsb(unsigned int u32val)
bool getKeyboardEvent(bool blocking=true)
static const vpColor gray
void displayPoint(const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1)
void setWindowPosition(int winx, int winy)
static const vpColor darkGray
void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
void displayArrow(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color=vpColor::white, unsigned int w=4, unsigned int h=2, unsigned int thickness=1)
static int round(double x)
Error that can be emited by the vpDisplay class and its derivates.
unsigned int getHeight() const
unsigned char R
Red component.
void setTitle(const std::string &title)
void displayImageROI(const vpImage< unsigned char > &I, const vpImagePoint &iP, unsigned int width, unsigned int height)
Defines a rectangle in the plane.
void setFont(const std::string &font)
static const vpColor darkGreen
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
static const vpColor yellow
static const vpColor lightBlue
static const vpColor purple
static const vpColor white
unsigned int getWidth() const
void displayCircle(const vpImagePoint ¢er, unsigned int radius, const vpColor &color, bool fill=false, unsigned int thickness=1)
bool getPointerMotionEvent(vpImagePoint &ip)
static double distance(const vpImagePoint &iP1, const vpImagePoint &iP2)
void getImage(vpImage< vpRGBa > &I)
get the window pixmap and put it in vpRGBa image
unsigned int getScreenHeight()
static const vpColor blue
void flushDisplayROI(const vpImagePoint &iP, unsigned int width, unsigned int height)
void displayDotLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)