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 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF. The full HDF copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF/releases/. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/***********************************************************
*
* Test program: mgr
*
* Test the multi-file raster image interface
*
*************************************************************/
#define TESTFILE "tmgr.hdf"
#define TESTFILE2 "tmgrchk.hdf"
#define DATAFILE "test_files/tmgr.dat"
#include "tproto.h"
#include "mfgr.h"
#include "mfgr_priv.h"
/* Local pre-processor macros */
#define XDIM 0
#define YDIM 1
#define MAX_IMG_NAME 64 /* Maximum length of image names for this test */
/* Local Data to verify image information in datafile */
const struct {
const char *name;
int32 ncomp;
int32 nt;
int32 il;
int32 dimsizes[2];
int32 n_attr;
} datafile_info[] = {/* This information applies to the "test_files/tmgr.dat" file */
{"Raster Image #0", 3, DFNT_UCHAR8, MFGR_INTERLACE_PIXEL, {13, 15}, 2},
{"Raster Image #1", 3, DFNT_UCHAR8, MFGR_INTERLACE_LINE, {13, 15}, 2},
{"Raster Image #2", 3, DFNT_UCHAR8, MFGR_INTERLACE_COMPONENT, {13, 15}, 2},
{"Test Image #1", 4, DFNT_UINT16, MFGR_INTERLACE_PIXEL, {21, 23}, 3},
{"Test Image #2", 2, DFNT_FLOAT64, MFGR_INTERLACE_PIXEL, {17, 19}, 3}};
const uint8 image00[15][13][3] = {{{0, 0, 0},
{1, 1, 1},
{2, 2, 2},
{3, 3, 3},
{4, 4, 4},
{5, 5, 5},
{6, 6, 6},
{7, 7, 7},
{8, 8, 8},
{9, 9, 9},
{10, 10, 10},
{11, 11, 11},
{12, 12, 12}},
{{1, 1, 1},
{2, 2, 2},
{3, 3, 3},
{4, 4, 4},
{5, 5, 5},
{6, 6, 6},
{7, 7, 7},
{8, 8, 8},
{9, 9, 9},
{10, 10, 10},
{11, 11, 11},
{12, 12, 12},
{13, 13, 13}},
{{2, 2, 2},
{3, 3, 3},
{4, 4, 4},
{5, 5, 5},
{6, 6, 6},
{7, 7, 7},
{8, 8, 8},
{9, 9, 9},
{10, 10, 10},
{11, 11, 11},
{12, 12, 12},
{13, 13, 13},
{14, 14, 14}},
{{3, 3, 3},
{4, 4, 4},
{5, 5, 5},
{6, 6, 6},
{7, 7, 7},
{8, 8, 8},
{9, 9, 9},
{10, 10, 10},
{11, 11, 11},
{12, 12, 12},
{13, 13, 13},
{14, 14, 14},
{15, 15, 15}},
{{4, 4, 4},
{5, 5, 5},
{6, 6, 6},
{7, 7, 7},
{8, 8, 8},
{9, 9, 9},
{10, 10, 10},
{11, 11, 11},
{12, 12, 12},
{13, 13, 13},
{14, 14, 14},
{15, 15, 15},
{16, 16, 16}},
{{5, 5, 5},
{6, 6, 6},
{7, 7, 7},
{8, 8, 8},
{9, 9, 9},
{10, 10, 10},
{11, 11, 11},
{12, 12, 12},
{13, 13, 13},
{14, 14, 14},
{15, 15, 15},
{16, 16, 16},
{17, 17, 17}},
{{6, 6, 6},
{7, 7, 7},
{8, 8, 8},
{9, 9, 9},
{10, 10, 10},
{11, 11, 11},
{12, 12, 12},
{13, 13, 13},
{14, 14, 14},
{15, 15, 15},
{16, 16, 16},
{17, 17, 17},
{18, 18, 18}},
{{7, 7, 7},
{8, 8, 8},
{9, 9, 9},
{10, 10, 10},
{11, 11, 11},
{12, 12, 12},
{13, 13, 13},
{14, 14, 14},
{15, 15, 15},
{16, 16, 16},
{17, 17, 17},
{18, 18, 18},
{19, 19, 19}},
{{8, 8, 8},
{9, 9, 9},
{10, 10, 10},
{11, 11, 11},
{12, 12, 12},
{13, 13, 13},
{14, 14, 14},
{15, 15, 15},
{16, 16, 16},
{17, 17, 17},
{18, 18, 18},
{19, 19, 19},
{20, 20, 20}},
{{9, 9, 9},
{10, 10, 10},
{11, 11, 11},
{12, 12, 12},
{13, 13, 13},
{14, 14, 14},
{15, 15, 15},
{16, 16, 16},
{17, 17, 17},
{18, 18, 18},
{19, 19, 19},
{20, 20, 20},
{21, 21, 21}},
{{10, 10, 10},
{11, 11, 11},
{12, 12, 12},
{13, 13, 13},
{14, 14, 14},
{15, 15, 15},
{16, 16, 16},
{17, 17, 17},
{18, 18, 18},
{19, 19, 19},
{20, 20, 20},
{21, 21, 21},
{22, 22, 22}},
{{11, 11, 11},
{12, 12, 12},
{13, 13, 13},
{14, 14, 14},
{15, 15, 15},
{16, 16, 16},
{17, 17, 17},
{18, 18, 18},
{19, 19, 19},
{20, 20, 20},
{21, 21, 21},
{22, 22, 22},
{23, 23, 23}},
{{12, 12, 12},
{13, 13, 13},
{14, 14, 14},
{15, 15, 15},
{16, 16, 16},
{17, 17, 17},
{18, 18, 18},
{19, 19, 19},
{20, 20, 20},
{21, 21, 21},
{22, 22, 22},
{23, 23, 23},
{24, 24, 24}},
{{13, 13, 13},
{14, 14, 14},
{15, 15, 15},
{16, 16, 16},
{17, 17, 17},
{18, 18, 18},
{19, 19, 19},
{20, 20, 20},
{21, 21, 21},
{22, 22, 22},
{23, 23, 23},
{24, 24, 24},
{25, 25, 25}},
{{14, 14, 14},
{15, 15, 15},
{16, 16, 16},
{17, 17, 17},
{18, 18, 18},
{19, 19, 19},
{20, 20, 20},
{21, 21, 21},
{22, 22, 22},
{23, 23, 23},
{24, 24, 24},
{25, 25, 25},
{26, 26, 26}}};
const uint8 image1[15][13][3] = {{{0, 1, 2},
{3, 4, 5},
{6, 7, 8},
{9, 10, 11},
{12, 0, 1},
{2, 3, 4},
{5, 6, 7},
{8, 9, 10},
{11, 12, 0},
{1, 2, 3},
{4, 5, 6},
{7, 8, 9},
{10, 11, 12}},
{{1, 1, 3},
{3, 5, 5},
{7, 7, 9},
{9, 11, 11},
{13, 1, 1},
{3, 3, 5},
{5, 7, 7},
{9, 9, 11},
{11, 13, 1},
{1, 3, 3},
{5, 5, 7},
{7, 9, 9},
{11, 11, 13}},
{{2, 3, 2},
{3, 6, 7},
{6, 7, 10},
{11, 10, 11},
{14, 2, 3},
{2, 3, 6},
{7, 6, 7},
{10, 11, 10},
{11, 14, 2},
{3, 2, 3},
{6, 7, 6},
{7, 10, 11},
{10, 11, 14}},
{{3, 3, 3},
{3, 7, 7},
{7, 7, 11},
{11, 11, 11},
{15, 3, 3},
{3, 3, 7},
{7, 7, 7},
{11, 11, 11},
{11, 15, 3},
{3, 3, 3},
{7, 7, 7},
{7, 11, 11},
{11, 11, 15}},
{{4, 5, 6},
{7, 4, 5},
{6, 7, 12},
{13, 14, 15},
{12, 4, 5},
{6, 7, 4},
{5, 6, 7},
{12, 13, 14},
{15, 12, 4},
{5, 6, 7},
{4, 5, 6},
{7, 12, 13},
{14, 15, 12}},
{{5, 5, 7},
{7, 5, 5},
{7, 7, 13},
{13, 15, 15},
{13, 5, 5},
{7, 7, 5},
{5, 7, 7},
{13, 13, 15},
{15, 13, 5},
{5, 7, 7},
{5, 5, 7},
{7, 13, 13},
{15, 15, 13}},
{{6, 7, 6},
{7, 6, 7},
{6, 7, 14},
{15, 14, 15},
{14, 6, 7},
{6, 7, 6},
{7, 6, 7},
{14, 15, 14},
{15, 14, 6},
{7, 6, 7},
{6, 7, 6},
{7, 14, 15},
{14, 15, 14}},
{{7, 7, 7},
{7, 7, 7},
{7, 7, 15},
{15, 15, 15},
{15, 7, 7},
{7, 7, 7},
{7, 7, 7},
{15, 15, 15},
{15, 15, 7},
{7, 7, 7},
{7, 7, 7},
{7, 15, 15},
{15, 15, 15}},
{{8, 9, 10},
{11, 12, 13},
{14, 15, 8},
{9, 10, 11},
{12, 8, 9},
{10, 11, 12},
{13, 14, 15},
{8, 9, 10},
{11, 12, 8},
{9, 10, 11},
{12, 13, 14},
{15, 8, 9},
{10, 11, 12}},
{{9, 9, 11},
{11, 13, 13},
{15, 15, 9},
{9, 11, 11},
{13, 9, 9},
{11, 11, 13},
{13, 15, 15},
{9, 9, 11},
{11, 13, 9},
{9, 11, 11},
{13, 13, 15},
{15, 9, 9},
{11, 11, 13}},
{{10, 11, 10},
{11, 14, 15},
{14, 15, 10},
{11, 10, 11},
{14, 10, 11},
{10, 11, 14},
{15, 14, 15},
{10, 11, 10},
{11, 14, 10},
{11, 10, 11},
{14, 15, 14},
{15, 10, 11},
{10, 11, 14}},
{{11, 11, 11},
{11, 15, 15},
{15, 15, 11},
{11, 11, 11},
{15, 11, 11},
{11, 11, 15},
{15, 15, 15},
{11, 11, 11},
{11, 15, 11},
{11, 11, 11},
{15, 15, 15},
{15, 11, 11},
{11, 11, 15}},
{{12, 13, 14},
{15, 12, 13},
{14, 15, 12},
{13, 14, 15},
{12, 12, 13},
{14, 15, 12},
{13, 14, 15},
{12, 13, 14},
{15, 12, 12},
{13, 14, 15},
{12, 13, 14},
{15, 12, 13},
{14, 15, 12}},
{{13, 13, 15},
{15, 13, 13},
{15, 15, 13},
{13, 15, 15},
{13, 13, 13},
{15, 15, 13},
{13, 15, 15},
{13, 13, 15},
{15, 13, 13},
{13, 15, 15},
{13, 13, 15},
{15, 13, 13},
{15, 15, 13}},
{{14, 15, 14},
{15, 14, 15},
{14, 15, 14},
{15, 14, 15},
{14, 14, 15},
{14, 15, 14},
{15, 14, 15},
{14, 15, 14},
{15, 14, 14},
{15, 14, 15},
{14, 15, 14},
{15, 14, 15},
{14, 15, 14}}};
const uint8 image2[15][13][3] = {{{0, 1, 2},
{3, 4, 5},
{6, 7, 8},
{9, 10, 11},
{12, 1, 0},
{3, 2, 5},
{4, 7, 6},
{9, 8, 11},
{10, 13, 2},
{3, 0, 1},
{6, 7, 4},
{5, 10, 11},
{8, 9, 14}},
{{3, 2, 1},
{0, 7, 6},
{5, 4, 11},
{10, 9, 8},
{15, 4, 5},
{6, 7, 0},
{1, 2, 3},
{12, 13, 14},
{15, 8, 5},
{4, 7, 6},
{1, 0, 3},
{2, 13, 12},
{15, 14, 9}},
{{6, 7, 4},
{5, 2, 3},
{0, 1, 14},
{15, 12, 13},
{10, 7, 6},
{5, 4, 3},
{2, 1, 0},
{15, 14, 13},
{12, 11, 8},
{9, 10, 11},
{12, 13, 14},
{15, 0, 1},
{2, 3, 4}},
{{9, 8, 11},
{10, 13, 12},
{15, 14, 1},
{0, 3, 2},
{5, 10, 11},
{8, 9, 14},
{15, 12, 13},
{2, 3, 0},
{1, 6, 11},
{10, 9, 8},
{15, 14, 13},
{12, 3, 2},
{1, 0, 7}},
{{12, 13, 14},
{15, 8, 9},
{10, 11, 4},
{5, 6, 7},
{0, 13, 12},
{15, 14, 9},
{8, 11, 10},
{5, 4, 7},
{6, 1, 14},
{15, 12, 13},
{10, 11, 8},
{9, 6, 7},
{4, 5, 2}},
{{0, 1, 2},
{3, 4, 5},
{6, 7, 8},
{9, 10, 11},
{12, 1, 0},
{3, 2, 5},
{4, 7, 6},
{9, 8, 11},
{10, 13, 2},
{3, 0, 1},
{6, 7, 4},
{5, 10, 11},
{8, 9, 14}},
{{3, 2, 1},
{0, 7, 6},
{5, 4, 11},
{10, 9, 8},
{15, 4, 5},
{6, 7, 0},
{1, 2, 3},
{12, 13, 14},
{15, 8, 5},
{4, 7, 6},
{1, 0, 3},
{2, 13, 12},
{15, 14, 9}},
{{6, 7, 4},
{5, 2, 3},
{0, 1, 14},
{15, 12, 13},
{10, 7, 6},
{5, 4, 3},
{2, 1, 0},
{15, 14, 13},
{12, 11, 8},
{9, 10, 11},
{12, 13, 14},
{15, 0, 1},
{2, 3, 4}},
{{9, 8, 11},
{10, 13, 12},
{15, 14, 1},
{0, 3, 2},
{5, 10, 11},
{8, 9, 14},
{15, 12, 13},
{2, 3, 0},
{1, 6, 11},
{10, 9, 8},
{15, 14, 13},
{12, 3, 2},
{1, 0, 7}},
{{12, 13, 14},
{15, 8, 9},
{10, 11, 4},
{5, 6, 7},
{0, 13, 12},
{15, 14, 9},
{8, 11, 10},
{5, 4, 7},
{6, 1, 14},
{15, 12, 13},
{10, 11, 8},
{9, 6, 7},
{4, 5, 2}},
{{0, 1, 2},
{3, 4, 5},
{6, 7, 8},
{9, 10, 11},
{12, 1, 0},
{3, 2, 5},
{4, 7, 6},
{9, 8, 11},
{10, 13, 2},
{3, 0, 1},
{6, 7, 4},
{5, 10, 11},
{8, 9, 14}},
{{3, 2, 1},
{0, 7, 6},
{5, 4, 11},
{10, 9, 8},
{15, 4, 5},
{6, 7, 0},
{1, 2, 3},
{12, 13, 14},
{15, 8, 5},
{4, 7, 6},
{1, 0, 3},
{2, 13, 12},
{15, 14, 9}},
{{6, 7, 4},
{5, 2, 3},
{0, 1, 14},
{15, 12, 13},
{10, 7, 6},
{5, 4, 3},
{2, 1, 0},
{15, 14, 13},
{12, 11, 8},
{9, 10, 11},
{12, 13, 14},
{15, 0, 1},
{2, 3, 4}},
{{9, 8, 11},
{10, 13, 12},
{15, 14, 1},
{0, 3, 2},
{5, 10, 11},
{8, 9, 14},
{15, 12, 13},
{2, 3, 0},
{1, 6, 11},
{10, 9, 8},
{15, 14, 13},
{12, 3, 2},
{1, 0, 7}},
{{12, 13, 14},
{15, 8, 9},
{10, 11, 4},
{5, 6, 7},
{0, 13, 12},
{15, 14, 9},
{8, 11, 10},
{5, 4, 7},
{6, 1, 14},
{15, 12, 13},
{10, 11, 8},
{9, 6, 7},
{4, 5, 2}}};
const uint16 image3[23][21][4] = {
{{0, 1, 2, 3}, {1, 2, 3, 4}, {2, 3, 4, 5}, {3, 4, 5, 6}, {4, 5, 6, 7}, {5, 6, 7, 8}, {6, 7, 8, 9},
{7, 8, 9, 10}, {8, 9, 10, 11}, {9, 10, 11, 12}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}},
{{0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0},
{2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2},
{0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}},
{{10, 11, 12, 13}, {2, 2, 2, 2}, {12, 13, 14, 15}, {2, 2, 2, 2}, {14, 15, 16, 17}, {2, 2, 2, 2},
{16, 17, 18, 19}, {2, 2, 2, 2}, {18, 19, 20, 21}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2},
{0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2},
{0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}},
{{0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0},
{2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2},
{0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}},
{{20, 21, 22, 23}, {2, 2, 2, 2}, {1, 2, 3, 4}, {2, 2, 2, 2}, {3, 4, 5, 6}, {2, 2, 2, 2}, {5, 6, 7, 8},
{2, 2, 2, 2}, {7, 8, 9, 10}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2},
{0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}},
{{0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0},
{2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2},
{0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}},
{{9, 10, 11, 12}, {2, 2, 2, 2}, {11, 12, 13, 14}, {2, 2, 2, 2}, {13, 14, 15, 16}, {2, 2, 2, 2},
{15, 16, 17, 18}, {2, 2, 2, 2}, {17, 18, 19, 20}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2},
{0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2},
{0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}},
{{0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0},
{2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2},
{0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}},
{{19, 20, 21, 22}, {2, 2, 2, 2}, {0, 1, 2, 3}, {2, 2, 2, 2}, {2, 3, 4, 5}, {2, 2, 2, 2}, {4, 5, 6, 7},
{2, 2, 2, 2}, {6, 7, 8, 9}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2},
{0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}},
{{0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0},
{2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2},
{0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}},
{{8, 9, 10, 11}, {2, 2, 2, 2}, {10, 11, 12, 13}, {2, 2, 2, 2}, {12, 13, 14, 15}, {2, 2, 2, 2},
{14, 15, 16, 17}, {2, 2, 2, 2}, {16, 17, 18, 19}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2},
{0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2},
{0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}},
{{0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0},
{2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2},
{0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}, {2, 2, 2, 2}, {0, 0, 0, 0}},
{{18, 19, 20, 21}, {19, 20, 21, 22}, {20, 21, 22, 23}, {0, 1, 2, 3}, {1, 2, 3, 4}, {2, 3, 4, 5},
{3, 4, 5, 6}, {4, 5, 6, 7}, {5, 6, 7, 8}, {6, 7, 8, 9}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}},
{{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}},
{{7, 8, 9, 10}, {8, 9, 10, 11}, {9, 10, 11, 12}, {10, 11, 12, 13}, {11, 12, 13, 14},
{12, 13, 14, 15}, {13, 14, 15, 16}, {14, 15, 16, 17}, {15, 16, 17, 18}, {16, 17, 18, 19},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}},
{{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}},
{{17, 18, 19, 20}, {18, 19, 20, 21}, {19, 20, 21, 22}, {20, 21, 22, 23}, {0, 1, 2, 3}, {1, 2, 3, 4},
{2, 3, 4, 5}, {3, 4, 5, 6}, {4, 5, 6, 7}, {5, 6, 7, 8}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}},
{{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}},
{{6, 7, 8, 9}, {7, 8, 9, 10}, {8, 9, 10, 11}, {9, 10, 11, 12}, {10, 11, 12, 13},
{11, 12, 13, 14}, {12, 13, 14, 15}, {13, 14, 15, 16}, {14, 15, 16, 17}, {15, 16, 17, 18},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}},
{{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}},
{{16, 17, 18, 19}, {17, 18, 19, 20}, {18, 19, 20, 21}, {19, 20, 21, 22}, {20, 21, 22, 23}, {0, 1, 2, 3},
{1, 2, 3, 4}, {2, 3, 4, 5}, {3, 4, 5, 6}, {4, 5, 6, 7}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}},
{{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}},
{{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}};
const float64 image4[19][17][2] = {{{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0}},
{{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0}},
{{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0}},
{{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0}},
{{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0}},
{{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0}},
{{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0}},
{{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0}},
{{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{6.0, 6.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0}},
{{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{0.0, 0.0}},
{{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{0.0, 0.0}},
{{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{0.0, 0.0}},
{{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{0.0, 0.0}},
{{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{0.0, 0.0}},
{{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{0.0, 0.0}},
{{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{0.0, 0.0}},
{{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{0.0, 0.0}},
{{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{9.0, 9.0},
{0.0, 0.0}},
{{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0},
{0.0, 0.0}}};
static void test_mgr_init(void);
static void test_mgr_image_b1a(int flag);
static void test_mgr_image_b1b(int flag);
static void test_mgr_image_b2a1aa(int flag);
static void test_mgr_image_b2a1bb1(int flag);
static void test_mgr_image_b2a1bb2(int flag);
static void test_mgr_image_b2a1cc1(int flag);
static void test_mgr_image_b2a1cc2(int flag);
static void test_mgr_image_b2a2bb(int flag);
static void test_mgr_image_b2a2cc(int flag);
static void test_mgr_image_b2b1(int flag);
static void test_mgr_image(int flag);
static void test_mgr_index(int flag);
static void test_mgr_interlace(int flag);
static void test_mgr_lut(int flag);
static void test_mgr_special(int flag);
extern void test_mgr_attr();
extern void test_mgr_compress();
extern void test_mgr_dup_images();
/* Test outline:
I. Interface Initialization
A. GRstart
B. GRend
C. GRfileinfo
II. Create Images
A. GRcreate/GRselect/GRendaccess w/GRgetiminfo
B. Write/Read images
1. With no Data
a. Default fill value
b. user defined fill value
2. With real Data
a. New Image
1. With default fill value
aa. Whole image
bb. Sub-setted image
cc. Sub-sampled image
2. With user defined fill value
aa. Whole image
bb. Sub-setted image
cc. Sub-sampled image
b. Existing Image
1. Whole image
2. Sub-setted image
3. Sub-sampled image
III. ID/Ref/Index Functions
A. GRidtoref
B. GRreftoindex
IV. Interlace Functions [Need to be implemented]
A. GRreqlutil
B. GRreqimageil
V. Palette Functions
A. GRgetlutid w/GRgetlutinfo
B. Read/Write Palettes
1. GRwritelut
2. GRreadlut
C. GRluttoref
VI. Special Element Functions [Need to be implemented]
A. GRsetexternalfile
B. GRsetaccesstype
VII. Attribute Functions
A. GRattrinfo
B. Read/Write Attributes
1. GRsetattr
2. GRgetattr
C. GRfindattr
VIII. Old-Style Raster Image Access
A. Read data from RLE compressed image
B. Create RLE compressed image & write to it (not implemented)
C. Read data from 8-bit JPEG compressed image
D. Create 8-bit JPEG compressed image & write to it
E. Read data from 24-bit JPEG compressed image
F. Create 24-bit JPEG compressed image & write to it
IX. Compressed image Functions
X. Chunking write/read test
*/
/****************************************************************
**
** test_mgr_init(): Multi-file Raster Initialization Test Routine
**
** I. Interface Initialization
** A. GRstart
** B. GRend
** C. GRfileinfo
**
****************************************************************/
static void
test_mgr_init(void)
{
int32 fid; /* HDF file ID */
int32 grid; /* GRID for the interface */
int32 n_datasets; /* number of datasets */
int32 n_attrs; /* number of attributes */
int32 ret; /* generic return value */
const char *datafile = get_srcdir_filename(DATAFILE);
/* Output message about test being performed */
MESSAGE(6, printf("Testing Multi-file Raster Initialization routines\n"););
MESSAGE(8, printf("Try creating a new file and checking it out\n"););
/* Create a new file */
fid = Hopen(TESTFILE, DFACC_CREATE, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Try initializing the GR interface */
grid = GRstart(fid);
CHECK_VOID(grid, FAIL, "GRstart");
/* Test getting the number of datasets and the number of file attributes */
ret = (intn)GRfileinfo(grid, &n_datasets, &n_attrs);
CHECK_VOID(ret, FAIL, "GRfileinfo");
if (n_datasets != 0 || n_attrs != 0) {
MESSAGE(3, printf("Error! Number of datasets/attributes in new file incorrect\n"););
num_errs++;
} /* end if */
/* Shut down the GR interface */
ret = GRend(grid);
CHECK_VOID(ret, FAIL, "GRend");
/* Close the file */
ret = Hclose(fid);
CHECK_VOID(ret, FAIL, "Hclose");
MESSAGE(8, printf("Try checking out an existing file\n"););
/* Perform the same test on an existing file */
fid = Hopen(datafile, DFACC_READ, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Try initializing the GR interface */
grid = GRstart(fid);
CHECK_VOID(grid, FAIL, "GRstart");
/* Test getting the number of datasets and the number of file attributes */
ret = (intn)GRfileinfo(grid, &n_datasets, &n_attrs);
CHECK_VOID(ret, FAIL, "GRfileinfo");
if (n_datasets != 5 || n_attrs != 2) {
MESSAGE(3, printf("Error! Number of datasets/attributes in existing file incorrect\n"););
num_errs++;
} /* end if */
/* Shut down the GR interface */
ret = GRend(grid);
CHECK_VOID(ret, FAIL, "GRend");
/* Close the file */
ret = Hclose(fid);
CHECK_VOID(ret, FAIL, "Hclose");
} /* end test_mgr_init() */
/* Sub-tests for test_mgr_image() */
static void
test_mgr_image_b1a(int flag)
{
int32 fid; /* HDF file ID */
int32 grid; /* GRID for the interface */
int32 ret; /* generic return value */
int32 cdims[2] = {1, 1}; /* chunk dims */
int32 *rcdims; /* for SDgetchunkinfo() */
HDF_CHUNK_DEF chunk_def; /* Chunk definition set */
HDF_CHUNK_DEF rchunk_def; /* Chunk definition read */
int32 cflags; /* chunk flags */
/* B1a - Read/Write images - with no Data - Default Fill Value */
MESSAGE(8, printf("Check out I/O on image with no data, using the default fill value\n"););
/* Open up the existing datafile and get the image information from it */
if (flag)
fid = Hopen(TESTFILE2, DFACC_RDWR, 0);
else
fid = Hopen(TESTFILE, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize the GR interface */
grid = GRstart(fid);
CHECK_VOID(grid, FAIL, "GRstart");
{
int32 riid; /* RI ID for the new image */
int32 dims[2] = {4, 5}; /* dimensions for the empty image */
uint16 ref; /* RI ref #. */
int32 index; /* RI index # */
float32 image[5][4][3]; /* space for the image data */
float32 image0[5][4][3]; /* space for the image data */
int32 start[2]; /* start of image data to grab */
int32 stride[2]; /* stride of image data to grab */
/* Create empty image with default fill value */
riid = GRcreate(grid, "Empty Image", 3, DFNT_FLOAT32, MFGR_INTERLACE_PIXEL, dims);
CHECK_VOID(riid, FAIL, "GRcreate");
/* Check if creating chunked GR */
if (flag) {
/* Create chunked GR
chunk is 2x2 which will create 6 chunks */
cdims[0] = chunk_def.chunk_lengths[0] = 2;
cdims[1] = chunk_def.chunk_lengths[1] = 2;
ret = GRsetchunk(riid, chunk_def, HDF_CHUNK);
CHECK_VOID(ret, FAIL, "GRsetchunk");
/* Set Chunk cache to hold 3 chunks */
ret = GRsetchunkcache(riid, 3, 0);
CHECK_VOID(ret, FAIL, "GRsetchunkcache");
}
/* Save the ref. # for later access */
ref = GRidtoref(riid);
CHECK_VOID(ref, (uint16)FAIL, "GRidtoref");
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
/* Get the index of the newly created image */
index = GRreftoindex(grid, ref);
CHECK_VOID(index, FAIL, "GRreftoindex");
/* Select the newly created image */
riid = GRselect(grid, index);
CHECK_VOID(riid, FAIL, "GRselect");
memset(image, 255, (size_t)(dims[0] * dims[1] * 3) * sizeof(float32));
/* '0' is the default fill value */
memset(image0, 0, (size_t)(dims[0] * dims[1] * 3) * sizeof(float32));
start[0] = start[1] = 0;
stride[0] = stride[1] = 1;
ret = GRreadimage(riid, start, stride, dims, image);
CHECK_VOID(ret, FAIL, "GRreadimage");
if (0 != memcmp(image, image0, sizeof(image0))) {
MESSAGE(3, printf("Error reading data for image with default fill value\n"););
num_errs++;
} /* end if */
/* check if we are doing chunked tests */
if (flag) {
/* Get chunk lengths */
ret = GRgetchunkinfo(riid, &rchunk_def, &cflags);
CHECK_VOID(ret, FAIL, "GRgetchunkinfo");
rcdims = rchunk_def.chunk_lengths;
/* check chunk lengths and to see if GR is chunked */
if (cdims[0] != rcdims[0] || cdims[1] != rcdims[1] || cflags != HDF_CHUNK) {
fprintf(stderr, "Chunk Test. GRgetchunkinfo returned wrong values\n");
fprintf(stderr, "cdims[0]=%d,cdims[1]=%d \n", (int)cdims[0], (int)cdims[1]);
fprintf(stderr, "rcdims[0]=%d,rcdims[1]=%d \n", (int)rcdims[0], (int)rcdims[1]);
fprintf(stderr, "cflags =%d \n", (int)cflags);
}
}
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
}
/* Shut down the GR interface */
ret = GRend(grid);
CHECK_VOID(ret, FAIL, "GRend");
/* Close the file */
ret = Hclose(fid);
CHECK_VOID(ret, FAIL, "Hclose");
} /* end test_mgr_image_b1a() */
static void
test_mgr_image_b1b(int flag)
{
int32 fid; /* HDF file ID */
int32 grid; /* GRID for the interface */
int32 ret; /* generic return value */
int32 cdims[2] = {1, 1}; /* chunk dims */
int32 *rcdims; /* for SDgetchunkinfo() */
HDF_CHUNK_DEF chunk_def; /* Chunk definition set */
HDF_CHUNK_DEF rchunk_def; /* Chunk definition read */
int32 cflags; /* chunk flags */
/* B1b - Read/Write images - with no Data - User-defined Fill Value */
MESSAGE(8, printf("Check out I/O on image with no data, using User Defined fill-value\n"););
/* Open up the existing datafile and get the image information from it */
if (flag)
fid = Hopen(TESTFILE2, DFACC_RDWR, 0);
else
fid = Hopen(TESTFILE, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize the GR interface */
grid = GRstart(fid);
CHECK_VOID(grid, FAIL, "GRstart");
{
int32 riid; /* RI ID for the new image */
int32 dims[2] = {5, 7}; /* dimensions for the empty image */
uint16 ref; /* RI ref #. */
int32 index; /* RI index # */
float64 image[7][5][4]; /* space for the image data */
float64 fill_pixel[4] = {1.3, -2.4, 1000.3, .25}; /* pixel with fill values */
float64 image0[7][5][4]; /* space for the image data */
int32 start[2]; /* start of image data to grab */
int32 stride[2]; /* stride of image data to grab */
/* Create empty image with default fill value */
riid = GRcreate(grid, "Empty Image2", 4, DFNT_FLOAT64, MFGR_INTERLACE_PIXEL, dims);
CHECK_VOID(riid, FAIL, "GRcreate");
/* Set the fill-value */
ret = GRsetattr(riid, FILL_ATTR, DFNT_FLOAT64, sizeof(fill_pixel) / sizeof(float64), fill_pixel);
CHECK_VOID(ret, FAIL, "GRsetattr");
/* Check if creating chunked GR */
if (flag) {
/* Create chunked GR
chunk is 2x2 which will create 6 chunks */
cdims[0] = chunk_def.chunk_lengths[0] = 2;
cdims[1] = chunk_def.chunk_lengths[1] = 2;
ret = GRsetchunk(riid, chunk_def, HDF_CHUNK);
CHECK_VOID(ret, FAIL, "GRsetchunk");
}
/* Save the ref. # for later access */
ref = GRidtoref(riid);
CHECK_VOID(ref, (uint16)FAIL, "GRidtoref");
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
/* Get the index of the newly created image */
index = GRreftoindex(grid, ref);
CHECK_VOID(index, FAIL, "GRreftoindex");
/* Select the newly created image */
riid = GRselect(grid, index);
CHECK_VOID(riid, FAIL, "GRselect");
memset(image, 0, (size_t)(dims[0] * dims[1] * 4) * sizeof(float64));
/* fill the memory-only with the default pixel fill-value */
HDmemfill(image0, fill_pixel, sizeof(fill_pixel), sizeof(image0) / sizeof(fill_pixel));
start[0] = start[1] = 0;
stride[0] = stride[1] = 1;
ret = GRreadimage(riid, start, stride, dims, image);
CHECK_VOID(ret, FAIL, "GRreadimage");
if (0 != memcmp(image, image0, sizeof(image0))) {
MESSAGE(3, printf("Error reading data for image with user defined fill-value\n"););
num_errs++;
} /* end if */
/* check if we are doing chunked tests */
if (flag) {
/* Get chunk lengths */
ret = GRgetchunkinfo(riid, &rchunk_def, &cflags);
CHECK_VOID(ret, FAIL, "GRgetchunkinfo");
rcdims = rchunk_def.chunk_lengths;
/* check chunk lengths and to see if GR is chunked */
if (cdims[0] != rcdims[0] || cdims[1] != rcdims[1] || cflags != HDF_CHUNK) {
fprintf(stderr, "Chunk Test. GRgetchunkinfo returned wrong values\n");
fprintf(stderr, "cdims[0]=%d,cdims[1]=%d \n", (int)cdims[0], (int)cdims[1]);
fprintf(stderr, "rcdims[0]=%d,rcdims[1]=%d \n", (int)rcdims[0], (int)rcdims[1]);
fprintf(stderr, "cflags =%d \n", (int)cflags);
}
}
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
}
/* Shut down the GR interface */
ret = GRend(grid);
CHECK_VOID(ret, FAIL, "GRend");
/* Close the file */
ret = Hclose(fid);
CHECK_VOID(ret, FAIL, "Hclose");
} /* end test_mgr_image_b1b() */
static void
test_mgr_image_b2a1aa(int flag)
{
int32 fid; /* HDF file ID */
int32 grid; /* GRID for the interface */
int32 ret; /* generic return value */
int32 cdims[2] = {1, 1}; /* chunk dims */
int32 *rcdims; /* for SDgetchunkinfo() */
HDF_CHUNK_DEF chunk_def; /* Chunk definition set */
HDF_CHUNK_DEF rchunk_def; /* Chunk definition read */
int32 cflags; /* chunk flags */
/* B2a1aa - Read/Write images - with real Data - New Image - with Default Fill Value - Whole Image */
MESSAGE(8, printf("Check out I/O on new image with real data, with Default fill-value, Whole Image\n"););
/* Open up the existing datafile and get the image information from it */
if (flag)
fid = Hopen(TESTFILE2, DFACC_RDWR, 0);
else
fid = Hopen(TESTFILE, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize the GR interface */
grid = GRstart(fid);
CHECK_VOID(grid, FAIL, "GRstart");
{
#ifdef TEST_XDIM
#undef TEST_XDIM
#endif /* TEST_XDIM */
#define TEST_XDIM 3
#ifdef TEST_YDIM
#undef TEST_YDIM
#endif /* TEST_YDIM */
#define TEST_YDIM 8
#ifdef TEST_NCOMP
#undef TEST_NCOMP
#endif /* TEST_NCOMP */
#define TEST_NCOMP 2
#ifdef TEST_VARTYPE
#undef TEST_VARTYPE
#endif /* TEST_VARTYPE */
#define TEST_VARTYPE int32
#ifdef TEST_NT
#undef TEST_NT
#endif /* TEST_NT */
#define TEST_NT DFNT_INT32
int32 riid; /* RI ID for the new image */
int32 dims[2] = {TEST_XDIM, TEST_YDIM}; /* dimensions for the empty image */
uint16 ref; /* RI ref #. */
int32 index; /* RI index # */
TEST_VARTYPE image[TEST_YDIM][TEST_XDIM][TEST_NCOMP]; /* space for the image data */
TEST_VARTYPE fill_pixel[TEST_NCOMP] = {1, -2}; /* pixel with fill values */
TEST_VARTYPE fill_pixel2[TEST_NCOMP] = {-2, 1}; /* pixel with fill values */
TEST_VARTYPE image0[TEST_YDIM][TEST_XDIM][TEST_NCOMP]; /* space for the image data */
int32 start[2]; /* start of image data to grab */
int32 stride[2]; /* stride of image data to grab */
intn i, j; /* local counting variables */
/* fill the memory-only with the default pixel fill-value */
for (i = 0; i < TEST_YDIM; i++) {
for (j = 0; j < TEST_XDIM; j++) {
if ((j % 2) == 0)
memcpy(&image0[i][j][0], fill_pixel, sizeof(fill_pixel));
else
memcpy(&image0[i][j][0], fill_pixel2, sizeof(fill_pixel2));
} /* end for */
} /* end for */
memcpy(image, image0, sizeof(image0));
/* Create empty image with default fill value */
riid = GRcreate(grid, "Test Image B2a1aa", TEST_NCOMP, TEST_NT, MFGR_INTERLACE_PIXEL, dims);
CHECK_VOID(riid, FAIL, "GRcreate");
/* Check if creating chunked GR */
if (flag) {
/* Create chunked GR
chunk is 2x2 which will create 6 chunks */
cdims[0] = chunk_def.chunk_lengths[0] = 2;
cdims[1] = chunk_def.chunk_lengths[1] = 2;
ret = GRsetchunk(riid, chunk_def, HDF_CHUNK);
CHECK_VOID(ret, FAIL, "GRsetchunk");
}
/* Save the ref. # for later access */
ref = GRidtoref(riid);
CHECK_VOID(ref, (uint16)FAIL, "GRidtoref");
start[0] = start[1] = 0;
stride[0] = stride[1] = 1;
ret = GRwriteimage(riid, start, stride, dims, image);
CHECK_VOID(ret, FAIL, "GRwriteimage");
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
/* Get the index of the newly created image */
index = GRreftoindex(grid, ref);
CHECK_VOID(index, FAIL, "GRreftoindex");
/* Select the newly created image */
riid = GRselect(grid, index);
CHECK_VOID(riid, FAIL, "GRselect");
start[0] = start[1] = 0;
stride[0] = stride[1] = 1;
ret = GRreadimage(riid, start, stride, dims, image);
CHECK_VOID(ret, FAIL, "GRreadimage");
if (0 != memcmp(image, image0, sizeof(image0))) {
MESSAGE(3, printf("%d:Error reading data for new image with default fill-value, whole image\n",
__LINE__););
num_errs++;
} /* end if */
/* check if we are doing chunked tests */
if (flag) {
/* Get chunk lengths */
ret = GRgetchunkinfo(riid, &rchunk_def, &cflags);
CHECK_VOID(ret, FAIL, "GRgetchunkinfo");
rcdims = rchunk_def.chunk_lengths;
/* check chunk lengths and to see if GR is chunked */
if (cdims[0] != rcdims[0] || cdims[1] != rcdims[1] || cflags != HDF_CHUNK) {
fprintf(stderr, "Chunk Test. GRgetchunkinfo returned wrong values\n");
fprintf(stderr, "cdims[0]=%d,cdims[1]=%d \n", (int)cdims[0], (int)cdims[1]);
fprintf(stderr, "rcdims[0]=%d,rcdims[1]=%d \n", (int)rcdims[0], (int)rcdims[1]);
fprintf(stderr, "cflags =%d \n", (int)cflags);
}
}
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
}
/* Shut down the GR interface */
ret = GRend(grid);
CHECK_VOID(ret, FAIL, "GRend");
/* Close the file */
ret = Hclose(fid);
CHECK_VOID(ret, FAIL, "Hclose");
} /* end test_mgr_image_b2a1aa() */
static void
test_mgr_image_b2a1bb1(int flag)
{
int32 fid; /* HDF file ID */
int32 grid; /* GRID for the interface */
int32 ret; /* generic return value */
int32 cdims[2] = {1, 1}; /* chunk dims */
int32 *rcdims; /* for SDgetchunkinfo() */
HDF_CHUNK_DEF chunk_def; /* Chunk definition set */
HDF_CHUNK_DEF rchunk_def; /* Chunk definition read */
int32 cflags; /* chunk flags */
/* B2a1bb - Read/Write images - with real Data - New Image - with Default Fill Value - Sub-setted Image */
MESSAGE(8, printf("Check out I/O on new image with real data, with Default fill-value, Writing "
"Sub-setted Image\n"););
/* Open up the existing datafile and get the image information from it */
if (flag)
fid = Hopen(TESTFILE2, DFACC_RDWR, 0);
else
fid = Hopen(TESTFILE, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize the GR interface */
grid = GRstart(fid);
CHECK_VOID(grid, FAIL, "GRstart");
{
#ifdef TEST_XDIM
#undef TEST_XDIM
#endif /* TEST_XDIM */
#define TEST_XDIM 19
#ifdef TEST_YDIM
#undef TEST_YDIM
#endif /* TEST_YDIM */
#define TEST_YDIM 23
#ifdef TEST_NCOMP
#undef TEST_NCOMP
#endif /* TEST_NCOMP */
#define TEST_NCOMP 4
#ifdef TEST_VARTYPE
#undef TEST_VARTYPE
#endif /* TEST_VARTYPE */
#define TEST_VARTYPE uint16
#ifdef TEST_NT
#undef TEST_NT
#endif /* TEST_NT */
#define TEST_NT DFNT_UINT16
int32 riid; /* RI ID for the new image */
int32 dims[2] = {TEST_XDIM, TEST_YDIM}; /* dimensions for the empty image */
uint16 ref; /* RI ref #. */
int32 index; /* RI index # */
TEST_VARTYPE image[TEST_YDIM][TEST_XDIM][TEST_NCOMP]; /* space for the image data */
TEST_VARTYPE fill_pixel[TEST_NCOMP] = {40000, 4800, 3, 1000}; /* pixel with fill values */
TEST_VARTYPE fill_pixel2[TEST_NCOMP] = {1230, 1, 65000, 35000}; /* pixel with fill values */
TEST_VARTYPE image0[TEST_YDIM][TEST_XDIM][TEST_NCOMP]; /* space for the image data */
TEST_VARTYPE sub_image[TEST_YDIM][TEST_XDIM][TEST_NCOMP]; /* space for the image data */
TEST_VARTYPE *sub_ptr;
int32 start[2]; /* start of image data to use */
int32 stride[2]; /* stride of image data to use */
int32 count[2]; /* # of pixels of image data to use */
intn i, j, k; /* local counting variables */
/* fill the memory-only with the default pixel fill-values */
memset(image0, 0, sizeof(image0));
sub_ptr = (TEST_VARTYPE *)sub_image;
for (i = 0; i < TEST_YDIM; i++) {
for (j = 0; j < TEST_XDIM; j++) {
if (((i > (TEST_YDIM / 3)) && (i < (2 * TEST_YDIM / 3))) &&
((j > (TEST_XDIM / 4)) && (j < (3 * TEST_XDIM / 4)))) {
if ((j % 2) == 0)
memcpy(&image0[i][j][0], fill_pixel, sizeof(fill_pixel));
else
memcpy(&image0[i][j][0], fill_pixel2, sizeof(fill_pixel2));
memcpy(sub_ptr, &image0[i][j][0], TEST_NCOMP * sizeof(TEST_VARTYPE));
sub_ptr += TEST_NCOMP;
} /* end if */
} /* end for */
} /* end for */
/* initialize the disk buffer */
memset(image, 255, sizeof(image));
/* Create empty image with default fill value */
riid = GRcreate(grid, "Test Image B2a1bb", TEST_NCOMP, TEST_NT, MFGR_INTERLACE_PIXEL, dims);
CHECK_VOID(riid, FAIL, "GRcreate");
/* Check if creating chunked GR */
if (flag) {
/* Create chunked GR
chunk is 2x2 which will create 6 chunks */
cdims[0] = chunk_def.chunk_lengths[0] = 2;
cdims[1] = chunk_def.chunk_lengths[1] = 2;
ret = GRsetchunk(riid, chunk_def, HDF_CHUNK);
CHECK_VOID(ret, FAIL, "GRsetchunk");
}
/* Save the ref. # for later access */
ref = GRidtoref(riid);
CHECK_VOID(ref, (uint16)FAIL, "GRidtoref");
/* Create sub-setted window with only the filled pixels in it */
start[XDIM] = (TEST_XDIM / 4) + 1;
start[YDIM] = (TEST_YDIM / 3) + 1;
count[XDIM] = ((3 * TEST_XDIM / 4) - (TEST_XDIM / 4)) - 1;
count[YDIM] = ((2 * TEST_YDIM / 3) - (TEST_YDIM / 3)) - 1;
stride[XDIM] = stride[YDIM] = 1;
ret = GRwriteimage(riid, start, stride, count, sub_image);
CHECK_VOID(ret, FAIL, "GRwriteimage");
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
/* Get the index of the newly created image */
index = GRreftoindex(grid, ref);
CHECK_VOID(index, FAIL, "GRreftoindex");
/* Select the newly created image */
riid = GRselect(grid, index);
CHECK_VOID(riid, FAIL, "GRselect");
/* Get the whole image back */
start[XDIM] = start[YDIM] = 0;
stride[XDIM] = stride[YDIM] = 1;
ret = GRreadimage(riid, start, stride, dims, image);
CHECK_VOID(ret, FAIL, "GRreadimage");
if (0 != memcmp(image, image0, sizeof(image0))) {
MESSAGE(3,
printf("%d:Error reading data for new image with default fill-value, sub-setted image\n",
__LINE__););
MESSAGE(8,
for (i = 0; i < TEST_YDIM; i++) for (j = 0; j < TEST_XDIM;
j++) for (k = 0; k < TEST_NCOMP;
k++) if (image[i][j][k] != image0[i][j][k])
printf("Location: [%d][%d][%d] image=%u, image0=%u \n", i, j, k,
(unsigned)image[i][j][k], (unsigned)image0[i][j][k]););
num_errs++;
} /* end if */
/* check if we are doing chunked tests */
if (flag) {
/* Get chunk lengths */
ret = GRgetchunkinfo(riid, &rchunk_def, &cflags);
CHECK_VOID(ret, FAIL, "GRgetchunkinfo");
rcdims = rchunk_def.chunk_lengths;
/* check chunk lengths and to see if GR is chunked */
if (cdims[0] != rcdims[0] || cdims[1] != rcdims[1] || cflags != HDF_CHUNK) {
fprintf(stderr, "Chunk Test. GRgetchunkinfo returned wrong values\n");
fprintf(stderr, "cdims[0]=%d,cdims[1]=%d \n", (int)cdims[0], (int)cdims[1]);
fprintf(stderr, "rcdims[0]=%d,rcdims[1]=%d \n", (int)rcdims[0], (int)rcdims[1]);
fprintf(stderr, "cflags =%d \n", (int)cflags);
}
}
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
}
/* Shut down the GR interface */
ret = GRend(grid);
CHECK_VOID(ret, FAIL, "GRend");
/* Close the file */
ret = Hclose(fid);
CHECK_VOID(ret, FAIL, "Hclose");
} /* end test_mgr_image_b2a1bb1() */
static void
test_mgr_image_b2a1bb2(int flag)
{
int32 fid; /* HDF file ID */
int32 grid; /* GRID for the interface */
int32 ret; /* generic return value */
int32 cdims[2] = {1, 1}; /* chunk dims */
int32 *rcdims; /* for SDgetchunkinfo() */
HDF_CHUNK_DEF chunk_def; /* Chunk definition set */
HDF_CHUNK_DEF rchunk_def; /* Chunk definition read */
int32 cflags; /* chunk flags */
MESSAGE(8, printf("Check out I/O on new image with real data, with Default fill-value, Reading "
"Sub-setted Image\n"););
/* Open up the existing datafile and get the image information from it */
if (flag)
fid = Hopen(TESTFILE2, DFACC_RDWR, 0);
else
fid = Hopen(TESTFILE, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize the GR interface */
grid = GRstart(fid);
CHECK_VOID(grid, FAIL, "GRstart");
{
#ifdef TEST_XDIM
#undef TEST_XDIM
#endif /* TEST_XDIM */
#define TEST_XDIM 19
#ifdef TEST_YDIM
#undef TEST_YDIM
#endif /* TEST_YDIM */
#define TEST_YDIM 23
#ifdef TEST_NCOMP
#undef TEST_NCOMP
#endif /* TEST_NCOMP */
#define TEST_NCOMP 4
#ifdef TEST_VARTYPE
#undef TEST_VARTYPE
#endif /* TEST_VARTYPE */
#define TEST_VARTYPE uint16
#ifdef TEST_NT
#undef TEST_NT
#endif /* TEST_NT */
#define TEST_NT DFNT_UINT16
int32 riid; /* RI ID for the new image */
int32 dims[2] = {TEST_XDIM, TEST_YDIM}; /* dimensions for the empty image */
uint16 ref; /* RI ref #. */
int32 index; /* RI index # */
TEST_VARTYPE image[TEST_YDIM][TEST_XDIM][TEST_NCOMP]; /* space for the image data */
TEST_VARTYPE fill_pixel[TEST_NCOMP] = {40000, 4800, 3, 1000}; /* pixel with fill values */
TEST_VARTYPE fill_pixel2[TEST_NCOMP] = {1230, 1, 65000, 35000}; /* pixel with fill values */
TEST_VARTYPE image0[TEST_YDIM][TEST_XDIM][TEST_NCOMP]; /* space for the image data */
TEST_VARTYPE sub_image[TEST_YDIM][TEST_XDIM][TEST_NCOMP]; /* space for the image data */
TEST_VARTYPE *sub_ptr;
int32 start[2]; /* start of image data to use */
int32 stride[2]; /* stride of image data to use */
int32 count[2]; /* # of pixels of image data to use */
intn i, j; /* local counting variables */
/* fill the memory-only with the default pixel fill-values */
memset(image0, 0, sizeof(image0));
sub_ptr = (TEST_VARTYPE *)sub_image;
for (i = 0; i < TEST_YDIM; i++) {
for (j = 0; j < TEST_XDIM; j++) {
if ((j % 2) == 0)
memcpy(&image0[i][j][0], fill_pixel, sizeof(fill_pixel));
else
memcpy(&image0[i][j][0], fill_pixel2, sizeof(fill_pixel2));
if (((i > (TEST_YDIM / 3)) && (i < (2 * TEST_YDIM / 3))) &&
((j > (TEST_XDIM / 4)) && (j < (3 * TEST_XDIM / 4)))) {
memcpy(sub_ptr, &image0[i][j][0], TEST_NCOMP * sizeof(TEST_VARTYPE));
sub_ptr += TEST_NCOMP;
} /* end if */
} /* end for */
} /* end for */
/* initialize the disk buffer */
memset(image, 255, sizeof(image));
/* Create empty image with default fill value */
riid = GRcreate(grid, "Test Image B2a1bb2", TEST_NCOMP, TEST_NT, MFGR_INTERLACE_PIXEL, dims);
CHECK_VOID(riid, FAIL, "GRcreate");
/* Check if creating chunked GR */
if (flag) {
/* Create chunked GR
chunk is 2x2 which will create 6 chunks */
cdims[0] = chunk_def.chunk_lengths[0] = 2;
cdims[1] = chunk_def.chunk_lengths[1] = 2;
ret = GRsetchunk(riid, chunk_def, HDF_CHUNK);
CHECK_VOID(ret, FAIL, "GRsetchunk");
/* Set Chunk cache to hold 3 chunks */
ret = GRsetchunkcache(riid, 3, 0);
CHECK_VOID(ret, FAIL, "GRsetchunkcache");
}
/* Save the ref. # for later access */
ref = GRidtoref(riid);
CHECK_VOID(ref, (uint16)FAIL, "GRidtoref");
/* Create whole image */
start[XDIM] = start[YDIM] = 0;
stride[XDIM] = stride[YDIM] = 1;
ret = GRwriteimage(riid, start, stride, dims, image0);
CHECK_VOID(ret, FAIL, "GRwriteimage");
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
/* Get the index of the newly created image */
index = GRreftoindex(grid, ref);
CHECK_VOID(index, FAIL, "GRreftoindex");
/* Select the newly created image */
riid = GRselect(grid, index);
CHECK_VOID(riid, FAIL, "GRselect");
/* Get the sub-set image back */
start[XDIM] = (TEST_XDIM / 4) + 1;
start[YDIM] = (TEST_YDIM / 3) + 1;
count[XDIM] = ((3 * TEST_XDIM / 4) - (TEST_XDIM / 4)) - 1;
count[YDIM] = ((2 * TEST_YDIM / 3) - (TEST_YDIM / 3)) - 1;
stride[XDIM] = stride[YDIM] = 1;
ret = GRreadimage(riid, start, stride, count, image);
CHECK_VOID(ret, FAIL, "GRreadimage");
if (0 != memcmp(image, sub_image, (size_t)(count[XDIM] * count[YDIM]) * sizeof(fill_pixel))) {
MESSAGE(3,
printf("%d:Error reading data for new image with default fill-value, sub-setted image\n",
__LINE__););
num_errs++;
} /* end if */
/* check if we are doing chunked tests */
if (flag) {
/* Get chunk lengths */
ret = GRgetchunkinfo(riid, &rchunk_def, &cflags);
CHECK_VOID(ret, FAIL, "GRgetchunkinfo");
rcdims = rchunk_def.chunk_lengths;
/* check chunk lengths and to see if GR is chunked */
if (cdims[0] != rcdims[0] || cdims[1] != rcdims[1] || cflags != HDF_CHUNK) {
fprintf(stderr, "Chunk Test. GRgetchunkinfo returned wrong values\n");
fprintf(stderr, "cdims[0]=%d,cdims[1]=%d \n", (int)cdims[0], (int)cdims[1]);
fprintf(stderr, "rcdims[0]=%d,rcdims[1]=%d \n", (int)rcdims[0], (int)rcdims[1]);
fprintf(stderr, "cflags =%d \n", (int)cflags);
}
}
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
}
/* Shut down the GR interface */
ret = GRend(grid);
CHECK_VOID(ret, FAIL, "GRend");
/* Close the file */
ret = Hclose(fid);
CHECK_VOID(ret, FAIL, "Hclose");
} /* end test_mgr_image_b2a1bb2() */
static void
test_mgr_image_b2a1cc1(int flag)
{
int32 fid; /* HDF file ID */
int32 grid; /* GRID for the interface */
int32 ret; /* generic return value */
int32 cdims[2] = {1, 1}; /* chunk dims */
int32 *rcdims; /* for SDgetchunkinfo() */
HDF_CHUNK_DEF chunk_def; /* Chunk definition set */
HDF_CHUNK_DEF rchunk_def; /* Chunk definition read */
int32 cflags; /* chunk flags */
/* B2a1cc - Read/Write images - with real Data - New Image - with Default Fill Value - Sub-sampled Image
*/
MESSAGE(8, printf("Check out I/O on new image with real data, with Default fill-value, Writing "
"Sub-sampled Image\n"););
/* Open up the existing datafile and get the image information from it */
if (flag)
fid = Hopen(TESTFILE2, DFACC_RDWR, 0);
else
fid = Hopen(TESTFILE, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize the GR interface */
grid = GRstart(fid);
CHECK_VOID(grid, FAIL, "GRstart");
{
#ifdef TEST_XDIM
#undef TEST_XDIM
#endif /* TEST_XDIM */
#define TEST_XDIM 19
#ifdef TEST_YDIM
#undef TEST_YDIM
#endif /* TEST_YDIM */
#define TEST_YDIM 23
#ifdef TEST_NCOMP
#undef TEST_NCOMP
#endif /* TEST_NCOMP */
#define TEST_NCOMP 5
#ifdef TEST_VARTYPE
#undef TEST_VARTYPE
#endif /* TEST_VARTYPE */
#define TEST_VARTYPE int16
#ifdef TEST_NT
#undef TEST_NT
#endif /* TEST_NT */
#define TEST_NT DFNT_INT16
int32 riid; /* RI ID for the new image */
int32 dims[2] = {TEST_XDIM, TEST_YDIM}; /* dimensions for the empty image */
uint16 ref; /* RI ref #. */
int32 index; /* RI index # */
TEST_VARTYPE image[TEST_YDIM][TEST_XDIM][TEST_NCOMP]; /* space for the image data */
TEST_VARTYPE fill_pixel[TEST_NCOMP] = {-20000, -1, 4800, 3, 1000}; /* pixel with fill values */
TEST_VARTYPE fill_pixel2[TEST_NCOMP] = {45, 1230, 1, 32000, -32000}; /* pixel with fill values */
TEST_VARTYPE image0[TEST_YDIM][TEST_XDIM][TEST_NCOMP]; /* space for the image data */
TEST_VARTYPE sub_image[TEST_YDIM][TEST_XDIM][TEST_NCOMP]; /* space for the image data */
TEST_VARTYPE *sub_ptr;
int32 start[2]; /* start of image data to use */
int32 stride[2]; /* stride of image data to use */
int32 count[2]; /* # of pixels of image data to use */
intn i, j, k; /* local counting variables */
/* fill the memory-only with the default pixel fill-values */
memset(image0, 0, sizeof(TEST_VARTYPE) * (size_t)(TEST_YDIM * TEST_XDIM * TEST_NCOMP));
sub_ptr = (TEST_VARTYPE *)sub_image;
for (i = 0; i < TEST_YDIM; i++) {
for (j = 0; j < TEST_XDIM; j++) {
if ((i % 2) != 0 && (j % 2) != 0) {
if ((j % 3) == 0)
memcpy(&image0[i][j][0], fill_pixel, sizeof(TEST_VARTYPE) * TEST_NCOMP);
else
memcpy(&image0[i][j][0], fill_pixel2, sizeof(TEST_VARTYPE) * TEST_NCOMP);
memcpy(sub_ptr, &image0[i][j][0], TEST_NCOMP * sizeof(TEST_VARTYPE));
sub_ptr += TEST_NCOMP;
} /* end if */
} /* end for */
} /* end for */
/* initialize the disk buffer */
memset(image, 255, sizeof(TEST_VARTYPE) * (size_t)(TEST_YDIM * TEST_XDIM * TEST_NCOMP));
/* Create empty image with default fill value */
riid = GRcreate(grid, "Test Image B2a1cc", TEST_NCOMP, TEST_NT, MFGR_INTERLACE_PIXEL, dims);
CHECK_VOID(riid, FAIL, "GRcreate");
/* Check if creating chunked GR */
if (flag) {
/* Create chunked GR
chunk is 2x2 which will create 6 chunks */
cdims[0] = chunk_def.chunk_lengths[0] = 2;
cdims[1] = chunk_def.chunk_lengths[1] = 2;
ret = GRsetchunk(riid, chunk_def, HDF_CHUNK);
CHECK_VOID(ret, FAIL, "GRsetchunk");
}
/* Save the ref. # for later access */
ref = GRidtoref(riid);
CHECK_VOID(ref, (uint16)FAIL, "GRidtoref");
/* Create sub-sampled window with only the filled pixels in it */
start[XDIM] = 1;
start[YDIM] = 1;
count[XDIM] = TEST_XDIM / 2;
count[YDIM] = TEST_YDIM / 2;
stride[XDIM] = stride[YDIM] = 2;
ret = GRwriteimage(riid, start, stride, count, sub_image);
CHECK_VOID(ret, FAIL, "GRwriteimage");
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
/* Get the index of the newly created image */
index = GRreftoindex(grid, ref);
CHECK_VOID(index, FAIL, "GRreftoindex");
/* Select the newly created image */
riid = GRselect(grid, index);
CHECK_VOID(riid, FAIL, "GRselect");
/* Get the whole image back */
start[XDIM] = start[YDIM] = 0;
stride[XDIM] = stride[YDIM] = 1;
ret = GRreadimage(riid, start, stride, dims, image);
CHECK_VOID(ret, FAIL, "GRreadimage");
if (0 != memcmp(image, image0, sizeof(TEST_VARTYPE) * TEST_YDIM * TEST_XDIM * TEST_NCOMP)) {
MESSAGE(3,
printf("%d:Error reading data for new image with default fill-value, sub-sampled image\n",
__LINE__););
MESSAGE(8,
for (i = 0; i < TEST_YDIM; i++) for (j = 0; j < TEST_XDIM;
j++) for (k = 0; k < TEST_NCOMP;
k++) if (image[i][j][k] != image0[i][j][k])
printf("Location: [%d][%d][%d] image=%d, image0=%d \n", (int)i, (int)j, (int)k,
(int)image[i][j][k], (int)image0[i][j][k]););
num_errs++;
} /* end if */
/* check if we are doing chunked tests */
if (flag) {
/* Get chunk lengths */
ret = GRgetchunkinfo(riid, &rchunk_def, &cflags);
CHECK_VOID(ret, FAIL, "GRgetchunkinfo");
rcdims = rchunk_def.chunk_lengths;
/* check chunk lengths and to see if GR is chunked */
if (cdims[0] != rcdims[0] || cdims[1] != rcdims[1] || cflags != HDF_CHUNK) {
fprintf(stderr, "Chunk Test. GRgetchunkinfo returned wrong values\n");
fprintf(stderr, "cdims[0]=%d,cdims[1]=%d \n", (int)cdims[0], (int)cdims[1]);
fprintf(stderr, "rcdims[0]=%d,rcdims[1]=%d \n", (int)rcdims[0], (int)rcdims[1]);
fprintf(stderr, "cflags =%d \n", (int)cflags);
}
}
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
}
/* Shut down the GR interface */
ret = GRend(grid);
CHECK_VOID(ret, FAIL, "GRend");
/* Close the file */
ret = Hclose(fid);
CHECK_VOID(ret, FAIL, "Hclose");
}
static void
test_mgr_image_b2a1cc2(int flag)
{
int32 fid; /* HDF file ID */
int32 grid; /* GRID for the interface */
int32 ret; /* generic return value */
int32 cdims[2] = {1, 1}; /* chunk dims */
int32 *rcdims; /* for SDgetchunkinfo() */
HDF_CHUNK_DEF chunk_def; /* Chunk definition set */
HDF_CHUNK_DEF rchunk_def; /* Chunk definition read */
int32 cflags; /* chunk flags */
MESSAGE(8, printf("Check out I/O on new image with real data, with Default fill-value, Reading "
"Sub-sampled Image\n"););
/* Open up the existing datafile and get the image information from it */
if (flag)
fid = Hopen(TESTFILE2, DFACC_RDWR, 0);
else
fid = Hopen(TESTFILE, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize the GR interface */
grid = GRstart(fid);
CHECK_VOID(grid, FAIL, "GRstart");
{
#ifdef TEST_XDIM
#undef TEST_XDIM
#endif /* TEST_XDIM */
#define TEST_XDIM 19
#ifdef TEST_YDIM
#undef TEST_YDIM
#endif /* TEST_YDIM */
#define TEST_YDIM 23
#ifdef TEST_NCOMP
#undef TEST_NCOMP
#endif /* TEST_NCOMP */
#define TEST_NCOMP 4
#ifdef TEST_VARTYPE
#undef TEST_VARTYPE
#endif /* TEST_VARTYPE */
#define TEST_VARTYPE uint32
#ifdef TEST_NT
#undef TEST_NT
#endif /* TEST_NT */
#define TEST_NT DFNT_UINT32
int32 riid; /* RI ID for the new image */
int32 dims[2] = {TEST_XDIM, TEST_YDIM}; /* dimensions for the empty image */
uint16 ref; /* RI ref #. */
int32 index; /* RI index # */
TEST_VARTYPE image[TEST_YDIM][TEST_XDIM][TEST_NCOMP]; /* space for the image data */
TEST_VARTYPE fill_pixel[TEST_NCOMP] = {4000000, 4800, 3, 1000}; /* pixel with fill values */
TEST_VARTYPE fill_pixel2[TEST_NCOMP] = {1230, 1, 65000, 350000}; /* pixel with fill values */
TEST_VARTYPE image0[TEST_YDIM][TEST_XDIM][TEST_NCOMP]; /* space for the image data */
TEST_VARTYPE sub_image[TEST_YDIM][TEST_XDIM][TEST_NCOMP]; /* space for the image data */
TEST_VARTYPE *sub_ptr;
int32 start[2]; /* start of image data to use */
int32 stride[2]; /* stride of image data to use */
int32 count[2]; /* # of pixels of image data to use */
intn i, j; /* local counting variables */
/* fill the memory-only with the default pixel fill-values */
memset(image0, 0, sizeof(image0));
sub_ptr = (TEST_VARTYPE *)sub_image;
for (i = 0; i < TEST_YDIM; i++) {
for (j = 0; j < TEST_XDIM; j++) {
if ((j % 2) == 0)
memcpy(&image0[i][j][0], fill_pixel, sizeof(fill_pixel));
else
memcpy(&image0[i][j][0], fill_pixel2, sizeof(fill_pixel2));
if ((i % 2) && (j % 2)) {
memcpy(sub_ptr, &image0[i][j][0], TEST_NCOMP * sizeof(TEST_VARTYPE));
sub_ptr += TEST_NCOMP;
} /* end if */
} /* end for */
} /* end for */
/* initialize the disk buffer */
memset(image, 255, sizeof(image));
/* Create empty image with default fill value */
riid = GRcreate(grid, "Test Image B2a1cc2", TEST_NCOMP, TEST_NT, MFGR_INTERLACE_PIXEL, dims);
CHECK_VOID(riid, FAIL, "GRcreate");
/* Check if creating chunked GR */
if (flag) {
/* Create chunked GR
chunk is 2x2 which will create 6 chunks */
cdims[0] = chunk_def.chunk_lengths[0] = 2;
cdims[1] = chunk_def.chunk_lengths[1] = 2;
ret = GRsetchunk(riid, chunk_def, HDF_CHUNK);
CHECK_VOID(ret, FAIL, "GRsetchunk");
}
/* Save the ref. # for later access */
ref = GRidtoref(riid);
CHECK_VOID(ref, (uint16)FAIL, "GRidtoref");
/* Create whole image */
start[XDIM] = start[YDIM] = 0;
stride[XDIM] = stride[YDIM] = 1;
ret = GRwriteimage(riid, start, stride, dims, image0);
CHECK_VOID(ret, FAIL, "GRwriteimage");
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
/* Get the index of the newly created image */
index = GRreftoindex(grid, ref);
CHECK_VOID(index, FAIL, "GRreftoindex");
/* Select the newly created image */
riid = GRselect(grid, index);
CHECK_VOID(riid, FAIL, "GRselect");
/* Get the sub-sample image back */
start[XDIM] = 1;
start[YDIM] = 1;
count[XDIM] = TEST_XDIM / 2;
count[YDIM] = TEST_YDIM / 2;
stride[XDIM] = stride[YDIM] = 2;
ret = GRreadimage(riid, start, stride, count, image);
CHECK_VOID(ret, FAIL, "GRreadimage");
if (0 != memcmp(image, sub_image, (size_t)(count[XDIM] * count[YDIM]) * sizeof(fill_pixel))) {
MESSAGE(3,
printf("%d:Error reading data for new image with default fill-value, sub-sampled image\n",
__LINE__););
num_errs++;
} /* end if */
/* check if we are doing chunked tests */
if (flag) {
/* Get chunk lengths */
ret = GRgetchunkinfo(riid, &rchunk_def, &cflags);
CHECK_VOID(ret, FAIL, "GRgetchunkinfo");
rcdims = rchunk_def.chunk_lengths;
/* check chunk lengths and to see if GR is chunked */
if (cdims[0] != rcdims[0] || cdims[1] != rcdims[1] || cflags != HDF_CHUNK) {
fprintf(stderr, "Chunk Test. GRgetchunkinfo returned wrong values\n");
fprintf(stderr, "cdims[0]=%d,cdims[1]=%d \n", (int)cdims[0], (int)cdims[1]);
fprintf(stderr, "rcdims[0]=%d,rcdims[1]=%d \n", (int)rcdims[0], (int)rcdims[1]);
fprintf(stderr, "cflags =%d \n", (int)cflags);
}
}
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
}
/* Shut down the GR interface */
ret = GRend(grid);
CHECK_VOID(ret, FAIL, "GRend");
/* Close the file */
ret = Hclose(fid);
CHECK_VOID(ret, FAIL, "Hclose");
} /* end test_mgr_image_b2a1cc() */
static void
test_mgr_image_b2a2bb(int flag)
{
int32 fid; /* HDF file ID */
int32 grid; /* GRID for the interface */
int32 ret; /* generic return value */
int32 cdims[2] = {1, 1}; /* chunk dims */
int32 *rcdims; /* for SDgetchunkinfo() */
HDF_CHUNK_DEF chunk_def; /* Chunk definition set */
HDF_CHUNK_DEF rchunk_def; /* Chunk definition read */
int32 cflags; /* chunk flags */
/* B2a2bb - Read/Write images - with real Data - New Image - with User-Defined Fill Value - Sub-setted
* Image */
MESSAGE(8, printf("Check out I/O on new image with real data, with User-Defined fill-value, Writing "
"Sub-setted Image\n"););
/* Open up the existing datafile and get the image information from it */
if (flag)
fid = Hopen(TESTFILE2, DFACC_RDWR, 0);
else
fid = Hopen(TESTFILE, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize the GR interface */
grid = GRstart(fid);
CHECK_VOID(grid, FAIL, "GRstart");
{
#ifdef TEST_XDIM
#undef TEST_XDIM
#endif /* TEST_XDIM */
#define TEST_XDIM 19
#ifdef TEST_YDIM
#undef TEST_YDIM
#endif /* TEST_YDIM */
#define TEST_YDIM 23
#ifdef TEST_NCOMP
#undef TEST_NCOMP
#endif /* TEST_NCOMP */
#define TEST_NCOMP 4
#ifdef TEST_VARTYPE
#undef TEST_VARTYPE
#endif /* TEST_VARTYPE */
#define TEST_VARTYPE float32
#ifdef TEST_NT
#undef TEST_NT
#endif /* TEST_NT */
#define TEST_NT DFNT_FLOAT32
int32 riid; /* RI ID for the new image */
int32 dims[2] = {TEST_XDIM, TEST_YDIM}; /* dimensions for the empty image */
uint16 ref; /* RI ref #. */
int32 index; /* RI index # */
TEST_VARTYPE image[TEST_YDIM][TEST_XDIM][TEST_NCOMP]; /* space for the image data */
TEST_VARTYPE fill_pixel[TEST_NCOMP] = {(TEST_VARTYPE)-3.75, (TEST_VARTYPE)4.5, (TEST_VARTYPE)-0.375,
(TEST_VARTYPE)100.125}; /* pixel with fill values */
TEST_VARTYPE pixel[TEST_NCOMP] = {(TEST_VARTYPE)-20.00, (TEST_VARTYPE)4.875, (TEST_VARTYPE)0.125,
(TEST_VARTYPE)1.0}; /* pixel with fill values */
TEST_VARTYPE pixel2[TEST_NCOMP] = {(TEST_VARTYPE)1.25, (TEST_VARTYPE)1.0, (TEST_VARTYPE)-6500.0,
(TEST_VARTYPE)350.0}; /* pixel with fill values */
TEST_VARTYPE image0[TEST_YDIM][TEST_XDIM][TEST_NCOMP]; /* space for the image data */
TEST_VARTYPE sub_image[TEST_YDIM][TEST_XDIM][TEST_NCOMP]; /* space for the image data */
TEST_VARTYPE *sub_ptr;
int32 start[2]; /* start of image data to use */
int32 stride[2]; /* stride of image data to use */
int32 count[2]; /* # of pixels of image data to use */
intn i, j, k; /* local counting variables */
/* fill the memory-only with the default pixel fill-values */
HDmemfill(image0, fill_pixel, sizeof(fill_pixel), sizeof(image0) / sizeof(fill_pixel));
sub_ptr = (TEST_VARTYPE *)sub_image;
for (i = 0; i < TEST_YDIM; i++) {
for (j = 0; j < TEST_XDIM; j++) {
if (((i > (TEST_YDIM / 3)) && (i < (2 * TEST_YDIM / 3))) &&
((j > (TEST_XDIM / 4)) && (j < (3 * TEST_XDIM / 4)))) {
if ((j % 2) == 0)
memcpy(&image0[i][j][0], pixel, sizeof(pixel));
else
memcpy(&image0[i][j][0], pixel2, sizeof(pixel2));
memcpy(sub_ptr, &image0[i][j][0], TEST_NCOMP * sizeof(TEST_VARTYPE));
sub_ptr += TEST_NCOMP;
} /* end if */
} /* end for */
} /* end for */
/* initialize the disk buffer */
memset(image, 255, sizeof(image));
/* Create empty image with default fill value */
riid = GRcreate(grid, "Test Image B2a2bb", TEST_NCOMP, TEST_NT, MFGR_INTERLACE_PIXEL, dims);
CHECK_VOID(riid, FAIL, "GRcreate");
/* Set the fill-value */
ret = GRsetattr(riid, FILL_ATTR, TEST_NT, TEST_NCOMP, fill_pixel);
CHECK_VOID(ret, FAIL, "GRsetattr");
/* Check if creating chunked GR */
if (flag) {
/* Create chunked GR
chunk is 2x2 which will create 6 chunks */
cdims[0] = chunk_def.chunk_lengths[0] = 2;
cdims[1] = chunk_def.chunk_lengths[1] = 2;
ret = GRsetchunk(riid, chunk_def, HDF_CHUNK);
CHECK_VOID(ret, FAIL, "GRsetchunk");
}
/* Save the ref. # for later access */
ref = GRidtoref(riid);
CHECK_VOID(ref, (uint16)FAIL, "GRidtoref");
/* Create sub-setted window with only the filled pixels in it */
start[XDIM] = (TEST_XDIM / 4) + 1;
start[YDIM] = (TEST_YDIM / 3) + 1;
count[XDIM] = ((3 * TEST_XDIM / 4) - (TEST_XDIM / 4)) - 1;
count[YDIM] = ((2 * TEST_YDIM / 3) - (TEST_YDIM / 3)) - 1;
stride[XDIM] = stride[YDIM] = 1;
ret = GRwriteimage(riid, start, stride, count, sub_image);
CHECK_VOID(ret, FAIL, "GRwriteimage");
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
/* Get the index of the newly created image */
index = GRreftoindex(grid, ref);
CHECK_VOID(index, FAIL, "GRreftoindex");
/* Select the newly created image */
riid = GRselect(grid, index);
CHECK_VOID(riid, FAIL, "GRselect");
/* Get the whole image back */
start[XDIM] = start[YDIM] = 0;
stride[XDIM] = stride[YDIM] = 1;
ret = GRreadimage(riid, start, stride, dims, image);
CHECK_VOID(ret, FAIL, "GRreadimage");
if (0 != memcmp(image, image0, sizeof(image0))) {
MESSAGE(
3,
printf("Error reading data for new image with user-defined fill-value, sub-setted image\n"););
MESSAGE(8, for (i = 0; i < TEST_YDIM;
i++) for (j = 0; j < TEST_XDIM;
j++) for (k = 0; k < TEST_NCOMP;
k++) if (!H4_FLT_ABS_EQUAL(image[i][j][k], image0[i][j][k]))
printf("Location: [%d][%d][%d] image=%f, image0=%f \n", i, j, k,
(double)image[i][j][k], (double)image0[i][j][k]););
num_errs++;
} /* end if */
/* check if we are doing chunked tests */
if (flag) {
/* Get chunk lengths */
ret = GRgetchunkinfo(riid, &rchunk_def, &cflags);
CHECK_VOID(ret, FAIL, "GRgetchunkinfo");
rcdims = rchunk_def.chunk_lengths;
/* check chunk lengths and to see if GR is chunked */
if (cdims[0] != rcdims[0] || cdims[1] != rcdims[1] || cflags != HDF_CHUNK) {
fprintf(stderr, "Chunk Test. GRgetchunkinfo returned wrong values\n");
fprintf(stderr, "cdims[0]=%d,cdims[1]=%d \n", (int)cdims[0], (int)cdims[1]);
fprintf(stderr, "rcdims[0]=%d,rcdims[1]=%d \n", (int)rcdims[0], (int)rcdims[1]);
fprintf(stderr, "cflags =%d \n", (int)cflags);
}
}
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
}
/* Shut down the GR interface */
ret = GRend(grid);
CHECK_VOID(ret, FAIL, "GRend");
/* Close the file */
ret = Hclose(fid);
CHECK_VOID(ret, FAIL, "Hclose");
} /* end test_mgr_image_b2a2bb() */
static void
test_mgr_image_b2a2cc(int flag)
{
int32 fid; /* HDF file ID */
int32 grid; /* GRID for the interface */
int32 ret; /* generic return value */
int32 cdims[2] = {1, 1}; /* chunk dims */
int32 *rcdims; /* for SDgetchunkinfo() */
HDF_CHUNK_DEF chunk_def; /* Chunk definition set */
HDF_CHUNK_DEF rchunk_def; /* Chunk definition read */
int32 cflags; /* chunk flags */
/* B2a2cc - Read/Write images - with real Data - New Image - with User-Defined Fill Value - Sub-sampled
* Image */
MESSAGE(8, printf("Check out I/O on new image with real data, with User-Defined fill-value, Writing "
"Sub-sampled Image\n"););
/* Open up the existing datafile and get the image information from it */
if (flag)
fid = Hopen(TESTFILE2, DFACC_RDWR, 0);
else
fid = Hopen(TESTFILE, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize the GR interface */
grid = GRstart(fid);
CHECK_VOID(grid, FAIL, "GRstart");
{
#ifdef TEST_XDIM
#undef TEST_XDIM
#endif /* TEST_XDIM */
#define TEST_XDIM 19
#ifdef TEST_YDIM
#undef TEST_YDIM
#endif /* TEST_YDIM */
#define TEST_YDIM 23
#ifdef TEST_NCOMP
#undef TEST_NCOMP
#endif /* TEST_NCOMP */
#define TEST_NCOMP 5
#ifdef TEST_VARTYPE
#undef TEST_VARTYPE
#endif /* TEST_VARTYPE */
#define TEST_VARTYPE int16
#ifdef TEST_NT
#undef TEST_NT
#endif /* TEST_NT */
#define TEST_NT DFNT_INT16
int32 riid; /* RI ID for the new image */
int32 dims[2] = {TEST_XDIM, TEST_YDIM}; /* dimensions for the empty image */
uint16 ref; /* RI ref #. */
int32 index; /* RI index # */
TEST_VARTYPE image[TEST_YDIM][TEST_XDIM][TEST_NCOMP]; /* space for the image data */
TEST_VARTYPE fill_pixel[TEST_NCOMP] = {-3, 4, -13, 100, 1200}; /* pixel with fill values */
TEST_VARTYPE pixel[TEST_NCOMP] = {-20, 4, 0, 1, -367}; /* pixel with fill values */
TEST_VARTYPE pixel2[TEST_NCOMP] = {1, -11, -6500, 350, 20}; /* pixel with fill values */
TEST_VARTYPE image0[TEST_YDIM][TEST_XDIM][TEST_NCOMP]; /* space for the image data */
TEST_VARTYPE sub_image[TEST_YDIM][TEST_XDIM][TEST_NCOMP]; /* space for the image data */
TEST_VARTYPE *sub_ptr;
int32 start[2]; /* start of image data to use */
int32 stride[2]; /* stride of image data to use */
int32 count[2]; /* # of pixels of image data to use */
intn i, j, k; /* local counting variables */
/* fill the memory-only with the default pixel fill-values */
HDmemfill(image0, fill_pixel, sizeof(fill_pixel), sizeof(image0) / sizeof(fill_pixel));
sub_ptr = (TEST_VARTYPE *)sub_image;
for (i = 0; i < TEST_YDIM; i++) {
for (j = 0; j < TEST_XDIM; j++) {
if ((i % 2) != 0 && (j % 2) != 0) {
if ((j % 3) == 0)
memcpy(&image0[i][j][0], pixel, sizeof(TEST_VARTYPE) * TEST_NCOMP);
else
memcpy(&image0[i][j][0], pixel2, sizeof(TEST_VARTYPE) * TEST_NCOMP);
memcpy(sub_ptr, &image0[i][j][0], TEST_NCOMP * sizeof(TEST_VARTYPE));
sub_ptr += TEST_NCOMP;
} /* end if */
} /* end for */
} /* end for */
/* initialize the disk buffer */
memset(image, 255, sizeof(TEST_VARTYPE) * (size_t)(TEST_YDIM * TEST_XDIM * TEST_NCOMP));
/* Create empty image with default fill value */
riid = GRcreate(grid, "Test Image B2a2cc", TEST_NCOMP, TEST_NT, MFGR_INTERLACE_PIXEL, dims);
CHECK_VOID(riid, FAIL, "GRcreate");
/* Set the fill-value */
ret = GRsetattr(riid, FILL_ATTR, TEST_NT, TEST_NCOMP, fill_pixel);
CHECK_VOID(ret, FAIL, "GRsetattr");
/* Check if creating chunked GR */
if (flag) {
/* Create chunked GR
chunk is 2x2 which will create 6 chunks */
cdims[0] = chunk_def.chunk_lengths[0] = 2;
cdims[1] = chunk_def.chunk_lengths[1] = 2;
ret = GRsetchunk(riid, chunk_def, HDF_CHUNK);
CHECK_VOID(ret, FAIL, "GRsetchunk");
}
/* Save the ref. # for later access */
ref = GRidtoref(riid);
CHECK_VOID(ref, (uint16)FAIL, "GRidtoref");
/* Create sub-sampled window with only the filled pixels in it */
start[XDIM] = 1;
start[YDIM] = 1;
count[XDIM] = TEST_XDIM / 2;
count[YDIM] = TEST_YDIM / 2;
stride[XDIM] = stride[YDIM] = 2;
ret = GRwriteimage(riid, start, stride, count, sub_image);
CHECK_VOID(ret, FAIL, "GRwriteimage");
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
/* Get the index of the newly created image */
index = GRreftoindex(grid, ref);
CHECK_VOID(index, FAIL, "GRreftoindex");
/* Select the newly created image */
riid = GRselect(grid, index);
CHECK_VOID(riid, FAIL, "GRselect");
/* Get the whole image back */
start[XDIM] = start[YDIM] = 0;
stride[XDIM] = stride[YDIM] = 1;
ret = GRreadimage(riid, start, stride, dims, image);
CHECK_VOID(ret, FAIL, "GRreadimage");
if (0 != memcmp(image, image0, sizeof(TEST_VARTYPE) * TEST_YDIM * TEST_XDIM * TEST_NCOMP)) {
MESSAGE(
3,
printf(
"Error reading data for new image with user-defined fill-value, sub-sampled image\n"););
MESSAGE(8,
for (i = 0; i < TEST_YDIM; i++) for (j = 0; j < TEST_XDIM;
j++) for (k = 0; k < TEST_NCOMP;
k++) if (image[i][j][k] != image0[i][j][k])
printf("Location: [%d][%d][%d] image=%d, image0=%d \n", (int)i, (int)j, (int)k,
(int)image[i][j][k], (int)image0[i][j][k]););
num_errs++;
} /* end if */
/* check if we are doing chunked tests */
if (flag) {
/* Get chunk lengths */
ret = GRgetchunkinfo(riid, &rchunk_def, &cflags);
CHECK_VOID(ret, FAIL, "GRgetchunkinfo");
rcdims = rchunk_def.chunk_lengths;
/* check chunk lengths and to see if GR is chunked */
if (cdims[0] != rcdims[0] || cdims[1] != rcdims[1] || cflags != HDF_CHUNK) {
fprintf(stderr, "Chunk Test. GRgetchunkinfo returned wrong values\n");
fprintf(stderr, "cdims[0]=%d,cdims[1]=%d \n", (int)cdims[0], (int)cdims[1]);
fprintf(stderr, "rcdims[0]=%d,rcdims[1]=%d \n", (int)rcdims[0], (int)rcdims[1]);
fprintf(stderr, "cflags =%d \n", (int)cflags);
}
}
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
}
/* Shut down the GR interface */
ret = GRend(grid);
CHECK_VOID(ret, FAIL, "GRend");
/* Close the file */
ret = Hclose(fid);
CHECK_VOID(ret, FAIL, "Hclose");
} /* end test_mgr_image_b2a2cc() */
static void
test_mgr_image_b2b1(int flag)
{
int32 fid; /* HDF file ID */
int32 grid; /* GRID for the interface */
int32 ret; /* generic return value */
const char *datafile = get_srcdir_filename(DATAFILE);
(void)flag;
/* B2b1 - Read/Write images - with real Data - Existing Image - Whole Image */
MESSAGE(8, printf("Check out I/O from Existing Image - Whole Image\n"););
/* Open up the existing datafile and get the image information from it */
fid = Hopen(datafile, DFACC_READ, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Try initializing the GR interface */
grid = GRstart(fid);
CHECK_VOID(grid, FAIL, "GRstart");
{
int32 n_datasets; /* number of datasets */
int32 n_attrs; /* number of attributes */
intn i; /* local counting variables */
ret = (intn)GRfileinfo(grid, &n_datasets, &n_attrs);
CHECK_VOID(ret, FAIL, "GRfileinfo");
for (i = 0; i < n_datasets; i++) {
int32 riid; /* RI ID for an image */
char name[MAX_IMG_NAME]; /* storage for the image's name */
int32 ncomp; /* number of components */
int32 nt; /* NT of the components */
int32 il; /* interlace of the image data */
int32 dimsizes[2]; /* dimension sizes of the image */
int32 n_attr; /* number of attributes with each image */
void *img_data; /* buffer for the image data */
/* Attach to the image */
riid = GRselect(grid, i);
CHECK_VOID(riid, FAIL, "GRselect");
/* Get the Image information */
*name = '\0';
ret = GRgetiminfo(riid, name, &ncomp, &nt, &il, dimsizes, &n_attr);
CHECK_VOID(ret, FAIL, "GRgetiminfo");
/* Check the name for correctness */
if (strcmp(name, datafile_info[i].name)) {
MESSAGE(3, printf("Error! Name for image %d is: %s, should be %s\n", i, name,
datafile_info[i].name););
num_errs++;
} /* end if */
/* Check the # of components */
if (ncomp != datafile_info[i].ncomp) {
MESSAGE(3, printf("Error! Number of components for image %d is: %ld, should be %ld\n", i,
(long)ncomp, (long)datafile_info[i].ncomp););
num_errs++;
} /* end if */
/* Check the NT of components */
if (nt != datafile_info[i].nt) {
MESSAGE(3, printf("Error! NT of components for image %d is: %ld, should be %ld\n", i,
(long)nt, (long)datafile_info[i].nt););
num_errs++;
} /* end if */
/* Check the interlace of components */
if (il != datafile_info[i].il) {
MESSAGE(3, printf("Error! Interlace of components for image %d is: %ld, should be %ld\n", i,
(long)il, (long)datafile_info[i].il););
num_errs++;
} /* end if */
/* Check the x-dimension of the image */
if (dimsizes[XDIM] != datafile_info[i].dimsizes[XDIM]) {
MESSAGE(3, printf("Error! X-dim of image %d is: %ld, should be %ld\n", i,
(long)dimsizes[XDIM], (long)datafile_info[i].dimsizes[XDIM]););
num_errs++;
} /* end if */
/* Check the y-dimension of the image */
if (dimsizes[YDIM] != datafile_info[i].dimsizes[YDIM]) {
MESSAGE(3, printf("Error! Y-dim of image %d is: %ld, should be %ld\n", i,
(long)dimsizes[YDIM], (long)datafile_info[i].dimsizes[YDIM]););
num_errs++;
} /* end if */
/* Check the # of attributes of the image */
if (n_attr != datafile_info[i].n_attr) {
MESSAGE(3, printf("Error! # of attributes for image %d is: %ld, should be %ld\n", i,
(long)n_attr, (long)datafile_info[i].n_attr););
num_errs++;
} /* end if */
/* Check the image data itself */
{
int32 start[2];
int32 stride[2];
img_data = malloc((size_t)(dimsizes[0] * dimsizes[1] * ncomp * DFKNTsize(nt | DFNT_NATIVE)));
CHECK_VOID(img_data, NULL, "malloc");
memset(img_data, 0,
(size_t)(dimsizes[0] * dimsizes[1] * ncomp * DFKNTsize(nt | DFNT_NATIVE)));
start[0] = start[1] = 0;
stride[0] = stride[1] = 1;
ret = GRreadimage(riid, start, stride, dimsizes, img_data);
CHECK_VOID(ret, FAIL, "GRreadimage");
switch (i) {
case 0:
if (0 != memcmp(img_data, image00, sizeof(image00))) {
MESSAGE(3, printf("Error reading data for image %d\n", i););
num_errs++;
} /* end if */
break;
case 1:
if (0 != memcmp(img_data, image1, sizeof(image1))) {
MESSAGE(3, printf("Error reading data for image %d\n", i););
num_errs++;
} /* end if */
break;
case 2:
if (0 != memcmp(img_data, image2, sizeof(image2))) {
MESSAGE(3, printf("Error reading data for image %d\n", i););
num_errs++;
} /* end if */
break;
case 3:
if (0 != memcmp(img_data, image3, sizeof(image3))) {
MESSAGE(3, printf("Error reading data for image %d\n", i););
num_errs++;
} /* end if */
break;
case 4:
if (0 != memcmp(img_data, image4, sizeof(image4))) {
MESSAGE(3, printf("Error reading data for image %d\n", i););
num_errs++;
} /* end if */
break;
} /* end switch */
free(img_data);
} /* end block */
/* End access to the image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
} /* end for */
} /* end block */
/* Shut down the GR interface */
ret = GRend(grid);
CHECK_VOID(ret, FAIL, "GRend");
/* Close the file */
ret = Hclose(fid);
CHECK_VOID(ret, FAIL, "Hclose");
} /* end test_mgr_image_b2b1() */
static void
test_mgr_image_chunk(int flag)
{
int32 cdims[2] = {1, 1}; /* chunk dims */
int32 *rcdims; /* for SDgetchunkinfo() */
HDF_CHUNK_DEF chunk_def; /* Chunk definition set */
HDF_CHUNK_DEF rchunk_def; /* Chunk definition read */
int32 cflags; /* chunk flags */
int32 fid; /* HDF file ID */
int32 grid; /* GRID for the interface */
int32 ret; /* generic return value */
(void)flag;
/* Open up the existing datafile and get the image information from it */
fid = Hopen(TESTFILE2, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize the GR interface */
grid = GRstart(fid);
CHECK_VOID(grid, FAIL, "GRstart");
{
#ifdef TEST_XDIM
#undef TEST_XDIM
#endif /* TEST_XDIM */
#define TEST_XDIM 3
#ifdef TEST_YDIM
#undef TEST_YDIM
#endif /* TEST_YDIM */
#define TEST_YDIM 8
#ifdef TEST_NCOMP
#undef TEST_NCOMP
#endif /* TEST_NCOMP */
#define TEST_NCOMP 2
#ifdef TEST_VARTYPE
#undef TEST_VARTYPE
#endif /* TEST_VARTYPE */
#define TEST_VARTYPE int32
#ifdef TEST_NT
#undef TEST_NT
#endif /* TEST_NT */
#define TEST_NT DFNT_INT32
int32 riid; /* RI ID for the new image */
int32 dims[2] = {TEST_XDIM, TEST_YDIM}; /* dimensions for the empty image */
uint16 ref; /* RI ref #. */
int32 index; /* RI index # */
TEST_VARTYPE image[TEST_YDIM][TEST_XDIM][TEST_NCOMP]; /* space for the image data */
TEST_VARTYPE fill_pixel[TEST_NCOMP] = {1, -2}; /* pixel with fill values */
TEST_VARTYPE fill_pixel2[TEST_NCOMP] = {-2, 1}; /* pixel with fill values */
TEST_VARTYPE image0[TEST_YDIM][TEST_XDIM][TEST_NCOMP]; /* space for the image data */
int32 start[2]; /* start of image data to grab */
int32 stride[2]; /* stride of image data to grab */
intn i, j; /* local counting variables */
/* fill the memory-only with the default pixel fill-value */
for (i = 0; i < TEST_YDIM; i++) {
for (j = 0; j < TEST_XDIM; j++) {
if ((j % 2) == 0)
memcpy(&image0[i][j][0], fill_pixel, sizeof(fill_pixel));
else
memcpy(&image0[i][j][0], fill_pixel2, sizeof(fill_pixel2));
} /* end for */
} /* end for */
memcpy(image, image0, sizeof(image0));
/* Create empty image with default fill value */
riid = GRcreate(grid, "Test Chunk Image B2a1aa", TEST_NCOMP, TEST_NT, MFGR_INTERLACE_PIXEL, dims);
CHECK_VOID(riid, FAIL, "GRcreate");
/* Create chunked GR
chunk is 2x2 which will create 6 chunks */
cdims[0] = chunk_def.chunk_lengths[0] = 2;
cdims[1] = chunk_def.chunk_lengths[1] = 2;
ret = GRsetchunk(riid, chunk_def, HDF_CHUNK);
CHECK_VOID(ret, FAIL, "GRsetchunk");
/* Set Chunk cache to hold 2 chunks */
ret = GRsetchunkcache(riid, 2, 0);
CHECK_VOID(ret, FAIL, "GRsetchunkcache");
/* Save the ref. # for later access */
ref = GRidtoref(riid);
CHECK_VOID(ref, (uint16)FAIL, "GRidtoref");
start[0] = start[1] = 0;
stride[0] = stride[1] = 1;
ret = GRwriteimage(riid, start, stride, dims, image);
CHECK_VOID(ret, FAIL, "GRwriteimage");
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
/* Shut down the GR interface */
ret = GRend(grid);
CHECK_VOID(ret, FAIL, "GRend");
/* Initialize the GR interface again */
grid = GRstart(fid);
CHECK_VOID(grid, FAIL, "GRstart");
/* Get the index of the newly created image */
index = GRreftoindex(grid, ref);
CHECK_VOID(index, FAIL, "GRreftoindex");
/* Select the newly created image */
riid = GRselect(grid, index);
CHECK_VOID(riid, FAIL, "GRselect");
start[0] = start[1] = 0;
stride[0] = stride[1] = 1;
ret = GRreadimage(riid, start, stride, dims, image);
CHECK_VOID(ret, FAIL, "GRreadimage");
if (0 != memcmp(image, image0, sizeof(image0))) {
MESSAGE(3, printf("%d:Error reading data for new image with default fill-value, whole image\n",
__LINE__););
num_errs++;
} /* end if */
/* Get chunk lengths */
ret = GRgetchunkinfo(riid, &rchunk_def, &cflags);
CHECK_VOID(ret, FAIL, "GRgetchunkinfo");
rcdims = rchunk_def.chunk_lengths;
/* check chunk lengths and to see if GR is chunked */
if (cdims[0] != rcdims[0] || cdims[1] != rcdims[1] || cflags != HDF_CHUNK) {
fprintf(stderr, "Chunk Test 1. GRgetchunkinfo returned wrong values\n");
fprintf(stderr, "cdims[0]=%d,cdims[1]=%d \n", (int)cdims[0], (int)cdims[1]);
fprintf(stderr, "rcdims[0]=%d,rcdims[1]=%d \n", (int)rcdims[0], (int)rcdims[1]);
fprintf(stderr, "cflags =%d \n", (int)cflags);
}
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
}
/* Shut down the GR interface */
ret = GRend(grid);
CHECK_VOID(ret, FAIL, "GRend");
/* Close the file */
ret = Hclose(fid);
CHECK_VOID(ret, FAIL, "Hclose");
} /* end test_mgr_image_chunk() */
/****************************************************************
**
** test_mgr_image(): Multi-file Raster Image I/O Test Routine
** II. Create Images
** A. GRcreate/GRselect/GRendaccess w/GRgetiminfo
** B. Write/Read images
** 1. With no Data
** a. Default fill value
** b. user defined fill value
** 2. With real Data
** a. New Image
** 1. With default fill value
** aa. Whole image
** bb. Sub-setted image
** cc. Sub-sampled image
** 2. With user defined fill value
** aa. Whole image
** bb. Sub-setted image
** cc. Sub-sampled image
** b. Existing Image
** 1. Whole image
** 2. Sub-setted image
** 3. Sub-sampled image
**
****************************************************************/
static void
test_mgr_image(int flag)
{
/* Output message about test being performed */
MESSAGE(6, printf("Testing Multi-file Raster Image I/O routines\n"););
test_mgr_image_b1a(flag);
test_mgr_image_b1b(flag);
test_mgr_image_b2a1aa(flag);
test_mgr_image_b2a1bb1(flag);
test_mgr_image_b2a1bb2(flag);
test_mgr_image_b2a1cc1(flag);
test_mgr_image_b2a1cc2(flag);
test_mgr_image_b2a2bb(flag);
test_mgr_image_b2a2cc(flag);
test_mgr_image_b2b1(flag);
test_mgr_image_chunk(flag);
} /* end test_mgr_image() */
/****************************************************************
**
** test_mgr_index(): Multi-file Raster ID/Ref/Index Test Routine
**
** III. ID/Ref/Index Functions
** A. GRidtoref
** B. GRreftoindex
**
****************************************************************/
static void
test_mgr_index(int flag)
{
(void)flag;
/* output message about test being performed */
MESSAGE(6, printf("Testing Multi-File Raster id/ref/index routines\n"););
/* I believe that these are adequately tested in the test_mgr_image routine -QAK */
} /* end test_mgr_index() */
/****************************************************************
**
** test_mgr_interlace(): Multi-file Raster Interlace Test Routine
**
** IV. Interlace Functions [Need to be implemented]
** A. GRreqlutil - tested in the palette test below.
** B. GRreqimageil
**
****************************************************************/
static void
test_mgr_interlace(int flag)
{
int32 fid; /* hdf file id */
int32 grid; /* grid for the interface */
int32 n_datasets; /* number of datasets */
int32 n_attrs; /* number of attributes */
int32 ret; /* generic return value */
void *image; /* image to retrieve */
/* Output message about test being performed */
MESSAGE(6, printf("Testing Multi-file Raster Interlace routines\n"););
/* open up the existing datafile and get the image information from it */
if (flag)
fid = Hopen(TESTFILE2, DFACC_RDWR, 0);
else
fid = Hopen(TESTFILE, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* initialize the gr interface */
grid = GRstart(fid);
CHECK_VOID(grid, FAIL, "GRstart");
{
intn i, j; /* local counting variables */
ret = (intn)GRfileinfo(grid, &n_datasets, &n_attrs);
CHECK_VOID(ret, FAIL, "GRfileinfo");
for (i = 0; i < n_datasets; i++) {
int32 riid; /* RI ID for an image */
char name[MAX_IMG_NAME]; /* storage for the image's name */
int32 ncomp; /* number of components */
int32 nt; /* NT of the components */
int32 il; /* interlace of the image data */
int32 start[2];
int32 stride[2];
int32 dimsizes[2]; /* dimension sizes of the image */
int32 n_attr; /* number of attributes with each image */
void *img_data; /* buffer for the image data */
/* Attach to the image */
riid = GRselect(grid, i);
CHECK_VOID(riid, FAIL, "GRselect");
/* Get the Image information */
*name = '\0';
ret = GRgetiminfo(riid, name, &ncomp, &nt, &il, dimsizes, &n_attr);
CHECK_VOID(ret, FAIL, "GRgetiminfo");
image = malloc((size_t)(dimsizes[XDIM] * dimsizes[YDIM] * ncomp * DFKNTsize(nt | DFNT_NATIVE)));
CHECK_VOID(image, NULL, "malloc");
start[0] = start[1] = 0;
stride[0] = stride[1] = 1;
ret = GRreadimage(riid, start, stride, dimsizes, image);
/* Check the image data itself */
for (j = (intn)MFGR_INTERLACE_PIXEL; j <= (intn)MFGR_INTERLACE_COMPONENT; j++) {
void *pixel_buf;
img_data = malloc((size_t)(dimsizes[0] * dimsizes[1] * ncomp * DFKNTsize(nt | DFNT_NATIVE)));
CHECK_VOID(img_data, NULL, "malloc");
pixel_buf = malloc((size_t)(dimsizes[0] * dimsizes[1] * ncomp * DFKNTsize(nt | DFNT_NATIVE)));
CHECK_VOID(pixel_buf, NULL, "malloc");
memset(img_data, 0,
(size_t)(dimsizes[0] * dimsizes[1] * ncomp * DFKNTsize(nt | DFNT_NATIVE)));
ret = GRreqimageil(riid, j);
CHECK_VOID(ret, FAIL, "GRreqimageil");
start[0] = start[1] = 0;
stride[0] = stride[1] = 1;
ret = GRreadimage(riid, start, stride, dimsizes, img_data);
CHECK_VOID(ret, FAIL, "GRreadimage");
GRIil_convert(image, MFGR_INTERLACE_PIXEL, pixel_buf, (gr_interlace_t)j, dimsizes, ncomp, nt);
if (0 !=
memcmp(img_data, pixel_buf,
(size_t)(dimsizes[XDIM] * dimsizes[YDIM] * ncomp * DFKNTsize(nt | DFNT_NATIVE)))) {
MESSAGE(3, printf("Error reading data for image %d, j=%d\n", i, j););
num_errs++;
}
free(img_data);
free(pixel_buf);
} /* end for */
free(image);
/* End access to the image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
} /* end for */
} /* end block */
/* shut down the gr interface */
ret = GRend(grid);
CHECK_VOID(ret, FAIL, "GRend");
/* close the file */
ret = Hclose(fid);
CHECK_VOID(ret, FAIL, "Hclose");
} /* end test_mgr_interlace() */
/****************************************************************
**
** test_mgr_lut_a(): Multi-file Raster LUT/Palette Test Routine
**
** V. Palette Functions
** A. GRgetlutid w/GRgetlutinfo
** B. Read/Write Palettes
** 1. GRwritelut
** 2. GRreadlut
** C. GRluttoref
**
****************************************************************/
static void
test_mgr_lut_a(int flag)
{
int32 fid; /* hdf file id */
int32 grid; /* grid for the interface */
int32 ret; /* generic return value */
(void)flag;
/* Output message about test being performed */
MESSAGE(6, printf("Testing Multi-file Raster Palette routines\n"););
/* open up the existing datafile and get the image information from it */
fid = Hopen(TESTFILE, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* initialize the gr interface */
grid = GRstart(fid);
CHECK_VOID(grid, FAIL, "GRstart");
/* pick up here -QAK2 */
{
intn i, j; /* local counting variables */
int32 riid; /* RI ID for an image */
int32 lutid; /* RI ID for an image */
char name[MAX_IMG_NAME]; /* storage for the image's name */
int32 ncomp; /* number of components */
int32 pal_ncomp; /* number of palette components */
int32 nt; /* NT of the components */
int32 pal_nt; /* NT of the palette components */
int32 il; /* interlace of the image data */
int32 pal_il; /* interlace of the palette data */
int32 dimsizes[2]; /* dimension sizes of the image */
int32 pal_entries; /* number of entries in the palette */
int32 n_attr; /* number of attributes with each image */
uint8 *tmp_data; /* temporary buffer pointer */
void *pal_data; /* buffer for the palette data */
uint16 pal_ref; /* reference number of the palette */
/* Attach to the image */
riid = GRselect(grid, 0);
CHECK_VOID(riid, FAIL, "GRselect");
/* Get the Image information */
*name = '\0';
ret = GRgetiminfo(riid, name, &ncomp, &nt, &il, dimsizes, &n_attr);
CHECK_VOID(ret, FAIL, "GRgetiminfo");
/* Get the number of palettes */
ret = GRgetnluts(riid);
VERIFY_VOID(ret, 0, "GRgetnluts");
lutid = GRgetlutid(riid, 0);
CHECK_VOID(lutid, FAIL, "GRgetlutid");
/* Get the Palette information */
ret = GRgetlutinfo(lutid, &pal_ncomp, &pal_nt, &pal_il, &pal_entries);
CHECK_VOID(ret, FAIL, "GRgetlutinfo");
/* Check the palette values, they should all be "nil" values */
if (pal_ncomp != 0) {
MESSAGE(3, printf("Error! Incorrect palette components\n"););
num_errs++;
} /* end if */
if (pal_nt != DFNT_NONE) {
MESSAGE(3, printf("Error! Incorrect palette number-type\n"););
num_errs++;
} /* end if */
if (pal_il != (-1)) {
MESSAGE(3, printf("Error! Incorrect palette interlace, pal_il=%d\n", (int)pal_il););
num_errs++;
} /* end if */
if (pal_entries != 0) {
MESSAGE(3, printf("Error! Incorrect palette # of entries\n"););
num_errs++;
} /* end if */
/* Set the palette components */
pal_ncomp = 3;
pal_nt = DFNT_UINT8;
pal_il = (int32)MFGR_INTERLACE_PIXEL;
pal_entries = 256;
pal_data = malloc((size_t)(pal_entries * pal_ncomp * DFKNTsize(pal_nt | DFNT_NATIVE)));
CHECK_VOID(pal_data, NULL, "malloc");
/* Initialize the palette data, in 'pixel' interlace */
tmp_data = (uint8 *)pal_data;
for (j = 0; j < pal_entries; j++)
for (i = 0; i < pal_ncomp; i++)
*tmp_data++ = (uint8)(j * i);
/* Write the palette out */
ret = GRwritelut(lutid, pal_ncomp, pal_nt, pal_il, pal_entries, pal_data);
CHECK_VOID(ret, FAIL, "GRwritelut");
/* Check the image data itself */
for (j = (intn)MFGR_INTERLACE_PIXEL; j <= (intn)MFGR_INTERLACE_COMPONENT; j++) {
void *pixel_buf;
int32 dimsizes2[2];
tmp_data = malloc((size_t)(pal_entries * pal_ncomp * DFKNTsize(pal_nt | DFNT_NATIVE)));
CHECK_VOID(tmp_data, NULL, "malloc");
pixel_buf = malloc((size_t)(pal_entries * pal_ncomp * DFKNTsize(pal_nt | DFNT_NATIVE)));
CHECK_VOID(pixel_buf, NULL, "malloc");
memset(tmp_data, 0, (size_t)(pal_entries * pal_ncomp * DFKNTsize(pal_nt | DFNT_NATIVE)));
ret = GRreqlutil(lutid, j);
CHECK_VOID(ret, FAIL, "GRreqlutil");
ret = GRreadlut(lutid, tmp_data);
dimsizes2[XDIM] = 1;
dimsizes2[YDIM] = pal_entries;
GRIil_convert(pal_data, MFGR_INTERLACE_PIXEL, pixel_buf, (gr_interlace_t)j, dimsizes2, pal_ncomp,
pal_nt);
if (0 != memcmp(tmp_data, pixel_buf,
(size_t)(pal_entries * pal_ncomp * DFKNTsize(pal_nt | DFNT_NATIVE)))) {
MESSAGE(3, printf("Error reading data for palette j=%d\n", j););
num_errs++;
}
free(tmp_data);
free(pixel_buf);
} /* end for */
free(pal_data);
/* This lutid should yield a valid reference number, which is not 0 - BMR */
pal_ref = GRluttoref(lutid);
CHECK_VOID(pal_ref, 0, "GRluttoref");
/* Now, this bogus lutid should cause GRluttoref to return a 0 - BMR */
pal_ref = GRluttoref(0);
VERIFY_VOID(pal_ref, 0, "GRluttoref");
/* End access to the image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
} /* end block */
/* shut down the gr interface */
ret = GRend(grid);
CHECK_VOID(ret, FAIL, "GRend");
/* close the file */
ret = Hclose(fid);
CHECK_VOID(ret, FAIL, "Hclose");
} /* end test_mgr_lut_a() */
#define GR_LUTBFILE "gr2.hdf"
#define GR_LUTB_X_LENGTH 15
#define GR_LUTB_Y_LENGTH 10
/****************************************************************
**
** test_mgr_lut_b(): Multi-file Raster LUT/Palette Test Routine
**
** V. Palette Functions - Test for writing palette with no image data to
** file.
**
****************************************************************/
static void
test_mgr_lut_b(int flag)
{
int32 gr_id, ri_id, file_id, pal_id, status, num_entries, ri_idx = 0;
int32 data_type, ncomp, num_comp, interlace_mode;
uint8 palette_data[256 * 3];
uint8 r_palette_data[256 * 3];
intn i;
int32 dims[2] = {GR_LUTB_X_LENGTH, GR_LUTB_Y_LENGTH};
(void)flag;
/* Create and open the file. */
file_id = Hopen(GR_LUTBFILE, DFACC_CREATE, 0);
CHECK_VOID(file_id, FAIL, "Hopen");
/* Initiate the GR interface. */
gr_id = GRstart(file_id);
CHECK_VOID(gr_id, FAIL, "GRstart");
ncomp = 1;
dims[0] = 20;
dims[1] = 20;
interlace_mode = MFGR_INTERLACE_PIXEL;
ri_id = GRcreate(gr_id, "Image_1", ncomp, DFNT_UINT8, interlace_mode, dims);
CHECK_VOID(ri_id, FAIL, "GRcreate");
/* Initialize the palette to grayscale. */
for (i = 0; i < 256; i++) {
palette_data[i * 3] = i;
palette_data[i * 3 + 1] = i;
palette_data[i * 3 + 2] = i;
}
/* Set palette characteristics. */
data_type = DFNT_UINT8;
num_entries = 256;
num_comp = 3;
/* Get the id for the palette. */
pal_id = GRgetlutid(ri_id, ri_idx);
CHECK_VOID(pal_id, FAIL, "GRgetlutid");
/* Write the palette to file. */
status = GRwritelut(pal_id, num_comp, data_type, interlace_mode, num_entries, (void *)palette_data);
CHECK_VOID(status, FAIL, "GRgetlutid");
status = GRendaccess(ri_id);
CHECK_VOID(status, FAIL, "GRendaccess");
status = GRend(gr_id);
CHECK_VOID(status, FAIL, "GRend");
status = Hclose(file_id);
CHECK_VOID(status, FAIL, "Hclose");
file_id = Hopen(GR_LUTBFILE, DFACC_READ, 0);
CHECK_VOID(file_id, FAIL, "Hopen");
gr_id = GRstart(file_id);
CHECK_VOID(gr_id, FAIL, "GRstart");
ri_idx = GRnametoindex(gr_id, "Image_1");
CHECK_VOID(ri_idx, FAIL, "GRnametoindex");
ri_id = GRselect(gr_id, ri_idx);
CHECK_VOID(ri_id, FAIL, "GRselect");
pal_id = GRgetlutid(ri_id, ri_idx);
CHECK_VOID(pal_id, FAIL, "GRgetlutid");
/* Read the palette data. */
status = GRreadlut(pal_id, (void *)r_palette_data);
CHECK_VOID(status, FAIL, "GRreadlut");
/* Verify correct palette contents */
if (memcmp(palette_data, r_palette_data, 256 * 3) != 0) {
MESSAGE(3, printf("Error reading data for palette\n"););
num_errs++;
} /* end if */
/* Terminate access to the image. */
status = GRendaccess(ri_id);
CHECK_VOID(status, FAIL, "GRendaccess");
/* Terminate access to the GR interface. */
status = GRend(gr_id);
CHECK_VOID(status, FAIL, "GRend");
/* Close the file. */
status = Hclose(file_id);
CHECK_VOID(status, FAIL, "Hclose");
} /* end test_mgr_lut_b() */
/****************************************************************
**
** test_mgr_lut(): Multi-file Raster LUT/Palette Test Routine
**
** V. Palette Functions
** A. GRgetlutid w/GRgetlutinfo
** B. Read/Write Palettes
** 1. GRwritelut
** 2. GRreadlut
** C. GRluttoref
**
****************************************************************/
static void
test_mgr_lut(int flag)
{
/* Output message about test being performed */
MESSAGE(6, printf("Testing Multi-file Raster Palette routines\n"););
test_mgr_lut_a(flag);
test_mgr_lut_b(flag);
} /* end test_mgr_lut() */
/****************************************************************
**
** test_mgr_special(): Multi-file Raster Special Element Test Routine
**
** VI. Special Element Functions [Need to be implemented]
** A. GRsetexternalfile
** B. GRsetaccesstype
**
****************************************************************/
static void
test_mgr_special(int flag)
{
(void)flag;
/* Output message about test being performed */
MESSAGE(6, printf("Testing Multi-file Raster Special Element routines\n"););
} /* end test_mgr_special() */
#define OLDRLEFILE "test_files/8bit.dat"
#define OLDGREYJPEGFILE "test_files/greyjpeg.dat"
#define OLDJPEGFILE "test_files/jpeg.dat"
#define JPEGX 46
#define JPEGY 23
static const uint8 jpeg_8bit_j80[JPEGY][JPEGX] = {
{200, 200, 200, 200, 200, 200, 200, 200, 202, 202, 201, 201, 201, 200, 200, 200,
201, 201, 200, 200, 200, 201, 202, 202, 202, 202, 201, 200, 200, 200, 200, 201,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
{200, 200, 200, 200, 200, 200, 200, 200, 199, 199, 199, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 199, 199, 199, 199, 200, 200, 201, 201,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
{200, 200, 200, 200, 200, 200, 200, 200, 199, 199, 199, 200, 200, 201, 201, 201,
200, 200, 201, 201, 201, 200, 199, 199, 199, 199, 200, 201, 201, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
{200, 200, 200, 200, 200, 200, 200, 200, 201, 201, 201, 201, 201, 201, 201, 201,
201, 201, 202, 202, 202, 201, 200, 199, 202, 202, 202, 202, 202, 200, 199, 198,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
{200, 200, 200, 200, 200, 200, 200, 200, 201, 201, 201, 200, 200, 200, 199, 199,
200, 200, 200, 201, 201, 200, 200, 200, 200, 200, 201, 201, 201, 200, 200, 199,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
{200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 199, 199, 199, 198, 198, 198,
199, 199, 198, 198, 198, 199, 200, 201, 197, 197, 197, 198, 198, 200, 201, 202,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
{200, 200, 200, 200, 200, 200, 200, 200, 199, 199, 200, 200, 201, 202, 202, 203,
201, 200, 199, 198, 199, 201, 204, 205, 203, 202, 200, 199, 198, 200, 202, 203,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
{200, 200, 200, 200, 200, 200, 200, 200, 200, 201, 202, 203, 205, 207, 208, 209,
205, 203, 201, 200, 202, 205, 208, 211, 214, 211, 206, 202, 200, 200, 201, 202,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
{199, 199, 198, 199, 200, 202, 204, 205, 202, 200, 197, 198, 201, 204, 205, 205,
220, 204, 207, 222, 225, 201, 206, 213, 205, 218, 219, 224, 222, 198, 222, 208,
222, 208, 235, 201, 189, 204, 198, 202, 199, 201, 209, 192, 192, 217},
{200, 200, 199, 199, 200, 201, 202, 203, 210, 208, 205, 203, 201, 197, 191, 186,
170, 212, 216, 191, 222, 217, 218, 185, 216, 226, 200, 193, 207, 232, 193, 221,
210, 124, 127, 218, 223, 192, 197, 207, 207, 209, 210, 220, 209, 184},
{202, 201, 201, 200, 200, 200, 201, 201, 196, 197, 200, 203, 203, 200, 195, 191,
196, 180, 168, 123, 34, 66, 56, 74, 57, 83, 73, 81, 94, 221, 72, 64,
120, 119, 83, 100, 207, 190, 198, 198, 94, 44, 57, 50, 213, 215},
{54, 54, 54, 53, 53, 54, 54, 54, 49, 51, 55, 59, 62, 63, 63, 62, 54, 110, 65, 43, 69, 40, 54,
36, 53, 67, 57, 65, 66, 61, 94, 83, 83, 69, 102, 99, 64, 214, 195, 90, 28, 46, 63, 51, 43, 57},
{52, 52, 53, 54, 54, 55, 55, 55, 56, 54, 51, 48, 47, 46, 48, 49, 56, 63, 48, 72, 67, 55, 51,
65, 50, 48, 46, 70, 49, 67, 63, 86, 59, 107, 60, 73, 40, 44, 102, 36, 40, 218, 192, 165, 101, 44},
{198, 199, 200, 201, 202, 202, 202, 202, 199, 197, 194, 190, 188, 190, 194, 198,
196, 151, 88, 202, 61, 71, 148, 169, 165, 188, 139, 77, 86, 70, 81, 84,
163, 226, 206, 184, 52, 46, 48, 165, 204, 189, 179, 213, 208, 79},
{199, 200, 201, 202, 202, 201, 200, 199, 201, 203, 204, 205, 206, 209, 214, 218,
218, 198, 195, 199, 182, 201, 202, 206, 201, 228, 240, 191, 131, 121, 110, 221,
211, 208, 207, 198, 213, 231, 204, 220, 197, 211, 207, 194, 207, 213},
{201, 202, 202, 203, 202, 200, 199, 197, 199, 202, 206, 206, 204, 202, 202, 203,
205, 195, 210, 199, 211, 220, 210, 224, 224, 204, 215, 205, 227, 218, 229, 220,
203, 201, 199, 202, 206, 206, 195, 205, 203, 194, 202, 197, 210, 190},
{200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
203, 206, 210, 213, 213, 210, 206, 203, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
{200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
198, 199, 201, 202, 202, 201, 199, 198, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
{200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
199, 199, 198, 197, 197, 198, 199, 199, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
{200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
202, 201, 200, 199, 199, 200, 201, 202, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
{200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
199, 199, 199, 199, 199, 199, 199, 199, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
{200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
198, 199, 200, 201, 201, 200, 199, 198, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
{200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
201, 201, 202, 202, 202, 202, 201, 201, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200}};
static const uint8 jpeg_24bit_j80[JPEGY][JPEGX][3] = {
{{252, 106, 0}, {252, 106, 0}, {252, 106, 0}, {252, 106, 0}, {253, 105, 0}, {253, 105, 0},
{255, 104, 0}, {255, 104, 0}, {255, 105, 0}, {255, 105, 0}, {255, 105, 0}, {255, 104, 0},
{255, 104, 0}, {255, 103, 0}, {255, 102, 0}, {252, 106, 0}, {237, 111, 0}, {235, 114, 0},
{246, 111, 0}, {248, 111, 0}, {241, 114, 0}, {243, 111, 0}, {251, 103, 3}, {255, 99, 4},
{255, 105, 7}, {255, 106, 4}, {248, 110, 1}, {250, 108, 0}, {255, 99, 1}, {255, 97, 6},
{255, 101, 13}, {251, 104, 9}, {251, 106, 0}, {248, 108, 0}, {245, 109, 1}, {239, 110, 6},
{235, 111, 11}, {234, 111, 17}, {239, 107, 22}, {245, 107, 9}, {255, 106, 0}, {255, 105, 0},
{255, 102, 0}, {255, 101, 0}, {255, 101, 0}, {255, 101, 0}},
{{252, 105, 0}, {252, 105, 0}, {252, 105, 0}, {252, 105, 0}, {252, 105, 0}, {253, 105, 0},
{253, 105, 0}, {253, 105, 0}, {253, 102, 0}, {253, 102, 0}, {254, 101, 0}, {254, 101, 0},
{255, 102, 0}, {255, 102, 0}, {255, 101, 0}, {253, 105, 0}, {245, 109, 0}, {243, 109, 0},
{247, 105, 0}, {248, 104, 0}, {246, 105, 0}, {251, 106, 1}, {255, 104, 4}, {255, 105, 5},
{251, 98, 0}, {248, 102, 0}, {246, 105, 0}, {251, 105, 0}, {255, 101, 0}, {255, 100, 2},
{254, 104, 9}, {251, 105, 6}, {252, 106, 0}, {252, 106, 0}, {253, 105, 0}, {251, 105, 4},
{246, 106, 9}, {244, 106, 15}, {245, 105, 20}, {251, 104, 11}, {255, 104, 0}, {255, 104, 0},
{255, 102, 0}, {255, 102, 0}, {255, 104, 0}, {255, 105, 0}},
{{251, 105, 4}, {251, 105, 4}, {251, 105, 4}, {251, 105, 4}, {251, 105, 4}, {252, 104, 4}, {252, 104, 4},
{252, 104, 4}, {252, 103, 3}, {253, 104, 4}, {253, 104, 4}, {253, 104, 4}, {253, 104, 4}, {254, 105, 5},
{254, 105, 5}, {255, 105, 2}, {255, 105, 0}, {255, 103, 0}, {255, 102, 0}, {255, 99, 0}, {255, 97, 1},
{255, 98, 3}, {255, 102, 4}, {255, 105, 1}, {251, 104, 0}, {251, 107, 0}, {255, 108, 0}, {255, 107, 0},
{255, 104, 0}, {255, 104, 0}, {250, 105, 0}, {247, 105, 0}, {253, 106, 0}, {255, 103, 0}, {255, 96, 0},
{255, 94, 4}, {255, 95, 6}, {255, 98, 9}, {255, 98, 17}, {255, 99, 13}, {255, 99, 2}, {255, 100, 0},
{255, 103, 4}, {248, 106, 8}, {241, 109, 9}, {237, 111, 9}},
{{252, 104, 4}, {252, 104, 4}, {252, 104, 4}, {252, 104, 4}, {253, 104, 4}, {252, 104, 4},
{253, 104, 4}, {253, 104, 4}, {255, 106, 6}, {255, 106, 6}, {255, 106, 6}, {254, 105, 5},
{254, 105, 5}, {253, 104, 4}, {253, 104, 4}, {255, 102, 1}, {255, 98, 0}, {255, 97, 0},
{255, 100, 3}, {255, 98, 9}, {255, 95, 12}, {255, 95, 9}, {255, 98, 2}, {252, 101, 0},
{252, 108, 0}, {254, 108, 0}, {255, 103, 0}, {255, 103, 0}, {255, 103, 0}, {253, 106, 0},
{244, 109, 0}, {244, 107, 0}, {255, 105, 0}, {255, 99, 0}, {255, 95, 0}, {255, 94, 1},
{255, 94, 6}, {255, 96, 8}, {255, 98, 11}, {255, 99, 9}, {255, 98, 8}, {255, 99, 6},
{255, 102, 8}, {248, 105, 11}, {241, 108, 15}, {238, 109, 17}},
{{255, 102, 1}, {255, 102, 1}, {255, 102, 1}, {255, 103, 1}, {255, 102, 1}, {255, 103, 1}, {255, 102, 1},
{255, 103, 1}, {255, 103, 1}, {255, 103, 1}, {255, 103, 1}, {255, 103, 1}, {255, 103, 1}, {255, 103, 1},
{255, 103, 1}, {255, 99, 1}, {255, 93, 1}, {255, 92, 6}, {255, 93, 18}, {255, 93, 23}, {255, 92, 26},
{255, 95, 20}, {242, 105, 11}, {237, 108, 4}, {244, 105, 0}, {255, 100, 0}, {255, 90, 5}, {255, 91, 7},
{254, 99, 6}, {245, 108, 2}, {239, 114, 0}, {244, 112, 1}, {255, 99, 15}, {255, 96, 15}, {255, 101, 1},
{255, 102, 0}, {255, 102, 9}, {253, 103, 9}, {255, 103, 2}, {255, 103, 1}, {255, 100, 6}, {255, 99, 4},
{255, 100, 0}, {255, 101, 0}, {255, 100, 9}, {255, 100, 15}},
{{255, 101, 1}, {255, 101, 1}, {255, 101, 1}, {255, 101, 1}, {255, 101, 1}, {255, 101, 1},
{255, 101, 1}, {255, 101, 1}, {255, 102, 1}, {255, 102, 1}, {255, 103, 2}, {255, 103, 2},
{255, 104, 3}, {255, 105, 3}, {255, 105, 4}, {255, 104, 5}, {255, 100, 11}, {255, 97, 16},
{255, 94, 19}, {255, 93, 22}, {255, 95, 21}, {254, 102, 19}, {239, 115, 15}, {238, 120, 14},
{248, 108, 10}, {255, 100, 11}, {255, 88, 16}, {255, 89, 15}, {255, 100, 11}, {244, 107, 3},
{240, 111, 0}, {245, 107, 0}, {255, 98, 18}, {255, 96, 18}, {255, 103, 1}, {251, 106, 0},
{248, 105, 9}, {246, 106, 8}, {248, 108, 0}, {251, 107, 0}, {255, 103, 4}, {255, 101, 4},
{255, 101, 0}, {255, 100, 0}, {255, 99, 4}, {255, 98, 9}},
{{255, 100, 2}, {255, 100, 2}, {255, 100, 2}, {255, 100, 2}, {255, 100, 2}, {255, 100, 2},
{255, 101, 2}, {255, 101, 2}, {255, 104, 4}, {255, 104, 4}, {255, 103, 3}, {255, 102, 2},
{255, 102, 2}, {254, 102, 1}, {254, 100, 0}, {251, 101, 4}, {250, 103, 10}, {255, 101, 11},
{255, 99, 7}, {255, 100, 3}, {255, 102, 0}, {250, 105, 0}, {229, 112, 0}, {230, 109, 2},
{247, 98, 4}, {255, 91, 8}, {255, 85, 8}, {255, 89, 7}, {255, 100, 3}, {253, 105, 0},
{253, 103, 0}, {255, 100, 0}, {255, 99, 9}, {255, 99, 9}, {255, 102, 1}, {255, 104, 0},
{249, 106, 4}, {245, 108, 2}, {242, 112, 0}, {244, 111, 0}, {248, 106, 4}, {251, 105, 6},
{253, 105, 0}, {255, 105, 0}, {255, 103, 1}, {255, 102, 4}},
{{255, 99, 4}, {255, 99, 4}, {255, 99, 4}, {255, 100, 4}, {255, 99, 4}, {255, 100, 4},
{255, 100, 4}, {255, 101, 4}, {255, 102, 5}, {255, 101, 4}, {255, 98, 1}, {250, 96, 0},
{246, 92, 0}, {242, 90, 0}, {240, 86, 0}, {236, 86, 0}, {235, 92, 0}, {244, 96, 0},
{255, 96, 0}, {255, 97, 0}, {255, 97, 0}, {248, 92, 0}, {222, 87, 0}, {214, 78, 0},
{229, 68, 0}, {248, 67, 0}, {255, 72, 0}, {255, 81, 0}, {255, 94, 3}, {255, 99, 5},
{255, 97, 9}, {255, 98, 9}, {255, 101, 13}, {249, 104, 15}, {249, 104, 13}, {249, 105, 9},
{248, 106, 6}, {246, 108, 1}, {245, 110, 0}, {245, 110, 0}, {248, 106, 6}, {249, 105, 9},
{251, 105, 2}, {253, 105, 0}, {255, 103, 0}, {255, 103, 0}},
{{255, 98, 7}, {255, 98, 6}, {255, 98, 6}, {255, 99, 6}, {255, 94, 2}, {252, 89, 0},
{252, 89, 0}, {253, 93, 0}, {254, 94, 0}, {254, 95, 1}, {255, 96, 2}, {254, 97, 2},
{253, 96, 1}, {250, 96, 0}, {250, 93, 0}, {246, 93, 0}, {234, 86, 0}, {229, 71, 0},
{249, 64, 0}, {247, 51, 0}, {222, 30, 0}, {255, 73, 0}, {255, 83, 0}, {242, 72, 0},
{241, 67, 0}, {243, 64, 0}, {242, 60, 0}, {228, 41, 0}, {219, 28, 0}, {255, 83, 26},
{246, 56, 8}, {223, 52, 0}, {197, 60, 0}, {174, 54, 0}, {185, 64, 0}, {233, 105, 30},
{239, 101, 10}, {251, 105, 4}, {255, 110, 10}, {248, 94, 0}, {249, 98, 7}, {255, 111, 25},
{239, 83, 0}, {255, 105, 13}, {255, 99, 0}, {255, 100, 0}},
{{237, 105, 43}, {234, 104, 42}, {235, 105, 43}, {236, 106, 44}, {234, 104, 42}, {228, 100, 37},
{229, 101, 38}, {232, 104, 41}, {214, 89, 25}, {224, 99, 35}, {235, 111, 47}, {243, 119, 55},
{244, 120, 56}, {244, 122, 57}, {246, 124, 59}, {244, 130, 59}, {228, 126, 44}, {235, 132, 53},
{220, 100, 37}, {210, 84, 36}, {208, 85, 54}, {185, 62, 46}, {193, 64, 58}, {253, 126, 119},
{196, 79, 61}, {156, 47, 18}, {181, 78, 37}, {229, 120, 81}, {215, 89, 64}, {185, 62, 47},
{178, 73, 70}, {192, 114, 102}, {156, 111, 72}, {222, 190, 139}, {232, 195, 150}, {109, 49, 0},
{203, 101, 26}, {236, 106, 20}, {250, 104, 19}, {232, 90, 24}, {188, 75, 43}, {183, 83, 68},
{185, 83, 68}, {183, 70, 40}, {203, 68, 13}, {247, 100, 33}},
{{176, 117, 113}, {174, 116, 112}, {176, 118, 114}, {178, 120, 116}, {177, 119, 115}, {175, 117, 113},
{176, 118, 114}, {178, 123, 118}, {178, 123, 118}, {174, 119, 114}, {163, 108, 103}, {150, 97, 91},
{146, 93, 87}, {162, 109, 103}, {190, 137, 131}, {203, 166, 148}, {192, 185, 141}, {174, 190, 145},
{168, 193, 172}, {180, 214, 226}, {10, 45, 101}, {87, 110, 206}, {64, 61, 192}, {100, 92, 229},
{84, 94, 209}, {92, 118, 202}, {105, 143, 190}, {108, 147, 176}, {147, 170, 204}, {74, 112, 151},
{89, 171, 219}, {34, 144, 181}, {110, 227, 237}, {115, 232, 223}, {76, 187, 168}, {130, 191, 157},
{157, 124, 71}, {216, 124, 57}, {226, 108, 36}, {207, 113, 87}, {142, 120, 193}, {54, 69, 186},
{48, 66, 168}, {78, 66, 150}, {155, 87, 144}, {190, 95, 139}},
{{91, 67, 91}, {89, 65, 89}, {90, 66, 90}, {93, 69, 93}, {93, 69, 93}, {92, 68, 92},
{92, 70, 93}, {95, 73, 96}, {96, 74, 97}, {95, 73, 96}, {92, 68, 92}, {85, 63, 86},
{83, 61, 84}, {93, 71, 94}, {113, 91, 114}, {119, 113, 123}, {85, 113, 91}, {133, 192, 174},
{82, 171, 185}, {4, 111, 165}, {0, 108, 211}, {0, 58, 198}, {13, 72, 238}, {0, 40, 205},
{11, 77, 217}, {47, 127, 240}, {0, 95, 181}, {32, 134, 208}, {33, 129, 206}, {13, 135, 212},
{0, 168, 243}, {12, 203, 255}, {0, 143, 162}, {44, 194, 192}, {86, 226, 213}, {123, 220, 209},
{91, 110, 116}, {155, 123, 124}, {199, 145, 119}, {188, 145, 154}, {43, 40, 143}, {10, 34, 166},
{49, 83, 180}, {21, 42, 125}, {57, 44, 134}, {99, 70, 163}},
{{95, 70, 92}, {91, 66, 88}, {93, 65, 88}, {95, 67, 90}, {96, 68, 91}, {94, 66, 89},
{95, 67, 90}, {98, 70, 93}, {84, 56, 79}, {88, 60, 83}, {94, 64, 88}, {94, 66, 89},
{91, 63, 86}, {85, 57, 80}, {78, 50, 73}, {70, 50, 61}, {92, 90, 78}, {43, 72, 70},
{5, 73, 118}, {22, 115, 195}, {23, 124, 232}, {27, 117, 231}, {56, 114, 211}, {40, 83, 162},
{28, 74, 134}, {0, 51, 114}, {0, 64, 144}, {18, 97, 190}, {19, 114, 220}, {2, 128, 228},
{0, 159, 235}, {37, 205, 242}, {70, 177, 167}, {124, 193, 162}, {52, 106, 80}, {61, 109, 129},
{8, 60, 162}, {14, 64, 179}, {139, 181, 239}, {31, 41, 77}, {83, 30, 84}, {180, 109, 139},
{192, 142, 109}, {234, 217, 189}, {158, 185, 232}, {2, 52, 137}},
{{183, 122, 117}, {178, 117, 112}, {178, 115, 110}, {180, 117, 112}, {181, 118, 113}, {179, 116, 111},
{179, 116, 111}, {181, 118, 113}, {191, 126, 122}, {190, 125, 121}, {191, 126, 122}, {196, 131, 127},
{205, 137, 134}, {207, 139, 136}, {205, 137, 134}, {199, 136, 127}, {173, 116, 96}, {249, 217, 204},
{181, 186, 205}, {123, 151, 190}, {64, 97, 150}, {88, 110, 159}, {206, 203, 230}, {181, 160, 175},
{255, 230, 238}, {133, 110, 126}, {235, 230, 255}, {88, 111, 165}, {83, 137, 201}, {57, 137, 198},
{59, 159, 208}, {87, 166, 183}, {202, 217, 184}, {99, 76, 24}, {165, 128, 84}, {207, 177, 185},
{56, 58, 159}, {43, 62, 180}, {53, 75, 133}, {235, 218, 236}, {186, 84, 80}, {227, 96, 50},
{243, 136, 30}, {189, 124, 30}, {131, 128, 121}, {117, 145, 182}},
{{238, 109, 51}, {232, 103, 45}, {229, 100, 42}, {231, 102, 44}, {234, 104, 46}, {232, 102, 44},
{234, 101, 44}, {236, 103, 46}, {248, 113, 57}, {243, 108, 52}, {237, 102, 46}, {232, 97, 41},
{227, 90, 35}, {217, 80, 25}, {203, 66, 11}, {192, 55, 1}, {201, 66, 18}, {226, 102, 50},
{229, 127, 61}, {226, 135, 64}, {223, 130, 63}, {221, 116, 58}, {231, 108, 66}, {244, 103, 73},
{227, 68, 46}, {197, 48, 24}, {154, 42, 5}, {202, 134, 89}, {232, 210, 161}, {193, 179, 144},
{242, 195, 189}, {158, 81, 71}, {148, 43, 0}, {240, 117, 50}, {211, 76, 10}, {215, 80, 35},
{195, 67, 66}, {178, 57, 62}, {187, 72, 45}, {187, 63, 11}, {255, 108, 38}, {250, 97, 3},
{255, 126, 3}, {244, 120, 6}, {204, 100, 29}, {193, 98, 50}},
{{255, 101, 10}, {255, 96, 5}, {251, 92, 1}, {253, 94, 3}, {255, 95, 5}, {255, 95, 5},
{255, 95, 5}, {255, 95, 6}, {255, 91, 2}, {250, 86, 0}, {246, 81, 0}, {246, 81, 0},
{250, 85, 0}, {255, 91, 2}, {255, 93, 5}, {255, 92, 11}, {255, 88, 18}, {253, 86, 8},
{255, 100, 0}, {249, 96, 0}, {239, 80, 0}, {247, 81, 0}, {238, 62, 0}, {222, 30, 0},
{227, 20, 0}, {255, 72, 15}, {231, 69, 0}, {198, 74, 0}, {168, 82, 0}, {174, 88, 1},
{169, 39, 0}, {191, 36, 0}, {255, 102, 34}, {255, 91, 10}, {255, 98, 15}, {255, 95, 15},
{251, 67, 3}, {255, 80, 15}, {255, 85, 9}, {255, 96, 6}, {255, 91, 0}, {255, 110, 0},
{248, 94, 0}, {254, 101, 0}, {245, 92, 0}, {255, 103, 10}},
{{255, 104, 6}, {255, 104, 6}, {255, 103, 5}, {255, 102, 4}, {255, 101, 3}, {253, 99, 1},
{253, 99, 1}, {254, 97, 0}, {255, 101, 4}, {255, 101, 4}, {255, 101, 4}, {255, 101, 4},
{255, 101, 4}, {255, 101, 4}, {255, 101, 4}, {255, 100, 6}, {250, 86, 0}, {245, 80, 0},
{232, 73, 0}, {226, 67, 0}, {230, 69, 0}, {240, 77, 0}, {254, 86, 0}, {255, 93, 6},
{255, 95, 12}, {255, 94, 10}, {255, 96, 4}, {245, 99, 0}, {235, 103, 2}, {237, 104, 9},
{248, 102, 19}, {255, 101, 19}, {255, 101, 9}, {255, 101, 6}, {255, 101, 4}, {255, 100, 4},
{255, 99, 9}, {255, 99, 9}, {255, 100, 6}, {255, 101, 2}, {255, 102, 0}, {255, 103, 0},
{255, 104, 0}, {255, 104, 0}, {255, 104, 1}, {255, 103, 2}},
{{255, 105, 2}, {255, 105, 2}, {255, 104, 1}, {255, 104, 1}, {254, 103, 0}, {253, 102, 0}, {252, 101, 0},
{252, 101, 0}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1},
{255, 104, 1}, {255, 103, 1}, {255, 104, 6}, {255, 103, 5}, {255, 100, 2}, {255, 99, 1}, {255, 99, 1},
{255, 102, 4}, {255, 106, 8}, {255, 109, 10}, {255, 102, 3}, {255, 101, 2}, {255, 99, 0}, {255, 99, 0},
{255, 99, 0}, {255, 100, 0}, {255, 102, 2}, {255, 103, 3}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1},
{255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1},
{255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}},
{{255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {254, 103, 0}, {254, 103, 0}, {254, 103, 0},
{254, 103, 0}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1},
{255, 104, 1}, {255, 103, 1}, {255, 100, 1}, {255, 100, 2}, {255, 101, 3}, {255, 101, 3}, {255, 101, 3},
{255, 100, 2}, {255, 99, 1}, {255, 99, 0}, {255, 103, 4}, {255, 103, 3}, {255, 103, 3}, {255, 102, 2},
{255, 102, 2}, {255, 103, 3}, {255, 103, 3}, {255, 104, 4}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1},
{255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1},
{255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}},
{{255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1},
{255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1},
{255, 104, 1}, {255, 103, 1}, {255, 103, 4}, {255, 102, 3}, {255, 99, 1}, {255, 99, 0}, {255, 98, 0},
{255, 99, 0}, {255, 100, 1}, {255, 101, 1}, {255, 103, 3}, {255, 103, 3}, {255, 104, 4}, {255, 104, 4},
{255, 104, 4}, {255, 104, 4}, {255, 103, 3}, {255, 103, 3}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1},
{255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1},
{255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}},
{{254, 103, 0}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 105, 2}, {255, 105, 2},
{255, 105, 2}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1},
{255, 104, 1}, {255, 103, 1}, {255, 106, 6}, {255, 105, 5}, {255, 102, 3}, {255, 102, 2}, {255, 102, 2},
{255, 103, 3}, {255, 105, 5}, {255, 106, 6}, {255, 102, 2}, {255, 102, 2}, {255, 103, 3}, {255, 104, 3},
{255, 104, 3}, {255, 104, 3}, {255, 103, 2}, {255, 103, 2}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1},
{255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1},
{255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}},
{{255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 105, 2}, {255, 105, 2}, {255, 105, 2},
{255, 105, 2}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1},
{255, 104, 1}, {255, 104, 1}, {251, 97, 0}, {252, 98, 0}, {255, 100, 0}, {255, 101, 1}, {255, 102, 2},
{255, 101, 1}, {254, 100, 0}, {253, 99, 0}, {255, 101, 1}, {255, 103, 2}, {255, 103, 2}, {255, 103, 2},
{255, 103, 2}, {255, 103, 2}, {255, 103, 2}, {254, 102, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1},
{255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1},
{255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}},
{{255, 105, 2}, {255, 105, 2}, {255, 105, 2}, {255, 105, 2}, {255, 105, 2}, {255, 105, 2}, {255, 105, 2},
{255, 105, 2}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1},
{255, 104, 1}, {255, 104, 1}, {253, 102, 0}, {255, 104, 1}, {255, 105, 3}, {255, 108, 5}, {255, 108, 5},
{255, 107, 4}, {255, 105, 2}, {254, 103, 0}, {255, 104, 1}, {253, 104, 1}, {253, 104, 1}, {253, 104, 1},
{253, 104, 1}, {253, 104, 1}, {253, 104, 1}, {253, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1},
{255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1},
{255, 104, 1}, {255, 104, 1}, {255, 104, 1}, {255, 104, 1}}};
/* Sub-tests for test_mgr_old() */
static void
test_mgr_old_a(int flag)
{
int32 fid; /* HDF file ID */
int32 grid; /* GRID for the interface */
int32 ret; /* generic return value */
const char *oldrlefile = get_srcdir_filename(OLDRLEFILE);
(void)flag;
/* A - Read RLE compressed data from old raster image file */
MESSAGE(8, printf("Read RLE compressed image\n"););
/* Open up the existing datafile and get the image information from it */
fid = Hopen(oldrlefile, DFACC_READ, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize the GR interface */
grid = GRstart(fid);
CHECK_VOID(grid, FAIL, "GRstart");
{
int32 riid; /* RI ID for the new image */
int32 dims[2] = {10, 10}; /* dimensions for the empty image */
uint8 image[10][10]; /* space for the image data */
uint8 image0[10][10]; /* space for the image data */
int32 start[2]; /* start of image data to grab */
int32 stride[2]; /* stride of image data to grab */
intn i, j; /* indices */
/* Initialize data we are looking for in image */
for (i = 0; i < 10; i++)
for (j = 0; j < 10; j++)
image0[i][j] = (uint8)(i + j);
/* Get the first image in this file */
riid = GRselect(grid, 0);
CHECK_VOID(riid, FAIL, "GRselect");
/* Read the whole image in */
start[0] = start[1] = 0;
stride[0] = stride[1] = 1;
ret = GRreadimage(riid, start, stride, dims, image);
CHECK_VOID(ret, FAIL, "GRreadimage");
/* Verify correct image contents */
if (memcmp(image, image0, 10 * 10) != 0) {
MESSAGE(3, printf("Error reading data for RLE compressed image\n"););
num_errs++;
} /* end if */
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
}
/* Shut down the GR interface */
ret = GRend(grid);
CHECK_VOID(ret, FAIL, "GRend");
/* Close the file */
ret = Hclose(fid);
CHECK_VOID(ret, FAIL, "Hclose");
} /* end test_mgr_old_a() */
static void
test_mgr_old_c(int flag)
{
int32 fid; /* HDF file ID */
int32 grid; /* GRID for the interface */
int32 ret; /* generic return value */
const char *oldgreyjpegfile = get_srcdir_filename(OLDGREYJPEGFILE);
(void)flag;
/* C - Read 8-bit JPEG compressed data from old raster image file */
MESSAGE(8, printf("Read 8-bit JPEG compressed image\n"););
/* Open up the existing datafile and get the image information from it */
fid = Hopen(oldgreyjpegfile, DFACC_READ, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize the GR interface */
grid = GRstart(fid);
CHECK_VOID(grid, FAIL, "GRstart");
{
int32 riid; /* RI ID for the new image */
int32 dims[2] = {JPEGX, JPEGY}; /* dimensions for the empty image */
uint8 image[JPEGY][JPEGX]; /* space for the image data */
int32 start[2]; /* start of image data to grab */
int32 stride[2]; /* stride of image data to grab */
/* Get the first image in this file */
riid = GRselect(grid, 0);
CHECK_VOID(riid, FAIL, "GRselect");
/* Read the whole image in */
start[0] = start[1] = 0;
stride[0] = stride[1] = 1;
ret = GRreadimage(riid, start, stride, dims, image);
CHECK_VOID(ret, FAIL, "GRreadimage");
/* Verify correct image contents */
if (memcmp(image, jpeg_8bit_j80, JPEGY * JPEGX) != 0) {
MESSAGE(3, printf("Error reading data for 8-bit JPEG compressed image\n"););
num_errs++;
} /* end if */
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
}
/* Shut down the GR interface */
ret = GRend(grid);
CHECK_VOID(ret, FAIL, "GRend");
/* Close the file */
ret = Hclose(fid);
CHECK_VOID(ret, FAIL, "Hclose");
} /* end test_mgr_old_c() */
static void
test_mgr_old_e(int flag)
{
int32 fid; /* HDF file ID */
int32 grid; /* GRID for the interface */
int32 ret; /* generic return value */
const char *oldjpegfile = get_srcdir_filename(OLDJPEGFILE);
(void)flag;
/* E - Read 24-bit JPEG compressed data from old raster image file */
MESSAGE(8, printf("Read 24-bit JPEG compressed image\n"););
/* Open up the existing datafile and get the image information from it */
fid = Hopen(oldjpegfile, DFACC_READ, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize the GR interface */
grid = GRstart(fid);
CHECK_VOID(grid, FAIL, "GRstart");
{
int32 riid; /* RI ID for the new image */
int32 dims[2] = {JPEGX, JPEGY}; /* dimensions for the empty image */
uint8 image[JPEGY][JPEGX][3]; /* space for the image data */
int32 start[2]; /* start of image data to grab */
int32 stride[2]; /* stride of image data to grab */
/* Get the first image in this file */
riid = GRselect(grid, 0);
CHECK_VOID(riid, FAIL, "GRselect");
/* Read the whole image in */
start[0] = start[1] = 0;
stride[0] = stride[1] = 1;
ret = GRreadimage(riid, start, stride, dims, image);
CHECK_VOID(ret, FAIL, "GRreadimage");
/* Verify correct image contents */
if (memcmp(image, jpeg_24bit_j80, JPEGY * JPEGX * 3) != 0) {
/* MESSAGE(3, printf("Error reading data for 24-bit JPEG compressed image\n"););
num_errs++;
*/
} /* end if */
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
}
/* Shut down the GR interface */
ret = GRend(grid);
CHECK_VOID(ret, FAIL, "GRend");
/* Close the file */
ret = Hclose(fid);
CHECK_VOID(ret, FAIL, "Hclose");
} /* end test_mgr_old_e() */
/****************************************************************
**
** test_mgr_old(): Multi-file Raster Old-style Image Access tests
**
** VIII. Old-style raster image tests
** A. Read data from RLE compressed image
** B. Create RLE compressed image & write to it (not implemented)
** C. Read data from 8-bit JPEG compressed image
** D. Create 8-bit JPEG compressed image & write to it
** E. Read data from 24-bit JPEG compressed image
** F. Create 24-bit JPEG compressed image & write to it
**
****************************************************************/
static void
test_mgr_old(int flag)
{
/* Output message about test being performed */
MESSAGE(6, printf("Testing Multi-file Raster Old-Style Access\n"););
test_mgr_old_a(flag);
test_mgr_old_c(flag);
test_mgr_old_e(flag);
} /* end test_mgr_old() */
#define GR_R24FILE "test_files/gr_r24.dat"
#define GR_R24XDIM 8
#define GR_R24YDIM 10
/* Sub-tests for test_mgr_r24() */
static void
test_mgr_r24_a(int flag)
{
int32 fid; /* HDF file ID */
int32 grid; /* GRID for the interface */
int32 ret; /* generic return value */
const char *gr_r24file = get_srcdir_filename(GR_R24FILE);
(void)flag;
/* A - Write/Read DF24 image */
MESSAGE(8, printf("Operate on DF24 images\n"););
/* Open up the existing datafile and get the image information from it */
fid = Hopen(gr_r24file, DFACC_READ, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize the GR interface */
grid = GRstart(fid);
CHECK_VOID(grid, FAIL, "GRstart");
{
int32 riid; /* RI ID for the new image */
int32 dims[2] = {GR_R24XDIM, GR_R24YDIM}; /* dimensions for the empty image */
uint8 image[GR_R24YDIM][GR_R24XDIM][3]; /* space for the image data */
uint8 image0[GR_R24YDIM][GR_R24XDIM][3]; /* space for the image data */
int32 start[2]; /* start of image data to grab */
int32 stride[2]; /* stride of image data to grab */
int32 ncomp; /* Number of components in the DF24 image */
int32 nt; /* Number-type of the DF24 image */
int32 dimsizes[2]; /* Dimensions of the DF24 image */
intn i, j, k; /* indices */
intn is_mappedable; /* TRUE if the image is mapped-able (hmap project)*/
intn name_generated; /* TRUE if the image has name generated by lib */
/* Initialize data we are going to write out */
for (i = 0; i < GR_R24YDIM; i++)
for (j = 0; j < GR_R24XDIM; j++)
for (k = 0; k < 3; k++)
image[i][j][k] = (k + 1) * j;
/* Get the first image in this file */
riid = GRselect(grid, 0);
CHECK_VOID(riid, FAIL, "GRselect");
/* Check the image information */
ret = GRgetiminfo(riid, NULL, &ncomp, &nt, NULL, dimsizes, NULL);
CHECK_VOID(ret, FAIL, "GRgetiminfo");
VERIFY_VOID(ncomp, 3, "GRgetiminfo");
VERIFY_VOID(nt, DFNT_UCHAR8, "GRgetiminfo");
VERIFY_VOID(dimsizes[0], dims[0], "GRgetiminfo");
VERIFY_VOID(dimsizes[1], dims[1], "GRgetiminfo");
/* Test GR2bmapped on this image, should not be mapped-able because */
/* ncomp=3. (For hmap project only) */
ret = GR2bmapped(riid, &is_mappedable, &name_generated);
CHECK_VOID(ret, FAIL, "GR2bmapped");
VERIFY_VOID(is_mappedable, FALSE, "GR2bmapped");
VERIFY_VOID(name_generated, TRUE, "GR2bmapped");
/* Read the whole image in */
start[0] = start[1] = 0;
stride[0] = stride[1] = 1;
ret = GRreadimage(riid, start, stride, dims, image0);
CHECK_VOID(ret, FAIL, "GRreadimage");
/* Verify correct image contents */
if (memcmp(image, image0, GR_R24YDIM * GR_R24XDIM * 3) != 0) {
MESSAGE(3, printf("Error reading data for DF24 image\n"););
num_errs++;
} /* end if */
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
}
/* Shut down the GR interface */
ret = GRend(grid);
CHECK_VOID(ret, FAIL, "GRend");
/* Close the file */
ret = Hclose(fid);
CHECK_VOID(ret, FAIL, "Hclose");
} /* end test_mgr_r24_a() */
/****************************************************************
**
** test_mgr_r24(): Multi-file Raster/DF24 Compatibility Tests
**
** X. Multi-File Raster/DF24 Compatibility Tests
** A. Read/Write DF24 Image
**
****************************************************************/
static void
test_mgr_r24(int flag)
{
/* Output message about test being performed */
MESSAGE(6, printf("Testing Multi-file Raster/DF24 Compatibility\n"););
test_mgr_r24_a(flag);
} /* end test_mgr_r24() */
#define GR_R8FILE "gr_r8.hdf"
#define GR_R8XDIM 8
#define GR_R8YDIM 10
/* Sub-tests for test_mgr_r8() */
static void
test_mgr_r8_a(int flag)
{
int32 fid; /* HDF file ID */
int32 grid; /* GRID for the interface */
int32 ret; /* generic return value */
uint8 palette[256][3];
uint8 picture[GR_R8YDIM][GR_R8XDIM];
intn i, j; /* indices */
(void)flag;
/* A - Write/Read DF8 image with palette */
MESSAGE(8, printf("Operate on DF8 images\n"););
/* initialize the palette */
for (i = 0; i < 256; i++) {
for (j = 0; j < 3; j++) {
palette[i][j] = i;
}
}
/* initialize the image */
for (j = 0; j < GR_R8XDIM; j++) {
for (i = 0; i < GR_R8YDIM; i++) {
picture[i][j] = i + j;
}
}
/* Write out the test data */
ret = DFR8setpalette((void *)palette);
CHECK_VOID(ret, FAIL, "DFR8setpalette");
ret = DFR8putimage(GR_R8FILE, (void *)picture, GR_R8XDIM, GR_R8YDIM, COMP_RLE);
CHECK_VOID(ret, FAIL, "DFR8putimage");
/* Open up the existing datafile and get the image information from it */
fid = Hopen(GR_R8FILE, DFACC_READ, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize the GR interface */
grid = GRstart(fid);
CHECK_VOID(grid, FAIL, "GRstart");
{
int32 riid; /* RI ID for the image */
int32 pal_id; /* Palette ID for the LUT */
int32 dims[2] = {GR_R8XDIM, GR_R8YDIM}; /* dimensions for the empty image */
uint8 image[GR_R8YDIM][GR_R8XDIM]; /* space for the image data */
uint8 image0[GR_R8YDIM][GR_R8XDIM]; /* space for the image data */
int32 start[2]; /* start of image data to grab */
int32 stride[2]; /* stride of image data to grab */
int32 ncomp; /* Number of components in the DFR8 image */
int32 nt; /* Number-type of the DFR8 image */
int32 dimsizes[2]; /* Dimensions of the DFR8 image */
int32 interlace; /* Palette interlace */
int32 num_entries; /* Number of palette entries */
intn is_mappedable; /* TRUE if the image is mapped-able (hmap project)*/
intn name_generated; /* TRUE if the image has name generated by lib */
/* Initialize data we are expecting to read in */
for (i = 0; i < GR_R8YDIM; i++)
for (j = 0; j < GR_R8XDIM; j++)
image[i][j] = i + j;
/* Get the first image in this file */
riid = GRselect(grid, 0);
CHECK_VOID(riid, FAIL, "GRselect");
/* Check the image information */
ret = GRgetiminfo(riid, NULL, &ncomp, &nt, NULL, dimsizes, NULL);
CHECK_VOID(ret, FAIL, "GRgetiminfo");
VERIFY_VOID(ncomp, 1, "GRgetiminfo");
VERIFY_VOID(nt, DFNT_UCHAR8, "GRgetiminfo");
VERIFY_VOID(dimsizes[0], dims[0], "GRgetiminfo");
VERIFY_VOID(dimsizes[1], dims[1], "GRgetiminfo");
/* Test GR2bmapped on this image, should be mapped-able */
/* (For hmap project only) */
ret = GR2bmapped(riid, &is_mappedable, &name_generated);
CHECK_VOID(ret, FAIL, "GR2bmapped");
VERIFY_VOID(is_mappedable, TRUE, "GR2bmapped");
VERIFY_VOID(name_generated, TRUE, "GR2bmapped");
/* Read the whole image in */
start[0] = start[1] = 0;
stride[0] = stride[1] = 1;
ret = GRreadimage(riid, start, stride, dims, image0);
CHECK_VOID(ret, FAIL, "GRreadimage");
/* Verify correct image contents */
if (memcmp(image, image0, GR_R8YDIM * GR_R8XDIM) != 0) {
MESSAGE(3, printf("Error reading data for DF8 image\n"););
num_errs++;
} /* end if */
pal_id = GRgetlutid(riid, 0);
CHECK_VOID(pal_id, FAIL, "GRgetlutid");
ncomp = nt = 0;
ret = GRgetlutinfo(pal_id, &ncomp, &nt, &interlace, &num_entries);
CHECK_VOID(ret, FAIL, "GRgetlutinfo");
VERIFY_VOID(ncomp, 3, "GRgetlutinfo");
VERIFY_VOID(nt, DFNT_UINT8, "GRgetlutinfo");
VERIFY_VOID(interlace, 0, "GRgetlutinfo");
VERIFY_VOID(num_entries, 256, "GRgetlutinfo");
/* Close the empty image */
ret = GRendaccess(riid);
CHECK_VOID(ret, FAIL, "GRendaccess");
}
/* Shut down the GR interface */
ret = GRend(grid);
CHECK_VOID(ret, FAIL, "GRend");
/* Close the file */
ret = Hclose(fid);
CHECK_VOID(ret, FAIL, "Hclose");
} /* end test_mgr_r8_a() */
/****************************************************************
**
** test_mgr_r8(): Multi-file Raster/DF8 Compatibility Tests
**
** XI. Multi-File Raster/DF8 Compatibility Tests
** A. Read/Write DF8 Image with palette
**
****************************************************************/
static void
test_mgr_r8(int flag)
{
/* Output message about test being performed */
MESSAGE(6, printf("Testing Multi-file Raster/DF8 Compatibility\n"););
test_mgr_r8_a(flag);
} /* end test_mgr_r8() */
static void
test_mgr_chunkwr_pixelone()
{
/*
* This function tests GR chunking write/read operations for the
* following types of compressions:
* COMP_NONE
* COMP_CODE_RLE
* COMP_CODE_SKPHUFF
* COMP_CODE_DEFLATE
* and PIXEL interlace mode.
*/
#define CHUNKFILE "ChunkedGR.hdf"
#define X_LENGTH 10 /* number of columns in the image */
#define Y_LENGTH 6 /* number of rows in the image */
#define N_COMPS 3 /* number of components in the image */
#define COMP_METH 4 /* number of compression methods used - 4 (0-based) */
/************************* Variable declaration **************************/
intn status; /* status for functions returning an intn */
int32 file_id, /* HDF file identifier */
gr_id, /* GR interface identifier */
ri_id[4], /* raster image identifier */
origin[2], /* start position to write for each dimension */
dim_sizes[2], /* dimension sizes of the image array */
interlace_mode, /* interlace mode of the image */
data_type, /* data type of the image data */
comp_flag, /* compression flag */
index, i;
int32 start[2], stride[2], edge[2];
int16 data_out[3 * Y_LENGTH * X_LENGTH];
char *image_name[] = {"Image_NO", "Image_RL", "Image_Sk", "Image_DF"};
HDF_CHUNK_DEF chunk_def;
int16 chunk_buf[18];
int16 chunk00[] = {110, 111, 112, 120, 121, 122, 130, 131, 132,
140, 141, 142, 150, 151, 152, 160, 161, 162};
int16 chunk01[] = {210, 211, 212, 220, 221, 222, 230, 231, 232,
240, 241, 242, 250, 251, 252, 260, 261, 262};
int16 chunk14[] = {1010, 1011, 1012, 1020, 1021, 1022, 1030, 1031, 1032,
1040, 1041, 1042, 1050, 1051, 1052, 1060, 1061, 1062};
int16 data[] = {110, 111, 112, 120, 121, 122, 210, 211, 212, 220, 221, 222, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
130, 131, 132, 140, 141, 142, 230, 231, 232, 240, 241, 242, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
150, 151, 152, 160, 161, 162, 250, 251, 252, 260, 261, 262, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1010, 1011, 1012, 1020, 1021, 1022,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1030, 1031, 1032, 1040, 1041, 1042,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1050, 1051, 1052, 1060, 1061, 1062};
/********************** End of variable declaration **********************/
/*
* Create and open the file.
*/
file_id = Hopen(CHUNKFILE, DFACC_WRITE, 0);
CHECK_VOID(file_id, FAIL, "Hopen");
/*
* Initialize the GR interface.
*/
gr_id = GRstart(file_id);
CHECK_VOID(gr_id, FAIL, "GRstart");
/*
* Set the data type, interlace mode, and dimensions of the image.
*/
data_type = DFNT_INT16;
interlace_mode = MFGR_INTERLACE_PIXEL;
dim_sizes[0] = Y_LENGTH;
dim_sizes[1] = X_LENGTH;
for (i = 0; i < COMP_METH; i++) {
/*
* Create the raster image array.
*/
ri_id[i] = GRcreate(gr_id, image_name[i], N_COMPS, data_type, interlace_mode, dim_sizes);
CHECK_VOID(ri_id[i], FAIL, "GRcreate");
/*
* Create chunked image array.
*/
switch (i) {
case 0:
comp_flag = HDF_CHUNK;
chunk_def.chunk_lengths[0] = 3;
chunk_def.chunk_lengths[1] = 2;
break;
case 1:
comp_flag = HDF_CHUNK | HDF_COMP;
chunk_def.comp.chunk_lengths[0] = 3;
chunk_def.comp.chunk_lengths[1] = 2;
chunk_def.comp.comp_type = COMP_CODE_RLE;
break;
case 2: {
comp_flag = HDF_CHUNK | HDF_COMP;
chunk_def.comp.chunk_lengths[0] = 3;
chunk_def.comp.chunk_lengths[1] = 2;
chunk_def.comp.comp_type = COMP_CODE_SKPHUFF;
chunk_def.comp.cinfo.skphuff.skp_size = 2;
break;
}
case 3: {
comp_flag = HDF_CHUNK | HDF_COMP;
chunk_def.comp.chunk_lengths[0] = 3;
chunk_def.comp.chunk_lengths[1] = 2;
chunk_def.comp.comp_type = COMP_CODE_DEFLATE;
chunk_def.comp.cinfo.deflate.level = 6;
break;
}
default: {
printf("Error\n");
break;
}
} /* end switch */
status = GRsetchunk(ri_id[i], chunk_def, comp_flag);
CHECK_VOID(status, FAIL, "GRsetchunk");
/*
* Write first data chunk ( 0, 0 ).
*/
origin[0] = origin[1] = 0;
status = GRwritechunk(ri_id[i], origin, (void *)chunk00);
CHECK_VOID(status, FAIL, "GRwritechunk");
/*
* Write second data chunk ( 0, 1 ).
*/
origin[0] = 0;
origin[1] = 1;
status = GRwritechunk(ri_id[i], origin, (void *)chunk01);
CHECK_VOID(status, FAIL, "GRwritechunk");
/*
* Write third data chunk ( 1, 4 ).
*/
origin[0] = 1;
origin[1] = 4;
status = GRwritechunk(ri_id[i], origin, (void *)chunk14);
CHECK_VOID(status, FAIL, "GRwritechunk");
/*
* Read third chunk back.
*/
origin[0] = 1;
origin[1] = 4;
status = GRreadchunk(ri_id[i], origin, (void *)chunk_buf);
CHECK_VOID(status, FAIL, "GRreadchunk");
/*
* Terminate access to the GR interface and close the HDF file.
*/
status = GRendaccess(ri_id[i]);
CHECK_VOID(status, FAIL, "GRendaccess");
} /* end for*/
status = GRend(gr_id);
CHECK_VOID(status, FAIL, "GRend");
status = Hclose(file_id);
CHECK_VOID(status, FAIL, "Hclose");
/*
* Open the file.
*/
file_id = Hopen(CHUNKFILE, DFACC_WRITE, 0);
CHECK_VOID(file_id, FAIL, "Hopen");
/*
* Initialize the GR interface.
*/
gr_id = GRstart(file_id);
CHECK_VOID(gr_id, FAIL, "GRstart");
for (i = 0; i < COMP_METH; i++) {
/*
* Find the index of the specified image.
*/
index = GRnametoindex(gr_id, image_name[i]);
CHECK_VOID(index, FAIL, "GRnametoindex");
/*
* Select the image.
*/
ri_id[i] = GRselect(gr_id, index);
CHECK_VOID(ri_id[i], FAIL, "GRselect");
/*
* Read third chunk back.
*/
origin[0] = 1;
origin[1] = 4;
status = GRreadchunk(ri_id[i], origin, (void *)chunk_buf);
CHECK_VOID(status, FAIL, "GRreadchunk");
if (0 != memcmp(chunk_buf, chunk14, sizeof(chunk14))) {
MESSAGE(3, printf("%d: Error in reading chunk\n", __LINE__););
MESSAGE(3, printf("%d: Compression method\n", (int)i););
num_errs++;
} /* end if */
/*
* Read the whole image.
*/
start[0] = start[1] = 0;
stride[0] = stride[1] = 1;
edge[0] = Y_LENGTH;
edge[1] = X_LENGTH;
status = GRreadimage(ri_id[i], start, stride, edge, (void *)data_out);
CHECK_VOID(status, FAIL, "GRreadimage");
if (0 != memcmp(data_out, data, sizeof(data))) {
MESSAGE(3, printf("%d: Error reading data for the whole image\n", __LINE__););
MESSAGE(3, printf("%d: Compression method\n", (int)i););
num_errs++;
} /* end if */
status = GRendaccess(ri_id[i]);
CHECK_VOID(status, FAIL, "GRendaccess");
} /* end for */
/*
* Terminate access to the GR interface and close the HDF file.
*/
status = GRend(gr_id);
CHECK_VOID(status, FAIL, "GRend");
status = Hclose(file_id);
CHECK_VOID(status, FAIL, "Hclose");
}
static void
test_mgr_chunkwr_pixel(int flag)
{
/*
* This function tests GR chunking write/read operations for the
* following types of compressions:
* COMP_NONE
* COMP_CODE_RLE
* COMP_CODE_SKPHUFF
* COMP_CODE_DEFLATE
* and PIXEL interlace mode.
*/
/* Writing images to one file does not work , we will write each image to
the different files
#define FILE_NAME "ChunkedGR.hdf"
*/
#define X_LENGTH 10 /* number of columns in the image */
#define Y_LENGTH 6 /* number of rows in the image */
#define N_COMPS 3 /* number of components in the image */
#define COMP_METH 4 /* number of compression methods used - 4 (0-based) */
/************************* Variable declaration **************************/
intn status; /* status for functions returning an intn */
int32 file_id, /* HDF file identifier */
gr_id, /* GR interface identifier */
ri_id[4], /* raster image identifier */
origin[2], /* start position to write for each dimension */
dim_sizes[2], /* dimension sizes of the image array */
interlace_mode, /* interlace mode of the image */
data_type, /* data type of the image data */
comp_flag, /* compression flag */
index, i;
int32 start[2], stride[2], edge[2];
intn is_mappedable; /* TRUE if the image is mapped-able (hmap project)*/
intn name_generated; /* TRUE if the image has name generated by lib */
int16 data_out[3 * Y_LENGTH * X_LENGTH];
const char *image_name[] = {"Image_NO", "Image_RL", "Image_Sk", "Image_DF"};
const char *file_name[] = {"ChunkedGR_NO.hdf", "ChunkedGR_RL.hdf", "ChunkedGR_SK.hdf",
"ChunkedGR_DF.hdf"};
HDF_CHUNK_DEF chunk_def;
int16 chunk_buf[18];
int16 chunk00[] = {110, 111, 112, 120, 121, 122, 130, 131, 132,
140, 141, 142, 150, 151, 152, 160, 161, 162};
int16 chunk01[] = {210, 211, 212, 220, 221, 222, 230, 231, 232,
240, 241, 242, 250, 251, 252, 260, 261, 262};
int16 chunk14[] = {1010, 1011, 1012, 1020, 1021, 1022, 1030, 1031, 1032,
1040, 1041, 1042, 1050, 1051, 1052, 1060, 1061, 1062};
int16 data[] = {110, 111, 112, 120, 121, 122, 210, 211, 212, 220, 221, 222, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
130, 131, 132, 140, 141, 142, 230, 231, 232, 240, 241, 242, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
150, 151, 152, 160, 161, 162, 250, 251, 252, 260, 261, 262, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1010, 1011, 1012, 1020, 1021, 1022,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1030, 1031, 1032, 1040, 1041, 1042,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1050, 1051, 1052, 1060, 1061, 1062};
/********************** End of variable declaration **********************/
i = flag;
memset(&chunk_def, 0, sizeof(HDF_CHUNK_DEF));
/*
* Create and open the file.
*/
/* This call is commented out, since writing to one file does not work
file_id = Hopen (FILE_NAME, DFACC_WRITE, 0);
*/
file_id = Hopen(file_name[i], DFACC_CREATE, 0);
CHECK_VOID(file_id, FAIL, "Hopen");
/*
* Initialize the GR interface.
*/
gr_id = GRstart(file_id);
CHECK_VOID(gr_id, FAIL, "GRstart");
/*
* Set the data type, interlace mode, and dimensions of the image.
*/
data_type = DFNT_INT16;
interlace_mode = MFGR_INTERLACE_PIXEL;
dim_sizes[0] = Y_LENGTH;
dim_sizes[1] = X_LENGTH;
/* for (i = 0; i < COMP_METH; i++ ) { */
/*
* Create the raster image array.
*/
ri_id[i] = GRcreate(gr_id, image_name[i], N_COMPS, data_type, interlace_mode, dim_sizes);
CHECK_VOID(ri_id[i], FAIL, "GRcreate");
/*
* Create chunked image array.
*/
switch (i) {
case 0:
comp_flag = HDF_CHUNK;
chunk_def.chunk_lengths[0] = 3;
chunk_def.chunk_lengths[1] = 2;
break;
case 1:
comp_flag = HDF_CHUNK | HDF_COMP;
chunk_def.comp.chunk_lengths[0] = 3;
chunk_def.comp.chunk_lengths[1] = 2;
chunk_def.comp.comp_type = COMP_CODE_RLE;
break;
case 2: {
comp_flag = HDF_CHUNK | HDF_COMP;
chunk_def.comp.chunk_lengths[0] = 3;
chunk_def.comp.chunk_lengths[1] = 2;
chunk_def.comp.comp_type = COMP_CODE_SKPHUFF;
chunk_def.comp.cinfo.skphuff.skp_size = 2;
break;
}
case 3: {
comp_flag = HDF_CHUNK | HDF_COMP;
chunk_def.comp.chunk_lengths[0] = 3;
chunk_def.comp.chunk_lengths[1] = 2;
chunk_def.comp.comp_type = COMP_CODE_DEFLATE;
chunk_def.comp.cinfo.deflate.level = 6;
break;
}
default: {
comp_flag = HDF_NONE;
printf("Error\n");
break;
}
} /* end switch */
status = GRsetchunk(ri_id[i], chunk_def, comp_flag);
CHECK_VOID(status, FAIL, "GRsetchunk");
/*
* Write first data chunk ( 0, 0 ).
*/
origin[0] = origin[1] = 0;
status = GRwritechunk(ri_id[i], origin, (void *)chunk00);
CHECK_VOID(status, FAIL, "GRwritechunk");
/*
* Write second data chunk ( 0, 1 ).
*/
origin[0] = 0;
origin[1] = 1;
status = GRwritechunk(ri_id[i], origin, (void *)chunk01);
CHECK_VOID(status, FAIL, "GRwritechunk");
/*
* Write third data chunk ( 1, 4 ).
*/
origin[0] = 1;
origin[1] = 4;
status = GRwritechunk(ri_id[i], origin, (void *)chunk14);
CHECK_VOID(status, FAIL, "GRwritechunk");
/*
* Read third chunk back.
*/
origin[0] = 1;
origin[1] = 4;
status = GRreadchunk(ri_id[i], origin, (void *)chunk_buf);
/*
* Terminate access to the GR interface and close the HDF file.
*/
status = GRendaccess(ri_id[i]);
CHECK_VOID(status, FAIL, "GRendaccess");
/* } */ /* end for*/
status = GRend(gr_id);
CHECK_VOID(status, FAIL, "GRend");
status = Hclose(file_id);
CHECK_VOID(status, FAIL, "Hclose");
/*
* Open the file.
*/
/* This does not work, GRreadchunk will fail!
file_id = Hopen (FILE_NAME, DFACC_READ, 0);
*/
/* file_id = Hopen (FILE_NAME, DFACC_WRITE, 0); */
file_id = Hopen(file_name[i], DFACC_WRITE, 0);
CHECK_VOID(file_id, FAIL, "Hopen");
/*
* Initialize the GR interface.
*/
gr_id = GRstart(file_id);
CHECK_VOID(gr_id, FAIL, "GRstart");
/*for (i = 0; i < COMP_METH; i++ ) { */
/*
* Find the index of the specified image.
*/
index = GRnametoindex(gr_id, image_name[i]);
CHECK_VOID(index, FAIL, "GRnametoindex");
/*
* Select the image.
*/
ri_id[i] = GRselect(gr_id, index);
CHECK_VOID(ri_id[i], FAIL, "GRselect");
/*
* Read third chunk back.
*/
origin[0] = 1;
origin[1] = 4;
status = GRreadchunk(ri_id[i], origin, (void *)chunk_buf);
CHECK_VOID(status, FAIL, "GRreadchunk");
if (0 != memcmp(chunk_buf, chunk14, sizeof(chunk14))) {
MESSAGE(3, printf("%d: Error in reading chunk\n", __LINE__););
MESSAGE(3, printf("%d: Compression method\n", (int)i););
num_errs++;
} /* end if */
/*
* Read the whole image.
*/
start[0] = start[1] = 0;
stride[0] = stride[1] = 1;
edge[0] = Y_LENGTH;
edge[1] = X_LENGTH;
status = GRreadimage(ri_id[i], start, stride, edge, (void *)data_out);
CHECK_VOID(status, FAIL, "GRreadimage");
if (0 != memcmp(data_out, data, sizeof(data))) {
MESSAGE(3, printf("%d: Error reading data for the whole image\n", __LINE__););
MESSAGE(3, printf("%d: Compression method\n", (int)i););
num_errs++;
} /* end if */
/* Test GR2bmapped on this image, should not be mapped-able because it has */
/* chunking storage. (For hmap project only) */
status = GR2bmapped(ri_id[i], &is_mappedable, &name_generated);
CHECK_VOID(status, FAIL, "GR2bmapped");
VERIFY_VOID(is_mappedable, FALSE, "GR2bmapped");
VERIFY_VOID(name_generated, FALSE, "GR2bmapped");
status = GRendaccess(ri_id[i]);
CHECK_VOID(status, FAIL, "GRendaccess");
/*} */ /* end for */
/*
* Terminate access to the GR interface and close the HDF file.
*/
status = GRend(gr_id);
CHECK_VOID(status, FAIL, "GRend");
status = Hclose(file_id);
CHECK_VOID(status, FAIL, "Hclose");
}
/****************************************************************
**
** test_mgr_chunkwr(): GR chunking test
**
** XIII. GR write/read chunking test with enabled compression and
** different interlace modes.
**
** A. Write/read GR chunks with different kinds of compressions
** and PIXEL Interlace Mode (test_mgr_chunkrw_pixel)
**
**
****************************************************************/
static void
test_mgr_chunkwr(void)
{
/* Output message about test being performed */
MESSAGE(6, printf("Testing GR chunking WRITE/READ\n"););
test_mgr_chunkwr_pixelone();
test_mgr_chunkwr_pixel(0);
test_mgr_chunkwr_pixel(1);
test_mgr_chunkwr_pixel(2);
test_mgr_chunkwr_pixel(3);
} /* end test_mgr_chunkwr() */
/****************************************************************
**
** test_mgr(): Main multi-file raster image test routine
**
****************************************************************/
void
test_mgr(void)
{
/*
Each major outline portion has its own main function:
I. Interface Initialization - test_mgr_init
II. Create Images - test_mgr_image
III. ID/Ref/Index Functions - test_mgr_index
IV. Interlace Functions - test_mgr_interlace
V. Palette Functions - test_mgr_lut
VI. Special Element Functions - test_mgr_special
VII. Attribute Functions - test_mgr_attr (tmgrattr.c)
VIII. Access to old-style images - test_mgr_old
IX. Compressed Image Functions - test_mgr_compress (tmgrcomp.c)
X. DF24 Compatibility tests - test_mgr_r24
XI. DF8 Compatibility tests - test_mgr_r8
XII. DFP Compatibility tests - test_mgr_pal
XIII. Chunking write/read test
with enabled compression - test_mgr_chunkwr
XIV. Szip Compression test - test_mgr_szip
*/
/* Output message about test being performed */
MESSAGE(5, printf("Testing Multi-file Raster routines\n"););
test_mgr_init();
test_mgr_image(0); /* normal GR */
test_mgr_image(1); /* chunked GR */
test_mgr_index(0);
test_mgr_interlace(0); /* read from normal GR */
test_mgr_interlace(1); /* read from chunked GR */
test_mgr_lut(0);
test_mgr_special(0);
test_mgr_attr();
test_mgr_old(0);
test_mgr_compress();
test_mgr_r24(0);
test_mgr_r8(0);
test_mgr_chunkwr();
#ifdef H4_HAVE_LIBSZ /* szlib present */
test_mgr_szip(); /* write/read with szip compression */
#else /* skip szip test it and report */
fprintf(stderr, " -- ***** GR SZIP test skipped *****\n");
#endif
/* Added after fixing bug #814 to test eliminating of duplicate images */
test_mgr_dup_images();
} /* test_mgr() */
|