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
|
#ifdef __cplusplus
extern "C" {
#endif
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
#ifdef __cplusplus
}
#endif
#define i_int_hlines_testing() 1
#include "imager.h"
#include "feat.h"
#include "dynaload.h"
#include "regmach.h"
#include "imextdef.h"
typedef io_glue* Imager__IO;
#if i_int_hlines_testing()
#include "imageri.h"
#endif
#include "imperl.h"
/* These functions are all shared - then comes platform dependant code */
static int getstr(void *hv_t,char *key,char **store) {
SV** svpp;
HV* hv=(HV*)hv_t;
mm_log((1,"getstr(hv_t 0x%X, key %s, store 0x%X)\n",hv_t,key,store));
if ( !hv_exists(hv,key,strlen(key)) ) return 0;
svpp=hv_fetch(hv, key, strlen(key), 0);
*store=SvPV(*svpp, PL_na );
return 1;
}
static int getint(void *hv_t,char *key,int *store) {
SV** svpp;
HV* hv=(HV*)hv_t;
mm_log((1,"getint(hv_t 0x%X, key %s, store 0x%X)\n",hv_t,key,store));
if ( !hv_exists(hv,key,strlen(key)) ) return 0;
svpp=hv_fetch(hv, key, strlen(key), 0);
*store=(int)SvIV(*svpp);
return 1;
}
static int getdouble(void *hv_t,char* key,double *store) {
SV** svpp;
HV* hv=(HV*)hv_t;
mm_log((1,"getdouble(hv_t 0x%X, key %s, store 0x%X)\n",hv_t,key,store));
if ( !hv_exists(hv,key,strlen(key)) ) return 0;
svpp=hv_fetch(hv, key, strlen(key), 0);
*store=(float)SvNV(*svpp);
return 1;
}
static int getvoid(void *hv_t,char* key,void **store) {
SV** svpp;
HV* hv=(HV*)hv_t;
mm_log((1,"getvoid(hv_t 0x%X, key %s, store 0x%X)\n",hv_t,key,store));
if ( !hv_exists(hv,key,strlen(key)) ) return 0;
svpp=hv_fetch(hv, key, strlen(key), 0);
*store = INT2PTR(void*, SvIV(*svpp));
return 1;
}
static int getobj(void *hv_t,char *key,char *type,void **store) {
SV** svpp;
HV* hv=(HV*)hv_t;
mm_log((1,"getobj(hv_t 0x%X, key %s,type %s, store 0x%X)\n",hv_t,key,type,store));
if ( !hv_exists(hv,key,strlen(key)) ) return 0;
svpp=hv_fetch(hv, key, strlen(key), 0);
if (sv_derived_from(*svpp,type)) {
IV tmp = SvIV((SV*)SvRV(*svpp));
*store = INT2PTR(void*, tmp);
} else {
mm_log((1,"getobj: key exists in hash but is not of correct type"));
return 0;
}
return 1;
}
UTIL_table_t i_UTIL_table={getstr,getint,getdouble,getvoid,getobj};
void my_SvREFCNT_dec(void *p) {
SvREFCNT_dec((SV*)p);
}
static void
log_entry(char *string, int level) {
mm_log((level, string));
}
typedef struct i_reader_data_tag
{
/* presumably a CODE ref or name of a sub */
SV *sv;
} i_reader_data;
/* used by functions that want callbacks */
static int read_callback(char *userdata, char *buffer, int need, int want) {
i_reader_data *rd = (i_reader_data *)userdata;
int count;
int result;
SV *data;
dSP; dTARG = sv_newmortal();
/* thanks to Simon Cozens for help with the dTARG above */
ENTER;
SAVETMPS;
EXTEND(SP, 2);
PUSHMARK(SP);
PUSHi(want);
PUSHi(need);
PUTBACK;
count = perl_call_sv(rd->sv, G_SCALAR);
SPAGAIN;
if (count != 1)
croak("Result of perl_call_sv(..., G_SCALAR) != 1");
data = POPs;
if (SvOK(data)) {
STRLEN len;
char *ptr = SvPV(data, len);
if (len > want)
croak("Too much data returned in reader callback");
memcpy(buffer, ptr, len);
result = len;
}
else {
result = -1;
}
PUTBACK;
FREETMPS;
LEAVE;
return result;
}
typedef struct
{
SV *sv; /* a coderef or sub name */
} i_writer_data;
/* used by functions that want callbacks */
static int write_callback(char *userdata, char const *data, int size) {
i_writer_data *wd = (i_writer_data *)userdata;
int count;
int success;
SV *sv;
dSP;
ENTER;
SAVETMPS;
EXTEND(SP, 1);
PUSHMARK(SP);
XPUSHs(sv_2mortal(newSVpv((char *)data, size)));
PUTBACK;
count = perl_call_sv(wd->sv, G_SCALAR);
SPAGAIN;
if (count != 1)
croak("Result of perl_call_sv(..., G_SCALAR) != 1");
sv = POPs;
success = SvTRUE(sv);
PUTBACK;
FREETMPS;
LEAVE;
return success;
}
#define CBDATA_BUFSIZE 8192
struct cbdata {
/* the SVs we use to call back to Perl */
SV *writecb;
SV *readcb;
SV *seekcb;
SV *closecb;
/* we need to remember whether the buffer contains write data or
read data
*/
int reading;
int writing;
/* how far we've read into the buffer (not used for writing) */
int where;
/* the amount of space used/data available in the buffer */
int used;
/* the maximum amount to fill the buffer before flushing
If any write is larger than this then the buffer is flushed and
the full write is performed. The write is _not_ split into
maxwrite sized calls
*/
int maxlength;
char buffer[CBDATA_BUFSIZE];
};
/*
call_writer(cbd, buf, size)
Low-level function to call the perl writer callback.
*/
static ssize_t call_writer(struct cbdata *cbd, void const *buf, size_t size) {
int count;
int success;
SV *sv;
dSP;
if (!SvOK(cbd->writecb))
return -1;
ENTER;
SAVETMPS;
EXTEND(SP, 1);
PUSHMARK(SP);
PUSHs(sv_2mortal(newSVpv((char *)buf, size)));
PUTBACK;
count = perl_call_sv(cbd->writecb, G_SCALAR);
SPAGAIN;
if (count != 1)
croak("Result of perl_call_sv(..., G_SCALAR) != 1");
sv = POPs;
success = SvTRUE(sv);
PUTBACK;
FREETMPS;
LEAVE;
return success ? size : 0;
}
static ssize_t call_reader(struct cbdata *cbd, void *buf, size_t size,
size_t maxread) {
int count;
int result;
SV *data;
dSP;
if (!SvOK(cbd->readcb))
return -1;
ENTER;
SAVETMPS;
EXTEND(SP, 2);
PUSHMARK(SP);
PUSHs(sv_2mortal(newSViv(size)));
PUSHs(sv_2mortal(newSViv(maxread)));
PUTBACK;
count = perl_call_sv(cbd->readcb, G_SCALAR);
SPAGAIN;
if (count != 1)
croak("Result of perl_call_sv(..., G_SCALAR) != 1");
data = POPs;
if (SvOK(data)) {
STRLEN len;
char *ptr = SvPV(data, len);
if (len > maxread)
croak("Too much data returned in reader callback");
memcpy(buf, ptr, len);
result = len;
}
else {
result = -1;
}
PUTBACK;
FREETMPS;
LEAVE;
return result;
}
static ssize_t write_flush(struct cbdata *cbd) {
ssize_t result;
result = call_writer(cbd, cbd->buffer, cbd->used);
cbd->used = 0;
return result;
}
static off_t io_seeker(void *p, off_t offset, int whence) {
struct cbdata *cbd = p;
int count;
off_t result;
dSP;
if (!SvOK(cbd->seekcb))
return -1;
if (cbd->writing) {
if (cbd->used && write_flush(cbd) <= 0)
return -1;
cbd->writing = 0;
}
if (whence == SEEK_CUR && cbd->reading && cbd->where != cbd->used) {
offset -= cbd->where - cbd->used;
}
cbd->reading = 0;
cbd->where = cbd->used = 0;
ENTER;
SAVETMPS;
EXTEND(SP, 2);
PUSHMARK(SP);
PUSHs(sv_2mortal(newSViv(offset)));
PUSHs(sv_2mortal(newSViv(whence)));
PUTBACK;
count = perl_call_sv(cbd->seekcb, G_SCALAR);
SPAGAIN;
if (count != 1)
croak("Result of perl_call_sv(..., G_SCALAR) != 1");
result = POPi;
PUTBACK;
FREETMPS;
LEAVE;
return result;
}
static ssize_t io_writer(void *p, void const *data, size_t size) {
struct cbdata *cbd = p;
/*printf("io_writer(%p, %p, %u)\n", p, data, size);*/
if (!cbd->writing) {
if (cbd->reading && cbd->where < cbd->used) {
/* we read past the place where the caller expected us to be
so adjust our position a bit */
*(char *)0 = 0;
if (io_seeker(p, cbd->where - cbd->used, SEEK_CUR) < 0) {
return -1;
}
cbd->reading = 0;
}
cbd->where = cbd->used = 0;
}
cbd->writing = 1;
if (cbd->used && cbd->used + size > cbd->maxlength) {
if (write_flush(cbd) <= 0) {
return 0;
}
cbd->used = 0;
}
if (cbd->used+size <= cbd->maxlength) {
memcpy(cbd->buffer + cbd->used, data, size);
cbd->used += size;
return size;
}
/* it doesn't fit - just pass it up */
return call_writer(cbd, data, size);
}
static ssize_t io_reader(void *p, void *data, size_t size) {
struct cbdata *cbd = p;
ssize_t total;
char *out = data; /* so we can do pointer arithmetic */
if (cbd->writing) {
if (write_flush(cbd) <= 0)
return 0;
cbd->writing = 0;
}
cbd->reading = 1;
if (size <= cbd->used - cbd->where) {
/* simplest case */
memcpy(data, cbd->buffer+cbd->where, size);
cbd->where += size;
return size;
}
total = 0;
memcpy(out, cbd->buffer + cbd->where, cbd->used - cbd->where);
total += cbd->used - cbd->where;
size -= cbd->used - cbd->where;
out += cbd->used - cbd->where;
if (size < sizeof(cbd->buffer)) {
int did_read;
int copy_size;
while (size
&& (did_read = call_reader(cbd, cbd->buffer, size,
sizeof(cbd->buffer))) > 0) {
cbd->where = 0;
cbd->used = did_read;
copy_size = i_min(size, cbd->used);
memcpy(out, cbd->buffer, copy_size);
cbd->where += copy_size;
out += copy_size;
total += copy_size;
size -= copy_size;
}
}
else {
/* just read the rest - too big for our buffer*/
int did_read;
while ((did_read = call_reader(cbd, out, size, size)) > 0) {
size -= did_read;
total += did_read;
out += did_read;
}
}
return total;
}
static void io_closer(void *p) {
struct cbdata *cbd = p;
if (cbd->writing && cbd->used > 0) {
write_flush(cbd);
cbd->writing = 0;
}
if (SvOK(cbd->closecb)) {
dSP;
ENTER;
SAVETMPS;
PUSHMARK(SP);
PUTBACK;
perl_call_sv(cbd->closecb, G_VOID);
SPAGAIN;
PUTBACK;
FREETMPS;
LEAVE;
}
}
static void io_destroyer(void *p) {
struct cbdata *cbd = p;
SvREFCNT_dec(cbd->writecb);
SvREFCNT_dec(cbd->readcb);
SvREFCNT_dec(cbd->seekcb);
SvREFCNT_dec(cbd->closecb);
myfree(cbd);
}
struct value_name {
char *name;
int value;
};
static int lookup_name(struct value_name *names, int count, char *name, int def_value)
{
int i;
for (i = 0; i < count; ++i)
if (strEQ(names[i].name, name))
return names[i].value;
return def_value;
}
static struct value_name transp_names[] =
{
{ "none", tr_none },
{ "threshold", tr_threshold },
{ "errdiff", tr_errdiff },
{ "ordered", tr_ordered, },
};
static struct value_name make_color_names[] =
{
{ "none", mc_none, },
{ "webmap", mc_web_map, },
{ "addi", mc_addi, },
{ "mediancut", mc_median_cut, },
};
static struct value_name translate_names[] =
{
#ifdef HAVE_LIBGIF
{ "giflib", pt_giflib, },
#endif
{ "closest", pt_closest, },
{ "perturb", pt_perturb, },
{ "errdiff", pt_errdiff, },
};
static struct value_name errdiff_names[] =
{
{ "floyd", ed_floyd, },
{ "jarvis", ed_jarvis, },
{ "stucki", ed_stucki, },
{ "custom", ed_custom, },
};
static struct value_name orddith_names[] =
{
{ "random", od_random, },
{ "dot8", od_dot8, },
{ "dot4", od_dot4, },
{ "hline", od_hline, },
{ "vline", od_vline, },
{ "/line", od_slashline, },
{ "slashline", od_slashline, },
{ "\\line", od_backline, },
{ "backline", od_backline, },
{ "tiny", od_tiny, },
{ "custom", od_custom, },
};
/* look through the hash for quantization options */
static void handle_quant_opts(i_quantize *quant, HV *hv)
{
/*** POSSIBLY BROKEN: do I need to unref the SV from hv_fetch ***/
SV **sv;
int i;
STRLEN len;
char *str;
quant->mc_colors = mymalloc(quant->mc_size * sizeof(i_color));
sv = hv_fetch(hv, "transp", 6, 0);
if (sv && *sv && (str = SvPV(*sv, len))) {
quant->transp =
lookup_name(transp_names, sizeof(transp_names)/sizeof(*transp_names),
str, tr_none);
if (quant->transp != tr_none) {
quant->tr_threshold = 127;
sv = hv_fetch(hv, "tr_threshold", 12, 0);
if (sv && *sv)
quant->tr_threshold = SvIV(*sv);
}
if (quant->transp == tr_errdiff) {
sv = hv_fetch(hv, "tr_errdiff", 10, 0);
if (sv && *sv && (str = SvPV(*sv, len)))
quant->tr_errdiff = lookup_name(errdiff_names, sizeof(errdiff_names)/sizeof(*errdiff_names), str, ed_floyd);
}
if (quant->transp == tr_ordered) {
quant->tr_orddith = od_tiny;
sv = hv_fetch(hv, "tr_orddith", 10, 0);
if (sv && *sv && (str = SvPV(*sv, len)))
quant->tr_orddith = lookup_name(orddith_names, sizeof(orddith_names)/sizeof(*orddith_names), str, od_random);
if (quant->tr_orddith == od_custom) {
sv = hv_fetch(hv, "tr_map", 6, 0);
if (sv && *sv && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
AV *av = (AV*)SvRV(*sv);
len = av_len(av) + 1;
if (len > sizeof(quant->tr_custom))
len = sizeof(quant->tr_custom);
for (i = 0; i < len; ++i) {
SV **sv2 = av_fetch(av, i, 0);
if (sv2 && *sv2) {
quant->tr_custom[i] = SvIV(*sv2);
}
}
while (i < sizeof(quant->tr_custom))
quant->tr_custom[i++] = 0;
}
}
}
}
quant->make_colors = mc_addi;
sv = hv_fetch(hv, "make_colors", 11, 0);
if (sv && *sv && (str = SvPV(*sv, len))) {
quant->make_colors =
lookup_name(make_color_names, sizeof(make_color_names)/sizeof(*make_color_names), str, mc_addi);
}
sv = hv_fetch(hv, "colors", 6, 0);
if (sv && *sv && SvROK(*sv) && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
/* needs to be an array of Imager::Color
note that the caller allocates the mc_color array and sets mc_size
to it's size */
AV *av = (AV *)SvRV(*sv);
quant->mc_count = av_len(av)+1;
if (quant->mc_count > quant->mc_size)
quant->mc_count = quant->mc_size;
for (i = 0; i < quant->mc_count; ++i) {
SV **sv1 = av_fetch(av, i, 0);
if (sv1 && *sv1 && SvROK(*sv1) && sv_derived_from(*sv1, "Imager::Color")) {
i_color *col = INT2PTR(i_color *, SvIV((SV*)SvRV(*sv1)));
quant->mc_colors[i] = *col;
}
}
}
sv = hv_fetch(hv, "max_colors", 10, 0);
if (sv && *sv) {
i = SvIV(*sv);
if (i <= quant->mc_size && i >= quant->mc_count)
quant->mc_size = i;
}
quant->translate = pt_closest;
sv = hv_fetch(hv, "translate", 9, 0);
if (sv && *sv && (str = SvPV(*sv, len))) {
quant->translate = lookup_name(translate_names, sizeof(translate_names)/sizeof(*translate_names), str, pt_closest);
}
sv = hv_fetch(hv, "errdiff", 7, 0);
if (sv && *sv && (str = SvPV(*sv, len))) {
quant->errdiff = lookup_name(errdiff_names, sizeof(errdiff_names)/sizeof(*errdiff_names), str, ed_floyd);
}
if (quant->translate == pt_errdiff && quant->errdiff == ed_custom) {
/* get the error diffusion map */
sv = hv_fetch(hv, "errdiff_width", 13, 0);
if (sv && *sv)
quant->ed_width = SvIV(*sv);
sv = hv_fetch(hv, "errdiff_height", 14, 0);
if (sv && *sv)
quant->ed_height = SvIV(*sv);
sv = hv_fetch(hv, "errdiff_orig", 12, 0);
if (sv && *sv)
quant->ed_orig = SvIV(*sv);
if (quant->ed_width > 0 && quant->ed_height > 0) {
int sum = 0;
quant->ed_map = mymalloc(sizeof(int)*quant->ed_width*quant->ed_height);
sv = hv_fetch(hv, "errdiff_map", 11, 0);
if (sv && *sv && SvROK(*sv) && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
AV *av = (AV*)SvRV(*sv);
len = av_len(av) + 1;
if (len > quant->ed_width * quant->ed_height)
len = quant->ed_width * quant->ed_height;
for (i = 0; i < len; ++i) {
SV **sv2 = av_fetch(av, i, 0);
if (sv2 && *sv2) {
quant->ed_map[i] = SvIV(*sv2);
sum += quant->ed_map[i];
}
}
}
if (!sum) {
/* broken map */
myfree(quant->ed_map);
quant->ed_map = 0;
quant->errdiff = ed_floyd;
}
}
}
sv = hv_fetch(hv, "perturb", 7, 0);
if (sv && *sv)
quant->perturb = SvIV(*sv);
}
static void cleanup_quant_opts(i_quantize *quant) {
myfree(quant->mc_colors);
if (quant->ed_map)
myfree(quant->ed_map);
}
/* copies the color map from the hv into the colors member of the HV */
static void copy_colors_back(HV *hv, i_quantize *quant) {
SV **sv;
AV *av;
int i;
SV *work;
sv = hv_fetch(hv, "colors", 6, 0);
if (!sv || !*sv || !SvROK(*sv) || SvTYPE(SvRV(*sv)) != SVt_PVAV) {
SV *ref;
av = newAV();
ref = newRV_inc((SV*) av);
sv = hv_store(hv, "colors", 6, ref, 0);
}
else {
av = (AV *)SvRV(*sv);
}
av_extend(av, quant->mc_count+1);
for (i = 0; i < quant->mc_count; ++i) {
i_color *in = quant->mc_colors+i;
Imager__Color c = ICL_new_internal(in->rgb.r, in->rgb.g, in->rgb.b, 255);
work = sv_newmortal();
sv_setref_pv(work, "Imager::Color", (void *)c);
SvREFCNT_inc(work);
if (!av_store(av, i, work)) {
SvREFCNT_dec(work);
}
}
}
/* loads the segments of a fountain fill into an array */
static i_fountain_seg *
load_fount_segs(AV *asegs, int *count) {
/* Each element of segs must contain:
[ start, middle, end, c0, c1, segtype, colortrans ]
start, middle, end are doubles from 0 to 1
c0, c1 are Imager::Color::Float or Imager::Color objects
segtype, colortrans are ints
*/
int i, j;
AV *aseg;
i_fountain_seg *segs;
double work[3];
int worki[2];
*count = av_len(asegs)+1;
if (*count < 1)
croak("i_fountain must have at least one segment");
segs = mymalloc(sizeof(i_fountain_seg) * *count);
for(i = 0; i < *count; i++) {
SV **sv1 = av_fetch(asegs, i, 0);
if (!sv1 || !*sv1 || !SvROK(*sv1)
|| SvTYPE(SvRV(*sv1)) != SVt_PVAV) {
myfree(segs);
croak("i_fountain: segs must be an arrayref of arrayrefs");
}
aseg = (AV *)SvRV(*sv1);
if (av_len(aseg) != 7-1) {
myfree(segs);
croak("i_fountain: a segment must have 7 members");
}
for (j = 0; j < 3; ++j) {
SV **sv2 = av_fetch(aseg, j, 0);
if (!sv2 || !*sv2) {
myfree(segs);
croak("i_fountain: XS error");
}
work[j] = SvNV(*sv2);
}
segs[i].start = work[0];
segs[i].middle = work[1];
segs[i].end = work[2];
for (j = 0; j < 2; ++j) {
SV **sv3 = av_fetch(aseg, 3+j, 0);
if (!sv3 || !*sv3 || !SvROK(*sv3) ||
(!sv_derived_from(*sv3, "Imager::Color")
&& !sv_derived_from(*sv3, "Imager::Color::Float"))) {
myfree(segs);
croak("i_fountain: segs must contain colors in elements 3 and 4");
}
if (sv_derived_from(*sv3, "Imager::Color::Float")) {
segs[i].c[j] = *INT2PTR(i_fcolor *, SvIV((SV *)SvRV(*sv3)));
}
else {
i_color c = *INT2PTR(i_color *, SvIV((SV *)SvRV(*sv3)));
int ch;
for (ch = 0; ch < MAXCHANNELS; ++ch) {
segs[i].c[j].channel[ch] = c.channel[ch] / 255.0;
}
}
}
for (j = 0; j < 2; ++j) {
SV **sv2 = av_fetch(aseg, j+5, 0);
if (!sv2 || !*sv2) {
myfree(segs);
croak("i_fountain: XS error");
}
worki[j] = SvIV(*sv2);
}
segs[i].type = worki[0];
segs[i].color = worki[1];
}
return segs;
}
/* I don't think ICLF_* names belong at the C interface
this makes the XS code think we have them, to let us avoid
putting function bodies in the XS code
*/
#define ICLF_new_internal(r, g, b, a) i_fcolor_new((r), (g), (b), (a))
#define ICLF_DESTROY(cl) i_fcolor_destroy(cl)
/* the m_init_log() function was called init_log(), renamed to reduce
potential naming conflicts */
#define init_log m_init_log
#if i_int_hlines_testing()
typedef i_int_hlines *Imager__Internal__Hlines;
static i_int_hlines *
i_int_hlines_new(int start_y, int count_y, int start_x, int count_x) {
i_int_hlines *result = mymalloc(sizeof(i_int_hlines));
i_int_init_hlines(result, start_y, count_y, start_x, count_x);
return result;
}
static i_int_hlines *
i_int_hlines_new_img(i_img *im) {
i_int_hlines *result = mymalloc(sizeof(i_int_hlines));
i_int_init_hlines_img(result, im);
return result;
}
static void
i_int_hlines_DESTROY(i_int_hlines *hlines) {
i_int_hlines_destroy(hlines);
myfree(hlines);
}
static int seg_compare(const void *vleft, const void *vright) {
const i_int_hline_seg *left = vleft;
const i_int_hline_seg *right = vright;
return left->minx - right->minx;
}
static SV *
i_int_hlines_dump(i_int_hlines *hlines) {
SV *dump = newSVpvf("start_y: %d limit_y: %d start_x: %d limit_x: %d\n",
hlines->start_y, hlines->limit_y, hlines->start_x, hlines->limit_x);
int y;
for (y = hlines->start_y; y < hlines->limit_y; ++y) {
i_int_hline_entry *entry = hlines->entries[y-hlines->start_y];
if (entry) {
int i;
/* sort the segments, if any */
if (entry->count)
qsort(entry->segs, entry->count, sizeof(i_int_hline_seg), seg_compare);
sv_catpvf(dump, " %d (%d):", y, entry->count);
for (i = 0; i < entry->count; ++i) {
sv_catpvf(dump, " [%d, %d)", entry->segs[i].minx,
entry->segs[i].x_limit);
}
sv_catpv(dump, "\n");
}
}
return dump;
}
#endif
#ifdef IMEXIF_ENABLE
#define i_exif_enabled() 1
#else
#define i_exif_enabled() 0
#endif
MODULE = Imager PACKAGE = Imager::Color PREFIX = ICL_
Imager::Color
ICL_new_internal(r,g,b,a)
unsigned char r
unsigned char g
unsigned char b
unsigned char a
void
ICL_DESTROY(cl)
Imager::Color cl
void
ICL_set_internal(cl,r,g,b,a)
Imager::Color cl
unsigned char r
unsigned char g
unsigned char b
unsigned char a
PPCODE:
ICL_set_internal(cl, r, g, b, a);
EXTEND(SP, 1);
PUSHs(ST(0));
void
ICL_info(cl)
Imager::Color cl
void
ICL_rgba(cl)
Imager::Color cl
PPCODE:
EXTEND(SP, 4);
PUSHs(sv_2mortal(newSVnv(cl->rgba.r)));
PUSHs(sv_2mortal(newSVnv(cl->rgba.g)));
PUSHs(sv_2mortal(newSVnv(cl->rgba.b)));
PUSHs(sv_2mortal(newSVnv(cl->rgba.a)));
Imager::Color
i_hsv_to_rgb(c)
Imager::Color c
CODE:
RETVAL = mymalloc(sizeof(i_color));
*RETVAL = *c;
i_hsv_to_rgb(RETVAL);
OUTPUT:
RETVAL
Imager::Color
i_rgb_to_hsv(c)
Imager::Color c
CODE:
RETVAL = mymalloc(sizeof(i_color));
*RETVAL = *c;
i_rgb_to_hsv(RETVAL);
OUTPUT:
RETVAL
MODULE = Imager PACKAGE = Imager::Color::Float PREFIX=ICLF_
Imager::Color::Float
ICLF_new_internal(r, g, b, a)
double r
double g
double b
double a
void
ICLF_DESTROY(cl)
Imager::Color::Float cl
void
ICLF_rgba(cl)
Imager::Color::Float cl
PREINIT:
int ch;
PPCODE:
EXTEND(SP, MAXCHANNELS);
for (ch = 0; ch < MAXCHANNELS; ++ch) {
/* printf("%d: %g\n", ch, cl->channel[ch]); */
PUSHs(sv_2mortal(newSVnv(cl->channel[ch])));
}
void
ICLF_set_internal(cl,r,g,b,a)
Imager::Color::Float cl
double r
double g
double b
double a
PPCODE:
cl->rgba.r = r;
cl->rgba.g = g;
cl->rgba.b = b;
cl->rgba.a = a;
EXTEND(SP, 1);
PUSHs(ST(0));
Imager::Color::Float
i_hsv_to_rgb(c)
Imager::Color::Float c
CODE:
RETVAL = mymalloc(sizeof(i_fcolor));
*RETVAL = *c;
i_hsv_to_rgbf(RETVAL);
OUTPUT:
RETVAL
Imager::Color::Float
i_rgb_to_hsv(c)
Imager::Color::Float c
CODE:
RETVAL = mymalloc(sizeof(i_fcolor));
*RETVAL = *c;
i_rgb_to_hsvf(RETVAL);
OUTPUT:
RETVAL
MODULE = Imager PACKAGE = Imager::ImgRaw PREFIX = IIM_
Imager::ImgRaw
IIM_new(x,y,ch)
int x
int y
int ch
void
IIM_DESTROY(im)
Imager::ImgRaw im
MODULE = Imager PACKAGE = Imager
PROTOTYPES: ENABLE
Imager::IO
io_new_fd(fd)
int fd
Imager::IO
io_new_bufchain()
Imager::IO
io_new_buffer(data)
char *data
PREINIT:
size_t length;
CODE:
SvPV(ST(0), length);
SvREFCNT_inc(ST(0));
RETVAL = io_new_buffer(data, length, my_SvREFCNT_dec, ST(0));
OUTPUT:
RETVAL
Imager::IO
io_new_cb(writecb, readcb, seekcb, closecb, maxwrite = CBDATA_BUFSIZE)
SV *writecb;
SV *readcb;
SV *seekcb;
SV *closecb;
int maxwrite;
PREINIT:
struct cbdata *cbd;
CODE:
cbd = mymalloc(sizeof(struct cbdata));
SvREFCNT_inc(writecb);
cbd->writecb = writecb;
SvREFCNT_inc(readcb);
cbd->readcb = readcb;
SvREFCNT_inc(seekcb);
cbd->seekcb = seekcb;
SvREFCNT_inc(closecb);
cbd->closecb = closecb;
cbd->reading = cbd->writing = cbd->where = cbd->used = 0;
if (maxwrite > CBDATA_BUFSIZE)
maxwrite = CBDATA_BUFSIZE;
cbd->maxlength = maxwrite;
RETVAL = io_new_cb(cbd, io_reader, io_writer, io_seeker, io_closer,
io_destroyer);
OUTPUT:
RETVAL
void
io_slurp(ig)
Imager::IO ig
PREINIT:
unsigned char* data;
size_t tlength;
PPCODE:
data = NULL;
tlength = io_slurp(ig, &data);
EXTEND(SP,1);
PUSHs(sv_2mortal(newSVpv((char *)data,tlength)));
myfree(data);
undef_int
i_set_image_file_limits(width, height, bytes)
int width
int height
int bytes
void
i_get_image_file_limits()
PREINIT:
int width, height, bytes;
PPCODE:
if (i_get_image_file_limits(&width, &height, &bytes)) {
EXTEND(SP, 3);
PUSHs(sv_2mortal(newSViv(width)));
PUSHs(sv_2mortal(newSViv(height)));
PUSHs(sv_2mortal(newSViv(bytes)));
}
MODULE = Imager PACKAGE = Imager::IO PREFIX = io_glue_
void
io_glue_DESTROY(ig)
Imager::IO ig
MODULE = Imager PACKAGE = Imager
PROTOTYPES: ENABLE
void
i_list_formats()
PREINIT:
char* item;
int i;
PPCODE:
i=0;
while( (item=i_format_list[i++]) != NULL ) {
EXTEND(SP, 1);
PUSHs(sv_2mortal(newSVpv(item,0)));
}
undef_int
i_has_format(frmt)
char* frmt
Imager::ImgRaw
i_img_new()
Imager::ImgRaw
i_img_empty(im,x,y)
Imager::ImgRaw im
int x
int y
Imager::ImgRaw
i_img_empty_ch(im,x,y,ch)
Imager::ImgRaw im
int x
int y
int ch
Imager::ImgRaw
i_sametype(im, x, y)
Imager::ImgRaw im
int x
int y
Imager::ImgRaw
i_sametype_chans(im, x, y, channels)
Imager::ImgRaw im
int x
int y
int channels
void
m_init_log(name,level)
char* name
int level
void
log_entry(string,level)
char* string
int level
void
i_img_exorcise(im)
Imager::ImgRaw im
void
i_img_destroy(im)
Imager::ImgRaw im
void
i_img_info(im)
Imager::ImgRaw im
PREINIT:
int info[4];
PPCODE:
i_img_info(im,info);
EXTEND(SP, 4);
PUSHs(sv_2mortal(newSViv(info[0])));
PUSHs(sv_2mortal(newSViv(info[1])));
PUSHs(sv_2mortal(newSViv(info[2])));
PUSHs(sv_2mortal(newSViv(info[3])));
void
i_img_setmask(im,ch_mask)
Imager::ImgRaw im
int ch_mask
int
i_img_getmask(im)
Imager::ImgRaw im
int
i_img_getchannels(im)
Imager::ImgRaw im
void
i_img_getdata(im)
Imager::ImgRaw im
PPCODE:
EXTEND(SP, 1);
PUSHs(im->idata ?
sv_2mortal(newSVpv((char *)im->idata, im->bytes))
: &PL_sv_undef);
void
i_line(im,x1,y1,x2,y2,val,endp)
Imager::ImgRaw im
int x1
int y1
int x2
int y2
Imager::Color val
int endp
void
i_line_aa(im,x1,y1,x2,y2,val,endp)
Imager::ImgRaw im
int x1
int y1
int x2
int y2
Imager::Color val
int endp
void
i_box(im,x1,y1,x2,y2,val)
Imager::ImgRaw im
int x1
int y1
int x2
int y2
Imager::Color val
void
i_box_filled(im,x1,y1,x2,y2,val)
Imager::ImgRaw im
int x1
int y1
int x2
int y2
Imager::Color val
void
i_box_cfill(im,x1,y1,x2,y2,fill)
Imager::ImgRaw im
int x1
int y1
int x2
int y2
Imager::FillHandle fill
void
i_arc(im,x,y,rad,d1,d2,val)
Imager::ImgRaw im
int x
int y
float rad
float d1
float d2
Imager::Color val
void
i_arc_aa(im,x,y,rad,d1,d2,val)
Imager::ImgRaw im
double x
double y
double rad
double d1
double d2
Imager::Color val
void
i_arc_cfill(im,x,y,rad,d1,d2,fill)
Imager::ImgRaw im
int x
int y
float rad
float d1
float d2
Imager::FillHandle fill
void
i_arc_aa_cfill(im,x,y,rad,d1,d2,fill)
Imager::ImgRaw im
double x
double y
double rad
double d1
double d2
Imager::FillHandle fill
void
i_circle_aa(im,x,y,rad,val)
Imager::ImgRaw im
float x
float y
float rad
Imager::Color val
void
i_bezier_multi(im,xc,yc,val)
Imager::ImgRaw im
Imager::Color val
PREINIT:
double *x,*y;
int len;
AV *av1;
AV *av2;
SV *sv1;
SV *sv2;
int i;
PPCODE:
ICL_info(val);
if (!SvROK(ST(1))) croak("Imager: Parameter 1 to i_bezier_multi must be a reference to an array\n");
if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 to i_bezier_multi must be a reference to an array\n");
if (!SvROK(ST(2))) croak("Imager: Parameter 2 to i_bezier_multi must be a reference to an array\n");
if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 2 to i_bezier_multi must be a reference to an array\n");
av1=(AV*)SvRV(ST(1));
av2=(AV*)SvRV(ST(2));
if (av_len(av1) != av_len(av2)) croak("Imager: x and y arrays to i_bezier_multi must be equal length\n");
len=av_len(av1)+1;
x=mymalloc( len*sizeof(double) );
y=mymalloc( len*sizeof(double) );
for(i=0;i<len;i++) {
sv1=(*(av_fetch(av1,i,0)));
sv2=(*(av_fetch(av2,i,0)));
x[i]=(double)SvNV(sv1);
y[i]=(double)SvNV(sv2);
}
i_bezier_multi(im,len,x,y,val);
myfree(x);
myfree(y);
void
i_poly_aa(im,xc,yc,val)
Imager::ImgRaw im
Imager::Color val
PREINIT:
double *x,*y;
int len;
AV *av1;
AV *av2;
SV *sv1;
SV *sv2;
int i;
PPCODE:
ICL_info(val);
if (!SvROK(ST(1))) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
if (!SvROK(ST(2))) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
av1=(AV*)SvRV(ST(1));
av2=(AV*)SvRV(ST(2));
if (av_len(av1) != av_len(av2)) croak("Imager: x and y arrays to i_poly_aa must be equal length\n");
len=av_len(av1)+1;
x=mymalloc( len*sizeof(double) );
y=mymalloc( len*sizeof(double) );
for(i=0;i<len;i++) {
sv1=(*(av_fetch(av1,i,0)));
sv2=(*(av_fetch(av2,i,0)));
x[i]=(double)SvNV(sv1);
y[i]=(double)SvNV(sv2);
}
i_poly_aa(im,len,x,y,val);
myfree(x);
myfree(y);
void
i_poly_aa_cfill(im,xc,yc,fill)
Imager::ImgRaw im
Imager::FillHandle fill
PREINIT:
double *x,*y;
int len;
AV *av1;
AV *av2;
SV *sv1;
SV *sv2;
int i;
PPCODE:
if (!SvROK(ST(1))) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
if (!SvROK(ST(2))) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
av1=(AV*)SvRV(ST(1));
av2=(AV*)SvRV(ST(2));
if (av_len(av1) != av_len(av2)) croak("Imager: x and y arrays to i_poly_aa_cfill must be equal length\n");
len=av_len(av1)+1;
x=mymalloc( len*sizeof(double) );
y=mymalloc( len*sizeof(double) );
for(i=0;i<len;i++) {
sv1=(*(av_fetch(av1,i,0)));
sv2=(*(av_fetch(av2,i,0)));
x[i]=(double)SvNV(sv1);
y[i]=(double)SvNV(sv2);
}
i_poly_aa_cfill(im,len,x,y,fill);
myfree(x);
myfree(y);
undef_int
i_flood_fill(im,seedx,seedy,dcol)
Imager::ImgRaw im
int seedx
int seedy
Imager::Color dcol
undef_int
i_flood_cfill(im,seedx,seedy,fill)
Imager::ImgRaw im
int seedx
int seedy
Imager::FillHandle fill
void
i_copyto(im,src,x1,y1,x2,y2,tx,ty)
Imager::ImgRaw im
Imager::ImgRaw src
int x1
int y1
int x2
int y2
int tx
int ty
void
i_copyto_trans(im,src,x1,y1,x2,y2,tx,ty,trans)
Imager::ImgRaw im
Imager::ImgRaw src
int x1
int y1
int x2
int y2
int tx
int ty
Imager::Color trans
Imager::ImgRaw
i_copy(src)
Imager::ImgRaw src
undef_int
i_rubthru(im,src,tx,ty,src_minx,src_miny,src_maxx,src_maxy)
Imager::ImgRaw im
Imager::ImgRaw src
int tx
int ty
int src_minx
int src_miny
int src_maxx
int src_maxy
undef_int
i_flipxy(im, direction)
Imager::ImgRaw im
int direction
Imager::ImgRaw
i_rotate90(im, degrees)
Imager::ImgRaw im
int degrees
Imager::ImgRaw
i_rotate_exact(im, amount, ...)
Imager::ImgRaw im
double amount
PREINIT:
i_color *backp = NULL;
i_fcolor *fbackp = NULL;
int i;
SV * sv1;
CODE:
/* extract the bg colors if any */
/* yes, this is kind of strange */
for (i = 2; i < items; ++i) {
sv1 = ST(i);
if (sv_derived_from(sv1, "Imager::Color")) {
IV tmp = SvIV((SV*)SvRV(sv1));
backp = INT2PTR(i_color *, tmp);
}
else if (sv_derived_from(sv1, "Imager::Color::Float")) {
IV tmp = SvIV((SV*)SvRV(sv1));
fbackp = INT2PTR(i_fcolor *, tmp);
}
}
RETVAL = i_rotate_exact_bg(im, amount, backp, fbackp);
OUTPUT:
RETVAL
Imager::ImgRaw
i_matrix_transform(im, xsize, ysize, matrix, ...)
Imager::ImgRaw im
int xsize
int ysize
PREINIT:
double matrix[9];
AV *av;
IV len;
SV *sv1;
int i;
i_color *backp = NULL;
i_fcolor *fbackp = NULL;
CODE:
if (!SvROK(ST(3)) || SvTYPE(SvRV(ST(3))) != SVt_PVAV)
croak("i_matrix_transform: parameter 4 must be an array ref\n");
av=(AV*)SvRV(ST(3));
len=av_len(av)+1;
if (len > 9)
len = 9;
for (i = 0; i < len; ++i) {
sv1=(*(av_fetch(av,i,0)));
matrix[i] = SvNV(sv1);
}
for (; i < 9; ++i)
matrix[i] = 0;
/* extract the bg colors if any */
/* yes, this is kind of strange */
for (i = 4; i < items; ++i) {
sv1 = ST(i);
if (sv_derived_from(sv1, "Imager::Color")) {
IV tmp = SvIV((SV*)SvRV(sv1));
backp = INT2PTR(i_color *, tmp);
}
else if (sv_derived_from(sv1, "Imager::Color::Float")) {
IV tmp = SvIV((SV*)SvRV(sv1));
fbackp = INT2PTR(i_fcolor *, tmp);
}
}
RETVAL = i_matrix_transform_bg(im, xsize, ysize, matrix, backp, fbackp);
OUTPUT:
RETVAL
void
i_gaussian(im,stdev)
Imager::ImgRaw im
float stdev
void
i_unsharp_mask(im,stdev,scale)
Imager::ImgRaw im
float stdev
double scale
void
i_conv(im,pcoef)
Imager::ImgRaw im
PREINIT:
float* coeff;
int len;
AV* av;
SV* sv1;
int i;
PPCODE:
if (!SvROK(ST(1))) croak("Imager: Parameter 1 must be a reference to an array\n");
if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 must be a reference to an array\n");
av=(AV*)SvRV(ST(1));
len=av_len(av)+1;
coeff=mymalloc( len*sizeof(float) );
for(i=0;i<len;i++) {
sv1=(*(av_fetch(av,i,0)));
coeff[i]=(float)SvNV(sv1);
}
i_conv(im,coeff,len);
myfree(coeff);
undef_int
i_convert(im, src, coeff)
Imager::ImgRaw im
Imager::ImgRaw src
PREINIT:
float *coeff;
int outchan;
int inchan;
AV *avmain;
SV **temp;
AV *avsub;
int len;
int i, j;
CODE:
if (!SvROK(ST(2)) || SvTYPE(SvRV(ST(2))) != SVt_PVAV)
croak("i_convert: parameter 3 must be an arrayref\n");
avmain = (AV*)SvRV(ST(2));
outchan = av_len(avmain)+1;
/* find the biggest */
inchan = 0;
for (j=0; j < outchan; ++j) {
temp = av_fetch(avmain, j, 0);
if (temp && SvROK(*temp) && SvTYPE(SvRV(*temp)) == SVt_PVAV) {
avsub = (AV*)SvRV(*temp);
len = av_len(avsub)+1;
if (len > inchan)
inchan = len;
}
}
coeff = mymalloc(sizeof(float) * outchan * inchan);
for (j = 0; j < outchan; ++j) {
avsub = (AV*)SvRV(*av_fetch(avmain, j, 0));
len = av_len(avsub)+1;
for (i = 0; i < len; ++i) {
temp = av_fetch(avsub, i, 0);
if (temp)
coeff[i+j*inchan] = SvNV(*temp);
else
coeff[i+j*inchan] = 0;
}
while (i < inchan)
coeff[i++ + j*inchan] = 0;
}
RETVAL = i_convert(im, src, coeff, outchan, inchan);
myfree(coeff);
OUTPUT:
RETVAL
void
i_map(im, pmaps)
Imager::ImgRaw im
PREINIT:
unsigned int mask = 0;
AV *avmain;
AV *avsub;
SV **temp;
int len;
int i, j;
unsigned char (*maps)[256];
CODE:
if (!SvROK(ST(1)) || SvTYPE(SvRV(ST(1))) != SVt_PVAV)
croak("i_map: parameter 2 must be an arrayref\n");
avmain = (AV*)SvRV(ST(1));
len = av_len(avmain)+1;
if (im->channels < len) len = im->channels;
maps = mymalloc( len * sizeof(unsigned char [256]) );
for (j=0; j<len ; j++) {
temp = av_fetch(avmain, j, 0);
if (temp && SvROK(*temp) && (SvTYPE(SvRV(*temp)) == SVt_PVAV) ) {
avsub = (AV*)SvRV(*temp);
if(av_len(avsub) != 255) continue;
mask |= 1<<j;
for (i=0; i<256 ; i++) {
int val;
temp = av_fetch(avsub, i, 0);
val = temp ? SvIV(*temp) : 0;
if (val<0) val = 0;
if (val>255) val = 255;
maps[j][i] = val;
}
}
}
i_map(im, maps, mask);
myfree(maps);
float
i_img_diff(im1,im2)
Imager::ImgRaw im1
Imager::ImgRaw im2
undef_int
i_init_fonts(t1log=0)
int t1log
#ifdef HAVE_LIBT1
void
i_t1_set_aa(st)
int st
int
i_t1_new(pfb,afm)
char* pfb
char* afm
int
i_t1_destroy(font_id)
int font_id
undef_int
i_t1_cp(im,xb,yb,channel,fontnum,points,str_sv,len_ignored,align,utf8=0,flags="")
Imager::ImgRaw im
int xb
int yb
int channel
int fontnum
float points
SV* str_sv
int align
int utf8
char* flags
PREINIT:
char *str;
STRLEN len;
CODE:
#ifdef SvUTF8
if (SvUTF8(str_sv))
utf8 = 1;
#endif
str = SvPV(str_sv, len);
RETVAL = i_t1_cp(im, xb,yb,channel,fontnum,points,str,len,align,
utf8,flags);
OUTPUT:
RETVAL
void
i_t1_bbox(fontnum,point,str_sv,len_ignored,utf8=0,flags="")
int fontnum
float point
SV* str_sv
int utf8
char* flags
PREINIT:
char *str;
STRLEN len;
int cords[BOUNDING_BOX_COUNT];
int i;
int rc;
PPCODE:
#ifdef SvUTF8
if (SvUTF8(str_sv))
utf8 = 1;
#endif
str = SvPV(str_sv, len);
rc = i_t1_bbox(fontnum,point,str,len,cords,utf8,flags);
if (rc > 0) {
EXTEND(SP, rc);
for (i = 0; i < rc; ++i)
PUSHs(sv_2mortal(newSViv(cords[i])));
}
undef_int
i_t1_text(im,xb,yb,cl,fontnum,points,str_sv,len_ignored,align,utf8=0,flags="")
Imager::ImgRaw im
int xb
int yb
Imager::Color cl
int fontnum
float points
SV* str_sv
int align
int utf8
char* flags
PREINIT:
char *str;
STRLEN len;
CODE:
#ifdef SvUTF8
if (SvUTF8(str_sv))
utf8 = 1;
#endif
str = SvPV(str_sv, len);
RETVAL = i_t1_text(im, xb,yb,cl,fontnum,points,str,len,align,
utf8,flags);
OUTPUT:
RETVAL
void
i_t1_has_chars(handle, text_sv, utf8 = 0)
int handle
SV *text_sv
int utf8
PREINIT:
char const *text;
STRLEN len;
char *work;
int count;
int i;
PPCODE:
#ifdef SvUTF8
if (SvUTF8(text_sv))
utf8 = 1;
#endif
text = SvPV(text_sv, len);
work = mymalloc(len);
count = i_t1_has_chars(handle, text, len, utf8, work);
if (GIMME_V == G_ARRAY) {
EXTEND(SP, count);
for (i = 0; i < count; ++i) {
PUSHs(sv_2mortal(newSViv(work[i])));
}
}
else {
EXTEND(SP, 1);
PUSHs(sv_2mortal(newSVpv(work, count)));
}
myfree(work);
void
i_t1_face_name(handle)
int handle
PREINIT:
char name[255];
int len;
PPCODE:
len = i_t1_face_name(handle, name, sizeof(name));
if (len) {
EXTEND(SP, 1);
PUSHs(sv_2mortal(newSVpv(name, strlen(name))));
}
void
i_t1_glyph_name(handle, text_sv, utf8 = 0)
int handle
SV *text_sv
int utf8
PREINIT:
char const *text;
STRLEN work_len;
int len;
char name[255];
PPCODE:
#ifdef SvUTF8
if (SvUTF8(text_sv))
utf8 = 1;
#endif
text = SvPV(text_sv, work_len);
len = work_len;
while (len) {
unsigned long ch;
if (utf8) {
ch = i_utf8_advance(&text, &len);
if (ch == ~0UL) {
i_push_error(0, "invalid UTF8 character");
break;
}
}
else {
ch = *text++;
--len;
}
EXTEND(SP, 1);
if (i_t1_glyph_name(handle, ch, name, sizeof(name))) {
PUSHs(sv_2mortal(newSVpv(name, 0)));
}
else {
PUSHs(&PL_sv_undef);
}
}
#endif
#ifdef HAVE_LIBTT
Imager::Font::TT
i_tt_new(fontname)
char* fontname
MODULE = Imager PACKAGE = Imager::Font::TT PREFIX=TT_
#define TT_DESTROY(handle) i_tt_destroy(handle)
void
TT_DESTROY(handle)
Imager::Font::TT handle
MODULE = Imager PACKAGE = Imager
undef_int
i_tt_text(handle,im,xb,yb,cl,points,str_sv,len_ignored,smooth,utf8,align=1)
Imager::Font::TT handle
Imager::ImgRaw im
int xb
int yb
Imager::Color cl
float points
SV * str_sv
int smooth
int utf8
int align
PREINIT:
char *str;
STRLEN len;
CODE:
#ifdef SvUTF8
if (SvUTF8(str_sv))
utf8 = 1;
#endif
str = SvPV(str_sv, len);
RETVAL = i_tt_text(handle, im, xb, yb, cl, points, str,
len, smooth, utf8, align);
OUTPUT:
RETVAL
undef_int
i_tt_cp(handle,im,xb,yb,channel,points,str_sv,len_ignored,smooth,utf8,align=1)
Imager::Font::TT handle
Imager::ImgRaw im
int xb
int yb
int channel
float points
SV * str_sv
int smooth
int utf8
int align
PREINIT:
char *str;
STRLEN len;
CODE:
#ifdef SvUTF8
if (SvUTF8(str_sv))
utf8 = 1;
#endif
str = SvPV(str_sv, len);
RETVAL = i_tt_cp(handle, im, xb, yb, channel, points, str, len,
smooth, utf8, align);
OUTPUT:
RETVAL
void
i_tt_bbox(handle,point,str_sv,len_ignored, utf8)
Imager::Font::TT handle
float point
SV* str_sv
int utf8
PREINIT:
int cords[BOUNDING_BOX_COUNT],rc;
char * str;
STRLEN len;
int i;
PPCODE:
#ifdef SvUTF8
if (SvUTF8(ST(2)))
utf8 = 1;
#endif
str = SvPV(str_sv, len);
if ((rc=i_tt_bbox(handle,point,str,len,cords, utf8))) {
EXTEND(SP, rc);
for (i = 0; i < rc; ++i) {
PUSHs(sv_2mortal(newSViv(cords[i])));
}
}
void
i_tt_has_chars(handle, text_sv, utf8)
Imager::Font::TT handle
SV *text_sv
int utf8
PREINIT:
char const *text;
STRLEN len;
char *work;
int count;
int i;
PPCODE:
#ifdef SvUTF8
if (SvUTF8(text_sv))
utf8 = 1;
#endif
text = SvPV(text_sv, len);
work = mymalloc(len);
count = i_tt_has_chars(handle, text, len, utf8, work);
if (GIMME_V == G_ARRAY) {
EXTEND(SP, count);
for (i = 0; i < count; ++i) {
PUSHs(sv_2mortal(newSViv(work[i])));
}
}
else {
EXTEND(SP, 1);
PUSHs(sv_2mortal(newSVpv(work, count)));
}
myfree(work);
void
i_tt_dump_names(handle)
Imager::Font::TT handle
void
i_tt_face_name(handle)
Imager::Font::TT handle
PREINIT:
char name[255];
int len;
PPCODE:
len = i_tt_face_name(handle, name, sizeof(name));
if (len) {
EXTEND(SP, 1);
PUSHs(sv_2mortal(newSVpv(name, strlen(name))));
}
void
i_tt_glyph_name(handle, text_sv, utf8 = 0)
Imager::Font::TT handle
SV *text_sv
int utf8
PREINIT:
char const *text;
STRLEN work_len;
int len;
int outsize;
char name[255];
PPCODE:
#ifdef SvUTF8
if (SvUTF8(text_sv))
utf8 = 1;
#endif
text = SvPV(text_sv, work_len);
len = work_len;
while (len) {
unsigned long ch;
if (utf8) {
ch = i_utf8_advance(&text, &len);
if (ch == ~0UL) {
i_push_error(0, "invalid UTF8 character");
break;
}
}
else {
ch = *text++;
--len;
}
EXTEND(SP, 1);
if ((outsize = i_tt_glyph_name(handle, ch, name, sizeof(name))) != 0) {
PUSHs(sv_2mortal(newSVpv(name, 0)));
}
else {
PUSHs(&PL_sv_undef);
}
}
#endif
#ifdef HAVE_LIBJPEG
undef_int
i_writejpeg_wiol(im, ig, qfactor)
Imager::ImgRaw im
Imager::IO ig
int qfactor
void
i_readjpeg_wiol(ig)
Imager::IO ig
PREINIT:
char* iptc_itext;
int tlength;
i_img* rimg;
SV* r;
PPCODE:
iptc_itext = NULL;
rimg = i_readjpeg_wiol(ig,-1,&iptc_itext,&tlength);
if (iptc_itext == NULL) {
r = sv_newmortal();
EXTEND(SP,1);
sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
PUSHs(r);
} else {
r = sv_newmortal();
EXTEND(SP,2);
sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
PUSHs(r);
PUSHs(sv_2mortal(newSVpv(iptc_itext,tlength)));
myfree(iptc_itext);
}
int
i_exif_enabled()
#endif
char *
i_test_format_probe(ig, length)
Imager::IO ig
int length
#ifdef HAVE_LIBTIFF
Imager::ImgRaw
i_readtiff_wiol(ig, length, page=0)
Imager::IO ig
int length
int page
void
i_readtiff_multi_wiol(ig, length)
Imager::IO ig
int length
PREINIT:
i_img **imgs;
int count;
int i;
PPCODE:
imgs = i_readtiff_multi_wiol(ig, length, &count);
if (imgs) {
EXTEND(SP, count);
for (i = 0; i < count; ++i) {
SV *sv = sv_newmortal();
sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
PUSHs(sv);
}
myfree(imgs);
}
undef_int
i_writetiff_wiol(im, ig)
Imager::ImgRaw im
Imager::IO ig
undef_int
i_writetiff_multi_wiol(ig, ...)
Imager::IO ig
PREINIT:
int i;
int img_count;
i_img **imgs;
CODE:
if (items < 2)
croak("Usage: i_writetiff_multi_wiol(ig, images...)");
img_count = items - 1;
RETVAL = 1;
if (img_count < 1) {
RETVAL = 0;
i_clear_error();
i_push_error(0, "You need to specify images to save");
}
else {
imgs = mymalloc(sizeof(i_img *) * img_count);
for (i = 0; i < img_count; ++i) {
SV *sv = ST(1+i);
imgs[i] = NULL;
if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv)));
}
else {
i_clear_error();
i_push_error(0, "Only images can be saved");
myfree(imgs);
RETVAL = 0;
break;
}
}
if (RETVAL) {
RETVAL = i_writetiff_multi_wiol(ig, imgs, img_count);
}
myfree(imgs);
}
OUTPUT:
RETVAL
undef_int
i_writetiff_wiol_faxable(im, ig, fine)
Imager::ImgRaw im
Imager::IO ig
int fine
undef_int
i_writetiff_multi_wiol_faxable(ig, fine, ...)
Imager::IO ig
int fine
PREINIT:
int i;
int img_count;
i_img **imgs;
CODE:
if (items < 3)
croak("Usage: i_writetiff_multi_wiol_faxable(ig, fine, images...)");
img_count = items - 2;
RETVAL = 1;
if (img_count < 1) {
RETVAL = 0;
i_clear_error();
i_push_error(0, "You need to specify images to save");
}
else {
imgs = mymalloc(sizeof(i_img *) * img_count);
for (i = 0; i < img_count; ++i) {
SV *sv = ST(2+i);
imgs[i] = NULL;
if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv)));
}
else {
i_clear_error();
i_push_error(0, "Only images can be saved");
myfree(imgs);
RETVAL = 0;
break;
}
}
if (RETVAL) {
RETVAL = i_writetiff_multi_wiol_faxable(ig, imgs, img_count, fine);
}
myfree(imgs);
}
OUTPUT:
RETVAL
#endif /* HAVE_LIBTIFF */
#ifdef HAVE_LIBPNG
Imager::ImgRaw
i_readpng_wiol(ig, length)
Imager::IO ig
int length
undef_int
i_writepng_wiol(im, ig)
Imager::ImgRaw im
Imager::IO ig
#endif
#ifdef HAVE_LIBGIF
void
i_giflib_version()
PPCODE:
PUSHs(sv_2mortal(newSVnv(IM_GIFMAJOR+IM_GIFMINOR*0.1)));
undef_int
i_writegif(im,fd,colors,pixdev,fixed)
Imager::ImgRaw im
int fd
int colors
int pixdev
PREINIT:
int fixedlen;
Imager__Color fixed;
Imager__Color tmp;
AV* av;
SV* sv1;
IV Itmp;
int i;
CODE:
if (!SvROK(ST(4))) croak("Imager: Parameter 4 must be a reference to an array\n");
if (SvTYPE(SvRV(ST(4))) != SVt_PVAV) croak("Imager: Parameter 4 must be a reference to an array\n");
av=(AV*)SvRV(ST(4));
fixedlen=av_len(av)+1;
fixed=mymalloc( fixedlen*sizeof(i_color) );
for(i=0;i<fixedlen;i++) {
sv1=(*(av_fetch(av,i,0)));
if (sv_derived_from(sv1, "Imager::Color")) {
Itmp = SvIV((SV*)SvRV(sv1));
tmp = INT2PTR(i_color*, Itmp);
} else croak("Imager: one of the elements of array ref is not of Imager::Color type\n");
fixed[i]=*tmp;
}
RETVAL=i_writegif(im,fd,colors,pixdev,fixedlen,fixed);
myfree(fixed);
ST(0) = sv_newmortal();
if (RETVAL == 0) ST(0)=&PL_sv_undef;
else sv_setiv(ST(0), (IV)RETVAL);
undef_int
i_writegifmc(im,fd,colors)
Imager::ImgRaw im
int fd
int colors
undef_int
i_writegif_gen(fd, ...)
int fd
PROTOTYPE: $$@
PREINIT:
i_quantize quant;
i_img **imgs = NULL;
int img_count;
int i;
HV *hv;
CODE:
if (items < 3)
croak("Usage: i_writegif_gen(fd,hashref, images...)");
if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
croak("i_writegif_gen: Second argument must be a hash ref");
hv = (HV *)SvRV(ST(1));
memset(&quant, 0, sizeof(quant));
quant.mc_size = 256;
handle_quant_opts(&quant, hv);
img_count = items - 2;
RETVAL = 1;
if (img_count < 1) {
RETVAL = 0;
i_clear_error();
i_push_error(0, "You need to specify images to save");
}
else {
imgs = mymalloc(sizeof(i_img *) * img_count);
for (i = 0; i < img_count; ++i) {
SV *sv = ST(2+i);
imgs[i] = NULL;
if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv)));
}
else {
i_clear_error();
i_push_error(0, "Only images can be saved");
RETVAL = 0;
break;
}
}
if (RETVAL) {
RETVAL = i_writegif_gen(&quant, fd, imgs, img_count);
}
myfree(imgs);
if (RETVAL) {
copy_colors_back(hv, &quant);
}
}
ST(0) = sv_newmortal();
if (RETVAL == 0) ST(0)=&PL_sv_undef;
else sv_setiv(ST(0), (IV)RETVAL);
cleanup_quant_opts(&quant);
undef_int
i_writegif_callback(cb, maxbuffer,...)
int maxbuffer;
PREINIT:
i_quantize quant;
i_img **imgs = NULL;
int img_count;
int i;
HV *hv;
i_writer_data wd;
CODE:
if (items < 4)
croak("Usage: i_writegif_callback(\\&callback,maxbuffer,hashref, images...)");
if (!SvROK(ST(2)) || ! SvTYPE(SvRV(ST(2))))
croak("i_writegif_callback: Second argument must be a hash ref");
hv = (HV *)SvRV(ST(2));
memset(&quant, 0, sizeof(quant));
quant.mc_size = 256;
handle_quant_opts(&quant, hv);
img_count = items - 3;
RETVAL = 1;
if (img_count < 1) {
RETVAL = 0;
}
else {
imgs = mymalloc(sizeof(i_img *) * img_count);
for (i = 0; i < img_count; ++i) {
SV *sv = ST(3+i);
imgs[i] = NULL;
if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv)));
}
else {
RETVAL = 0;
break;
}
}
if (RETVAL) {
wd.sv = ST(0);
RETVAL = i_writegif_callback(&quant, write_callback, (char *)&wd, maxbuffer, imgs, img_count);
}
myfree(imgs);
if (RETVAL) {
copy_colors_back(hv, &quant);
}
}
ST(0) = sv_newmortal();
if (RETVAL == 0) ST(0)=&PL_sv_undef;
else sv_setiv(ST(0), (IV)RETVAL);
cleanup_quant_opts(&quant);
undef_int
i_writegif_wiol(ig, opts,...)
Imager::IO ig
PREINIT:
i_quantize quant;
i_img **imgs = NULL;
int img_count;
int i;
HV *hv;
CODE:
if (items < 3)
croak("Usage: i_writegif_wiol(IO,hashref, images...)");
if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
croak("i_writegif_callback: Second argument must be a hash ref");
hv = (HV *)SvRV(ST(1));
memset(&quant, 0, sizeof(quant));
quant.mc_size = 256;
handle_quant_opts(&quant, hv);
img_count = items - 2;
RETVAL = 1;
if (img_count < 1) {
RETVAL = 0;
}
else {
imgs = mymalloc(sizeof(i_img *) * img_count);
for (i = 0; i < img_count; ++i) {
SV *sv = ST(2+i);
imgs[i] = NULL;
if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv)));
}
else {
RETVAL = 0;
break;
}
}
if (RETVAL) {
RETVAL = i_writegif_wiol(ig, &quant, imgs, img_count);
}
myfree(imgs);
if (RETVAL) {
copy_colors_back(hv, &quant);
}
}
ST(0) = sv_newmortal();
if (RETVAL == 0) ST(0)=&PL_sv_undef;
else sv_setiv(ST(0), (IV)RETVAL);
cleanup_quant_opts(&quant);
void
i_readgif(fd)
int fd
PREINIT:
int* colour_table;
int colours, q, w;
i_img* rimg;
SV* temp[3];
AV* ct;
SV* r;
PPCODE:
colour_table = NULL;
colours = 0;
if(GIMME_V == G_ARRAY) {
rimg = i_readgif(fd,&colour_table,&colours);
} else {
/* don't waste time with colours if they aren't wanted */
rimg = i_readgif(fd,NULL,NULL);
}
if (colour_table == NULL) {
EXTEND(SP,1);
r=sv_newmortal();
sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
PUSHs(r);
} else {
/* the following creates an [[r,g,b], [r, g, b], [r, g, b]...] */
/* I don't know if I have the reference counts right or not :( */
/* Neither do I :-) */
/* No Idea here either */
ct=newAV();
av_extend(ct, colours);
for(q=0; q<colours; q++) {
for(w=0; w<3; w++)
temp[w]=sv_2mortal(newSViv(colour_table[q*3 + w]));
av_store(ct, q, (SV*)newRV_noinc((SV*)av_make(3, temp)));
}
myfree(colour_table);
EXTEND(SP,2);
r = sv_newmortal();
sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
PUSHs(r);
PUSHs(newRV_noinc((SV*)ct));
}
void
i_readgif_wiol(ig)
Imager::IO ig
PREINIT:
int* colour_table;
int colours, q, w;
i_img* rimg;
SV* temp[3];
AV* ct;
SV* r;
PPCODE:
colour_table = NULL;
colours = 0;
if(GIMME_V == G_ARRAY) {
rimg = i_readgif_wiol(ig,&colour_table,&colours);
} else {
/* don't waste time with colours if they aren't wanted */
rimg = i_readgif_wiol(ig,NULL,NULL);
}
if (colour_table == NULL) {
EXTEND(SP,1);
r=sv_newmortal();
sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
PUSHs(r);
} else {
/* the following creates an [[r,g,b], [r, g, b], [r, g, b]...] */
/* I don't know if I have the reference counts right or not :( */
/* Neither do I :-) */
/* No Idea here either */
ct=newAV();
av_extend(ct, colours);
for(q=0; q<colours; q++) {
for(w=0; w<3; w++)
temp[w]=sv_2mortal(newSViv(colour_table[q*3 + w]));
av_store(ct, q, (SV*)newRV_noinc((SV*)av_make(3, temp)));
}
myfree(colour_table);
EXTEND(SP,2);
r = sv_newmortal();
sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
PUSHs(r);
PUSHs(newRV_noinc((SV*)ct));
}
Imager::ImgRaw
i_readgif_single_wiol(ig, page=0)
Imager::IO ig
int page
void
i_readgif_scalar(...)
PROTOTYPE: $
PREINIT:
char* data;
STRLEN length;
int* colour_table;
int colours, q, w;
i_img* rimg;
SV* temp[3];
AV* ct;
SV* r;
PPCODE:
data = (char *)SvPV(ST(0), length);
colour_table=NULL;
colours=0;
if(GIMME_V == G_ARRAY) {
rimg=i_readgif_scalar(data,length,&colour_table,&colours);
} else {
/* don't waste time with colours if they aren't wanted */
rimg=i_readgif_scalar(data,length,NULL,NULL);
}
if (colour_table == NULL) {
EXTEND(SP,1);
r=sv_newmortal();
sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
PUSHs(r);
} else {
/* the following creates an [[r,g,b], [r, g, b], [r, g, b]...] */
/* I don't know if I have the reference counts right or not :( */
/* Neither do I :-) */
ct=newAV();
av_extend(ct, colours);
for(q=0; q<colours; q++) {
for(w=0; w<3; w++)
temp[w]=sv_2mortal(newSViv(colour_table[q*3 + w]));
av_store(ct, q, (SV*)newRV_noinc((SV*)av_make(3, temp)));
}
myfree(colour_table);
EXTEND(SP,2);
r=sv_newmortal();
sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
PUSHs(r);
PUSHs(newRV_noinc((SV*)ct));
}
void
i_readgif_callback(...)
PROTOTYPE: &
PREINIT:
int* colour_table;
int colours, q, w;
i_img* rimg;
SV* temp[3];
AV* ct;
SV* r;
i_reader_data rd;
PPCODE:
rd.sv = ST(0);
colour_table=NULL;
colours=0;
if(GIMME_V == G_ARRAY) {
rimg=i_readgif_callback(read_callback, (char *)&rd,&colour_table,&colours);
} else {
/* don't waste time with colours if they aren't wanted */
rimg=i_readgif_callback(read_callback, (char *)&rd,NULL,NULL);
}
if (colour_table == NULL) {
EXTEND(SP,1);
r=sv_newmortal();
sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
PUSHs(r);
} else {
/* the following creates an [[r,g,b], [r, g, b], [r, g, b]...] */
/* I don't know if I have the reference counts right or not :( */
/* Neither do I :-) */
/* Neither do I - maybe I'll move this somewhere */
ct=newAV();
av_extend(ct, colours);
for(q=0; q<colours; q++) {
for(w=0; w<3; w++)
temp[w]=sv_2mortal(newSViv(colour_table[q*3 + w]));
av_store(ct, q, (SV*)newRV_noinc((SV*)av_make(3, temp)));
}
myfree(colour_table);
EXTEND(SP,2);
r=sv_newmortal();
sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
PUSHs(r);
PUSHs(newRV_noinc((SV*)ct));
}
void
i_readgif_multi(fd)
int fd
PREINIT:
i_img **imgs;
int count;
int i;
PPCODE:
imgs = i_readgif_multi(fd, &count);
if (imgs) {
EXTEND(SP, count);
for (i = 0; i < count; ++i) {
SV *sv = sv_newmortal();
sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
PUSHs(sv);
}
myfree(imgs);
}
void
i_readgif_multi_scalar(data)
PREINIT:
i_img **imgs;
int count;
char *data;
STRLEN length;
int i;
PPCODE:
data = (char *)SvPV(ST(0), length);
imgs = i_readgif_multi_scalar(data, length, &count);
if (imgs) {
EXTEND(SP, count);
for (i = 0; i < count; ++i) {
SV *sv = sv_newmortal();
sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
PUSHs(sv);
}
myfree(imgs);
}
void
i_readgif_multi_callback(cb)
PREINIT:
i_reader_data rd;
i_img **imgs;
int count;
int i;
PPCODE:
rd.sv = ST(0);
imgs = i_readgif_multi_callback(read_callback, (char *)&rd, &count);
if (imgs) {
EXTEND(SP, count);
for (i = 0; i < count; ++i) {
SV *sv = sv_newmortal();
sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
PUSHs(sv);
}
myfree(imgs);
}
void
i_readgif_multi_wiol(ig)
Imager::IO ig
PREINIT:
i_img **imgs;
int count;
int i;
PPCODE:
imgs = i_readgif_multi_wiol(ig, &count);
if (imgs) {
EXTEND(SP, count);
for (i = 0; i < count; ++i) {
SV *sv = sv_newmortal();
sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
PUSHs(sv);
}
myfree(imgs);
}
#endif
Imager::ImgRaw
i_readpnm_wiol(ig, length)
Imager::IO ig
int length
undef_int
i_writeppm_wiol(im, ig)
Imager::ImgRaw im
Imager::IO ig
Imager::ImgRaw
i_readraw_wiol(ig,x,y,datachannels,storechannels,intrl)
Imager::IO ig
int x
int y
int datachannels
int storechannels
int intrl
undef_int
i_writeraw_wiol(im,ig)
Imager::ImgRaw im
Imager::IO ig
undef_int
i_writebmp_wiol(im,ig)
Imager::ImgRaw im
Imager::IO ig
Imager::ImgRaw
i_readbmp_wiol(ig)
Imager::IO ig
undef_int
i_writetga_wiol(im,ig, wierdpack, compress, idstring)
Imager::ImgRaw im
Imager::IO ig
int wierdpack
int compress
char* idstring
PREINIT:
int idlen;
CODE:
idlen = SvCUR(ST(4));
RETVAL = i_writetga_wiol(im, ig, wierdpack, compress, idstring, idlen);
OUTPUT:
RETVAL
Imager::ImgRaw
i_readtga_wiol(ig, length)
Imager::IO ig
int length
undef_int
i_writergb_wiol(im,ig, wierdpack, compress, idstring)
Imager::ImgRaw im
Imager::IO ig
int wierdpack
int compress
char* idstring
PREINIT:
int idlen;
CODE:
idlen = SvCUR(ST(4));
RETVAL = i_writergb_wiol(im, ig, wierdpack, compress, idstring, idlen);
OUTPUT:
RETVAL
Imager::ImgRaw
i_readrgb_wiol(ig, length)
Imager::IO ig
int length
Imager::ImgRaw
i_scaleaxis(im,Value,Axis)
Imager::ImgRaw im
float Value
int Axis
Imager::ImgRaw
i_scale_nn(im,scx,scy)
Imager::ImgRaw im
float scx
float scy
Imager::ImgRaw
i_haar(im)
Imager::ImgRaw im
int
i_count_colors(im,maxc)
Imager::ImgRaw im
int maxc
Imager::ImgRaw
i_transform(im,opx,opy,parm)
Imager::ImgRaw im
PREINIT:
double* parm;
int* opx;
int* opy;
int opxl;
int opyl;
int parmlen;
AV* av;
SV* sv1;
int i;
CODE:
if (!SvROK(ST(1))) croak("Imager: Parameter 1 must be a reference to an array\n");
if (!SvROK(ST(2))) croak("Imager: Parameter 2 must be a reference to an array\n");
if (!SvROK(ST(3))) croak("Imager: Parameter 3 must be a reference to an array\n");
if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 must be a reference to an array\n");
if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 2 must be a reference to an array\n");
if (SvTYPE(SvRV(ST(3))) != SVt_PVAV) croak("Imager: Parameter 3 must be a reference to an array\n");
av=(AV*)SvRV(ST(1));
opxl=av_len(av)+1;
opx=mymalloc( opxl*sizeof(int) );
for(i=0;i<opxl;i++) {
sv1=(*(av_fetch(av,i,0)));
opx[i]=(int)SvIV(sv1);
}
av=(AV*)SvRV(ST(2));
opyl=av_len(av)+1;
opy=mymalloc( opyl*sizeof(int) );
for(i=0;i<opyl;i++) {
sv1=(*(av_fetch(av,i,0)));
opy[i]=(int)SvIV(sv1);
}
av=(AV*)SvRV(ST(3));
parmlen=av_len(av)+1;
parm=mymalloc( parmlen*sizeof(double) );
for(i=0;i<parmlen;i++) { /* FIXME: Bug? */
sv1=(*(av_fetch(av,i,0)));
parm[i]=(double)SvNV(sv1);
}
RETVAL=i_transform(im,opx,opxl,opy,opyl,parm,parmlen);
myfree(parm);
myfree(opy);
myfree(opx);
ST(0) = sv_newmortal();
if (RETVAL == 0) ST(0)=&PL_sv_undef;
else sv_setref_pv(ST(0), "Imager::ImgRaw", (void*)RETVAL);
Imager::ImgRaw
i_transform2(sv_width,sv_height,channels,sv_ops,av_n_regs,av_c_regs,av_in_imgs)
SV *sv_width
SV *sv_height
SV *sv_ops
AV *av_n_regs
AV *av_c_regs
AV *av_in_imgs
int channels
PREINIT:
int width;
int height;
struct rm_op *ops;
STRLEN ops_len;
int ops_count;
double *n_regs;
int n_regs_count;
i_color *c_regs;
int c_regs_count;
int in_imgs_count;
i_img **in_imgs;
SV *sv1;
IV tmp;
int i;
CODE:
in_imgs_count = av_len(av_in_imgs)+1;
for (i = 0; i < in_imgs_count; ++i) {
sv1 = *av_fetch(av_in_imgs, i, 0);
if (!sv_derived_from(sv1, "Imager::ImgRaw")) {
croak("sv_in_img must contain only images");
}
}
if (in_imgs_count > 0) {
in_imgs = mymalloc(in_imgs_count*sizeof(i_img*));
for (i = 0; i < in_imgs_count; ++i) {
sv1 = *av_fetch(av_in_imgs,i,0);
if (!sv_derived_from(sv1, "Imager::ImgRaw")) {
croak("Parameter 5 must contain only images");
}
tmp = SvIV((SV*)SvRV(sv1));
in_imgs[i] = INT2PTR(i_img*, tmp);
}
}
else {
/* no input images */
in_imgs = NULL;
}
/* default the output size from the first input if possible */
if (SvOK(sv_width))
width = SvIV(sv_width);
else if (in_imgs_count)
width = in_imgs[0]->xsize;
else
croak("No output image width supplied");
if (SvOK(sv_height))
height = SvIV(sv_height);
else if (in_imgs_count)
height = in_imgs[0]->ysize;
else
croak("No output image height supplied");
ops = (struct rm_op *)SvPV(sv_ops, ops_len);
if (ops_len % sizeof(struct rm_op))
croak("Imager: Parameter 3 must be a bitmap of regops\n");
ops_count = ops_len / sizeof(struct rm_op);
n_regs_count = av_len(av_n_regs)+1;
n_regs = mymalloc(n_regs_count * sizeof(double));
for (i = 0; i < n_regs_count; ++i) {
sv1 = *av_fetch(av_n_regs,i,0);
if (SvOK(sv1))
n_regs[i] = SvNV(sv1);
}
c_regs_count = av_len(av_c_regs)+1;
c_regs = mymalloc(c_regs_count * sizeof(i_color));
/* I don't bother initializing the colou?r registers */
RETVAL=i_transform2(width, height, channels, ops, ops_count,
n_regs, n_regs_count,
c_regs, c_regs_count, in_imgs, in_imgs_count);
if (in_imgs)
myfree(in_imgs);
myfree(n_regs);
myfree(c_regs);
ST(0) = sv_newmortal();
if (RETVAL == 0) ST(0)=&PL_sv_undef;
else sv_setref_pv(ST(0), "Imager::ImgRaw", (void*)RETVAL);
void
i_contrast(im,intensity)
Imager::ImgRaw im
float intensity
void
i_hardinvert(im)
Imager::ImgRaw im
void
i_noise(im,amount,type)
Imager::ImgRaw im
float amount
unsigned char type
void
i_bumpmap(im,bump,channel,light_x,light_y,strength)
Imager::ImgRaw im
Imager::ImgRaw bump
int channel
int light_x
int light_y
int strength
void
i_bumpmap_complex(im,bump,channel,tx,ty,Lx,Ly,Lz,cd,cs,n,Ia,Il,Is)
Imager::ImgRaw im
Imager::ImgRaw bump
int channel
int tx
int ty
float Lx
float Ly
float Lz
float cd
float cs
float n
Imager::Color Ia
Imager::Color Il
Imager::Color Is
void
i_postlevels(im,levels)
Imager::ImgRaw im
int levels
void
i_mosaic(im,size)
Imager::ImgRaw im
int size
void
i_watermark(im,wmark,tx,ty,pixdiff)
Imager::ImgRaw im
Imager::ImgRaw wmark
int tx
int ty
int pixdiff
void
i_autolevels(im,lsat,usat,skew)
Imager::ImgRaw im
float lsat
float usat
float skew
void
i_radnoise(im,xo,yo,rscale,ascale)
Imager::ImgRaw im
float xo
float yo
float rscale
float ascale
void
i_turbnoise(im, xo, yo, scale)
Imager::ImgRaw im
float xo
float yo
float scale
void
i_gradgen(im, ...)
Imager::ImgRaw im
PREINIT:
int num;
int *xo;
int *yo;
i_color *ival;
int dmeasure;
int i;
SV *sv;
AV *axx;
AV *ayy;
AV *ac;
CODE:
if (items != 5)
croak("Usage: i_gradgen(im, xo, yo, ival, dmeasure)");
if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
croak("i_gradgen: Second argument must be an array ref");
if (!SvROK(ST(2)) || ! SvTYPE(SvRV(ST(2))))
croak("i_gradgen: Third argument must be an array ref");
if (!SvROK(ST(3)) || ! SvTYPE(SvRV(ST(3))))
croak("i_gradgen: Fourth argument must be an array ref");
axx = (AV *)SvRV(ST(1));
ayy = (AV *)SvRV(ST(2));
ac = (AV *)SvRV(ST(3));
dmeasure = (int)SvIV(ST(4));
num = av_len(axx) < av_len(ayy) ? av_len(axx) : av_len(ayy);
num = num <= av_len(ac) ? num : av_len(ac);
num++;
if (num < 2) croak("Usage: i_gradgen array refs must have more than 1 entry each");
xo = mymalloc( sizeof(int) * num );
yo = mymalloc( sizeof(int) * num );
ival = mymalloc( sizeof(i_color) * num );
for(i = 0; i<num; i++) {
xo[i] = (int)SvIV(* av_fetch(axx, i, 0));
yo[i] = (int)SvIV(* av_fetch(ayy, i, 0));
sv = *av_fetch(ac, i, 0);
if ( !sv_derived_from(sv, "Imager::Color") ) {
free(axx); free(ayy); free(ac);
croak("i_gradgen: Element of fourth argument is not derived from Imager::Color");
}
ival[i] = *INT2PTR(i_color *, SvIV((SV *)SvRV(sv)));
}
i_gradgen(im, num, xo, yo, ival, dmeasure);
myfree(xo);
myfree(yo);
myfree(ival);
Imager::ImgRaw
i_diff_image(im, im2, mindist=0)
Imager::ImgRaw im
Imager::ImgRaw im2
int mindist
undef_int
i_fountain(im, xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs)
Imager::ImgRaw im
double xa
double ya
double xb
double yb
int type
int repeat
int combine
int super_sample
double ssample_param
PREINIT:
AV *asegs;
int count;
i_fountain_seg *segs;
CODE:
if (!SvROK(ST(10)) || ! SvTYPE(SvRV(ST(10))))
croak("i_fountain: argument 11 must be an array ref");
asegs = (AV *)SvRV(ST(10));
segs = load_fount_segs(asegs, &count);
RETVAL = i_fountain(im, xa, ya, xb, yb, type, repeat, combine,
super_sample, ssample_param, count, segs);
myfree(segs);
OUTPUT:
RETVAL
Imager::FillHandle
i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs)
double xa
double ya
double xb
double yb
int type
int repeat
int combine
int super_sample
double ssample_param
PREINIT:
AV *asegs;
int count;
i_fountain_seg *segs;
CODE:
if (!SvROK(ST(9)) || ! SvTYPE(SvRV(ST(9))))
croak("i_fountain: argument 11 must be an array ref");
asegs = (AV *)SvRV(ST(9));
segs = load_fount_segs(asegs, &count);
RETVAL = i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine,
super_sample, ssample_param, count, segs);
myfree(segs);
OUTPUT:
RETVAL
void
i_errors()
PREINIT:
i_errmsg *errors;
int i;
AV *av;
SV *sv;
PPCODE:
errors = i_errors();
i = 0;
while (errors[i].msg) {
av = newAV();
sv = newSVpv(errors[i].msg, strlen(errors[i].msg));
if (!av_store(av, 0, sv)) {
SvREFCNT_dec(sv);
}
sv = newSViv(errors[i].code);
if (!av_store(av, 1, sv)) {
SvREFCNT_dec(sv);
}
PUSHs(sv_2mortal(newRV_noinc((SV*)av)));
++i;
}
undef_int
i_nearest_color(im, ...)
Imager::ImgRaw im
PREINIT:
int num;
int *xo;
int *yo;
i_color *ival;
int dmeasure;
int i;
SV *sv;
AV *axx;
AV *ayy;
AV *ac;
CODE:
if (items != 5)
croak("Usage: i_nearest_color(im, xo, yo, ival, dmeasure)");
if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
croak("i_nearest_color: Second argument must be an array ref");
if (!SvROK(ST(2)) || ! SvTYPE(SvRV(ST(2))))
croak("i_nearest_color: Third argument must be an array ref");
if (!SvROK(ST(3)) || ! SvTYPE(SvRV(ST(3))))
croak("i_nearest_color: Fourth argument must be an array ref");
axx = (AV *)SvRV(ST(1));
ayy = (AV *)SvRV(ST(2));
ac = (AV *)SvRV(ST(3));
dmeasure = (int)SvIV(ST(4));
num = av_len(axx) < av_len(ayy) ? av_len(axx) : av_len(ayy);
num = num <= av_len(ac) ? num : av_len(ac);
num++;
if (num < 2) croak("Usage: i_nearest_color array refs must have more than 1 entry each");
xo = mymalloc( sizeof(int) * num );
yo = mymalloc( sizeof(int) * num );
ival = mymalloc( sizeof(i_color) * num );
for(i = 0; i<num; i++) {
xo[i] = (int)SvIV(* av_fetch(axx, i, 0));
yo[i] = (int)SvIV(* av_fetch(ayy, i, 0));
sv = *av_fetch(ac, i, 0);
if ( !sv_derived_from(sv, "Imager::Color") ) {
free(axx); free(ayy); free(ac);
croak("i_nearest_color: Element of fourth argument is not derived from Imager::Color");
}
ival[i] = *INT2PTR(i_color *, SvIV((SV *)SvRV(sv)));
}
RETVAL = i_nearest_color(im, num, xo, yo, ival, dmeasure);
OUTPUT:
RETVAL
void
malloc_state()
void
DSO_open(filename)
char* filename
PREINIT:
void *rc;
char *evstr;
PPCODE:
rc=DSO_open(filename,&evstr);
if (rc!=NULL) {
if (evstr!=NULL) {
EXTEND(SP,2);
PUSHs(sv_2mortal(newSViv(PTR2IV(rc))));
PUSHs(sv_2mortal(newSVpvn(evstr, strlen(evstr))));
} else {
EXTEND(SP,1);
PUSHs(sv_2mortal(newSViv(PTR2IV(rc))));
}
}
undef_int
DSO_close(dso_handle)
void* dso_handle
void
DSO_funclist(dso_handle_v)
void* dso_handle_v
PREINIT:
int i;
DSO_handle *dso_handle;
PPCODE:
dso_handle=(DSO_handle*)dso_handle_v;
i=0;
while( dso_handle->function_list[i].name != NULL) {
EXTEND(SP,1);
PUSHs(sv_2mortal(newSVpv(dso_handle->function_list[i].name,0)));
EXTEND(SP,1);
PUSHs(sv_2mortal(newSVpv(dso_handle->function_list[i++].pcode,0)));
}
void
DSO_call(handle,func_index,hv)
void* handle
int func_index
PREINIT:
HV* hv;
PPCODE:
if (!SvROK(ST(2))) croak("Imager: Parameter 2 must be a reference to a hash\n");
hv=(HV*)SvRV(ST(2));
if (SvTYPE(hv)!=SVt_PVHV) croak("Imager: Parameter 2 must be a reference to a hash\n");
DSO_call( (DSO_handle *)handle,func_index,hv);
SV *
i_get_pixel(im, x, y)
Imager::ImgRaw im
int x
int y;
PREINIT:
i_color *color;
CODE:
color = (i_color *)mymalloc(sizeof(i_color));
if (i_gpix(im, x, y, color) == 0) {
RETVAL = NEWSV(0, 0);
sv_setref_pv(RETVAL, "Imager::Color", (void *)color);
}
else {
myfree(color);
RETVAL = &PL_sv_undef;
}
OUTPUT:
RETVAL
int
i_ppix(im, x, y, cl)
Imager::ImgRaw im
int x
int y
Imager::Color cl
Imager::ImgRaw
i_img_pal_new(x, y, channels, maxpal)
int x
int y
int channels
int maxpal
Imager::ImgRaw
i_img_to_pal(src, quant)
Imager::ImgRaw src
PREINIT:
HV *hv;
i_quantize quant;
CODE:
if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
croak("i_img_to_pal: second argument must be a hash ref");
hv = (HV *)SvRV(ST(1));
memset(&quant, 0, sizeof(quant));
quant.mc_size = 256;
handle_quant_opts(&quant, hv);
RETVAL = i_img_to_pal(src, &quant);
if (RETVAL) {
copy_colors_back(hv, &quant);
}
cleanup_quant_opts(&quant);
OUTPUT:
RETVAL
Imager::ImgRaw
i_img_to_rgb(src)
Imager::ImgRaw src
void
i_gpal(im, l, r, y)
Imager::ImgRaw im
int l
int r
int y
PREINIT:
i_palidx *work;
int count, i;
PPCODE:
if (l < r) {
work = mymalloc((r-l) * sizeof(i_palidx));
count = i_gpal(im, l, r, y, work);
if (GIMME_V == G_ARRAY) {
EXTEND(SP, count);
for (i = 0; i < count; ++i) {
PUSHs(sv_2mortal(newSViv(work[i])));
}
}
else {
EXTEND(SP, 1);
PUSHs(sv_2mortal(newSVpv((char *)work, count * sizeof(i_palidx))));
}
myfree(work);
}
else {
if (GIMME_V != G_ARRAY) {
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
}
}
int
i_ppal(im, l, y, ...)
Imager::ImgRaw im
int l
int y
PREINIT:
i_palidx *work;
int i;
CODE:
if (items > 3) {
work = mymalloc(sizeof(i_palidx) * (items-3));
for (i=0; i < items-3; ++i) {
work[i] = SvIV(ST(i+3));
}
RETVAL = i_ppal(im, l, l+items-3, y, work);
myfree(work);
}
else {
RETVAL = 0;
}
OUTPUT:
RETVAL
SV *
i_addcolors(im, ...)
Imager::ImgRaw im
PREINIT:
int index;
i_color *colors;
int i;
CODE:
if (items < 2)
croak("i_addcolors: no colors to add");
colors = mymalloc((items-1) * sizeof(i_color));
for (i=0; i < items-1; ++i) {
if (sv_isobject(ST(i+1))
&& sv_derived_from(ST(i+1), "Imager::Color")) {
IV tmp = SvIV((SV *)SvRV(ST(i+1)));
colors[i] = *INT2PTR(i_color *, tmp);
}
else {
myfree(colors);
croak("i_addcolor: pixels must be Imager::Color objects");
}
}
index = i_addcolors(im, colors, items-1);
myfree(colors);
if (index == 0) {
RETVAL = newSVpv("0 but true", 0);
}
else if (index == -1) {
RETVAL = &PL_sv_undef;
}
else {
RETVAL = newSViv(index);
}
OUTPUT:
RETVAL
undef_int
i_setcolors(im, index, ...)
Imager::ImgRaw im
int index
PREINIT:
i_color *colors;
int i;
CODE:
if (items < 3)
croak("i_setcolors: no colors to add");
colors = mymalloc((items-2) * sizeof(i_color));
for (i=0; i < items-2; ++i) {
if (sv_isobject(ST(i+2))
&& sv_derived_from(ST(i+2), "Imager::Color")) {
IV tmp = SvIV((SV *)SvRV(ST(i+2)));
colors[i] = *INT2PTR(i_color *, tmp);
}
else {
myfree(colors);
croak("i_setcolors: pixels must be Imager::Color objects");
}
}
RETVAL = i_setcolors(im, index, colors, items-2);
myfree(colors);
OUTPUT:
RETVAL
void
i_getcolors(im, index, ...)
Imager::ImgRaw im
int index
PREINIT:
i_color *colors;
int count = 1;
int i;
PPCODE:
if (items > 3)
croak("i_getcolors: too many arguments");
if (items == 3)
count = SvIV(ST(2));
if (count < 1)
croak("i_getcolors: count must be positive");
colors = mymalloc(sizeof(i_color) * count);
if (i_getcolors(im, index, colors, count)) {
for (i = 0; i < count; ++i) {
i_color *pv;
SV *sv = sv_newmortal();
pv = mymalloc(sizeof(i_color));
*pv = colors[i];
sv_setref_pv(sv, "Imager::Color", (void *)pv);
PUSHs(sv);
}
}
myfree(colors);
undef_neg_int
i_colorcount(im)
Imager::ImgRaw im
undef_neg_int
i_maxcolors(im)
Imager::ImgRaw im
SV *
i_findcolor(im, color)
Imager::ImgRaw im
Imager::Color color
PREINIT:
i_palidx index;
CODE:
if (i_findcolor(im, color, &index)) {
RETVAL = newSViv(index);
}
else {
RETVAL = &PL_sv_undef;
}
OUTPUT:
RETVAL
int
i_img_bits(im)
Imager::ImgRaw im
int
i_img_type(im)
Imager::ImgRaw im
int
i_img_virtual(im)
Imager::ImgRaw im
void
i_gsamp(im, l, r, y, ...)
Imager::ImgRaw im
int l
int r
int y
PREINIT:
int *chans;
int chan_count;
i_sample_t *data;
int count, i;
PPCODE:
if (items < 5)
croak("No channel numbers supplied to g_samp()");
if (l < r) {
chan_count = items - 4;
chans = mymalloc(sizeof(int) * chan_count);
for (i = 0; i < chan_count; ++i)
chans[i] = SvIV(ST(i+4));
data = mymalloc(sizeof(i_sample_t) * (r-l) * chan_count); /* XXX: memleak? */
count = i_gsamp(im, l, r, y, data, chans, chan_count);
myfree(chans);
if (GIMME_V == G_ARRAY) {
EXTEND(SP, count);
for (i = 0; i < count; ++i)
PUSHs(sv_2mortal(newSViv(data[i])));
}
else {
EXTEND(SP, 1);
PUSHs(sv_2mortal(newSVpv((char *)data, count * sizeof(i_sample_t))));
}
myfree(data);
}
else {
if (GIMME_V != G_ARRAY) {
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
}
}
Imager::ImgRaw
i_img_masked_new(targ, mask, x, y, w, h)
Imager::ImgRaw targ
int x
int y
int w
int h
PREINIT:
i_img *mask;
CODE:
if (SvOK(ST(1))) {
if (!sv_isobject(ST(1))
|| !sv_derived_from(ST(1), "Imager::ImgRaw")) {
croak("i_img_masked_new: parameter 2 must undef or an image");
}
mask = INT2PTR(i_img *, SvIV((SV *)SvRV(ST(1))));
}
else
mask = NULL;
RETVAL = i_img_masked_new(targ, mask, x, y, w, h);
OUTPUT:
RETVAL
int
i_plin(im, l, y, ...)
Imager::ImgRaw im
int l
int y
PREINIT:
i_color *work;
int i;
STRLEN len;
int count;
CODE:
if (items > 3) {
if (items == 4 && SvOK(ST(3)) && !SvROK(ST(3))) {
/* supplied as a byte string */
work = (i_color *)SvPV(ST(3), len);
count = len / sizeof(i_color);
if (count * sizeof(i_color) != len) {
croak("i_plin: length of scalar argument must be multiple of sizeof i_color");
}
RETVAL = i_plin(im, l, l+count, y, work);
}
else {
work = mymalloc(sizeof(i_color) * (items-3));
for (i=0; i < items-3; ++i) {
if (sv_isobject(ST(i+3))
&& sv_derived_from(ST(i+3), "Imager::Color")) {
IV tmp = SvIV((SV *)SvRV(ST(i+3)));
work[i] = *INT2PTR(i_color *, tmp);
}
else {
myfree(work);
croak("i_plin: pixels must be Imager::Color objects");
}
}
RETVAL = i_plin(im, l, l+items-3, y, work);
myfree(work);
}
}
else {
RETVAL = 0;
}
OUTPUT:
RETVAL
int
i_ppixf(im, x, y, cl)
Imager::ImgRaw im
int x
int y
Imager::Color::Float cl
void
i_gsampf(im, l, r, y, ...)
Imager::ImgRaw im
int l
int r
int y
PREINIT:
int *chans;
int chan_count;
i_fsample_t *data;
int count, i;
PPCODE:
if (items < 5)
croak("No channel numbers supplied to g_sampf()");
if (l < r) {
chan_count = items - 4;
chans = mymalloc(sizeof(int) * chan_count);
for (i = 0; i < chan_count; ++i)
chans[i] = SvIV(ST(i+4));
data = mymalloc(sizeof(i_fsample_t) * (r-l) * chan_count);
count = i_gsampf(im, l, r, y, data, chans, chan_count);
myfree(chans);
if (GIMME_V == G_ARRAY) {
EXTEND(SP, count);
for (i = 0; i < count; ++i)
PUSHs(sv_2mortal(newSVnv(data[i])));
}
else {
EXTEND(SP, 1);
PUSHs(sv_2mortal(newSVpv((void *)data, count * sizeof(i_fsample_t))));
}
myfree(data);
}
else {
if (GIMME_V != G_ARRAY) {
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
}
}
int
i_plinf(im, l, y, ...)
Imager::ImgRaw im
int l
int y
PREINIT:
i_fcolor *work;
int i;
STRLEN len;
int count;
CODE:
if (items > 3) {
if (items == 4 && SvOK(ST(3)) && !SvROK(ST(3))) {
/* supplied as a byte string */
work = (i_fcolor *)SvPV(ST(3), len);
count = len / sizeof(i_fcolor);
if (count * sizeof(i_fcolor) != len) {
croak("i_plin: length of scalar argument must be multiple of sizeof i_fcolor");
}
RETVAL = i_plinf(im, l, l+count, y, work);
}
else {
work = mymalloc(sizeof(i_fcolor) * (items-3));
for (i=0; i < items-3; ++i) {
if (sv_isobject(ST(i+3))
&& sv_derived_from(ST(i+3), "Imager::Color::Float")) {
IV tmp = SvIV((SV *)SvRV(ST(i+3)));
work[i] = *INT2PTR(i_fcolor *, tmp);
}
else {
myfree(work);
croak("i_plinf: pixels must be Imager::Color::Float objects");
}
}
/**(char *)0 = 1;*/
RETVAL = i_plinf(im, l, l+items-3, y, work);
myfree(work);
}
}
else {
RETVAL = 0;
}
OUTPUT:
RETVAL
SV *
i_gpixf(im, x, y)
Imager::ImgRaw im
int x
int y;
PREINIT:
i_fcolor *color;
CODE:
color = (i_fcolor *)mymalloc(sizeof(i_fcolor));
if (i_gpixf(im, x, y, color) == 0) {
RETVAL = NEWSV(0,0);
sv_setref_pv(RETVAL, "Imager::Color::Float", (void *)color);
}
else {
myfree(color);
RETVAL = &PL_sv_undef;
}
OUTPUT:
RETVAL
void
i_glin(im, l, r, y)
Imager::ImgRaw im
int l
int r
int y
PREINIT:
i_color *vals;
int count, i;
PPCODE:
if (l < r) {
vals = mymalloc((r-l) * sizeof(i_color));
count = i_glin(im, l, r, y, vals);
if (GIMME_V == G_ARRAY) {
EXTEND(SP, count);
for (i = 0; i < count; ++i) {
SV *sv;
i_color *col = mymalloc(sizeof(i_color));
*col = vals[i];
sv = sv_newmortal();
sv_setref_pv(sv, "Imager::Color", (void *)col);
PUSHs(sv);
}
}
else if (count) {
EXTEND(SP, 1);
PUSHs(sv_2mortal(newSVpv((void *)vals, count * sizeof(i_color))));
}
myfree(vals);
}
void
i_glinf(im, l, r, y)
Imager::ImgRaw im
int l
int r
int y
PREINIT:
i_fcolor *vals;
int count, i;
PPCODE:
if (l < r) {
vals = mymalloc((r-l) * sizeof(i_fcolor));
count = i_glinf(im, l, r, y, vals);
if (GIMME_V == G_ARRAY) {
EXTEND(SP, count);
for (i = 0; i < count; ++i) {
SV *sv;
i_fcolor *col = mymalloc(sizeof(i_fcolor));
*col = vals[i];
sv = sv_newmortal();
sv_setref_pv(sv, "Imager::Color::Float", (void *)col);
PUSHs(sv);
}
}
else if (count) {
EXTEND(SP, 1);
PUSHs(sv_2mortal(newSVpv((void *)vals, count * sizeof(i_fcolor))));
}
myfree(vals);
}
Imager::ImgRaw
i_img_16_new(x, y, ch)
int x
int y
int ch
Imager::ImgRaw
i_img_double_new(x, y, ch)
int x
int y
int ch
undef_int
i_tags_addn(im, name, code, idata)
Imager::ImgRaw im
int code
int idata
PREINIT:
char *name;
STRLEN len;
CODE:
if (SvOK(ST(1)))
name = SvPV(ST(1), len);
else
name = NULL;
RETVAL = i_tags_addn(&im->tags, name, code, idata);
OUTPUT:
RETVAL
undef_int
i_tags_add(im, name, code, data, idata)
Imager::ImgRaw im
int code
int idata
PREINIT:
char *name;
char *data;
STRLEN len;
CODE:
if (SvOK(ST(1)))
name = SvPV(ST(1), len);
else
name = NULL;
if (SvOK(ST(3)))
data = SvPV(ST(3), len);
else {
data = NULL;
len = 0;
}
RETVAL = i_tags_add(&im->tags, name, code, data, len, idata);
OUTPUT:
RETVAL
SV *
i_tags_find(im, name, start)
Imager::ImgRaw im
char *name
int start
PREINIT:
int entry;
CODE:
if (i_tags_find(&im->tags, name, start, &entry)) {
if (entry == 0)
RETVAL = newSVpv("0 but true", 0);
else
RETVAL = newSViv(entry);
} else {
RETVAL = &PL_sv_undef;
}
OUTPUT:
RETVAL
SV *
i_tags_findn(im, code, start)
Imager::ImgRaw im
int code
int start
PREINIT:
int entry;
CODE:
if (i_tags_findn(&im->tags, code, start, &entry)) {
if (entry == 0)
RETVAL = newSVpv("0 but true", 0);
else
RETVAL = newSViv(entry);
}
else {
RETVAL = &PL_sv_undef;
}
OUTPUT:
RETVAL
int
i_tags_delete(im, entry)
Imager::ImgRaw im
int entry
CODE:
RETVAL = i_tags_delete(&im->tags, entry);
OUTPUT:
RETVAL
int
i_tags_delbyname(im, name)
Imager::ImgRaw im
char * name
CODE:
RETVAL = i_tags_delbyname(&im->tags, name);
OUTPUT:
RETVAL
int
i_tags_delbycode(im, code)
Imager::ImgRaw im
int code
CODE:
RETVAL = i_tags_delbycode(&im->tags, code);
OUTPUT:
RETVAL
void
i_tags_get(im, index)
Imager::ImgRaw im
int index
PPCODE:
if (index >= 0 && index < im->tags.count) {
i_img_tag *entry = im->tags.tags + index;
EXTEND(SP, 5);
if (entry->name) {
PUSHs(sv_2mortal(newSVpv(entry->name, 0)));
}
else {
PUSHs(sv_2mortal(newSViv(entry->code)));
}
if (entry->data) {
PUSHs(sv_2mortal(newSVpvn(entry->data, entry->size)));
}
else {
PUSHs(sv_2mortal(newSViv(entry->idata)));
}
}
void
i_tags_get_string(im, what_sv)
Imager::ImgRaw im
SV *what_sv
PREINIT:
char const *name = NULL;
int code;
char buffer[200];
PPCODE:
if (SvIOK(what_sv)) {
code = SvIV(what_sv);
name = NULL;
}
else {
name = SvPV_nolen(what_sv);
code = 0;
}
if (i_tags_get_string(&im->tags, name, code, buffer, sizeof(buffer))) {
EXTEND(SP, 1);
PUSHs(sv_2mortal(newSVpv(buffer, 0)));
}
int
i_tags_count(im)
Imager::ImgRaw im
CODE:
RETVAL = im->tags.count;
OUTPUT:
RETVAL
#ifdef HAVE_WIN32
void
i_wf_bbox(face, size, text)
char *face
int size
char *text
PREINIT:
int cords[BOUNDING_BOX_COUNT];
int rc, i;
PPCODE:
if (rc = i_wf_bbox(face, size, text, strlen(text), cords)) {
EXTEND(SP, rc);
for (i = 0; i < rc; ++i)
PUSHs(sv_2mortal(newSViv(cords[i])));
}
undef_int
i_wf_text(face, im, tx, ty, cl, size, text, align, aa)
char *face
Imager::ImgRaw im
int tx
int ty
Imager::Color cl
int size
char *text
int align
int aa
CODE:
RETVAL = i_wf_text(face, im, tx, ty, cl, size, text, strlen(text),
align, aa);
OUTPUT:
RETVAL
undef_int
i_wf_cp(face, im, tx, ty, channel, size, text, align, aa)
char *face
Imager::ImgRaw im
int tx
int ty
int channel
int size
char *text
int align
int aa
CODE:
RETVAL = i_wf_cp(face, im, tx, ty, channel, size, text, strlen(text),
align, aa);
OUTPUT:
RETVAL
undef_int
i_wf_addfont(font)
char *font
#endif
#ifdef HAVE_FT2
MODULE = Imager PACKAGE = Imager::Font::FT2 PREFIX=FT2_
#define FT2_DESTROY(font) i_ft2_destroy(font)
void
FT2_DESTROY(font)
Imager::Font::FT2 font
MODULE = Imager PACKAGE = Imager::Font::FreeType2
Imager::Font::FT2
i_ft2_new(name, index)
char *name
int index
undef_int
i_ft2_setdpi(font, xdpi, ydpi)
Imager::Font::FT2 font
int xdpi
int ydpi
void
i_ft2_getdpi(font)
Imager::Font::FT2 font
PREINIT:
int xdpi, ydpi;
CODE:
if (i_ft2_getdpi(font, &xdpi, &ydpi)) {
EXTEND(SP, 2);
PUSHs(sv_2mortal(newSViv(xdpi)));
PUSHs(sv_2mortal(newSViv(ydpi)));
}
undef_int
i_ft2_sethinting(font, hinting)
Imager::Font::FT2 font
int hinting
undef_int
i_ft2_settransform(font, matrix)
Imager::Font::FT2 font
PREINIT:
double matrix[6];
int len;
AV *av;
SV *sv1;
int i;
CODE:
if (!SvROK(ST(1)) || SvTYPE(SvRV(ST(1))) != SVt_PVAV)
croak("i_ft2_settransform: parameter 2 must be an array ref\n");
av=(AV*)SvRV(ST(1));
len=av_len(av)+1;
if (len > 6)
len = 6;
for (i = 0; i < len; ++i) {
sv1=(*(av_fetch(av,i,0)));
matrix[i] = SvNV(sv1);
}
for (; i < 6; ++i)
matrix[i] = 0;
RETVAL = i_ft2_settransform(font, matrix);
OUTPUT:
RETVAL
void
i_ft2_bbox(font, cheight, cwidth, text_sv, utf8)
Imager::Font::FT2 font
double cheight
double cwidth
SV *text_sv
int utf8
PREINIT:
int bbox[BOUNDING_BOX_COUNT];
int i;
char *text;
STRLEN text_len;
int rc;
PPCODE:
text = SvPV(text_sv, text_len);
#ifdef SvUTF8
if (SvUTF8(text_sv))
utf8 = 1;
#endif
rc = i_ft2_bbox(font, cheight, cwidth, text, text_len, bbox, utf8);
if (rc) {
EXTEND(SP, rc);
for (i = 0; i < rc; ++i)
PUSHs(sv_2mortal(newSViv(bbox[i])));
}
void
i_ft2_bbox_r(font, cheight, cwidth, text, vlayout, utf8)
Imager::Font::FT2 font
double cheight
double cwidth
char *text
int vlayout
int utf8
PREINIT:
int bbox[8];
int i;
PPCODE:
#ifdef SvUTF8
if (SvUTF8(ST(3)))
utf8 = 1;
#endif
if (i_ft2_bbox_r(font, cheight, cwidth, text, strlen(text), vlayout,
utf8, bbox)) {
EXTEND(SP, 8);
for (i = 0; i < 8; ++i)
PUSHs(sv_2mortal(newSViv(bbox[i])));
}
undef_int
i_ft2_text(font, im, tx, ty, cl, cheight, cwidth, text, align, aa, vlayout, utf8)
Imager::Font::FT2 font
Imager::ImgRaw im
int tx
int ty
Imager::Color cl
double cheight
double cwidth
int align
int aa
int vlayout
int utf8
PREINIT:
char *text;
STRLEN len;
CODE:
#ifdef SvUTF8
if (SvUTF8(ST(7))) {
utf8 = 1;
}
#endif
text = SvPV(ST(7), len);
RETVAL = i_ft2_text(font, im, tx, ty, cl, cheight, cwidth, text,
len, align, aa, vlayout, utf8);
OUTPUT:
RETVAL
undef_int
i_ft2_cp(font, im, tx, ty, channel, cheight, cwidth, text, align, aa, vlayout, utf8)
Imager::Font::FT2 font
Imager::ImgRaw im
int tx
int ty
int channel
double cheight
double cwidth
char *text
int align
int aa
int vlayout
int utf8
CODE:
#ifdef SvUTF8
if (SvUTF8(ST(7)))
utf8 = 1;
#endif
RETVAL = i_ft2_cp(font, im, tx, ty, channel, cheight, cwidth, text,
strlen(text), align, aa, vlayout, 1);
OUTPUT:
RETVAL
void
ft2_transform_box(font, x0, x1, x2, x3)
Imager::Font::FT2 font
int x0
int x1
int x2
int x3
PREINIT:
int box[4];
PPCODE:
box[0] = x0; box[1] = x1; box[2] = x2; box[3] = x3;
ft2_transform_box(font, box);
EXTEND(SP, 4);
PUSHs(sv_2mortal(newSViv(box[0])));
PUSHs(sv_2mortal(newSViv(box[1])));
PUSHs(sv_2mortal(newSViv(box[2])));
PUSHs(sv_2mortal(newSViv(box[3])));
void
i_ft2_has_chars(handle, text_sv, utf8)
Imager::Font::FT2 handle
SV *text_sv
int utf8
PREINIT:
char *text;
STRLEN len;
char *work;
int count;
int i;
PPCODE:
#ifdef SvUTF8
if (SvUTF8(text_sv))
utf8 = 1;
#endif
text = SvPV(text_sv, len);
work = mymalloc(len);
count = i_ft2_has_chars(handle, text, len, utf8, work);
if (GIMME_V == G_ARRAY) {
EXTEND(SP, count);
for (i = 0; i < count; ++i) {
PUSHs(sv_2mortal(newSViv(work[i])));
}
}
else {
EXTEND(SP, 1);
PUSHs(sv_2mortal(newSVpv(work, count)));
}
myfree(work);
void
i_ft2_face_name(handle)
Imager::Font::FT2 handle
PREINIT:
char name[255];
int len;
PPCODE:
len = i_ft2_face_name(handle, name, sizeof(name));
if (len) {
EXTEND(SP, 1);
PUSHs(sv_2mortal(newSVpv(name, 0)));
}
undef_int
i_ft2_can_face_name()
void
i_ft2_glyph_name(handle, text_sv, utf8 = 0, reliable_only = 1)
Imager::Font::FT2 handle
SV *text_sv
int utf8
int reliable_only
PREINIT:
char const *text;
STRLEN work_len;
int len;
char name[255];
PPCODE:
#ifdef SvUTF8
if (SvUTF8(text_sv))
utf8 = 1;
#endif
text = SvPV(text_sv, work_len);
len = work_len;
while (len) {
unsigned long ch;
if (utf8) {
ch = i_utf8_advance(&text, &len);
if (ch == ~0UL) {
i_push_error(0, "invalid UTF8 character");
break;
}
}
else {
ch = *text++;
--len;
}
EXTEND(SP, 1);
if (i_ft2_glyph_name(handle, ch, name, sizeof(name),
reliable_only)) {
PUSHs(sv_2mortal(newSVpv(name, 0)));
}
else {
PUSHs(&PL_sv_undef);
}
}
int
i_ft2_can_do_glyph_names()
int
i_ft2_face_has_glyph_names(handle)
Imager::Font::FT2 handle
int
i_ft2_is_multiple_master(handle)
Imager::Font::FT2 handle
void
i_ft2_get_multiple_masters(handle)
Imager::Font::FT2 handle
PREINIT:
i_font_mm mm;
int i;
PPCODE:
if (i_ft2_get_multiple_masters(handle, &mm)) {
EXTEND(SP, 2+mm.num_axis);
PUSHs(sv_2mortal(newSViv(mm.num_axis)));
PUSHs(sv_2mortal(newSViv(mm.num_designs)));
for (i = 0; i < mm.num_axis; ++i) {
AV *av = newAV();
SV *sv;
av_extend(av, 3);
sv = newSVpv(mm.axis[i].name, strlen(mm.axis[i].name));
SvREFCNT_inc(sv);
av_store(av, 0, sv);
sv = newSViv(mm.axis[i].minimum);
SvREFCNT_inc(sv);
av_store(av, 1, sv);
sv = newSViv(mm.axis[i].maximum);
SvREFCNT_inc(sv);
av_store(av, 2, sv);
PUSHs(newRV_noinc((SV *)av));
}
}
undef_int
i_ft2_set_mm_coords(handle, ...)
Imager::Font::FT2 handle
PROTOTYPE: DISABLE
PREINIT:
long *coords;
int ix_coords, i;
CODE:
/* T_ARRAY handling by xsubpp seems to be busted in 5.6.1, so
transfer the array manually */
ix_coords = items-1;
coords = mymalloc(sizeof(long) * ix_coords);
for (i = 0; i < ix_coords; ++i) {
coords[i] = (long)SvIV(ST(1+i));
}
RETVAL = i_ft2_set_mm_coords(handle, ix_coords, coords);
myfree(coords);
OUTPUT:
RETVAL
#endif
MODULE = Imager PACKAGE = Imager::FillHandle PREFIX=IFILL_
void
IFILL_DESTROY(fill)
Imager::FillHandle fill
MODULE = Imager PACKAGE = Imager
Imager::FillHandle
i_new_fill_solid(cl, combine)
Imager::Color cl
int combine
Imager::FillHandle
i_new_fill_solidf(cl, combine)
Imager::Color::Float cl
int combine
Imager::FillHandle
i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch, dx, dy)
Imager::Color fg
Imager::Color bg
int combine
int hatch
int dx
int dy
PREINIT:
unsigned char *cust_hatch;
STRLEN len;
CODE:
if (SvOK(ST(4))) {
cust_hatch = (unsigned char *)SvPV(ST(4), len);
}
else
cust_hatch = NULL;
RETVAL = i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch, dx, dy);
OUTPUT:
RETVAL
Imager::FillHandle
i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch, dx, dy)
Imager::Color::Float fg
Imager::Color::Float bg
int combine
int hatch
int dx
int dy
PREINIT:
unsigned char *cust_hatch;
STRLEN len;
CODE:
if (SvOK(ST(4))) {
cust_hatch = (unsigned char *)SvPV(ST(4), len);
}
else
cust_hatch = NULL;
RETVAL = i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch, dx, dy);
OUTPUT:
RETVAL
Imager::FillHandle
i_new_fill_image(src, matrix, xoff, yoff, combine)
Imager::ImgRaw src
int xoff
int yoff
int combine
PREINIT:
double matrix[9];
double *matrixp;
AV *av;
IV len;
SV *sv1;
int i;
CODE:
if (!SvOK(ST(1))) {
matrixp = NULL;
}
else {
if (!SvROK(ST(1)) || SvTYPE(SvRV(ST(1))) != SVt_PVAV)
croak("i_new_fill_image: parameter must be an arrayref");
av=(AV*)SvRV(ST(1));
len=av_len(av)+1;
if (len > 9)
len = 9;
for (i = 0; i < len; ++i) {
sv1=(*(av_fetch(av,i,0)));
matrix[i] = SvNV(sv1);
}
for (; i < 9; ++i)
matrix[i] = 0;
matrixp = matrix;
}
RETVAL = i_new_fill_image(src, matrixp, xoff, yoff, combine);
OUTPUT:
RETVAL
MODULE = Imager PACKAGE = Imager::Internal::Hlines PREFIX=i_int_hlines_
# this class is only exposed for testing
int
i_int_hlines_testing()
#if i_int_hlines_testing()
Imager::Internal::Hlines
i_int_hlines_new(start_y, count_y, start_x, count_x)
int start_y
int count_y
int start_x
int count_x
Imager::Internal::Hlines
i_int_hlines_new_img(im)
Imager::ImgRaw im
void
i_int_hlines_add(hlines, y, minx, width)
Imager::Internal::Hlines hlines
int y
int minx
int width
void
i_int_hlines_DESTROY(hlines)
Imager::Internal::Hlines hlines
SV *
i_int_hlines_dump(hlines)
Imager::Internal::Hlines hlines
#endif
BOOT:
PERL_SET_GLOBAL_CALLBACKS;
|