1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567
|
/*
* Motif
*
* Copyright (c) 1987-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these librararies and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef REV_INFO
#ifndef lint
static char rcsid[] = "$XConsortium: Mrmicon.c /main/14 1996/11/13 14:01:43 drk $"
#endif
#endif
/*
*++
* FACILITY:
*
* UIL Resource Manager (URM)
*
* ABSTRACT:
*
* This module contains routines which operate on URM icon images -
* RGMIconImage structs.
*
*--
*/
/*
*
* INCLUDE FILES
*
*/
#include <stdio.h>
#include <Mrm/MrmAppl.h>
#include <Mrm/Mrm.h>
#include "MrmMsgI.h"
/*
*++
*
* PROCEDURE DESCRIPTION:
*
* This routine creates and returns an X pixmap from a URM icon
* for some widget. It uses the foreground and background obtainable
* from the widget as required.
*
* FORMAL PARAMETERS:
*
* icon URM icon image to be converted to X pixmap
* screen screen to use for pixmap
* display display to use for pixmap
* fgpix foreground color for pixmap
* bgpix background color for pixmap
* pixmap to return resulting X pixmap
*
* IMPLICIT INPUTS:
*
* IMPLICIT OUTPUTS:
*
* FUNCTION VALUE:
*
* URM status
*
* SIDE EFFECTS:
*
*--
*/
Cardinal
UrmCreatePixmap (RGMIconImagePtr icon,
Screen *screen,
Display *display,
Pixel fgpix,
Pixel bgpix,
Pixel *pixmap,
Widget parent)
{
/*
* Local variables
*/
Cardinal result; /* function results */
RGMColorTablePtr ctable; /* color table in icon */
unsigned maxbits; /* # bits required for X image */
int srcpix; /* # bits per pixel in icon (actual) */
int dds ;
/*
* Convert the color table colors to pixels.
*/
ctable = icon->color_table.ctptr;
result =
Urm__RealizeColorTable (screen, display, fgpix, bgpix, ctable, parent);
if ( result != MrmSUCCESS ) return result;
/*
* Use the depth of screen to infer the number of bits required to
* hold the pixels in X format. The ZPixmap format only supports 1, 8, 16,
* and 32 bit pixels, so we always map to one of these sizes.
*/
if (parent) dds = parent->core.depth;
else dds = DefaultDepthOfScreen(screen) ;
if (dds == 1)
maxbits = 1;
else if (dds <= 8)
maxbits = 8;
else if (dds <= 16)
maxbits = 16;
else
maxbits = 32;
/*
* See if the icon can be mapped as a bitmap. This will be true if the
* color table has only FG/BG entries, or uses only those entries.
*/
if ( ctable->count <= 2 ) maxbits = 1;
/*
* Compute the number of bits available in the icon pixmap
*/
switch ( icon->pixel_size )
{
case URMPixelSize1Bit:
srcpix = 1;
break;
case URMPixelSize2Bit:
srcpix = 2;
break;
case URMPixelSize4Bit:
srcpix = 4;
break;
case URMPixelSize8Bit:
srcpix = 8;
break;
default:
return MrmNOT_VALID;
}
/*
* Map the icon image pixmap from color table indices to Pixel values.
* There are three cases:
* maxbits == 1; a bitmap is possible, so map to a bitmap.
* maxbits <= # bits/pixel in pixmap. Map in place. In fact,
* only works if maxbits == srcpix == 8.
* maxbits > # bits/pixel. Map to allocated pixmap.
*
* Each of the three routines which performs these mappings completes
* the entire process of doing the mapping and creating the X pixmap.
*/
if ( maxbits == 1 )
return Urm__MapIconBitmap
(icon, srcpix, ctable, screen, display, pixmap);
if ((maxbits == 8) && (srcpix == 8))
return Urm__MapIconReplace
(icon, srcpix, ctable, screen, display, pixmap, parent);
if ( maxbits > srcpix )
return Urm__MapIconAllocate
(icon, srcpix, maxbits, ctable, screen, display, pixmap, parent);
return MrmNOT_VALID;
}
/*
*++
*
* PROCEDURE DESCRIPTION:
*
* This routine creates and returns an X pixmap of depth 1 from a URM icon
* for some widget.
*
* FORMAL PARAMETERS:
*
* icon URM icon image to be converted to X pixmap
* screen screen to use for pixmap
* display display to use for pixmap
* pixmap to return resulting X pixmap
*
* IMPLICIT INPUTS:
*
* IMPLICIT OUTPUTS:
*
* FUNCTION VALUE:
*
* URM status
*
* SIDE EFFECTS:
*
*--
*/
Cardinal
UrmCreateBitmap (RGMIconImagePtr icon,
Screen *screen,
Display *display,
Pixel *pixmap)
{
/*
* Local variables
*/
int srcpix; /* # bits per pixel in icon (actual) */
/*
* Compute the number of bits available in the icon pixmap
*/
switch ( icon->pixel_size )
{
case URMPixelSize1Bit:
srcpix = URMPixelSize1Bit;
break;
default:
return MrmNOT_VALID;
}
return Urm__MapIconBitmapDepth1 (icon, srcpix, screen, display, pixmap);
}
/*
*++
*
* PROCEDURE DESCRIPTION:
*
* This routine creates and returns an X pixmap from the X bitmap file
* name specified. It uses the foreground and background as needed.
*
*
* FORMAL PARAMETERS:
*
* filename file containing the bitmap to be converted to X pixmap
* screen screen to use for pixmap
* display display to use for pixmap - not used
* fgint foreground color for pixmap
* bgint background color for pixmap
* pixmap to return resulting X pixmap
*
* IMPLICIT INPUTS:
*
* IMPLICIT OUTPUTS:
*
* FUNCTION VALUE:
*
* URM status
*
* SIDE EFFECTS:
*
*--
*/
Cardinal
Urm__CW_ReadBitmapFile (String filename,
Screen *screen,
Pixel fgint,
Pixel bgint,
Pixmap *pixmap,
Widget parent)
{
int depth;
char err_msg[300];
/*
** Create a pixmap from a X bitmap file specification
*/
depth = parent ? parent->core.depth : DefaultDepthOfScreen(screen);
*pixmap = XmGetPixmapByDepth(screen, filename, fgint, bgint, depth);
if (*pixmap == XmUNSPECIFIED_PIXMAP)
{
pixmap = 0;
sprintf (err_msg, _MrmMMsg_0033, filename);
return Urm__UT_Error ("UrmReadBitmapFile", err_msg,
NULL, NULL, MrmFAILURE);
}
return MrmSUCCESS;
}
/*
*++
*
* PROCEDURE DESCRIPTION:
*
* This routine maps the pixmap in the icon into a bitmap. The
* bitmap is written over pixmap data. The X pixmap is then
* constructed as an XYBitmap.
*
* FORMAL PARAMETERS:
*
* icon the IconImage being converted
* srcpix number of bits/pixel in icon
* ctable the color table for (in) icon
* screen screen for the X pixmap
* display display for the X pixmap
* pixmap to return the result
*
* IMPLICIT INPUTS:
*
* IMPLICIT OUTPUTS:
*
* FUNCTION VALUE:
*
* SIDE EFFECTS:
*
*--
*/
Cardinal
Urm__MapIconBitmap(RGMIconImagePtr icon,
int srcpix,
RGMColorTablePtr ctable,
Screen *screen,
Display *display,
Pixmap *pixmap)
{
/*
* Local variables
*/
Pixel fgpix; /* foreground pixel value */
int iconwid; /* icon width */
int srclinebyt; /* # bytes per icon line */
int dstlinebyt; /* # bytes per bitmap line */
char *srcbytptr; /* image byte pointer */
char *dstbytptr; /* bitmap pointer */
int lin; /* icon line number */
int byt; /* line byte number */
int pix; /* line pixel number */
unsigned char srcbyt; /* icon image byte */
unsigned char dstbyt; /* mapped image byte */
int tndx; /* color table index */
XImage *imagep; /* X image */
GC gc;
XGCValues gcValues;
int endian; /* to determine which endian. */
/*
* Overwrite the icon data with a bitmap. Use 0 for background, 1 for
* foreground.
*/
fgpix = ctable->item[URMColorTableFG].color_pixel;
iconwid = icon->width;
srclinebyt = (iconwid*srcpix+7) / 8;
dstlinebyt = (iconwid+7) / 8;
srcbytptr = icon->pixel_data.pdptr;
for ( lin=0 ; lin<icon->height ; lin++ )
{
pix = 0;
dstbytptr = icon->pixel_data.pdptr + lin*dstlinebyt;
dstbyt = 0;
for ( byt=0 ; byt<srclinebyt ; byt++ )
{
srcbyt = *srcbytptr;
switch ( icon->pixel_size )
{
case URMPixelSize1Bit:
*dstbytptr = srcbyt;
srcbytptr += 1;
dstbytptr += 1;
pix += 8;
/*
* NOTE: The original algorithm used here cleared any
* unused bits of the last byte. I don't think
* the protocol requires that...
if ( pix > iconwid )
*/
continue;
case URMPixelSize2Bit:
tndx = srcbyt & 0x3;
if ( pix < iconwid )
if ( ctable->item[tndx].color_pixel == fgpix)
dstbyt |= 1<<(pix%8);
pix += 1;
srcbyt >>= 2;
tndx = srcbyt & 0x3;
if ( pix < iconwid )
if ( ctable->item[tndx].color_pixel == fgpix)
dstbyt |= 1<<(pix%8);
pix += 1;
srcbyt >>= 2;
tndx = srcbyt & 0x3;
if ( pix < iconwid )
if ( ctable->item[tndx].color_pixel == fgpix)
dstbyt |= 1<<(pix%8);
pix += 1;
srcbyt >>= 2;
tndx = srcbyt & 0x3;
if ( pix < iconwid )
if ( ctable->item[tndx].color_pixel == fgpix)
dstbyt |= 1<<(pix%8);
pix += 1;
break;
case URMPixelSize4Bit:
tndx = srcbyt & 0xF;
if ( pix < iconwid )
if ( ctable->item[tndx].color_pixel == fgpix)
dstbyt |= 1<<(pix%8);
pix += 1;
srcbyt >>= 4;
tndx = srcbyt & 0xF;
if ( pix < iconwid )
if ( ctable->item[tndx].color_pixel == fgpix)
dstbyt |= 1<<(pix%8);
pix += 1;
break;
case URMPixelSize8Bit:
if ( pix < iconwid )
if ( ctable->item[srcbyt].color_pixel == fgpix)
dstbyt |= 1<<(pix%8);
pix += 1;
break;
}
/*
* NOTE: The "1Bit" case CONTINUEs directly and will never
* reach this point in the loop...
*/
srcbytptr += 1;
if ( pix%8 == 0 )
{
*dstbytptr = dstbyt;
dstbytptr += 1;
dstbyt = 0;
}
}
if ( pix%8 != 0 )
*dstbytptr = dstbyt;
}
imagep = XCreateImage(display,
DefaultVisualOfScreen(screen),
1,
XYBitmap,
0,
icon->pixel_data.pdptr,
(unsigned int)icon->width,
(unsigned int)icon->height,
8,
dstlinebyt);
if ( imagep == NULL )
return Urm__UT_Error ("Urm__MapIconBitmap", _MrmMMsg_0034,
NULL, NULL, MrmFAILURE);
/*
* Well, Uil creates a uid icon in its byteorder, on his side
* XCreateImage creates an image in the byte_order of the server, so
* its not correct, we have to adjust the byte_order fields of this
* image to match those of the icon.
*/
endian = 1;
imagep->bitmap_unit = 8 ;
if (*(char *) &endian) {
imagep->byte_order = LSBFirst ;
imagep->bitmap_bit_order = LSBFirst ;
}
else {
imagep->byte_order = MSBFirst;
imagep->bitmap_bit_order = LSBFirst ;
}
*pixmap = XCreatePixmap (display,
RootWindowOfScreen(screen),
icon->width,
icon->height,
(unsigned)DefaultDepthOfScreen(screen));
if ( *pixmap == (Pixmap)0)
{
XFree((char*)imagep);
return Urm__UT_Error ("Urm__MapIconBitmap", _MrmMMsg_0035,
NULL, NULL, MrmFAILURE);
}
/*
* Build a gc to use when drawing into the pixmap
*/
gcValues.foreground = ctable->item[URMColorTableFG].color_pixel;
gcValues.background = ctable->item[URMColorTableBG].color_pixel;
gcValues.fill_style = FillTiled;
gcValues.tile = *pixmap;
gc = XCreateGC (display,
RootWindowOfScreen (screen),
GCForeground | GCBackground | GCFillStyle | GCTile,
&gcValues);
if ( gc == NULL )
return Urm__UT_Error ("Urm__MapIconBitmap", _MrmMMsg_0036,
NULL, NULL, MrmFAILURE);
/*
* Put bits into the pixmap
*/
XPutImage (display,
*pixmap,
gc,
imagep,
0, 0, /* source x, y */
0, 0, icon->width, icon->height); /* dest, loc & size */
XFreeGC (display, gc);
XFree ((char*)imagep);
/*
* Successfully created
*/
return MrmSUCCESS;
}
/*
*++
*
* PROCEDURE DESCRIPTION:
*
* This routine maps the pixmap in the icon into a bitmap. The
* bitmap is written over pixmap data. The X pixmap is then
* constructed as an XYBitmap.
*
* FORMAL PARAMETERS:
*
* icon the IconImage being converted
* srcpix number of bits/pixel in icon
* screen screen for the X pixmap
* display display for the X pixmap
* pixmap to return the result
*
* IMPLICIT INPUTS:
*
* IMPLICIT OUTPUTS:
*
* FUNCTION VALUE:
*
* SIDE EFFECTS:
*
*--
*/
Cardinal
Urm__MapIconBitmapDepth1 (RGMIconImagePtr icon,
int srcpix,
Screen *screen,
Display *display,
Pixmap *pixmap)
{
/*
* Local variables
*/
int iconwid; /* icon width */
int srclinebyt; /* # bytes per icon line */
int dstlinebyt; /* # bytes per bitmap line */
char *srcbytptr; /* image byte pointer */
char *dstbytptr; /* bitmap pointer */
int lin; /* icon line number */
int byt; /* line byte number */
int pix; /* line pixel number */
unsigned char srcbyt; /* icon image byte */
unsigned char dstbyt; /* mapped image byte */
XImage *imagep; /* X image */
GC gc;
XGCValues gcValues;
int endian; /* to determine which endian. */
/*
* Overwrite the icon data with a bitmap. Use 0 for background, 1 for
* foreground.
*/
iconwid = icon->width;
srclinebyt = (iconwid*srcpix+7) / 8;
dstlinebyt = (iconwid+7) / 8;
srcbytptr = icon->pixel_data.pdptr;
for ( lin=0 ; lin<icon->height ; lin++ )
{
pix = 0;
dstbytptr = icon->pixel_data.pdptr + lin*dstlinebyt;
dstbyt = 0;
for ( byt=0 ; byt<srclinebyt ; byt++ )
{
srcbyt = *srcbytptr;
switch ( icon->pixel_size )
{
case URMPixelSize1Bit:
*dstbytptr = srcbyt;
srcbytptr += 1;
dstbytptr += 1;
pix += 8;
/*
* NOTE: The original algorithm used here cleared any
* unused bits of the last byte. I don't think
* the protocol requires that...
if ( pix > iconwid )
*/
continue;
default:
return MrmNOT_VALID;
}
}
if ( pix%8 != 0 )
*dstbytptr = dstbyt;
}
imagep = XCreateImage(display,
DefaultVisualOfScreen(screen),
1,
XYBitmap,
0,
icon->pixel_data.pdptr,
(unsigned int)icon->width,
(unsigned int)icon->height,
8,
dstlinebyt);
if ( imagep == NULL )
return Urm__UT_Error ("Urm__MapIconBitmapDepth1", _MrmMMsg_0034,
NULL, NULL, MrmFAILURE);
/* Well, Uil creates a uid icon in its byteorder, on his side
XCreateImage creates an image in the byte_order of the server, so
its not correct, we have to adjust the byte_order fields of this
image to match those of the icon. */
endian = 1;
imagep->bitmap_unit = 8 ;
if (*(char *) &endian) {
imagep->byte_order = LSBFirst ;
imagep->bitmap_bit_order = LSBFirst ;
}
else {
imagep->byte_order = MSBFirst;
imagep->bitmap_bit_order = LSBFirst ;
}
*pixmap = XCreatePixmap (display,
RootWindowOfScreen(screen),
icon->width,
icon->height,
1);
if ( *pixmap == (Pixmap)0)
{
XFree((char*)imagep);
return Urm__UT_Error ("Urm__MapIconBitmapDepth1", _MrmMMsg_0035,
NULL, NULL, MrmFAILURE);
}
/*
* Build a gc to use when drawing into the pixmap
*/
gcValues.foreground = 1;
gcValues.background = 0;
gcValues.fill_style = FillTiled;
gcValues.tile = *pixmap;
gc = XCreateGC (display,
*pixmap,
GCForeground | GCBackground | GCFillStyle | GCTile,
&gcValues);
if ( gc == NULL )
return Urm__UT_Error ("Urm__MapIconBitmapDepth1", _MrmMMsg_0036,
NULL, NULL, MrmFAILURE);
/*
* Put bits into the pixmap
*/
XPutImage (display,
*pixmap,
gc,
imagep,
0, 0, /* source x, y */
0, 0, icon->width, icon->height); /* dest, loc & size */
XFreeGC (display, gc);
XFree ((char *)imagep);
/*
* Successfully created
*/
return MrmSUCCESS;
}
/*
*++
*
* PROCEDURE DESCRIPTION:
*
* This routine maps the pixmap in the icon into a ZPixmap. The
* ZPixmap is written over the icon image pixmap data. The X pixmap
* is then constructed as a ZPixmap from the overwritten data.
*
* This routine is called only when srcpix == 8.
*
* FORMAL PARAMETERS:
*
* icon the IconImage being converted
* srcpix number of bits/pixel in icon
* ctable the color table for (in) icon
* screen screen for the X pixmap
* display display for the X pixmap
* pixmap to return the result
*
* IMPLICIT INPUTS:
*
* IMPLICIT OUTPUTS:
*
* FUNCTION VALUE:
*
* SIDE EFFECTS:
*
*--
*/
Cardinal
Urm__MapIconReplace (RGMIconImagePtr icon,
int srcpix,
RGMColorTablePtr ctable,
Screen *screen,
Display *display,
Pixmap *pixmap,
Widget parent)
{
/*
* Local variables
*/
int iconwid; /* icon width */
int linebyt; /* # bytes per icon line */
char *bytptr; /* image byte pointer */
int lin; /* icon line number */
int byt; /* line byte number */
int pix; /* line pixel number */
unsigned char srcbyt; /* icon image byte */
XImage *imagep; /* X image */
GC gc;
XGCValues gcValues;
int depth; /* depth of screen */
/*
* Overwrite the pixmap with actual Pixel values. The source and destination
* bit widths are the same (==8), and the same pointer can be used for
* both source and destination.
*/
iconwid = icon->width;
linebyt = (iconwid*srcpix+7) / 8;
bytptr = icon->pixel_data.pdptr;
for ( lin=0 ; lin<icon->height ; lin++ )
{
pix = 0;
for ( byt=0 ; byt<linebyt ; byt++ )
{
srcbyt = *bytptr;
if ( pix < iconwid )
*bytptr = ctable->item[srcbyt].color_pixel;
pix += 1;
bytptr += 1;
}
}
depth = parent ? parent->core.depth : DefaultDepthOfScreen(screen);
imagep = XCreateImage(display,
DefaultVisualOfScreen(screen),
depth,
ZPixmap,
0,
icon->pixel_data.pdptr,
(unsigned int)icon->width,
(unsigned int)icon->height,
srcpix,
linebyt);
if ( imagep == NULL )
return Urm__UT_Error ("Urm__MapIconReplace", _MrmMMsg_0034,
NULL, NULL, MrmFAILURE);
*pixmap = XCreatePixmap (display,
RootWindowOfScreen(screen),
icon->width,
icon->height,
(unsigned)depth);
if ( *pixmap == (Pixmap)0)
{
XFree((char*)imagep);
return Urm__UT_Error ("Urm__MapIconReplace", _MrmMMsg_0035,
NULL, NULL, MrmFAILURE);
}
/*
* Build a gc to use when drawing into the pixmap
*/
gcValues.foreground = ctable->item[URMColorTableFG].color_pixel;
gcValues.background = ctable->item[URMColorTableBG].color_pixel;
gcValues.fill_style = FillTiled;
gcValues.tile = *pixmap;
gc = XCreateGC (display,
RootWindowOfScreen (screen),
GCForeground | GCBackground | GCFillStyle | GCTile,
&gcValues);
if ( gc == NULL )
return Urm__UT_Error ("Urm__MapIconReplace", _MrmMMsg_0036,
NULL, NULL, MrmFAILURE);
/*
* Put bits into the pixmap
*/
XPutImage (display,
*pixmap,
gc,
imagep,
0, 0, /* source x, y */
0, 0, icon->width, icon->height); /* dest, loc & size */
XFreeGC (display, gc);
XFree((char*)imagep);
/*
* Successfully created
*/
return MrmSUCCESS;
}
/*
*++
*
* PROCEDURE DESCRIPTION:
*
* This routine maps the pixmap in the icon into a ZPixmap. The
* ZPixmap is allocated 1 byte per pixel, as the icon image pixmap
* has too few bits per pixel to be replace in situ. The X pixmap
* is created from the allocated ZPixmap.
*
* FORMAL PARAMETERS:
*
* icon the IconImage being converted
* srcpix number of bits/pixel in icon
* dstpix number of bits/pixel in resulting image
* ctable the color table for (in) icon
* screen screen for the X pixmap
* display display for the X pixmap
* pixmap to return the result
*
* IMPLICIT INPUTS:
*
* IMPLICIT OUTPUTS:
*
* FUNCTION VALUE:
*
* SIDE EFFECTS:
*
*--
*/
Cardinal
Urm__MapIconAllocate (RGMIconImagePtr icon,
int srcpix,
int dstpix,
RGMColorTablePtr ctable,
Screen *screen,
Display *display,
Pixmap *pixmap,
Widget parent)
{
/*
* Local variables
*/
int iconwid; /* icon width */
int iconhgt; /* icon height */
char *alloc_pixmap; /* allocated pixmap */
int dstbytsize; /* # 8-bit bytes per bitmap byte */
int srclinebyt; /* # bytes per icon line */
char *srcbytptr; /* image byte pointer */
int lin; /* icon line number */
int byt; /* line byte number */
int bit; /* bit loop index */
int pix; /* line pixel number */
unsigned char srcbyt; /* icon image byte */
int bitmask = 0; /* mask all but significant bits */
int num_bits = 0; /* real (not coded) pixel size */
int tndx; /* color table index */
XImage *imagep; /* X image */
GC gc;
XGCValues gcValues;
int depth; /* depth of screen */
/*
* Allocate a new pixmap image.
*/
iconwid = icon->width;
iconhgt = icon->height;
if (dstpix <= 8) dstpix = 8;
else if (dstpix <= 16) dstpix = 16;
else dstpix = 32;
dstbytsize = dstpix / 8;
alloc_pixmap = (char *) XtMalloc (iconwid * iconhgt * dstbytsize);
if (alloc_pixmap == NULL)
return Urm__UT_Error ("Urm__MapIconAllocate", _MrmMMsg_0037,
NULL, NULL, MrmFAILURE);
srclinebyt = (iconwid * srcpix + 7) / 8;
srcbytptr = icon->pixel_data.pdptr;
depth = parent ? parent->core.depth : DefaultDepthOfScreen(screen);
imagep = XCreateImage(display,
DefaultVisualOfScreen(screen),
depth,
ZPixmap,
0,
alloc_pixmap,
iconwid,
iconhgt,
dstpix,
0); /* Let Xlib calculate it. */
if ( imagep == NULL )
{
XtFree (alloc_pixmap);
return Urm__UT_Error ("Urm__MapIconAllocate", _MrmMMsg_0034,
NULL, NULL, MrmFAILURE);
}
if(icon->pixel_size == URMPixelSize1Bit)
{ num_bits = 1; bitmask=0x1; }
else if(icon->pixel_size == URMPixelSize2Bit)
{ num_bits = 2; bitmask=0x3; }
else if(icon->pixel_size == URMPixelSize4Bit)
{ num_bits = 4; bitmask=0xF; }
else if(icon->pixel_size == URMPixelSize8Bit)
{ num_bits = 8; bitmask=0xFF; }
for ( pix=0,lin=0 ; lin<icon->height ; pix=0,lin++ )
{
for ( byt=0 ; byt<srclinebyt ; byt++,srcbytptr++ )
{
srcbyt = *srcbytptr;
for ( bit=0 ; bit<8 ; bit+=num_bits )
{
tndx = srcbyt & bitmask;
if ( pix < iconwid )
XPutPixel(imagep, pix, lin, ctable->item[tndx].color_pixel);
pix++;
srcbyt >>= num_bits;
}
}
}
*pixmap = XCreatePixmap (display,
RootWindowOfScreen(screen),
iconwid,
iconhgt,
(unsigned)depth);
if ( *pixmap == (Pixmap)0)
{
XtFree (alloc_pixmap);
XFree((char*)imagep);
return Urm__UT_Error ("Urm__MapIconAllocate", _MrmMMsg_0035,
NULL, NULL, MrmFAILURE);
}
/*
* Build a gc to use when drawing into the pixmap
*/
gcValues.foreground = ctable->item[URMColorTableFG].color_pixel;
gcValues.background = ctable->item[URMColorTableBG].color_pixel;
gcValues.fill_style = FillTiled;
gcValues.tile = *pixmap;
gc = XCreateGC (display,
RootWindowOfScreen (screen),
GCForeground | GCBackground | GCFillStyle | GCTile,
&gcValues);
if ( gc == NULL )
{
XtFree (alloc_pixmap);
return Urm__UT_Error ("Urm__MapIconAllocate", _MrmMMsg_0036,
NULL, NULL, MrmFAILURE);
}
/*
* Put bits into the pixmap
*/
XPutImage (display,
*pixmap,
gc,
imagep,
0, 0, /* source x, y */
0, 0, iconwid, iconhgt); /* dest, loc & size */
/*
* don't deallocate with XDestroyImage, which would destroy alloc_pixmap
*/
XFree((char*)imagep);
XFreeGC (display, gc);
XtFree (alloc_pixmap);
/*
* Successfully created
*/
return MrmSUCCESS;
}
/*
*++
*
* PROCEDURE DESCRIPTION:
*
* This routine sets the Pixel values corresponding to each of the
* entries in the color table. Foreground and background are set by
* querying the widget for those values, or falling back on
* Black/WhitePixelOfScreen. All other colors are set by honoring
* FG/BG setting for monochrome devices, or by getting the xolor
* Pixel values from X.
*
* FORMAL PARAMETERS:
*
* screen screen to use for color table
* display display to use for color table
* fgpix foreground color for color table
* bgpix background color for color table
* ctable the color table
*
* IMPLICIT INPUTS:
*
* IMPLICIT OUTPUTS:
*
* FUNCTION VALUE:
*
* SIDE EFFECTS:
*
*--
*/
Cardinal
Urm__RealizeColorTable (Screen *screen,
Display *display,
Pixel fgpix,
Pixel bgpix,
RGMColorTablePtr ctable,
Widget parent)
{
/*
* Local variables
*/
Cardinal result = 0; /* function results */
Cardinal ndx; /* loop index */
RGMColorTableEntryPtr citem; /* color table entry */
Colormap cmap; /* default color map */
int depth; /* # planes in screen */
char err_msg[300];
/*
* Load the foreground and background pixel values.
*/
ctable->item[URMColorTableFG].color_pixel = fgpix;
ctable->item[URMColorTableBG].color_pixel = bgpix;
/*
* Get the Pixel for each defined color. Honor the FG/BG specification
* if present on monochrome displays. Otherwise, get the Pixel value for
* the color. Use the FG/BG specification as a fallback for unfound
* colors in non-monochrome. If no reasonable color Pixel can be found,
* return an error.
*/
cmap = parent ? parent->core.colormap : DefaultColormapOfScreen(screen);
depth = parent ? parent->core.depth : DefaultDepthOfScreen(screen);
for ( ndx=URMColorTableUserMin ; ndx<ctable->count ; ndx++ )
{
citem = &ctable->item[ndx];
if ( depth == 1 )
switch ( citem->color_item.cptr->mono_state )
{
case URMColorMonochromeUnspecified:
switch (citem->color_item.cptr->desc_type)
{
case URMColorDescTypeName:
result = Urm__UT_GetNamedColorPixel
(display, cmap, citem->color_item.cptr, &citem->color_pixel,
ctable->item[URMColorTableBG].color_pixel);
if ( result != MrmSUCCESS) {
/* we use PARTIAL_SUCCESS only to indicate
the color allocation failed and we've
substituted the fallback color. We still
want a warning, though */
if (result == MrmPARTIAL_SUCCESS) {
result = MrmSUCCESS;
sprintf (err_msg, _MrmMMsg_0038,
citem->color_item.cptr->desc.name);
return Urm__UT_Error ("Urm__RealizeColorTable",
err_msg, NULL, NULL, result);
} else {
sprintf (err_msg, _MrmMMsg_0038,
citem->color_item.cptr->desc.name);
return Urm__UT_Error ("Urm__RealizeColorTable",
err_msg, NULL, NULL, result);
}
}
break;
case URMColorDescTypeRGB:
result = Urm__UT_GetColorPixel
(display, cmap, citem->color_item.cptr, &citem->color_pixel,
ctable->item[URMColorTableBG].color_pixel);
if ( result != MrmSUCCESS ) {
/* we use PARTIAL_SUCCESS only to indicate
the color allocation failed and we've
substituted the fallback color. We still
want a warning, though */
if (result == MrmPARTIAL_SUCCESS) {
result = MrmSUCCESS;
sprintf (err_msg, _MrmMMsg_0038,
citem->color_item.cptr->desc.name);
return Urm__UT_Error ("Urm__RealizeColorTable",
err_msg, NULL, NULL, result);
} else {
sprintf (err_msg, _MrmMMsg_0039,
citem->color_item.cptr->desc.rgb.red,
citem->color_item.cptr->desc.rgb.green,
citem->color_item.cptr->desc.rgb.blue) ;
return Urm__UT_Error ("Urm__RealizeColorTable",
err_msg, NULL, NULL, result);
}
}
break;
default:
sprintf(err_msg, "%s", _MrmMMsg_0040);
return Urm__UT_Error ("Urm__RelizeColorTable",
err_msg, NULL, NULL, MrmFAILURE) ;
}
break;
case URMColorMonochromeForeground:
citem->color_pixel =
ctable->item[URMColorTableFG].color_pixel;
break;
case URMColorMonochromeBackground:
citem->color_pixel =
ctable->item[URMColorTableBG].color_pixel;
break;
default:
sprintf (err_msg, _MrmMMsg_0041,
citem->color_item.cptr->mono_state);
return Urm__UT_Error ("Urm__RealizeColorTable",
err_msg, NULL, NULL, result);
}
else
{
switch (citem->color_item.cptr->desc_type)
{
case URMColorDescTypeName:
result = Urm__UT_GetNamedColorPixel
(display, cmap, citem->color_item.cptr, &citem->color_pixel,
((citem->color_item.cptr->mono_state ==
URMColorMonochromeForeground) ?
ctable->item[URMColorTableFG].color_pixel :
ctable->item[URMColorTableBG].color_pixel));
if (result != MrmSUCCESS) {
/* we use PARTIAL_SUCCESS only to indicate
the color allocation failed and we've
substituted the fallback color. We still
want a warning, though */
if (result == MrmPARTIAL_SUCCESS) {
result = MrmSUCCESS;
sprintf (err_msg, _MrmMMsg_0038,
citem->color_item.cptr->desc.name);
return Urm__UT_Error ("Urm__RealizeColorTable",
err_msg, NULL, NULL, result);
} else {
sprintf (err_msg, _MrmMMsg_0038,
citem->color_item.cptr->desc.name);
Urm__UT_Error ("Urm__RealizeColorTable",
err_msg, NULL, NULL, result);
}
}
break;
case URMColorDescTypeRGB:
result = Urm__UT_GetColorPixel
(display, cmap, citem->color_item.cptr, &citem->color_pixel,
ctable->item[URMColorTableBG].color_pixel);
if (result != MrmSUCCESS) {
/* we use PARTIAL_SUCCESS only to indicate
the color allocation failed and we've
substituted the fallback color. We still
want a warning, though */
if (result == MrmPARTIAL_SUCCESS) {
result = MrmSUCCESS;
sprintf (err_msg, _MrmMMsg_0038,
citem->color_item.cptr->desc.name);
return Urm__UT_Error ("Urm__RealizeColorTable",
err_msg, NULL, NULL, result);
} else {
sprintf (err_msg, _MrmMMsg_0039,
citem->color_item.cptr->desc.rgb.red,
citem->color_item.cptr->desc.rgb.green,
citem->color_item.cptr->desc.rgb.blue) ;
Urm__UT_Error ("Urm__RealizeColorTable",
err_msg, NULL, NULL, result);
}
}
break;
default:
result = MrmFAILURE;
sprintf (err_msg, "%s", _MrmMMsg_0040);
Urm__UT_Error ("Urm__RelizeColorTable",
err_msg, NULL, NULL, MrmFAILURE) ;
}
if ( result != MrmSUCCESS )
{
switch ( citem->color_item.cptr->mono_state )
{
case URMColorMonochromeForeground:
citem->color_pixel =
ctable->item[URMColorTableFG].color_pixel;
break;
case URMColorMonochromeBackground:
citem->color_pixel =
ctable->item[URMColorTableBG].color_pixel;
break;
default:
return result;
}
}
}
}
return MrmSUCCESS;
}
/*
*++
*
* PROCEDURE DESCRIPTION:
*
* This routine makes a copy of a URM icon into a memory block
* which has been pre-allocated. The block must be big enough
* to hold both the header and the bit vector.
*
* FORMAL PARAMETERS:
*
* dst_icon the memory block to receive the copy
* src_icon the URM icon descriptor to be copied.
*
* IMPLICIT INPUTS:
*
* IMPLICIT OUTPUTS:
*
* FUNCTION VALUE:
*
* SIDE EFFECTS:
*
*--
*/
RGMIconImagePtr
UrmCopyAllocatedIconImage (RGMIconImagePtr dst_icon,
RGMIconImagePtr src_icon)
{
/*
* Copy the header and bit vector into the new memory block.
*/
dst_icon->validation = URMIconImageValid;
dst_icon->pixel_size = src_icon->pixel_size;
dst_icon->width = src_icon->width;
dst_icon->height = src_icon->height;
dst_icon->hot_x = src_icon->hot_x;
dst_icon->hot_y = src_icon->hot_y;
/*
* Copy the color table as an immediate. It is allocated immediately
* after the image header.
*/
/*
* Copy the pixel data
*/
return dst_icon;
}
/*
*++
*
* PROCEDURE DESCRIPTION:
*
* This routine attempts to look up the name of a color, and return
* the pixel value required as a widget arglist value. It will use
* the default color map if necessary, and returns the closest color
* supported by the hardware (as defined by X), not the exact database
* definition. If the screen is depth 1 (monochrome), the routine will
* honor the monochrome rendition specified in the color descriptor.
*
* FORMAL PARAMETERS:
*
* display specifies the X server connection
* cmap color map ID. If NULL, the default color map is used
* colorptr color descriptor
* pixel_return to return the pixel value for the color
* fallback fallback color to use in case of alloc failure
*
* IMPLICIT INPUTS:
*
* IMPLICIT OUTPUTS:
*
* FUNCTION VALUE:
*
* MrmSUCCESS color found and translated
* MrmNOT_FOUND conversion failure
* MrmPARTIAL_SUCCESS internal only, for allocation failure
*
* SIDE EFFECTS:
*
*--
*/
Cardinal
Urm__UT_GetNamedColorPixel (Display *display,
Colormap cmap,
RGMColorDescPtr colorptr,
Pixel *pixel_return,
Pixel fallback)
{
/*
* Local variables
*/
XColor screen_def; /* realizable values */
XColor exact_def; /* exact values */
int status; /* function return */
if ( cmap == (Colormap)0)
cmap = DefaultColormap (display, DefaultScreen(display));
/* CR 9891: Support new pixel constants. */
if (XmeNamesAreEqual(colorptr->desc.name, "default_select_color"))
{
*pixel_return = XmDEFAULT_SELECT_COLOR;
return MrmSUCCESS;
}
else if (XmeNamesAreEqual(colorptr->desc.name, "reversed_ground_colors"))
{
*pixel_return = XmREVERSED_GROUND_COLORS;
return MrmSUCCESS;
}
else if (XmeNamesAreEqual(colorptr->desc.name, "highlight_color"))
{
*pixel_return = XmHIGHLIGHT_COLOR;
return MrmSUCCESS;
}
status = XAllocNamedColor
(display, cmap, colorptr->desc.name, &screen_def, &exact_def);
if ( status == 0) {
if (fallback) {
*pixel_return = fallback;
return MrmPARTIAL_SUCCESS;
}
else
return MrmFAILURE;
}
*pixel_return = screen_def.pixel;
return MrmSUCCESS;
}
/*
*++
*
* PROCEDURE DESCRIPTION:
*
* This routine attempts to look up the RGB values of a color, and return
* the pixel value required as a widget arglist value. It will use
* the default color map if necessary, and returns the closest color
* supported by the hardware (as defined by X), not the exact database
* definition. If the screen is depth 1 (monochrome), the routine will
* honor the monochrome rendition specified in the color descriptor.
*
* FORMAL PARAMETERS:
*
* display specifies the X server connection
* cmap color map ID. If NULL, the default color map is used
* colorptr color descriptor
* pixel_return to return the pixel value for the color
* fallback fallback color to use in case of alloc failure
*
* IMPLICIT INPUTS:
*
* IMPLICIT OUTPUTS:
*
* FUNCTION VALUE:
*
* MrmSUCCESS color found and translated
* MrmNOT_FOUND conversion failure
* MrmPARTIAL_SUCCESS internal only, for allocation failure
*
* SIDE EFFECTS:
*
*--
*/
Cardinal
Urm__UT_GetColorPixel (Display *display,
Colormap cmap,
RGMColorDescPtr colorptr,
Pixel *pixel_return,
Pixel fallback)
{
/*
* Local variables
*/
XColor screen_in_out; /* realizable values */
int status; /* function return */
if ( cmap == (Colormap)0)
cmap = DefaultColormap (display, DefaultScreen(display));
screen_in_out.red = colorptr->desc.rgb.red;
screen_in_out.green = colorptr->desc.rgb.green;
screen_in_out.blue = colorptr->desc.rgb.blue;
status = XAllocColor (display, cmap, &screen_in_out);
if ( status == 0) {
if (fallback) {
*pixel_return = fallback;
return MrmPARTIAL_SUCCESS;
} else
return MrmFAILURE;
}
*pixel_return = screen_in_out.pixel;
return MrmSUCCESS;
}
/*
*++
*
* PROCEDURE DESCRIPTION:
*
* This routine computes the number of bytes used by a URM icon
*
* FORMAL PARAMETERS:
*
* icon URM icon image
*
* IMPLICIT INPUTS:
*
* IMPLICIT OUTPUTS:
*
* FUNCTION VALUE:
*
* # bytes in the image
*
* SIDE EFFECTS:
*
*--
*/
Cardinal
UrmIconImageSize (RGMIconImagePtr icon)
{
/*
* Local variables
*/
int bytes_per_line; /* # bytes for padded width */
int raster_len; /* bytes in image */
Cardinal size; /* # bytes in descriptor */
bytes_per_line = (icon->width+7) / 8;
raster_len = bytes_per_line * icon->height;
size = sizeof(RGMIconImage) + (raster_len-1)*sizeof(char);
return size;
}
/*
*++
*
* PROCEDURE DESCRIPTION:
*
* This routine computes the number of bytes necessary to store
* the given color table in a single memory block.
*
* FORMAL PARAMETERS:
*
* ctable An allocated color table
*
* IMPLICIT INPUTS:
*
* IMPLICIT OUTPUTS:
*
* FUNCTION VALUE:
*
* table size in bytes
*
* SIDE EFFECTS:
*
*--
*/
/*ARGSUSED*/
Cardinal
UrmColorTableSize (RGMColorTablePtr ctable) /* unused */
{
return sizeof(RGMColorTable);
}
|