/usr/lib/perl5/Imager/APIRef.pod is in libimager-perl 0.98+dfsg-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | Do not edit this file, it is generated automatically by apidocs.perl
from Imager's source files.
Each function description has a comment listing the source file where
you can find the documentation.
=head1 NAME
Imager::APIRef - Imager's C API - reference.
=head1 SYNOPSIS
i_color color;
color.rgba.r = 255; color.rgba.g = 0; color.rgba.b = 255;
# Blit tools
# Data Types
i_img *img;
i_color black;
black.rgba.r = black.rgba.g = black.rgba.b = black.rgba.a = 0;
i_fill_t *fill;
i_img_dim x, y;
printf("left %" i_DF "\n", i_DFc(x));
printf("point (" i_DFp ")\n", i_DFcp(x, y));
# Drawing
i_arc(im, 50, 50, 20, 45, 135, &color);
i_arc_cfill(im, 50, 50, 35, 90, 135, fill);
i_arc_aa(im, 50, 50, 35, 90, 135, &color);
i_arc_aa_cfill(im, 50, 50, 35, 90, 135, fill);
i_circle_aa(im, 50, 50, 45, &color);
i_box(im, 0, 0, im->xsize-1, im->ysize-1, &color).
i_box_filled(im, 0, 0, im->xsize-1, im->ysize-1, &color);
i_box_cfill(im, 0, 0, im->xsize-1, im->ysize-1, fill);
i_flood_fill(im, 50, 50, &color);
i_flood_cfill(im, 50, 50, fill);
i_flood_fill_border(im, 50, 50, &color, &border);
i_flood_cfill_border(im, 50, 50, fill, border);
# Error handling
im_clear_error(aIMCTX);
i_clear_error();
i_push_error(0, "Yep, it's broken");
i_push_error(errno, "Error writing");
im_push_error(aIMCTX, 0, "Something is wrong");
va_args args;
va_start(args, lastarg);
im_push_errorvf(ctx, code, format, args);
i_push_errorf(errno, "Cannot open file %s: %d", filename, errno);
im_push_errorf(aIMCTX, errno, "Cannot open file %s: %d", filename, errno);
# Files
im_set_image_file_limits(aIMCTX, 500, 500, 1000000);
i_set_image_file_limits(500, 500, 1000000);
im_get_image_file_limits(aIMCTX, &width, &height, &bytes)
i_get_image_file_limits(&width, &height, &bytes)
im_int_check_image_file_limits(aIMCTX, width, height, channels, sizeof(i_sample_t))
i_int_check_image_file_limits(width, height, channels, sizeof(i_sample_t))
# Fills
i_fill_t *fill = i_new_fill_solidf(&fcolor, combine);
i_fill_t *fill = i_new_fill_solid(&color, combine);
i_fill_t *fill = i_new_fill_hatch(&fg_color, &bg_color, combine, hatch, custom_hatch, dx, dy);
i_fill_t *fill = i_new_fill_hatchf(&fg_fcolor, &bg_fcolor, combine, hatch, custom_hatch, dx, dy);
i_fill_t *fill = i_new_fill_image(src_img, matrix, x_offset, y_offset, combine);
fill = i_new_fill_fount(0, 0, 100, 100, i_ft_linear, i_ft_linear,
i_fr_triangle, 0, i_fts_grid, 9, 1, segs);
i_fill_destroy(fill);
# I/O Layers
ssize_t count = i_io_peekn(ig, buffer, sizeof(buffer));
ssize_t result = i_io_write(io, buffer, size)
char buffer[BUFSIZ]
ssize_t len = i_io_gets(buffer, sizeof(buffer), '\n');
io_glue_destroy(ig);
# Image
# Image creation/destruction
i_img *img = i_sametype(src, width, height);
i_img *img = i_sametype_chans(src, width, height, channels);
i_img *img = im_img_16_new(aIMCTX, width, height, channels);
i_img *img = i_img_16_new(width, height, channels);
i_img *img = im_img_8_new(aIMCTX, width, height, channels);
i_img *img = i_img_8_new(width, height, channels);
i_img *img = im_img_double_new(aIMCTX, width, height, channels);
i_img *img = i_img_double_new(width, height, channels);
i_img *img = im_img_pal_new(aIMCTX, width, height, channels, max_palette_size)
i_img *img = i_img_pal_new(width, height, channels, max_palette_size)
i_img_destroy(img)
# Image Implementation
i_img *im = im_img_alloc(aIMCTX);
i_img *im = i_img_alloc();
im_img_init(aIMCTX, im);
i_img_init(im);
# Image Information
// only channel 0 writable
i_img_setmask(img, 0x01);
int mask = i_img_getmask(img);
int channels = i_img_getchannels(img);
i_img_dim width = i_img_get_width(im);
i_img_dim height = i_img_get_height(im);
# Image quantization
# Logging
# Mutex functions
i_mutex_t m = i_mutex_new();
i_mutex_destroy(m);
i_mutex_lock(m);
i_mutex_unlock(m);
# Paletted images
# Tags
i_tags_set(&img->tags, "i_comment", -1);
i_tags_setn(&img->tags, "i_xres", 204);
i_tags_setn(&img->tags, "i_yres", 196);
=head1 DESCRIPTION
=head2 Blit tools
=over
=item i_render_color(r, x, y, width, source, color)
Render the given color with the coverage specified by C<source[0]> to
C<source[width-1]>.
Renders in normal combine mode.
=for comment
From: File render.im
=item i_render_delete(r)
Release an C<i_render> object.
=for comment
From: File render.im
=item i_render_fill(r, x, y, width, source, fill)
Render the given fill with the coverage in C<source[0]> through
C<source[width-1]>.
=for comment
From: File render.im
=item i_render_line(r, x, y, width, source, fill)
Render the given fill with the coverage in C<source[0]> through
C<source[width-1]>.
=for comment
From: File render.im
=item i_render_linef(r, x, y, width, source, fill)
Render the given fill with the coverage in C<source[0]> through
C<source[width-1]>.
=for comment
From: File render.im
=item i_render_new(im, width)
Allocate a new C<i_render> object and initialize it.
=for comment
From: File render.im
=back
=head2 Data Types
=over
=item i_img
i_img *img;
This is Imager's image type.
It contains the following members:
=over
=item *
C<channels> - the number of channels in the image
=item *
C<xsize>, C<ysize> - the width and height of the image in pixels
=item *
C<bytes> - the number of bytes used to store the image data. Undefined
where virtual is non-zero.
=item *
C<ch_mask> - a mask of writable channels. eg. if this is 6 then only
channels 1 and 2 are writable. There may be bits set for which there
are no channels in the image.
=item *
C<bits> - the number of bits stored per sample. Should be one of
i_8_bits, i_16_bits, i_double_bits.
=item *
C<type> - either i_direct_type for direct color images, or i_palette_type
for paletted images.
=item *
C<virtual> - if zero then this image is-self contained. If non-zero
then this image could be an interface to some other implementation.
=item *
C<idata> - the image data. This should not be directly accessed. A new
image implementation can use this to store its image data.
i_img_destroy() will myfree() this pointer if it's non-null.
=item *
C<tags> - a structure storing the image's tags. This should only be
accessed via the i_tags_*() functions.
=item *
C<ext_data> - a pointer for use internal to an image implementation.
This should be freed by the image's destroy handler.
=item *
C<im_data> - data internal to Imager. This is initialized by
i_img_init().
=item *
i_f_ppix, i_f_ppixf, i_f_plin, i_f_plinf, i_f_gpix, i_f_gpixf,
i_f_glin, i_f_glinf, i_f_gsamp, i_f_gampf - implementations for each
of the required image functions. An image implementation should
initialize these between calling i_img_alloc() and i_img_init().
=item *
i_f_gpal, i_f_ppal, i_f_addcolors, i_f_getcolors, i_f_colorcount,
i_f_maxcolors, i_f_findcolor, i_f_setcolors - implementations for each
paletted image function.
=item *
i_f_destroy - custom image destruction function. This should be used
to release memory if necessary.
=item *
i_f_gsamp_bits - implements i_gsamp_bits() for this image.
=item *
i_f_psamp_bits - implements i_psamp_bits() for this image.
=item *
i_f_psamp - implements psamp() for this image.
=item *
i_f_psampf - implements psamp() for this image.
=item *
C<im_data> - image specific data internal to Imager.
=item *
C<context> - the Imager API context this image belongs to.
=back
=for comment
From: File imdatatypes.h
=item i_color
i_color black;
black.rgba.r = black.rgba.g = black.rgba.b = black.rgba.a = 0;
Type for 8-bit/sample color.
Samples as per;
i_color c;
i_color is a union of:
=over
=item *
gray - contains a single element gray_color, eg. C<c.gray.gray_color>
=item *
C<rgb> - contains three elements C<r>, C<g>, C<b>, eg. C<c.rgb.r>
=item *
C<rgba> - contains four elements C<r>, C<g>, C<b>, C<a>, eg. C<c.rgba.a>
=item *
C<cmyk> - contains four elements C<c>, C<m>, C<y>, C<k>,
eg. C<c.cmyk.y>. Note that Imager never uses CMYK colors except when
reading/writing files.
=item *
channels - an array of four channels, eg C<c.channels[2]>.
=back
=for comment
From: File imdatatypes.h
=item i_fcolor
This is the double/sample color type.
Its layout exactly corresponds to i_color.
=for comment
From: File imdatatypes.h
=item i_fill_t
i_fill_t *fill;
This is the "abstract" base type for Imager's fill types.
Unless you're implementing a new fill type you'll typically treat this
as an opaque type.
=for comment
From: File imdatatypes.h
=item i_img_dim
i_img_dim x, y;
A signed integer type that represents an image dimension or ordinate.
May be larger than int on some platforms.
=for comment
From: File imdatatypes.h
=item i_DF
printf("left %" i_DF "\n", i_DFc(x));
This is a constant string that can be used with functions like
printf() to format i_img_dim values after they're been cast with i_DFc().
Does not include the leading C<%>.
=for comment
From: File imdatatypes.h
=item i_DFc
Cast an C<i_img_dim> value to a type for use with the i_DF format
string.
=for comment
From: File imdatatypes.h
=item i_DFcp
Casts two C<i_img_dim> values for use with the i_DF (or i_DFp) format.
=for comment
From: File imdatatypes.h
=item i_DFp
printf("point (" i_DFp ")\n", i_DFcp(x, y));
Format a pair of C<i_img_dim> values. This format string I<does>
include the leading C<%>.
=for comment
From: File imdatatypes.h
=back
=head2 Drawing
=over
=item i_arc(im, x, y, rad, d1, d2, color)
i_arc(im, 50, 50, 20, 45, 135, &color);
Fills an arc centered at (x,y) with radius I<rad> covering the range
of angles in degrees from d1 to d2, with the color.
=for comment
From: File draw.c
=item i_arc_aa(im, x, y, rad, d1, d2, color)
i_arc_aa(im, 50, 50, 35, 90, 135, &color);
Anti-alias fills an arc centered at (x,y) with radius I<rad> covering
the range of angles in degrees from d1 to d2, with the color.
=for comment
From: File draw.c
=item i_arc_aa_cfill(im, x, y, rad, d1, d2, fill)
i_arc_aa_cfill(im, 50, 50, 35, 90, 135, fill);
Anti-alias fills an arc centered at (x,y) with radius I<rad> covering
the range of angles in degrees from d1 to d2, with the fill object.
=for comment
From: File draw.c
=item i_arc_cfill(im, x, y, rad, d1, d2, fill)
i_arc_cfill(im, 50, 50, 35, 90, 135, fill);
Fills an arc centered at (x,y) with radius I<rad> covering the range
of angles in degrees from d1 to d2, with the fill object.
=for comment
From: File draw.c
=item i_box(im, x1, y1, x2, y2, color)
i_box(im, 0, 0, im->xsize-1, im->ysize-1, &color).
Outlines the box from (x1,y1) to (x2,y2) inclusive with I<color>.
=for comment
From: File draw.c
=item i_box_cfill(im, x1, y1, x2, y2, fill)
i_box_cfill(im, 0, 0, im->xsize-1, im->ysize-1, fill);
Fills the box from (x1,y1) to (x2,y2) inclusive with fill.
=for comment
From: File draw.c
=item i_box_filled(im, x1, y1, x2, y2, color)
i_box_filled(im, 0, 0, im->xsize-1, im->ysize-1, &color);
Fills the box from (x1,y1) to (x2,y2) inclusive with color.
=for comment
From: File draw.c
=item i_circle_aa(im, x, y, rad, color)
i_circle_aa(im, 50, 50, 45, &color);
Anti-alias fills a circle centered at (x,y) for radius I<rad> with
color.
=for comment
From: File draw.c
=item i_flood_cfill(C<im>, C<seedx>, C<seedy>, C<fill>)
i_flood_cfill(im, 50, 50, fill);
Flood fills the 4-connected region starting from the point (C<seedx>,
C<seedy>) with C<fill>.
Returns false if (C<seedx>, C<seedy>) are outside the image.
=for comment
From: File draw.c
=item i_flood_cfill_border(C<im>, C<seedx>, C<seedy>, C<fill>, C<border>)
i_flood_cfill_border(im, 50, 50, fill, border);
Flood fills the 4-connected region starting from the point (C<seedx>,
C<seedy>) with C<fill>, the fill stops when it reaches pixels of color
C<border>.
Returns false if (C<seedx>, C<seedy>) are outside the image.
=for comment
From: File draw.c
=item i_flood_fill(C<im>, C<seedx>, C<seedy>, C<color>)
i_flood_fill(im, 50, 50, &color);
Flood fills the 4-connected region starting from the point (C<seedx>,
C<seedy>) with I<color>.
Returns false if (C<seedx>, C<seedy>) are outside the image.
=for comment
From: File draw.c
=item i_flood_fill_border(C<im>, C<seedx>, C<seedy>, C<color>, C<border>)
i_flood_fill_border(im, 50, 50, &color, &border);
Flood fills the 4-connected region starting from the point (C<seedx>,
C<seedy>) with C<color>, fill stops when the fill reaches a pixels
with color C<border>.
Returns false if (C<seedx>, C<seedy>) are outside the image.
=for comment
From: File draw.c
=item i_glin(im, l, r, y, colors)
Retrieves (r-l) pixels starting from (l,y) into I<colors>.
Returns the number of pixels retrieved.
=for comment
From: File imext.c
=item i_glinf(im, l, r, y, colors)
Retrieves (r-l) pixels starting from (l,y) into I<colors> as floating
point colors.
Returns the number of pixels retrieved.
=for comment
From: File imext.c
=item i_gpal(im, left, right, y, indexes)
Reads palette indexes for the horizontal line (left, y) to (right-1,
y) into C<indexes>.
Returns the number of indexes read.
Always returns 0 for direct color images.
=for comment
From: File imext.c
=item i_gpix(im, C<x>, C<y>, C<color>)
Retrieves the C<color> of the pixel (x,y).
Returns 0 if the pixel was retrieved, or -1 if not.
=for comment
From: File imext.c
=item i_gpixf(im, C<x>, C<y>, C<fcolor>)
Retrieves the color of the pixel (x,y) as a floating point color into
C<fcolor>.
Returns 0 if the pixel was retrieved, or -1 if not.
=for comment
From: File imext.c
=item i_gsamp(im, left, right, y, samples, channels, channel_count)
Reads sample values from C<im> for the horizontal line (left, y) to
(right-1,y) for the channels specified by C<channels>, an array of int
with C<channel_count> elements.
If channels is NULL then the first channels_count channels are retrieved for
each pixel.
Returns the number of samples read (which should be (right-left) *
channel_count)
=for comment
From: File imext.c
=item i_gsamp_bg(im, l, r, y, samples, out_channels, background)
Like C<i_gsampf()> but applies the source image color over a supplied
background color.
This is intended for output to image formats that don't support alpha
channels.
=for comment
From: File paste.im
=item i_gsamp_bits(im, left, right, y, samples, channels, channel_count, bits)
Reads integer samples scaled to C<bits> bits of precision into the
C<unsigned int> array C<samples>.
Expect this to be slow unless C<< bits == im->bits >>.
Returns the number of samples copied, or -1 on error.
Not all image types implement this method.
Pushes errors, but does not call C<i_clear_error()>.
=for comment
From: File imext.c
=item i_gsampf(im, left, right, y, samples, channels, channel_count)
Reads floating point sample values from C<im> for the horizontal line
(left, y) to (right-1,y) for the channels specified by C<channels>, an
array of int with channel_count elements.
If C<channels> is NULL then the first C<channel_count> channels are
retrieved for each pixel.
Returns the number of samples read (which should be (C<right>-C<left>)
* C<channel_count>)
=for comment
From: File imext.c
=item i_gsampf_bg(im, l, r, y, samples, out_channels, background)
Like C<i_gsampf()> but applies the source image color over a supplied
background color.
This is intended for output to image formats that don't support alpha
channels.
=for comment
From: File paste.im
=item i_line(C<im>, C<x1>, C<y1>, C<x2>, C<y2>, C<color>, C<endp>)
=for stopwords Bresenham's
Draw a line to image using Bresenham's line drawing algorithm
im - image to draw to
x1 - starting x coordinate
y1 - starting x coordinate
x2 - starting x coordinate
y2 - starting x coordinate
color - color to write to image
endp - endpoint flag (boolean)
=for comment
From: File draw.c
=item i_line_aa(C<im>, C<x1>, C<x2>, C<y1>, C<y2>, C<color>, C<endp>)
Anti-alias draws a line from (x1,y1) to (x2, y2) in color.
The point (x2, y2) is drawn only if C<endp> is set.
=for comment
From: File draw.c
=item i_plin(im, l, r, y, colors)
Sets (r-l) pixels starting from (l,y) using (r-l) values from
I<colors>.
Returns the number of pixels set.
=for comment
From: File imext.c
=item i_plinf(im, C<left>, C<right>, C<fcolors>)
Sets (right-left) pixels starting from (left,y) using (right-left)
floating point colors from C<fcolors>.
Returns the number of pixels set.
=for comment
From: File imext.c
=item i_ppal(im, left, right, y, indexes)
Writes palette indexes for the horizontal line (left, y) to (right-1,
y) from C<indexes>.
Returns the number of indexes written.
Always returns 0 for direct color images.
=for comment
From: File imext.c
=item i_ppix(im, x, y, color)
Sets the pixel at (x,y) to I<color>.
Returns 0 if the pixel was drawn, or -1 if not.
Does no alpha blending, just copies the channels from the supplied
color to the image.
=for comment
From: File imext.c
=item i_ppixf(im, C<x>, C<y>, C<fcolor>)
Sets the pixel at (C<x>,C<y>) to the floating point color C<fcolor>.
Returns 0 if the pixel was drawn, or -1 if not.
Does no alpha blending, just copies the channels from the supplied
color to the image.
=for comment
From: File imext.c
=item i_psamp(im, left, right, y, samples, channels, channel_count)
Writes sample values from C<samples> to C<im> for the horizontal line
(left, y) to (right-1, y) inclusive for the channels specified by
C<channels>, an array of C<int> with C<channel_count> elements.
If C<channels> is C<NULL> then the first C<channels_count> channels
are written to for each pixel.
Returns the number of samples written, which should be (right - left)
* channel_count. If a channel not in the image is in channels, left
is negative, left is outside the image or y is outside the image,
returns -1 and pushes an error.
=for comment
From: File immacros.h
=item i_psamp_bits(im, left, right, y, samples, channels, channel_count, bits)
Writes integer samples scaled to C<bits> bits of precision from the
C<unsigned int> array C<samples>.
Expect this to be slow unless C<< bits == im->bits >>.
Returns the number of samples copied, or -1 on error.
Not all image types implement this method.
Pushes errors, but does not call C<i_clear_error()>.
=for comment
From: File imext.c
=item i_psampf(im, left, right, y, samples, channels, channel_count)
Writes floating point sample values from C<samples> to C<im> for the
horizontal line (left, y) to (right-1, y) inclusive for the channels
specified by C<channels>, an array of C<int> with C<channel_count>
elements.
If C<channels> is C<NULL> then the first C<channels_count> channels
are written to for each pixel.
Returns the number of samples written, which should be (right - left)
* channel_count. If a channel not in the image is in channels, left
is negative, left is outside the image or y is outside the image,
returns -1 and pushes an error.
=for comment
From: File immacros.h
=back
=head2 Error handling
=over
=item i_push_errorf(int code, char const *fmt, ...)
i_push_errorf(errno, "Cannot open file %s: %d", filename, errno);
A version of i_push_error() that does printf() like formatting.
Does not support perl specific format codes.
=for comment
From: File error.c
=item im_clear_error(ctx)
X<im_clear_error API>X<i_clear_error API>
im_clear_error(aIMCTX);
i_clear_error();
Clears the error stack.
Called by any Imager function before doing any other processing.
Also callable as C<i_clear_error()>.
=for comment
From: File error.c
=item im_push_error(ctx, code, message)
X<im_push_error API>X<i_push_error API>
i_push_error(0, "Yep, it's broken");
i_push_error(errno, "Error writing");
im_push_error(aIMCTX, 0, "Something is wrong");
Called by an Imager function to push an error message onto the stack.
No message is pushed if the stack is full (since this means someone
forgot to call i_clear_error(), or that a function that doesn't do
error handling is calling function that does.).
=for comment
From: File error.c
=item im_push_errorf(ctx, code, char const *fmt, ...)
im_push_errorf(aIMCTX, errno, "Cannot open file %s: %d", filename, errno);
A version of im_push_error() that does printf() like formatting.
Does not support perl specific format codes.
=for comment
From: File error.c
=item im_push_errorvf(ctx, code, format, args)
X<im_push_error_vf API>X<i_push_errorvf API>
va_args args;
va_start(args, lastarg);
im_push_errorvf(ctx, code, format, args);
Intended for use by higher level functions, takes a varargs pointer
and a format to produce the finally pushed error message.
Does not support perl specific format codes.
Also callable as C<i_push_errorvf(code, format, args)>
=for comment
From: File error.c
=back
=head2 Files
=over
=item i_get_file_background(im, &bg)
Retrieve the file write background color tag from the image.
If not present, C<bg> is set to black.
Returns 1 if the C<i_background> tag was found and valid.
=for comment
From: File image.c
=item i_get_file_backgroundf(im, &bg)
Retrieve the file write background color tag from the image as a
floating point color.
Implemented in terms of i_get_file_background().
If not present, C<bg> is set to black.
Returns 1 if the C<i_background> tag was found and valid.
=for comment
From: File image.c
=item im_get_image_file_limits(ctx, &width, &height, &bytes)
X<im_get_image_file_limits API>X<i_get_image_file_limits>
im_get_image_file_limits(aIMCTX, &width, &height, &bytes)
i_get_image_file_limits(&width, &height, &bytes)
Retrieves the file limits set by i_set_image_file_limits().
=over
=item *
i_img_dim *width, *height - the maximum width and height of the image.
=item *
size_t *bytes - size in memory of the image in bytes.
=back
Also callable as C<i_get_image_file_limits(&width, &height, &bytes)>.
=for comment
From: File limits.c
=item im_int_check_image_file_limits(width, height, channels, sample_size)
X<im_int_check_image_file_limits API>X<i_int_check_image_file_limits>
im_int_check_image_file_limits(aIMCTX, width, height, channels, sizeof(i_sample_t))
i_int_check_image_file_limits(width, height, channels, sizeof(i_sample_t))
Checks the size of a file in memory against the configured image file
limits.
This also range checks the values to those permitted by Imager and
checks for overflows in calculating the size.
Returns non-zero if the file is within limits.
This function is intended to be called by image file read functions.
Also callable as C<i_int_check_image_file_limits(width, height, channels, sizeof(i_sample_t)>.
=for comment
From: File limits.c
=item im_set_image_file_limits(ctx, width, height, bytes)
X<im_set_image_file_limits API>X<i_set_image_file_limits API>
im_set_image_file_limits(aIMCTX, 500, 500, 1000000);
i_set_image_file_limits(500, 500, 1000000);
Set limits on the sizes of images read by Imager.
Setting a limit to 0 means that limit is ignored.
Negative limits result in failure.
Parameters:
=over
=item *
i_img_dim width, height - maximum width and height.
=item *
size_t bytes - maximum size in memory in bytes. A value of zero sets
this limit to one gigabyte.
=back
Returns non-zero on success.
Also callable as C<i_set_image_file_limits(width, height, bytes)>.
=for comment
From: File limits.c
=back
=head2 Fills
=over
=item i_new_fill_fount(C<xa>, C<ya>, C<xb>, C<yb>, C<type>, C<repeat>, C<combine>, C<super_sample>, C<ssample_param>, C<count>, C<segs>)
fill = i_new_fill_fount(0, 0, 100, 100, i_ft_linear, i_ft_linear,
i_fr_triangle, 0, i_fts_grid, 9, 1, segs);
Creates a new general fill which fills with a fountain fill.
=for comment
From: File filters.im
=item i_new_fill_hatch(C<fg>, C<bg>, C<combine>, C<hatch>, C<cust_hatch>, C<dx>, C<dy>)
i_fill_t *fill = i_new_fill_hatch(&fg_color, &bg_color, combine, hatch, custom_hatch, dx, dy);
Creates a new hatched fill with the C<fg> color used for the 1 bits in
the hatch and C<bg> for the 0 bits. If C<combine> is non-zero alpha
values will be combined.
If C<cust_hatch> is non-NULL it should be a pointer to 8 bytes of the
hash definition, with the high-bits to the left.
If C<cust_hatch> is NULL then one of the standard hatches is used.
(C<dx>, C<dy>) are an offset into the hatch which can be used to hatch
adjoining areas out of alignment, or to align the origin of a hatch
with the side of a filled area.
=for comment
From: File fills.c
=item i_new_fill_hatchf(C<fg>, C<bg>, C<combine>, C<hatch>, C<cust_hatch>, C<dx>, C<dy>)
i_fill_t *fill = i_new_fill_hatchf(&fg_fcolor, &bg_fcolor, combine, hatch, custom_hatch, dx, dy);
Creates a new hatched fill with the C<fg> color used for the 1 bits in
the hatch and C<bg> for the 0 bits. If C<combine> is non-zero alpha
values will be combined.
If C<cust_hatch> is non-NULL it should be a pointer to 8 bytes of the
hash definition, with the high-bits to the left.
If C<cust_hatch> is NULL then one of the standard hatches is used.
(C<dx>, C<dy>) are an offset into the hatch which can be used to hatch
adjoining areas out of alignment, or to align the origin of a hatch
with the side of a filled area.
=for comment
From: File fills.c
=item i_new_fill_image(C<im>, C<matrix>, C<xoff>, C<yoff>, C<combine>)
i_fill_t *fill = i_new_fill_image(src_img, matrix, x_offset, y_offset, combine);
Create an image based fill.
matrix is an array of 9 doubles representing a transformation matrix.
C<xoff> and C<yoff> are the offset into the image to start filling from.
=for comment
From: File fills.c
=item i_new_fill_solid(color, combine)
i_fill_t *fill = i_new_fill_solid(&color, combine);
Create a solid fill based on an 8-bit color.
If combine is non-zero then alpha values will be combined.
=for comment
From: File fills.c
=item i_new_fill_solidf(color, combine)
i_fill_t *fill = i_new_fill_solidf(&fcolor, combine);
Create a solid fill based on a float color.
If combine is non-zero then alpha values will be combined.
=for comment
From: File fills.c
=item i_fill_destroy(fill)
i_fill_destroy(fill);
Call to destroy any fill object.
=for comment
From: File fills.c
=back
=head2 I/O Layers
=over
=item im_io_new_bufchain(ctx)
X<im_io_new_bufchain API>X<i_io_new_bufchain API>
Returns a new io_glue object that has the 'empty' source and but can
be written to and read from later (like a pseudo file).
Also callable as C<io_new_bufchain()>.
=for comment
From: File iolayer.c
=item im_io_new_buffer(ctx, data, length)
X<im_io_new_buffer API>X<io_new_buffer API>
Returns a new io_glue object that has the source defined as reading
from specified buffer. Note that the buffer is not copied.
ctx - an Imager context object
data - buffer to read from
length - length of buffer
Also callable as C<io_new_buffer(data, length>.
=for comment
From: File iolayer.c
=item im_io_new_cb(ctx, p, read_cb, write_cb, seek_cb, close_cb, destroy_cb)
X<im_io_new_cb API>X<io_new_cb API>
Create a new I/O layer object that calls your supplied callbacks.
In general the callbacks should behave like the corresponding POSIX
primitives.
=over
=item *
C<read_cb>(p, buffer, length) should read up to C<length> bytes into
C<buffer> and return the number of bytes read. At end of file, return
0. On error, return -1.
=item *
C<write_cb>(p, buffer, length) should write up to C<length> bytes from
C<buffer> and return the number of bytes written. A return value <= 0
will be treated as an error.
=item *
C<seekcb>(p, offset, whence) should seek and return the new offset.
=item *
C<close_cb>(p) should return 0 on success, -1 on failure.
=item *
C<destroy_cb>(p) should release any memory specific to your callback
handlers.
=back
Also callable as C<io_new_cb(p, readcb, writecb, seekcb, closecb,
destroycb)>.
=for comment
From: File iolayer.c
=item im_io_new_fd(ctx, file)
X<io_new_fd API>X<im_io_new_fd API>
Returns a new io_glue object that has the source defined as reading
from specified file descriptor. Note that the interface to receiving
data from the io_glue callbacks hasn't been done yet.
ctx - and Imager context object
file - file descriptor to read/write from
Also callable as C<io_new_fd(file)>.
=for comment
From: File iolayer.c
=item i_io_close(io)
Flush any pending output and perform the close action for the stream.
Returns 0 on success.
=for comment
From: File iolayer.c
=item i_io_flush(io)
Flush any buffered output.
Returns true on success,
=for comment
From: File iolayer.c
=item i_io_getc(ig)
A macro to read a single byte from a buffered I/O glue object.
Returns EOF on failure, or a byte.
=for comment
From: File iolayer.c
=item i_io_gets(ig, buffer, size, end_of_line)
char buffer[BUFSIZ]
ssize_t len = i_io_gets(buffer, sizeof(buffer), '\n');
Read up to C<size>-1 bytes from the stream C<ig> into C<buffer>.
If the byte C<end_of_line> is seen then no further bytes will be read.
Returns the number of bytes read.
Always C<NUL> terminates the buffer.
=for comment
From: File iolayer.c
=item i_io_peekc(ig)
Read the next character from the stream without advancing the stream.
On error or end of file, return EOF.
For unbuffered streams a single character buffer will be setup.
=for comment
From: File iolayer.c
=item i_io_peekn(ig, buffer, size)
ssize_t count = i_io_peekn(ig, buffer, sizeof(buffer));
Buffer at least C<size> (at most C<< ig->buf_size >> bytes of data
from the stream and return C<size> bytes of it to the caller in
C<buffer>.
This ignores the buffered state of the stream, and will always setup
buffering if needed.
If no C<type> parameter is provided to Imager::read() or
Imager::read_multi(), Imager will call C<i_io_peekn()> when probing
for the file format.
Returns -1 on error, 0 if there is no data before EOF, or the number
of bytes read into C<buffer>.
=for comment
From: File iolayer.c
=item i_io_putc(ig, c)
Write a single character to the stream.
On success return c, on error returns EOF
=for comment
From: File iolayer.c
=item i_io_read(io, buffer, size)
Read up to C<size> bytes from the stream C<io> into C<buffer>.
Returns the number of bytes read. Returns 0 on end of file. Returns
-1 on error.
=for comment
From: File iolayer.c
=item i_io_seek(io, offset, whence)
Seek within the stream.
Acts like perl's seek.
=for comment
From: File iolayer.c
=item i_io_set_buffered(io, buffered)
Set the buffering mode of the stream.
If you switch buffering off on a stream with buffering on:
=over
=item *
any buffered output will be flushed.
=item *
any existing buffered input will be consumed before reads become
unbuffered.
=back
Returns true on success. This may fail if any buffered output cannot
be flushed.
=for comment
From: File iolayer.c
=item i_io_write(io, buffer, size)
ssize_t result = i_io_write(io, buffer, size)
Write to the given I/O stream.
Returns the number of bytes written.
=for comment
From: File iolayer.c
=item io_slurp(ig, c)
X<io_slurp API>
Takes the source that the io_glue is bound to and allocates space for
a return buffer and returns the entire content in a single buffer.
Note: This only works for io_glue objects created by
io_new_bufchain(). It is useful for saving to scalars and such.
ig - io_glue object
c - pointer to a pointer to where data should be copied to
char *data;
size_t size = io_slurp(ig, &data);
... do something with the data ...
myfree(data);
io_slurp() will abort the program if the supplied I/O layer is not
from io_new_bufchain().
=for comment
From: File iolayer.c
=item io_glue_destroy(ig)
X<io_glue_destroy API>
io_glue_destroy(ig);
Destroy an io_glue objects. Should clean up all related buffers.
ig - io_glue object to destroy.
=for comment
From: File iolayer.c
=back
=head2 Image
=over
=item i_copy(source)
Creates a new image that is a copy of the image C<source>.
Tags are not copied, only the image data.
Returns: i_img *
=for comment
From: File image.c
=item i_copyto(C<dest>, C<src>, C<x1>, C<y1>, C<x2>, C<y2>, C<tx>, C<ty>)
Copies image data from the area (C<x1>,C<y1>)-[C<x2>,C<y2>] in the
source image to a rectangle the same size with it's top-left corner at
(C<tx>,C<ty>) in the destination image.
If C<x1> > C<x2> or C<y1> > C<y2> then the corresponding co-ordinates
are swapped.
=for comment
From: File paste.im
=item i_copyto_trans(C<im>, C<src>, C<x1>, C<y1>, C<x2>, C<y2>, C<tx>, C<ty>, C<trans>)
(C<x1>,C<y1>) (C<x2>,C<y2>) specifies the region to copy (in the
source coordinates) (C<tx>,C<ty>) specifies the upper left corner for
the target image. pass NULL in C<trans> for non transparent i_colors.
=for comment
From: File image.c
=item i_img_info(im, info)
Return image information
im - Image pointer
info - pointer to array to return data
info is an array of 4 integers with the following values:
info[0] - width
info[1] - height
info[2] - channels
info[3] - channel mask
=for comment
From: File image.c
=item i_rubthru(C<im>, C<src>, C<tx>, C<ty>, C<src_minx>, C<src_miny>, C<src_maxx>, C<src_maxy>)
Takes the sub image C<src>[C<src_minx>, C<src_maxx>)[C<src_miny>, C<src_maxy>)> and
overlays it at (C<tx>,C<ty>) on the image object.
The alpha channel of each pixel in C<src> is used to control how much
the existing color in C<im> is replaced, if it is 255 then the color
is completely replaced, if it is 0 then the original color is left
unmodified.
=for comment
From: File rubthru.im
=back
=head2 Image creation/destruction
=over
=item i_sametype(C<im>, C<xsize>, C<ysize>)
i_img *img = i_sametype(src, width, height);
Returns an image of the same type (sample size, channels, paletted/direct).
For paletted images the palette is copied from the source.
=for comment
From: File image.c
=item i_sametype_chans(C<im>, C<xsize>, C<ysize>, C<channels>)
i_img *img = i_sametype_chans(src, width, height, channels);
Returns an image of the same type (sample size).
For paletted images the equivalent direct type is returned.
=for comment
From: File image.c
=item im_img_16_new(ctx, x, y, ch)
X<im_img_16_new API>X<i_img_16_new API>
i_img *img = im_img_16_new(aIMCTX, width, height, channels);
i_img *img = i_img_16_new(width, height, channels);
Create a new 16-bit/sample image.
Returns the image on success, or NULL on failure.
Also callable as C<i_img_16_new(x, y, ch)>
=for comment
From: File img16.c
=item im_img_8_new(ctx, x, y, ch)
X<im_img_8_new API>X<i_img_8_new API>
i_img *img = im_img_8_new(aIMCTX, width, height, channels);
i_img *img = i_img_8_new(width, height, channels);
Creates a new image object I<x> pixels wide, and I<y> pixels high with
I<ch> channels.
=for comment
From: File img8.c
=item im_img_double_new(ctx, x, y, ch)
X<im_img_double_new API>X<i_img_double_new API>
i_img *img = im_img_double_new(aIMCTX, width, height, channels);
i_img *img = i_img_double_new(width, height, channels);
Creates a new double per sample image.
Also callable as C<i_img_double_new(width, height, channels)>.
=for comment
From: File imgdouble.c
=item im_img_pal_new(ctx, C<x>, C<y>, C<channels>, C<maxpal>)
X<im_img_pal_new API>X<i_img_pal_new API>
i_img *img = im_img_pal_new(aIMCTX, width, height, channels, max_palette_size)
i_img *img = i_img_pal_new(width, height, channels, max_palette_size)
Creates a new paletted image of the supplied dimensions.
C<maxpal> is the maximum palette size and should normally be 256.
Returns a new image or NULL on failure.
Also callable as C<i_img_pal_new(width, height, channels, max_palette_size)>.
=for comment
From: File palimg.c
=item i_img_destroy(C<img>)
i_img_destroy(img)
Destroy an image object
=for comment
From: File image.c
=back
=head2 Image Implementation
=over
=item im_img_alloc(aIMCTX)
X<im_img_alloc API>X<i_img_alloc API>
i_img *im = im_img_alloc(aIMCTX);
i_img *im = i_img_alloc();
Allocates a new i_img structure.
When implementing a new image type perform the following steps in your
image object creation function:
=over
=item 1.
allocate the image with i_img_alloc().
=item 2.
initialize any function pointers or other data as needed, you can
overwrite the whole block if you need to.
=item 3.
initialize Imager's internal data by calling i_img_init() on the image
object.
=back
=for comment
From: File image.c
=item im_img_init(aIMCTX, image)
X<im_img_init API>X<i_img_init API>
im_img_init(aIMCTX, im);
i_img_init(im);
Imager internal initialization of images.
See L</im_img_alloc(aIMCTX)> for more information.
=for comment
From: File image.c
=back
=head2 Image Information
=over
=item i_img_color_channels(C<im>)
The number of channels holding color information.
=for comment
From: File immacros.h
=item i_img_get_height(C<im>)
i_img_dim height = i_img_get_height(im);
Returns the height in pixels of the image.
=for comment
From: File image.c
=item i_img_get_width(C<im>)
i_img_dim width = i_img_get_width(im);
Returns the width in pixels of the image.
=for comment
From: File image.c
=item i_img_getchannels(C<im>)
int channels = i_img_getchannels(img);
Get the number of channels in C<im>.
=for comment
From: File image.c
=item i_img_getmask(C<im>)
int mask = i_img_getmask(img);
Get the image channel mask for C<im>.
=for comment
From: File image.c
=item i_img_has_alpha(C<im>)
Return true if the image has an alpha channel.
=for comment
From: File immacros.h
=item i_img_is_monochrome(img, &zero_is_white)
Tests an image to check it meets our monochrome tests.
The idea is that a file writer can use this to test where it should
write the image in whatever bi-level format it uses, eg. C<pbm> for
C<pnm>.
For performance of encoders we require monochrome images:
=over
=item *
be paletted
=item *
have a palette of two colors, containing only C<(0,0,0)> and
C<(255,255,255)> in either order.
=back
C<zero_is_white> is set to non-zero if the first palette entry is white.
=for comment
From: File image.c
=item i_img_setmask(C<im>, C<ch_mask>)
// only channel 0 writable
i_img_setmask(img, 0x01);
Set the image channel mask for C<im> to C<ch_mask>.
The image channel mask gives some control over which channels can be
written to in the image.
=for comment
From: File image.c
=back
=head2 Image quantization
=over
=item i_quant_makemap(C<quant>, C<imgs>, C<count>)
Analyzes the C<count> images in C<imgs> according to the rules in
C<quant> to build a color map (optimal or not depending on
C<< quant->make_colors >>).
=for comment
From: File quant.c
=item i_quant_translate(C<quant>, C<img>)
Quantize the image given the palette in C<quant>.
On success returns a pointer to a memory block of C<< img->xsize *
img->ysize >> C<i_palidx> entries.
On failure returns NULL.
You should call myfree() on the returned block when you're done with
it.
This function will fail if the supplied palette contains no colors.
=for comment
From: File quant.c
=item i_quant_transparent(C<quant>, C<data>, C<img>, C<trans_index>)
Dither the alpha channel on C<img> into the palette indexes in
C<data>. Pixels to be transparent are replaced with C<trans_pixel>.
The method used depends on the tr_* members of C<quant>.
=for comment
From: File quant.c
=back
=head2 Logging
=over
=item i_lhead(file, line)
This is an internal function called by the mm_log() macro.
=for comment
From: File log.c
=item i_loog(level, format, ...)
This is an internal function called by the mm_log() macro.
=for comment
From: File log.c
=back
=head2 Mutex functions
=over
=item i_mutex_new()
i_mutex_t m = i_mutex_new();
Create a mutex.
If a critical section cannot be created for whatever reason, Imager
will abort.
=for comment
From: File mutexwin.c
=item i_mutex_destroy(m)
i_mutex_destroy(m);
Destroy a mutex.
=for comment
From: File mutexwin.c
=item i_mutex_lock(m)
i_mutex_lock(m);
Lock the mutex, waiting if another thread has the mutex locked.
=for comment
From: File mutexwin.c
=item i_mutex_unlock(m)
i_mutex_unlock(m);
Release the mutex.
The behavior of releasing a mutex you don't hold is unspecified.
=for comment
From: File mutexwin.c
=back
=head2 Paletted images
=over
=item i_addcolors(im, colors, count)
Adds colors to the image's palette.
On success returns the index of the lowest color added.
On failure returns -1.
Always fails for direct color images.
=for comment
From: File imext.c
=item i_colorcount(im)
Returns the number of colors in the image's palette.
Returns -1 for direct images.
=for comment
From: File imext.c
=item i_findcolor(im, color, &entry)
Searches the images palette for the given color.
On success sets *I<entry> to the index of the color, and returns true.
On failure returns false.
Always fails on direct color images.
=for comment
From: File imext.c
=item i_getcolors(im, index, colors, count)
Retrieves I<count> colors starting from I<index> in the image's
palette.
On success stores the colors into I<colors> and returns true.
On failure returns false.
Always fails for direct color images.
Fails if there are less than I<index>+I<count> colors in the image's
palette.
=for comment
From: File imext.c
=item i_maxcolors(im)
Returns the maximum number of colors the palette can hold for the
image.
Returns -1 for direct color images.
=for comment
From: File imext.c
=item i_setcolors(im, index, colors, count)
Sets I<count> colors starting from I<index> in the image's palette.
On success returns true.
On failure returns false.
The image must have at least I<index>+I<count> colors in it's palette
for this to succeed.
Always fails on direct color images.
=for comment
From: File imext.c
=back
=head2 Tags
=over
=item i_tags_delbycode(tags, code)
Delete any tags with the given code.
Returns the number of tags deleted.
=for comment
From: File tags.c
=item i_tags_delbyname(tags, name)
Delete any tags with the given name.
Returns the number of tags deleted.
=for comment
From: File tags.c
=item i_tags_delete(tags, index)
Delete a tag by index.
Returns true on success.
=for comment
From: File tags.c
=item i_tags_destroy(tags)
Destroys the given tags structure. Called by i_img_destroy().
=for comment
From: File tags.c
=item i_tags_find(tags, name, start, &entry)
Searches for a tag of the given I<name> starting from index I<start>.
On success returns true and sets *I<entry>.
On failure returns false.
=for comment
From: File tags.c
=item i_tags_findn(tags, code, start, &entry)
Searches for a tag of the given I<code> starting from index I<start>.
On success returns true and sets *I<entry>.
On failure returns false.
=for comment
From: File tags.c
=item i_tags_get_color(tags, name, code, &value)
Retrieve a tag specified by name or code as color.
On success sets the i_color *I<value> to the color and returns true.
On failure returns false.
=for comment
From: File tags.c
=item i_tags_get_float(tags, name, code, value)
Retrieves a tag as a floating point value.
If the tag has a string value then that is parsed as a floating point
number, otherwise the integer value of the tag is used.
On success sets *I<value> and returns true.
On failure returns false.
=for comment
From: File tags.c
=item i_tags_get_int(tags, name, code, &value)
Retrieve a tag specified by name or code as an integer.
On success sets the int *I<value> to the integer and returns true.
On failure returns false.
=for comment
From: File tags.c
=item i_tags_get_string(tags, name, code, value, value_size)
Retrieves a tag by name or code as a string.
On success copies the string to value for a max of value_size and
returns true.
On failure returns false.
value_size must be at least large enough for a string representation
of an integer.
The copied value is always C<NUL> terminated.
=for comment
From: File tags.c
=item i_tags_new(i_img_tags *tags)
Initialize a tags structure. Should not be used if the tags structure
has been previously used.
This should be called tags member of an i_img object on creation (in
i_img_*_new() functions).
To destroy the contents use i_tags_destroy()
=for comment
From: File tags.c
=item i_tags_set(tags, name, data, size)
i_tags_set(&img->tags, "i_comment", -1);
Sets the given tag to the string I<data>
If size is -1 then the strlen(I<data>) bytes are stored.
Even on failure, if an existing tag I<name> exists, it will be
removed.
=for comment
From: File tags.c
=item i_tags_set_color(tags, name, code, &value)
Stores the given color as a tag with the given name and code.
=for comment
From: File tags.c
=item i_tags_set_float(tags, name, code, value)
Equivalent to i_tags_set_float2(tags, name, code, value, 30).
=for comment
From: File tags.c
=item i_tags_set_float2(tags, name, code, value, places)
Sets the tag with the given name and code to the given floating point
value.
Since tags are strings or ints, we convert the value to a string before
storage at the precision specified by C<places>.
=for comment
From: File tags.c
=item i_tags_setn(C<tags>, C<name>, C<idata>)
i_tags_setn(&img->tags, "i_xres", 204);
i_tags_setn(&img->tags, "i_yres", 196);
Sets the given tag to the integer C<idata>
Even on failure, if an existing tag C<name> exists, it will be
removed.
=for comment
From: File tags.c
=back
=head2 Uncategorized functions
=over
=item i_utf8_advance(char **p, size_t *len)
Retrieve a C<UTF-8> character from the stream.
Modifies *p and *len to indicate the consumed characters.
This doesn't support the extended C<UTF-8> encoding used by later
versions of Perl. Since this is typically used to implement text
output by font drivers, the strings supplied shouldn't have such out
of range characters.
This doesn't check that the C<UTF-8> character is using the shortest
possible representation.
Returns ~0UL on failure.
=for comment
From: File io.c
=item im_context_refdec(ctx, where)
X<im_context_refdec API>
=section Context objects
im_context_refdec(aIMCTX, "a description");
Remove a reference to the context, releasing it if all references have
been removed.
=for comment
From: File context.c
=item im_context_refinc(ctx, where)
X<im_context_refinc API>
=section Context objects
im_context_refinc(aIMCTX, "a description");
Add a new reference to the context.
=for comment
From: File context.c
=item im_context_slot_get(ctx, slot)
Retrieve the value previously stored in the given slot of the context
object.
=for comment
From: File context.c
=item im_context_slot_new(destructor)
Allocate a new context-local-storage slot.
C<desctructor> will be called when the context is destroyed if the
corresponding slot is non-NULL.
=for comment
From: File context.c
=item im_context_slot_set(slot, value)
Set the value of a slot.
Returns true on success.
Aborts if the slot supplied is invalid.
If reallocation of slot storage fails, returns false.
=for comment
From: File context.c
=item im_errors(ctx)
i_errmsg *errors = im_errors(aIMCTX);
i_errmsg *errors = i_errors();
Returns a pointer to the first element of an array of error messages,
terminated by a NULL pointer. The highest level message is first.
Also callable as C<i_errors()>.
=for comment
From: File error.c
=item im_get_context()
Retrieve the context object for the current thread.
Inside Imager itself this is just a function pointer, which the
F<Imager.xs> BOOT handler initializes for use within perl. If you're
taking the Imager code and embedding it elsewhere you need to
initialize the C<im_get_context> pointer at some point.
=for comment
From: File imext.c
=back
=head1 UNDOCUMENTED
The following API functions are undocumented so far, hopefully this
will change:
=over
=item *
B<im_lhead>
=item *
B<im_loog>
=item *
B<mm_log>
=back
=head1 AUTHOR
Tony Cook <tonyc@cpan.org>
=head1 SEE ALSO
Imager, Imager::API, Imager::ExtUtils, Imager::Inline
=cut
|