/usr/include/ImageMagick/Magick++/STL.h is in libmagick++-dev 8:6.7.7.10-6ubuntu3.
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 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 | // This may look like C code, but it is really -*- C++ -*-
//
// Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003
//
// Definition and implementation of template functions for using
// Magick::Image with STL containers.
//
#ifndef Magick_STL_header
#define Magick_STL_header
#include "Magick++/Include.h"
#include <algorithm>
#include <functional>
#include <iterator>
#include <map>
#include <utility>
#include "Magick++/CoderInfo.h"
#include "Magick++/Drawable.h"
#include "Magick++/Exception.h"
#include "Magick++/Montage.h"
namespace Magick
{
//
// STL function object declarations/definitions
//
// Function objects provide the means to invoke an operation on one
// or more image objects in an STL-compatable container. The
// arguments to the function object constructor(s) are compatable
// with the arguments to the equivalent Image class method and
// provide the means to supply these options when the function
// object is invoked.
// For example, to read a GIF animation, set the color red to
// transparent for all frames, and write back out:
//
// list<image> images;
// readImages( &images, "animation.gif" );
// for_each( images.begin(), images.end(), transparentImage( "red" ) );
// writeImages( images.begin(), images.end(), "animation.gif" );
// Adaptive-blur image with specified blur factor
class MagickPPExport adaptiveBlurImage : public std::unary_function<Image&,void>
{
public:
adaptiveBlurImage( const double radius_ = 1, const double sigma_ = 0.5 );
void operator()( Image &image_ ) const;
private:
double _radius;
double _sigma;
};
// Local adaptive threshold image
// http://www.dai.ed.ac.uk/HIPR2/adpthrsh.htm
// Width x height define the size of the pixel neighborhood
// offset = constant to subtract from pixel neighborhood mean
class MagickPPExport adaptiveThresholdImage : public std::unary_function<Image&,void>
{
public:
adaptiveThresholdImage( const size_t width_,
const size_t height_,
const ::ssize_t offset_ = 0 );
void operator()( Image &image_ ) const;
private:
size_t _width;
size_t _height;
::ssize_t _offset;
};
// Add noise to image with specified noise type
class MagickPPExport addNoiseImage : public std::unary_function<Image&,void>
{
public:
addNoiseImage ( NoiseType noiseType_ );
void operator()( Image &image_ ) const;
private:
NoiseType _noiseType;
};
// Transform image by specified affine (or free transform) matrix.
class MagickPPExport affineTransformImage : public std::unary_function<Image&,void>
{
public:
affineTransformImage( const DrawableAffine &affine_ );
void operator()( Image &image_ ) const;
private:
DrawableAffine _affine;
};
// Annotate image (draw text on image)
class MagickPPExport annotateImage : public std::unary_function<Image&,void>
{
public:
// Annotate using specified text, and placement location
annotateImage ( const std::string &text_,
const Geometry &geometry_ );
// Annotate using specified text, bounding area, and placement
// gravity
annotateImage ( const std::string &text_,
const Geometry &geometry_,
const GravityType gravity_ );
// Annotate with text using specified text, bounding area,
// placement gravity, and rotation.
annotateImage ( const std::string &text_,
const Geometry &geometry_,
const GravityType gravity_,
const double degrees_ );
// Annotate with text (bounding area is entire image) and
// placement gravity.
annotateImage ( const std::string &text_,
const GravityType gravity_ );
void operator()( Image &image_ ) const;
private:
// Copy constructor and assignment are not supported
annotateImage(const annotateImage&);
annotateImage& operator=(const annotateImage&);
const std::string _text;
const Geometry _geometry;
const GravityType _gravity;
const double _degrees;
};
// Blur image with specified blur factor
class MagickPPExport blurImage : public std::unary_function<Image&,void>
{
public:
blurImage( const double radius_ = 1, const double sigma_ = 0.5 );
void operator()( Image &image_ ) const;
private:
double _radius;
double _sigma;
};
// Border image (add border to image)
class MagickPPExport borderImage : public std::unary_function<Image&,void>
{
public:
borderImage( const Geometry &geometry_ = borderGeometryDefault );
void operator()( Image &image_ ) const;
private:
Geometry _geometry;
};
// Extract channel from image
class MagickPPExport channelImage : public std::unary_function<Image&,void>
{
public:
channelImage( const ChannelType channel_ );
void operator()( Image &image_ ) const;
private:
ChannelType _channel;
};
// Charcoal effect image (looks like charcoal sketch)
class MagickPPExport charcoalImage : public std::unary_function<Image&,void>
{
public:
charcoalImage( const double radius_ = 1, const double sigma_ = 0.5 );
void operator()( Image &image_ ) const;
private:
double _radius;
double _sigma;
};
// Chop image (remove vertical or horizontal subregion of image)
class MagickPPExport chopImage : public std::unary_function<Image&,void>
{
public:
chopImage( const Geometry &geometry_ );
void operator()( Image &image_ ) const;
private:
Geometry _geometry;
};
// Accepts a lightweight Color Correction Collection (CCC) file which solely
// contains one or more color corrections and applies the correction to the
// image.
class MagickPPExport cdlImage : public std::unary_function<Image&,void>
{
public:
cdlImage( const std::string &cdl_ );
void operator()( Image &image_ ) const;
private:
std::string _cdl;
};
// Colorize image using pen color at specified percent opacity
class MagickPPExport colorizeImage : public std::unary_function<Image&,void>
{
public:
colorizeImage( const unsigned int opacityRed_,
const unsigned int opacityGreen_,
const unsigned int opacityBlue_,
const Color &penColor_ );
colorizeImage( const unsigned int opacity_,
const Color &penColor_ );
void operator()( Image &image_ ) const;
private:
unsigned int _opacityRed;
unsigned int _opacityGreen;
unsigned int _opacityBlue;
Color _penColor;
};
// Apply a color matrix to the image channels. The user supplied
// matrix may be of order 1 to 5 (1x1 through 5x5).
class MagickPPExport colorMatrixImage : public std::unary_function<Image&,void>
{
public:
colorMatrixImage( const size_t order_,
const double *color_matrix_ );
void operator()( Image &image_ ) const;
private:
size_t _order;
const double *_color_matrix;
};
// Convert the image colorspace representation
class MagickPPExport colorSpaceImage : public std::unary_function<Image&,void>
{
public:
colorSpaceImage( ColorspaceType colorSpace_ );
void operator()( Image &image_ ) const;
private:
ColorspaceType _colorSpace;
};
// Comment image (add comment string to image)
class MagickPPExport commentImage : public std::unary_function<Image&,void>
{
public:
commentImage( const std::string &comment_ );
void operator()( Image &image_ ) const;
private:
std::string _comment;
};
// Compose an image onto another at specified offset and using
// specified algorithm
class MagickPPExport compositeImage : public std::unary_function<Image&,void>
{
public:
compositeImage( const Image &compositeImage_,
::ssize_t xOffset_,
::ssize_t yOffset_,
CompositeOperator compose_ = InCompositeOp );
compositeImage( const Image &compositeImage_,
const Geometry &offset_,
CompositeOperator compose_ = InCompositeOp );
void operator()( Image &image_ ) const;
private:
Image _compositeImage;
::ssize_t _xOffset;
::ssize_t _yOffset;
CompositeOperator _compose;
};
// Contrast image (enhance intensity differences in image)
class MagickPPExport contrastImage : public std::unary_function<Image&,void>
{
public:
contrastImage( const size_t sharpen_ );
void operator()( Image &image_ ) const;
private:
size_t _sharpen;
};
// Crop image (subregion of original image)
class MagickPPExport cropImage : public std::unary_function<Image&,void>
{
public:
cropImage( const Geometry &geometry_ );
void operator()( Image &image_ ) const;
private:
Geometry _geometry;
};
// Cycle image colormap
class MagickPPExport cycleColormapImage : public std::unary_function<Image&,void>
{
public:
cycleColormapImage( const ::ssize_t amount_ );
void operator()( Image &image_ ) const;
private:
::ssize_t _amount;
};
// Despeckle image (reduce speckle noise)
class MagickPPExport despeckleImage : public std::unary_function<Image&,void>
{
public:
despeckleImage( void );
void operator()( Image &image_ ) const;
private:
};
// Distort image. distorts an image using various distortion methods, by
// mapping color lookups of the source image to a new destination image
// usally of the same size as the source image, unless 'bestfit' is set to
// true.
class MagickPPExport distortImage : public std::unary_function<Image&,void>
{
public:
distortImage( const Magick::DistortImageMethod method_,
const size_t number_arguments_,
const double *arguments_,
const bool bestfit_ );
distortImage( const Magick::DistortImageMethod method_,
const size_t number_arguments_,
const double *arguments_ );
void operator()( Image &image_ ) const;
private:
DistortImageMethod _method;
size_t _number_arguments;
const double *_arguments;
bool _bestfit;
};
// Draw on image
class MagickPPExport drawImage : public std::unary_function<Image&,void>
{
public:
// Draw on image using a single drawable
// Store in list to make implementation easier
drawImage( const Drawable &drawable_ );
// Draw on image using a drawable list
drawImage( const DrawableList &drawable_ );
void operator()( Image &image_ ) const;
private:
DrawableList _drawableList;
};
// Edge image (hilight edges in image)
class MagickPPExport edgeImage : public std::unary_function<Image&,void>
{
public:
edgeImage( const double radius_ = 0.0 );
void operator()( Image &image_ ) const;
private:
double _radius;
};
// Emboss image (hilight edges with 3D effect)
class MagickPPExport embossImage : public std::unary_function<Image&,void>
{
public:
embossImage( void );
embossImage( const double radius_, const double sigma_ );
void operator()( Image &image_ ) const;
private:
double _radius;
double _sigma;
};
// Enhance image (minimize noise)
class MagickPPExport enhanceImage : public std::unary_function<Image&,void>
{
public:
enhanceImage( void );
void operator()( Image &image_ ) const;
private:
};
// Equalize image (histogram equalization)
class MagickPPExport equalizeImage : public std::unary_function<Image&,void>
{
public:
equalizeImage( void );
void operator()( Image &image_ ) const;
private:
};
// Color to use when filling drawn objects
class MagickPPExport fillColorImage : public std::unary_function<Image&,void>
{
public:
fillColorImage( const Color &fillColor_ );
void operator()( Image &image_ ) const;
private:
Color _fillColor;
};
// Flip image (reflect each scanline in the vertical direction)
class MagickPPExport flipImage : public std::unary_function<Image&,void>
{
public:
flipImage( void );
void operator()( Image &image_ ) const;
private:
};
// Flood-fill image with color
class MagickPPExport floodFillColorImage : public std::unary_function<Image&,void>
{
public:
// Flood-fill color across pixels starting at target-pixel and
// stopping at pixels matching specified border color.
// Uses current fuzz setting when determining color match.
floodFillColorImage( const ::ssize_t x_,
const ::ssize_t y_,
const Color &fillColor_ );
floodFillColorImage( const Geometry &point_,
const Color &fillColor_ );
// Flood-fill color across pixels starting at target-pixel and
// stopping at pixels matching specified border color.
// Uses current fuzz setting when determining color match.
floodFillColorImage( const ::ssize_t x_,
const ::ssize_t y_,
const Color &fillColor_,
const Color &borderColor_ );
floodFillColorImage( const Geometry &point_,
const Color &fillColor_,
const Color &borderColor_ );
void operator()( Image &image_ ) const;
private:
::ssize_t _x;
::ssize_t _y;
Color _fillColor;
Color _borderColor;
};
// Flood-fill image with texture
class MagickPPExport floodFillTextureImage : public std::unary_function<Image&,void>
{
public:
// Flood-fill texture across pixels that match the color of the
// target pixel and are neighbors of the target pixel.
// Uses current fuzz setting when determining color match.
floodFillTextureImage( const ::ssize_t x_,
const ::ssize_t y_,
const Image &texture_ );
floodFillTextureImage( const Geometry &point_,
const Image &texture_ );
// Flood-fill texture across pixels starting at target-pixel and
// stopping at pixels matching specified border color.
// Uses current fuzz setting when determining color match.
floodFillTextureImage( const ::ssize_t x_,
const ::ssize_t y_,
const Image &texture_,
const Color &borderColor_ );
floodFillTextureImage( const Geometry &point_,
const Image &texture_,
const Color &borderColor_ );
void operator()( Image &image_ ) const;
private:
::ssize_t _x;
::ssize_t _y;
Image _texture;
Color _borderColor;
};
// Flop image (reflect each scanline in the horizontal direction)
class MagickPPExport flopImage : public std::unary_function<Image&,void>
{
public:
flopImage( void );
void operator()( Image &image_ ) const;
private:
};
// Frame image
class MagickPPExport frameImage : public std::unary_function<Image&,void>
{
public:
frameImage( const Geometry &geometry_ = frameGeometryDefault );
frameImage( const size_t width_, const size_t height_,
const ::ssize_t innerBevel_ = 6, const ::ssize_t outerBevel_ = 6 );
void operator()( Image &image_ ) const;
private:
size_t _width;
size_t _height;
::ssize_t _outerBevel;
::ssize_t _innerBevel;
};
// Gamma correct image
class MagickPPExport gammaImage : public std::unary_function<Image&,void>
{
public:
gammaImage( const double gamma_ );
gammaImage ( const double gammaRed_,
const double gammaGreen_,
const double gammaBlue_ );
void operator()( Image &image_ ) const;
private:
double _gammaRed;
double _gammaGreen;
double _gammaBlue;
};
// Gaussian blur image
// The number of neighbor pixels to be included in the convolution
// mask is specified by 'width_'. The standard deviation of the
// gaussian bell curve is specified by 'sigma_'.
class MagickPPExport gaussianBlurImage : public std::unary_function<Image&,void>
{
public:
gaussianBlurImage( const double width_, const double sigma_ );
void operator()( Image &image_ ) const;
private:
double _width;
double _sigma;
};
// Apply a color lookup table (Hald CLUT) to the image.
class MagickPPExport haldClutImage : public std::unary_function<Image&,void>
{
public:
haldClutImage( const Image &haldClutImage_ );
void operator()( Image &image_ ) const;
private:
Image _haldClutImage;
};
// Implode image (special effect)
class MagickPPExport implodeImage : public std::unary_function<Image&,void>
{
public:
implodeImage( const double factor_ = 50 );
void operator()( Image &image_ ) const;
private:
double _factor;
};
// implements the inverse discrete Fourier transform (IFT) of the image
// either as a magnitude / phase or real / imaginary image pair.
class MagickPPExport inverseFourierTransformImage : public std::unary_function<Image&,void>
{
public:
inverseFourierTransformImage( const Image &phaseImage_ );
void operator()( Image &image_ ) const;
private:
Image _phaseImage;
};
// Set image validity. Valid images become empty (inValid) if
// argument is false.
class MagickPPExport isValidImage : public std::unary_function<Image&,void>
{
public:
isValidImage( const bool isValid_ );
void operator()( Image &image_ ) const;
private:
bool _isValid;
};
// Label image
class MagickPPExport labelImage : public std::unary_function<Image&,void>
{
public:
labelImage( const std::string &label_ );
void operator()( Image &image_ ) const;
private:
std::string _label;
};
// Level image
class MagickPPExport levelImage : public std::unary_function<Image&,void>
{
public:
levelImage( const double black_point,
const double white_point,
const double mid_point=1.0 );
void operator()( Image &image_ ) const;
private:
double _black_point;
double _white_point;
double _mid_point;
};
// Level image channel
class MagickPPExport levelChannelImage : public std::unary_function<Image&,void>
{
public:
levelChannelImage( const Magick::ChannelType channel,
const double black_point,
const double white_point,
const double mid_point=1.0 );
void operator()( Image &image_ ) const;
private:
Magick::ChannelType _channel;
double _black_point;
double _white_point;
double _mid_point;
};
// Magnify image by integral size
class MagickPPExport magnifyImage : public std::unary_function<Image&,void>
{
public:
magnifyImage( void );
void operator()( Image &image_ ) const;
private:
};
// Remap image colors with closest color from reference image
class MagickPPExport mapImage : public std::unary_function<Image&,void>
{
public:
mapImage( const Image &mapImage_ ,
const bool dither_ = false );
void operator()( Image &image_ ) const;
private:
Image _mapImage;
bool _dither;
};
// Floodfill designated area with a matte value
class MagickPPExport matteFloodfillImage : public std::unary_function<Image&,void>
{
public:
matteFloodfillImage( const Color &target_ ,
const unsigned int matte_,
const ::ssize_t x_, const ::ssize_t y_,
const PaintMethod method_ );
void operator()( Image &image_ ) const;
private:
Color _target;
unsigned int _matte;
::ssize_t _x;
::ssize_t _y;
PaintMethod _method;
};
// Filter image by replacing each pixel component with the median
// color in a circular neighborhood
class MagickPPExport medianFilterImage : public std::unary_function<Image&,void>
{
public:
medianFilterImage( const double radius_ = 0.0 );
void operator()( Image &image_ ) const;
private:
double _radius;
};
// Reduce image by integral size
class MagickPPExport minifyImage : public std::unary_function<Image&,void>
{
public:
minifyImage( void );
void operator()( Image &image_ ) const;
private:
};
// Modulate percent hue, saturation, and brightness of an image
class MagickPPExport modulateImage : public std::unary_function<Image&,void>
{
public:
modulateImage( const double brightness_,
const double saturation_,
const double hue_ );
void operator()( Image &image_ ) const;
private:
double _brightness;
double _saturation;
double _hue;
};
// Negate colors in image. Set grayscale to only negate grayscale
// values in image.
class MagickPPExport negateImage : public std::unary_function<Image&,void>
{
public:
negateImage( const bool grayscale_ = false );
void operator()( Image &image_ ) const;
private:
bool _grayscale;
};
// Normalize image (increase contrast by normalizing the pixel
// values to span the full range of color values)
class MagickPPExport normalizeImage : public std::unary_function<Image&,void>
{
public:
normalizeImage( void );
void operator()( Image &image_ ) const;
private:
};
// Oilpaint image (image looks like oil painting)
class MagickPPExport oilPaintImage : public std::unary_function<Image&,void>
{
public:
oilPaintImage( const double radius_ = 3 );
void operator()( Image &image_ ) const;
private:
double _radius;
};
// Set or attenuate the image opacity channel. If the image pixels
// are opaque then they are set to the specified opacity value,
// otherwise they are blended with the supplied opacity value. The
// value of opacity_ ranges from 0 (completely opaque) to
// QuantumRange. The defines OpaqueOpacity and TransparentOpacity are
// available to specify completely opaque or completely transparent,
// respectively.
class MagickPPExport opacityImage : public std::unary_function<Image&,void>
{
public:
opacityImage( const unsigned int opacity_ );
void operator()( Image &image_ ) const;
private:
unsigned int _opacity;
};
// Change color of opaque pixel to specified pen color.
class MagickPPExport opaqueImage : public std::unary_function<Image&,void>
{
public:
opaqueImage( const Color &opaqueColor_,
const Color &penColor_ );
void operator()( Image &image_ ) const;
private:
Color _opaqueColor;
Color _penColor;
};
// Quantize image (reduce number of colors)
class MagickPPExport quantizeImage : public std::unary_function<Image&,void>
{
public:
quantizeImage( const bool measureError_ = false );
void operator()( Image &image_ ) const;
private:
bool _measureError;
};
// Raise image (lighten or darken the edges of an image to give a
// 3-D raised or lowered effect)
class MagickPPExport raiseImage : public std::unary_function<Image&,void>
{
public:
raiseImage( const Geometry &geometry_ = raiseGeometryDefault,
const bool raisedFlag_ = false );
void operator()( Image &image_ ) const;
private:
Geometry _geometry;
bool _raisedFlag;
};
// Reduce noise in image using a noise peak elimination filter
class MagickPPExport reduceNoiseImage : public std::unary_function<Image&,void>
{
public:
reduceNoiseImage( void );
reduceNoiseImage (const size_t order_ );
void operator()( Image &image_ ) const;
private:
size_t _order;
};
// Resize image to specified size.
class MagickPPExport resizeImage : public std::unary_function<Image&,void>
{
public:
resizeImage( const Geometry &geometry_ );
void operator()( Image &image_ ) const;
private:
Geometry _geometry;
};
// Roll image (rolls image vertically and horizontally) by specified
// number of columnms and rows)
class MagickPPExport rollImage : public std::unary_function<Image&,void>
{
public:
rollImage( const Geometry &roll_ );
rollImage( const ::ssize_t columns_, const ::ssize_t rows_ );
void operator()( Image &image_ ) const;
private:
size_t _columns;
size_t _rows;
};
// Rotate image counter-clockwise by specified number of degrees.
class MagickPPExport rotateImage : public std::unary_function<Image&,void>
{
public:
rotateImage( const double degrees_ );
void operator()( Image &image_ ) const;
private:
double _degrees;
};
// Resize image by using pixel sampling algorithm
class MagickPPExport sampleImage : public std::unary_function<Image&,void>
{
public:
sampleImage( const Geometry &geometry_ );
void operator()( Image &image_ ) const;
private:
Geometry _geometry;
};
// Resize image by using simple ratio algorithm
class MagickPPExport scaleImage : public std::unary_function<Image&,void>
{
public:
scaleImage( const Geometry &geometry_ );
void operator()( Image &image_ ) const;
private:
Geometry _geometry;
};
// Segment (coalesce similar image components) by analyzing the
// histograms of the color components and identifying units that are
// homogeneous with the fuzzy c-means technique.
// Also uses QuantizeColorSpace and Verbose image attributes
class MagickPPExport segmentImage : public std::unary_function<Image&,void>
{
public:
segmentImage( const double clusterThreshold_ = 1.0,
const double smoothingThreshold_ = 1.5 );
void operator()( Image &image_ ) const;
private:
double _clusterThreshold;
double _smoothingThreshold;
};
// Shade image using distant light source
class MagickPPExport shadeImage : public std::unary_function<Image&,void>
{
public:
shadeImage( const double azimuth_ = 30,
const double elevation_ = 30,
const bool colorShading_ = false );
void operator()( Image &image_ ) const;
private:
double _azimuth;
double _elevation;
bool _colorShading;
};
// Shadow effect image (simulate an image shadow)
class MagickPPExport shadowImage : public std::unary_function<Image&,void>
{
public:
shadowImage( const double percent_opacity_ = 80, const double sigma_ = 0.5,
const ssize_t x_ = 5, const ssize_t y_ = 5 );
void operator()( Image &image_ ) const;
private:
double _percent_opacity;
double _sigma;
ssize_t _x;
ssize_t _y;
};
// Sharpen pixels in image
class MagickPPExport sharpenImage : public std::unary_function<Image&,void>
{
public:
sharpenImage( const double radius_ = 1, const double sigma_ = 0.5 );
void operator()( Image &image_ ) const;
private:
double _radius;
double _sigma;
};
// Shave pixels from image edges.
class MagickPPExport shaveImage : public std::unary_function<Image&,void>
{
public:
shaveImage( const Geometry &geometry_ );
void operator()( Image &image_ ) const;
private:
Geometry _geometry;
};
// Shear image (create parallelogram by sliding image by X or Y axis)
class MagickPPExport shearImage : public std::unary_function<Image&,void>
{
public:
shearImage( const double xShearAngle_,
const double yShearAngle_ );
void operator()( Image &image_ ) const;
private:
double _xShearAngle;
double _yShearAngle;
};
// Solarize image (similar to effect seen when exposing a
// photographic film to light during the development process)
class MagickPPExport solarizeImage : public std::unary_function<Image&,void>
{
public:
solarizeImage( const double factor_ );
void operator()( Image &image_ ) const;
private:
double _factor;
};
// Splice the background color into the image.
class MagickPPExport spliceImage : public std::unary_function<Image&,void>
{
public:
spliceImage( const Geometry &geometry_ );
void operator()( Image &image_ ) const;
private:
Geometry _geometry;
};
// Spread pixels randomly within image by specified ammount
class MagickPPExport spreadImage : public std::unary_function<Image&,void>
{
public:
spreadImage( const size_t amount_ = 3 );
void operator()( Image &image_ ) const;
private:
size_t _amount;
};
// Add a digital watermark to the image (based on second image)
class MagickPPExport steganoImage : public std::unary_function<Image&,void>
{
public:
steganoImage( const Image &waterMark_ );
void operator()( Image &image_ ) const;
private:
Image _waterMark;
};
// Create an image which appears in stereo when viewed with red-blue glasses
// (Red image on left, blue on right)
class MagickPPExport stereoImage : public std::unary_function<Image&,void>
{
public:
stereoImage( const Image &rightImage_ );
void operator()( Image &image_ ) const;
private:
Image _rightImage;
};
// Color to use when drawing object outlines
class MagickPPExport strokeColorImage : public std::unary_function<Image&,void>
{
public:
strokeColorImage( const Color &strokeColor_ );
void operator()( Image &image_ ) const;
private:
Color _strokeColor;
};
// Swirl image (image pixels are rotated by degrees)
class MagickPPExport swirlImage : public std::unary_function<Image&,void>
{
public:
swirlImage( const double degrees_ );
void operator()( Image &image_ ) const;
private:
double _degrees;
};
// Channel a texture on image background
class MagickPPExport textureImage : public std::unary_function<Image&,void>
{
public:
textureImage( const Image &texture_ );
void operator()( Image &image_ ) const;
private:
Image _texture;
};
// Threshold image
class MagickPPExport thresholdImage : public std::unary_function<Image&,void>
{
public:
thresholdImage( const double threshold_ );
void operator()( Image &image_ ) const;
private:
double _threshold;
};
// Transform image based on image and crop geometries
class MagickPPExport transformImage : public std::unary_function<Image&,void>
{
public:
transformImage( const Geometry &imageGeometry_ );
transformImage( const Geometry &imageGeometry_,
const Geometry &cropGeometry_ );
void operator()( Image &image_ ) const;
private:
Geometry _imageGeometry;
Geometry _cropGeometry;
};
// Set image color to transparent
class MagickPPExport transparentImage : public std::unary_function<Image&,void>
{
public:
transparentImage( const Color& color_ );
void operator()( Image &image_ ) const;
private:
Color _color;
};
// Trim edges that are the background color from the image
class MagickPPExport trimImage : public std::unary_function<Image&,void>
{
public:
trimImage( void );
void operator()( Image &image_ ) const;
private:
};
// Map image pixels to a sine wave
class MagickPPExport waveImage : public std::unary_function<Image&,void>
{
public:
waveImage( const double amplitude_ = 25.0,
const double wavelength_ = 150.0 );
void operator()( Image &image_ ) const;
private:
double _amplitude;
double _wavelength;
};
// Zoom image to specified size.
class MagickPPExport zoomImage : public std::unary_function<Image&,void>
{
public:
zoomImage( const Geometry &geometry_ );
void operator()( Image &image_ ) const;
private:
Geometry _geometry;
};
//
// Function object image attribute accessors
//
// Anti-alias Postscript and TrueType fonts (default true)
class MagickPPExport antiAliasImage : public std::unary_function<Image&,void>
{
public:
antiAliasImage( const bool flag_ );
void operator()( Image &image_ ) const;
private:
bool _flag;
};
// Join images into a single multi-image file
class MagickPPExport adjoinImage : public std::unary_function<Image&,void>
{
public:
adjoinImage( const bool flag_ );
void operator()( Image &image_ ) const;
private:
bool _flag;
};
// Time in 1/100ths of a second which must expire before displaying
// the next image in an animated sequence.
class MagickPPExport animationDelayImage : public std::unary_function<Image&,void>
{
public:
animationDelayImage( const size_t delay_ );
void operator()( Image &image_ ) const;
private:
size_t _delay;
};
// Number of iterations to loop an animation (e.g. Netscape loop
// extension) for.
class MagickPPExport animationIterationsImage : public std::unary_function<Image&,void>
{
public:
animationIterationsImage( const size_t iterations_ );
void operator()( Image &image_ ) const;
private:
size_t _iterations;
};
// Image background color
class MagickPPExport backgroundColorImage : public std::unary_function<Image&,void>
{
public:
backgroundColorImage( const Color &color_ );
void operator()( Image &image_ ) const;
private:
Color _color;
};
// Name of texture image to tile onto the image background
class MagickPPExport backgroundTextureImage : public std::unary_function<Image&,void>
{
public:
backgroundTextureImage( const std::string &backgroundTexture_ );
void operator()( Image &image_ ) const;
private:
std::string _backgroundTexture;
};
// Image border color
class MagickPPExport borderColorImage : public std::unary_function<Image&,void>
{
public:
borderColorImage( const Color &color_ );
void operator()( Image &image_ ) const;
private:
Color _color;
};
// Text bounding-box base color (default none)
class MagickPPExport boxColorImage : public std::unary_function<Image&,void>
{
public:
boxColorImage( const Color &boxColor_ );
void operator()( Image &image_ ) const;
private:
Color _boxColor;
};
// Chromaticity blue primary point (e.g. x=0.15, y=0.06)
class MagickPPExport chromaBluePrimaryImage : public std::unary_function<Image&,void>
{
public:
chromaBluePrimaryImage( const double x_, const double y_ );
void operator()( Image &image_ ) const;
private:
double _x;
double _y;
};
// Chromaticity green primary point (e.g. x=0.3, y=0.6)
class MagickPPExport chromaGreenPrimaryImage : public std::unary_function<Image&,void>
{
public:
chromaGreenPrimaryImage( const double x_, const double y_ );
void operator()( Image &image_ ) const;
private:
double _x;
double _y;
};
// Chromaticity red primary point (e.g. x=0.64, y=0.33)
class MagickPPExport chromaRedPrimaryImage : public std::unary_function<Image&,void>
{
public:
chromaRedPrimaryImage( const double x_, const double y_ );
void operator()( Image &image_ ) const;
private:
double _x;
double _y;
};
// Chromaticity white point (e.g. x=0.3127, y=0.329)
class MagickPPExport chromaWhitePointImage : public std::unary_function<Image&,void>
{
public:
chromaWhitePointImage( const double x_, const double y_ );
void operator()( Image &image_ ) const;
private:
double _x;
double _y;
};
// Colors within this distance are considered equal
class MagickPPExport colorFuzzImage : public std::unary_function<Image&,void>
{
public:
colorFuzzImage( const double fuzz_ );
void operator()( Image &image_ ) const;
private:
double _fuzz;
};
// Color at colormap position index_
class MagickPPExport colorMapImage : public std::unary_function<Image&,void>
{
public:
colorMapImage( const size_t index_, const Color &color_ );
void operator()( Image &image_ ) const;
private:
size_t _index;
Color _color;
};
// Composition operator to be used when composition is implicitly used
// (such as for image flattening).
class MagickPPExport composeImage : public std::unary_function<Image&,void>
{
public:
composeImage( const CompositeOperator compose_ );
void operator()( Image &image_ ) const;
private:
CompositeOperator _compose;
};
// Compression type
class MagickPPExport compressTypeImage : public std::unary_function<Image&,void>
{
public:
compressTypeImage( const CompressionType compressType_ );
void operator()( Image &image_ ) const;
private:
CompressionType _compressType;
};
// Vertical and horizontal resolution in pixels of the image
class MagickPPExport densityImage : public std::unary_function<Image&,void>
{
public:
densityImage( const Geometry &geomery_ );
void operator()( Image &image_ ) const;
private:
Geometry _geomery;
};
// Image depth (bits allocated to red/green/blue components)
class MagickPPExport depthImage : public std::unary_function<Image&,void>
{
public:
depthImage( const size_t depth_ );
void operator()( Image &image_ ) const;
private:
size_t _depth;
};
// Endianness (LSBEndian like Intel or MSBEndian like SPARC) for image
// formats which support endian-specific options.
class MagickPPExport endianImage : public std::unary_function<Image&,void>
{
public:
endianImage( const EndianType endian_ );
void operator()( Image &image_ ) const;
private:
EndianType _endian;
};
// Image file name
class MagickPPExport fileNameImage : public std::unary_function<Image&,void>
{
public:
fileNameImage( const std::string &fileName_ );
void operator()( Image &image_ ) const;
private:
std::string _fileName;
};
// Filter to use when resizing image
class MagickPPExport filterTypeImage : public std::unary_function<Image&,void>
{
public:
filterTypeImage( const FilterTypes filterType_ );
void operator()( Image &image_ ) const;
private:
FilterTypes _filterType;
};
// Text rendering font
class MagickPPExport fontImage : public std::unary_function<Image&,void>
{
public:
fontImage( const std::string &font_ );
void operator()( Image &image_ ) const;
private:
std::string _font;
};
// Font point size
class MagickPPExport fontPointsizeImage : public std::unary_function<Image&,void>
{
public:
fontPointsizeImage( const size_t pointsize_ );
void operator()( Image &image_ ) const;
private:
size_t _pointsize;
};
// GIF disposal method
class MagickPPExport gifDisposeMethodImage : public std::unary_function<Image&,void>
{
public:
gifDisposeMethodImage( const size_t disposeMethod_ );
void operator()( Image &image_ ) const;
private:
size_t _disposeMethod;
};
// Type of interlacing to use
class MagickPPExport interlaceTypeImage : public std::unary_function<Image&,void>
{
public:
interlaceTypeImage( const InterlaceType interlace_ );
void operator()( Image &image_ ) const;
private:
InterlaceType _interlace;
};
// Linewidth for drawing vector objects (default one)
class MagickPPExport lineWidthImage : public std::unary_function<Image&,void>
{
public:
lineWidthImage( const double lineWidth_ );
void operator()( Image &image_ ) const;
private:
double _lineWidth;
};
// File type magick identifier (.e.g "GIF")
class MagickPPExport magickImage : public std::unary_function<Image&,void>
{
public:
magickImage( const std::string &magick_ );
void operator()( Image &image_ ) const;
private:
std::string _magick;
};
// Image supports transparent color
class MagickPPExport matteImage : public std::unary_function<Image&,void>
{
public:
matteImage( const bool matteFlag_ );
void operator()( Image &image_ ) const;
private:
bool _matteFlag;
};
// Transparent color
class MagickPPExport matteColorImage : public std::unary_function<Image&,void>
{
public:
matteColorImage( const Color &matteColor_ );
void operator()( Image &image_ ) const;
private:
Color _matteColor;
};
// Indicate that image is black and white
class MagickPPExport monochromeImage : public std::unary_function<Image&,void>
{
public:
monochromeImage( const bool monochromeFlag_ );
void operator()( Image &image_ ) const;
private:
bool _monochromeFlag;
};
// Pen color
class MagickPPExport penColorImage : public std::unary_function<Image&,void>
{
public:
penColorImage( const Color &penColor_ );
void operator()( Image &image_ ) const;
private:
Color _penColor;
};
// Pen texture image.
class MagickPPExport penTextureImage : public std::unary_function<Image&,void>
{
public:
penTextureImage( const Image &penTexture_ );
void operator()( Image &image_ ) const;
private:
Image _penTexture;
};
// Set pixel color at location x & y.
class MagickPPExport pixelColorImage : public std::unary_function<Image&,void>
{
public:
pixelColorImage( const ::ssize_t x_,
const ::ssize_t y_,
const Color &color_);
void operator()( Image &image_ ) const;
private:
::ssize_t _x;
::ssize_t _y;
Color _color;
};
// Postscript page size.
class MagickPPExport pageImage : public std::unary_function<Image&,void>
{
public:
pageImage( const Geometry &pageSize_ );
void operator()( Image &image_ ) const;
private:
Geometry _pageSize;
};
// JPEG/MIFF/PNG compression level (default 75).
class MagickPPExport qualityImage : public std::unary_function<Image&,void>
{
public:
qualityImage( const size_t quality_ );
void operator()( Image &image_ ) const;
private:
size_t _quality;
};
// Maximum number of colors to quantize to
class MagickPPExport quantizeColorsImage : public std::unary_function<Image&,void>
{
public:
quantizeColorsImage( const size_t colors_ );
void operator()( Image &image_ ) const;
private:
size_t _colors;
};
// Colorspace to quantize in.
class MagickPPExport quantizeColorSpaceImage : public std::unary_function<Image&,void>
{
public:
quantizeColorSpaceImage( const ColorspaceType colorSpace_ );
void operator()( Image &image_ ) const;
private:
ColorspaceType _colorSpace;
};
// Dither image during quantization (default true).
class MagickPPExport quantizeDitherImage : public std::unary_function<Image&,void>
{
public:
quantizeDitherImage( const bool ditherFlag_ );
void operator()( Image &image_ ) const;
private:
bool _ditherFlag;
};
// Quantization tree-depth
class MagickPPExport quantizeTreeDepthImage : public std::unary_function<Image&,void>
{
public:
quantizeTreeDepthImage( const size_t treeDepth_ );
void operator()( Image &image_ ) const;
private:
size_t _treeDepth;
};
// The type of rendering intent
class MagickPPExport renderingIntentImage : public std::unary_function<Image&,void>
{
public:
renderingIntentImage( const RenderingIntent renderingIntent_ );
void operator()( Image &image_ ) const;
private:
RenderingIntent _renderingIntent;
};
// Units of image resolution
class MagickPPExport resolutionUnitsImage : public std::unary_function<Image&,void>
{
public:
resolutionUnitsImage( const ResolutionType resolutionUnits_ );
void operator()( Image &image_ ) const;
private:
ResolutionType _resolutionUnits;
};
// Image scene number
class MagickPPExport sceneImage : public std::unary_function<Image&,void>
{
public:
sceneImage( const size_t scene_ );
void operator()( Image &image_ ) const;
private:
size_t _scene;
};
// adjust the image contrast with a non-linear sigmoidal contrast algorithm
class MagickPPExport sigmoidalContrastImage : public std::unary_function<Image&,void>
{
public:
sigmoidalContrastImage( const size_t sharpen_,
const double contrast,
const double midpoint = QuantumRange / 2.0 );
void operator()( Image &image_ ) const;
private:
size_t _sharpen;
double contrast;
double midpoint;
};
// Width and height of a raw image
class MagickPPExport sizeImage : public std::unary_function<Image&,void>
{
public:
sizeImage( const Geometry &geometry_ );
void operator()( Image &image_ ) const;
private:
Geometry _geometry;
};
// stripImage strips an image of all profiles and comments.
class MagickPPExport stripImage : public std::unary_function<Image&,void>
{
public:
stripImage( void );
void operator()( Image &image_ ) const;
private:
};
// Subimage of an image sequence
class MagickPPExport subImageImage : public std::unary_function<Image&,void>
{
public:
subImageImage( const size_t subImage_ );
void operator()( Image &image_ ) const;
private:
size_t _subImage;
};
// Number of images relative to the base image
class MagickPPExport subRangeImage : public std::unary_function<Image&,void>
{
public:
subRangeImage( const size_t subRange_ );
void operator()( Image &image_ ) const;
private:
size_t _subRange;
};
// Tile name
class MagickPPExport tileNameImage : public std::unary_function<Image&,void>
{
public:
tileNameImage( const std::string &tileName_ );
void operator()( Image &image_ ) const;
private:
std::string _tileName;
};
// Image storage type
class MagickPPExport typeImage : public std::unary_function<Image&,void>
{
public:
typeImage( const ImageType type_ );
void operator()( Image &image_ ) const;
private:
Magick::ImageType _type;
};
// Print detailed information about the image
class MagickPPExport verboseImage : public std::unary_function<Image&,void>
{
public:
verboseImage( const bool verbose_ );
void operator()( Image &image_ ) const;
private:
bool _verbose;
};
// FlashPix viewing parameters
class MagickPPExport viewImage : public std::unary_function<Image&,void>
{
public:
viewImage( const std::string &view_ );
void operator()( Image &image_ ) const;
private:
std::string _view;
};
// X11 display to display to, obtain fonts from, or to capture
// image from
class MagickPPExport x11DisplayImage : public std::unary_function<Image&,void>
{
public:
x11DisplayImage( const std::string &display_ );
void operator()( Image &image_ ) const;
private:
std::string _display;
};
//////////////////////////////////////////////////////////
//
// Implementation template definitions. Not for end-use.
//
//////////////////////////////////////////////////////////
// Link images together into an image list based on the ordering of
// the container implied by the iterator. This step is done in
// preparation for use with ImageMagick functions which operate on
// lists of images.
// Images are selected by range, first_ to last_ so that a subset of
// the container may be selected. Specify first_ via the
// container's begin() method and last_ via the container's end()
// method in order to specify the entire container.
template <class InputIterator>
void linkImages( InputIterator first_,
InputIterator last_ ) {
MagickCore::Image* previous = 0;
::ssize_t scene = 0;
for ( InputIterator iter = first_; iter != last_; ++iter )
{
// Unless we reduce the reference count to one, the same image
// structure may occur more than once in the container, causing
// the linked list to fail.
iter->modifyImage();
MagickCore::Image* current = iter->image();
current->previous = previous;
current->next = 0;
if ( previous != 0)
previous->next = current;
current->scene=scene;
++scene;
previous = current;
}
}
// Remove links added by linkImages. This should be called after the
// ImageMagick function call has completed to reset the image list
// back to its pristine un-linked state.
template <class InputIterator>
void unlinkImages( InputIterator first_,
InputIterator last_ ) {
for( InputIterator iter = first_; iter != last_; ++iter )
{
MagickCore::Image* image = iter->image();
image->previous = 0;
image->next = 0;
}
}
// Insert images in image list into existing container (appending to container)
// The images should not be deleted since only the image ownership is passed.
// The options are copied into the object.
template <class Container>
void insertImages( Container *sequence_,
MagickCore::Image* images_ ) {
MagickCore::Image *image = images_;
if ( image )
{
do
{
MagickCore::Image* next_image = image->next;
image->next = 0;
if (next_image != 0)
next_image->previous=0;
sequence_->push_back( Magick::Image( image ) );
image=next_image;
} while( image );
return;
}
}
///////////////////////////////////////////////////////////////////
//
// Template definitions for documented API
//
///////////////////////////////////////////////////////////////////
template <class InputIterator>
void animateImages( InputIterator first_,
InputIterator last_ ) {
MagickCore::ExceptionInfo exceptionInfo;
MagickCore::GetExceptionInfo( &exceptionInfo );
linkImages( first_, last_ );
MagickCore::AnimateImages( first_->imageInfo(), first_->image() );
MagickCore::GetImageException( first_->image(), &exceptionInfo );
unlinkImages( first_, last_ );
throwException( exceptionInfo );
(void) MagickCore::DestroyExceptionInfo( &exceptionInfo );
}
// Append images from list into single image in either horizontal or
// vertical direction.
template <class InputIterator>
void appendImages( Image *appendedImage_,
InputIterator first_,
InputIterator last_,
bool stack_ = false) {
MagickCore::ExceptionInfo exceptionInfo;
MagickCore::GetExceptionInfo( &exceptionInfo );
linkImages( first_, last_ );
MagickCore::Image* image = MagickCore::AppendImages( first_->image(),
(MagickBooleanType) stack_,
&exceptionInfo );
unlinkImages( first_, last_ );
appendedImage_->replaceImage( image );
throwException( exceptionInfo );
(void) MagickCore::DestroyExceptionInfo( &exceptionInfo );
}
// Average a set of images.
// All the input images must be the same size in pixels.
template <class InputIterator>
void averageImages( Image *averagedImage_,
InputIterator first_,
InputIterator last_ ) {
MagickCore::ExceptionInfo exceptionInfo;
MagickCore::GetExceptionInfo( &exceptionInfo );
linkImages( first_, last_ );
MagickCore::Image* image = MagickCore::EvaluateImages( first_->image(),
MagickCore::MeanEvaluateOperator, &exceptionInfo );
unlinkImages( first_, last_ );
averagedImage_->replaceImage( image );
throwException( exceptionInfo );
(void) MagickCore::DestroyExceptionInfo( &exceptionInfo );
}
// Merge a sequence of images.
// This is useful for GIF animation sequences that have page
// offsets and disposal methods. A container to contain
// the updated image sequence is passed via the coalescedImages_
// option.
template <class InputIterator, class Container >
void coalesceImages( Container *coalescedImages_,
InputIterator first_,
InputIterator last_ ) {
MagickCore::ExceptionInfo exceptionInfo;
MagickCore::GetExceptionInfo( &exceptionInfo );
// Build image list
linkImages( first_, last_ );
MagickCore::Image* images = MagickCore::CoalesceImages( first_->image(),
&exceptionInfo);
// Unlink image list
unlinkImages( first_, last_ );
// Ensure container is empty
coalescedImages_->clear();
// Move images to container
insertImages( coalescedImages_, images );
// Report any error
throwException( exceptionInfo );
(void) MagickCore::DestroyExceptionInfo( &exceptionInfo );
}
// Return format coders matching specified conditions.
//
// The default (if no match terms are supplied) is to return all
// available format coders.
//
// For example, to return all readable formats:
// list<CoderInfo> coderList;
// coderInfoList( &coderList, CoderInfo::TrueMatch, CoderInfo::AnyMatch, CoderInfo::AnyMatch)
//
template <class Container >
void coderInfoList( Container *container_,
CoderInfo::MatchType isReadable_ = CoderInfo::AnyMatch,
CoderInfo::MatchType isWritable_ = CoderInfo::AnyMatch,
CoderInfo::MatchType isMultiFrame_ = CoderInfo::AnyMatch
) {
// Obtain first entry in MagickInfo list
size_t number_formats;
MagickCore::ExceptionInfo exceptionInfo;
MagickCore::GetExceptionInfo( &exceptionInfo );
char **coder_list =
MagickCore::GetMagickList( "*", &number_formats, &exceptionInfo );
if( !coder_list )
{
throwException( exceptionInfo );
throwExceptionExplicit(MagickCore::MissingDelegateError,
"Coder array not returned!", 0 );
}
// Clear out container
container_->clear();
for ( ::ssize_t i=0; i < (::ssize_t) number_formats; i++)
{
const MagickCore::MagickInfo *magick_info =
MagickCore::GetMagickInfo( coder_list[i], &exceptionInfo );
coder_list[i]=(char *)
MagickCore::RelinquishMagickMemory( coder_list[i] );
// Skip stealth coders
if ( magick_info->stealth )
continue;
try {
CoderInfo coderInfo( magick_info->name );
// Test isReadable_
if ( isReadable_ != CoderInfo::AnyMatch &&
(( coderInfo.isReadable() && isReadable_ != CoderInfo::TrueMatch ) ||
( !coderInfo.isReadable() && isReadable_ != CoderInfo::FalseMatch )) )
continue;
// Test isWritable_
if ( isWritable_ != CoderInfo::AnyMatch &&
(( coderInfo.isWritable() && isWritable_ != CoderInfo::TrueMatch ) ||
( !coderInfo.isWritable() && isWritable_ != CoderInfo::FalseMatch )) )
continue;
// Test isMultiFrame_
if ( isMultiFrame_ != CoderInfo::AnyMatch &&
(( coderInfo.isMultiFrame() && isMultiFrame_ != CoderInfo::TrueMatch ) ||
( !coderInfo.isMultiFrame() && isMultiFrame_ != CoderInfo::FalseMatch )) )
continue;
// Append matches to container
container_->push_back( coderInfo );
}
// Intentionally ignore missing module errors
catch ( Magick::ErrorModule )
{
continue;
}
}
coder_list=(char **) MagickCore::RelinquishMagickMemory( coder_list );
throwException( exceptionInfo );
(void) MagickCore::DestroyExceptionInfo( &exceptionInfo );
}
//
// Fill container with color histogram.
// Entries are of type "std::pair<Color,size_t>". Use the pair
// "first" member to access the Color and the "second" member to access
// the number of times the color occurs in the image.
//
// For example:
//
// Using <map>:
//
// Image image("image.miff");
// map<Color,size_t> histogram;
// colorHistogram( &histogram, image );
// std::map<Color,size_t>::const_iterator p=histogram.begin();
// while (p != histogram.end())
// {
// cout << setw(10) << (int)p->second << ": ("
// << setw(quantum_width) << (int)p->first.redQuantum() << ","
// << setw(quantum_width) << (int)p->first.greenQuantum() << ","
// << setw(quantum_width) << (int)p->first.blueQuantum() << ")"
// << endl;
// p++;
// }
//
// Using <vector>:
//
// Image image("image.miff");
// std::vector<std::pair<Color,size_t> > histogram;
// colorHistogram( &histogram, image );
// std::vector<std::pair<Color,size_t> >::const_iterator p=histogram.begin();
// while (p != histogram.end())
// {
// cout << setw(10) << (int)p->second << ": ("
// << setw(quantum_width) << (int)p->first.redQuantum() << ","
// << setw(quantum_width) << (int)p->first.greenQuantum() << ","
// << setw(quantum_width) << (int)p->first.blueQuantum() << ")"
// << endl;
// p++;
// }
template <class Container >
void colorHistogram( Container *histogram_, const Image image)
{
MagickCore::ExceptionInfo exceptionInfo;
MagickCore::GetExceptionInfo( &exceptionInfo );
// Obtain histogram array
size_t colors;
MagickCore::ColorPacket *histogram_array =
MagickCore::GetImageHistogram( image.constImage(), &colors, &exceptionInfo );
throwException( exceptionInfo );
(void) MagickCore::DestroyExceptionInfo( &exceptionInfo );
// Clear out container
histogram_->clear();
// Transfer histogram array to container
for ( size_t i=0; i < colors; i++)
{
histogram_->insert(histogram_->end(),std::pair<const Color,size_t>
( Color(histogram_array[i].pixel.red,
histogram_array[i].pixel.green,
histogram_array[i].pixel.blue),
(size_t) histogram_array[i].count) );
}
// Deallocate histogram array
histogram_array=(MagickCore::ColorPacket *)
MagickCore::RelinquishMagickMemory(histogram_array);
}
// Break down an image sequence into constituent parts. This is
// useful for creating GIF or MNG animation sequences.
template <class InputIterator, class Container >
void deconstructImages( Container *deconstructedImages_,
InputIterator first_,
InputIterator last_ ) {
MagickCore::ExceptionInfo exceptionInfo;
MagickCore::GetExceptionInfo( &exceptionInfo );
// Build image list
linkImages( first_, last_ );
MagickCore::Image* images = DeconstructImages( first_->image(),
&exceptionInfo);
// Unlink image list
unlinkImages( first_, last_ );
// Ensure container is empty
deconstructedImages_->clear();
// Move images to container
insertImages( deconstructedImages_, images );
// Report any error
throwException( exceptionInfo );
(void) MagickCore::DestroyExceptionInfo( &exceptionInfo );
}
//
// Display an image sequence
//
template <class InputIterator>
void displayImages( InputIterator first_,
InputIterator last_ ) {
MagickCore::ExceptionInfo exceptionInfo;
MagickCore::GetExceptionInfo( &exceptionInfo );
linkImages( first_, last_ );
MagickCore::DisplayImages( first_->imageInfo(), first_->image() );
MagickCore::GetImageException( first_->image(), &exceptionInfo );
unlinkImages( first_, last_ );
throwException( exceptionInfo );
(void) MagickCore::DestroyExceptionInfo( &exceptionInfo );
}
// Merge a sequence of image frames which represent image layers.
// This is useful for combining Photoshop layers into a single image.
template <class InputIterator>
void flattenImages( Image *flattendImage_,
InputIterator first_,
InputIterator last_ ) {
MagickCore::ExceptionInfo exceptionInfo;
MagickCore::GetExceptionInfo( &exceptionInfo );
linkImages( first_, last_ );
MagickCore::Image* image = MagickCore::MergeImageLayers( first_->image(),
FlattenLayer,&exceptionInfo );
unlinkImages( first_, last_ );
flattendImage_->replaceImage( image );
throwException( exceptionInfo );
(void) MagickCore::DestroyExceptionInfo( &exceptionInfo );
}
// Implements the discrete Fourier transform (DFT) of the image either as a
// magnitude / phase or real / imaginary image pair.
template <class Container >
void forwardFourierTransformImage( Container *fourierImages_,
const Image &image_ ) {
MagickCore::ExceptionInfo exceptionInfo;
MagickCore::GetExceptionInfo( &exceptionInfo );
// Build image list
MagickCore::Image* images = ForwardFourierTransformImage(
image_.constImage(), MagickTrue, &exceptionInfo);
// Ensure container is empty
fourierImages_->clear();
// Move images to container
insertImages( fourierImages_, images );
// Report any error
throwException( exceptionInfo );
(void) MagickCore::DestroyExceptionInfo( &exceptionInfo );
}
template <class Container >
void forwardFourierTransformImage( Container *fourierImages_,
const Image &image_, const bool magnitude_ ) {
MagickCore::ExceptionInfo exceptionInfo;
MagickCore::GetExceptionInfo( &exceptionInfo );
// Build image list
MagickCore::Image* images = ForwardFourierTransformImage(
image_.constImage(), magnitude_ == true ? MagickTrue : MagickFalse,
&exceptionInfo);
// Ensure container is empty
fourierImages_->clear();
// Move images to container
insertImages( fourierImages_, images );
// Report any error
throwException( exceptionInfo );
(void) MagickCore::DestroyExceptionInfo( &exceptionInfo );
}
// Replace the colors of a sequence of images with the closest color
// from a reference image.
// Set dither_ to true to enable dithering. Set measureError_ to
// true in order to evaluate quantization error.
template <class InputIterator>
void mapImages( InputIterator first_,
InputIterator last_,
const Image& mapImage_,
bool dither_ = false,
bool measureError_ = false ) {
MagickCore::ExceptionInfo exceptionInfo;
MagickCore::GetExceptionInfo( &exceptionInfo );
MagickCore::QuantizeInfo quantizeInfo;
MagickCore::GetQuantizeInfo( &quantizeInfo );
quantizeInfo.dither = dither_ ? MagickCore::MagickTrue : MagickCore::MagickFalse;
linkImages( first_, last_ );
MagickCore::RemapImages( &quantizeInfo, first_->image(),
mapImage_.constImage());
MagickCore::GetImageException( first_->image(), &exceptionInfo );
if ( exceptionInfo.severity != MagickCore::UndefinedException )
{
unlinkImages( first_, last_ );
throwException( exceptionInfo );
}
MagickCore::Image* image = first_->image();
while( image )
{
// Calculate quantization error
if ( measureError_ )
{
MagickCore::GetImageQuantizeError( image );
if ( image->exception.severity > MagickCore::UndefinedException )
{
unlinkImages( first_, last_ );
throwException( exceptionInfo );
}
}
// Udate DirectClass representation of pixels
MagickCore::SyncImage( image );
if ( image->exception.severity > MagickCore::UndefinedException )
{
unlinkImages( first_, last_ );
throwException( exceptionInfo );
}
// Next image
image=image->next;
}
unlinkImages( first_, last_ );
(void) MagickCore::DestroyExceptionInfo( &exceptionInfo );
}
// Create a composite image by combining several separate images.
template <class Container, class InputIterator>
void montageImages( Container *montageImages_,
InputIterator first_,
InputIterator last_,
const Montage &montageOpts_ ) {
MagickCore::MontageInfo* montageInfo =
static_cast<MagickCore::MontageInfo*>(MagickCore::AcquireMagickMemory(sizeof(MagickCore::MontageInfo)));
// Update montage options with those set in montageOpts_
montageOpts_.updateMontageInfo( *montageInfo );
// Update options which must transfer to image options
if ( montageOpts_.label().length() != 0 )
first_->label( montageOpts_.label() );
// Create linked image list
linkImages( first_, last_ );
// Reset output container to pristine state
montageImages_->clear();
// Do montage
MagickCore::ExceptionInfo exceptionInfo;
MagickCore::GetExceptionInfo( &exceptionInfo );
MagickCore::Image *images = MagickCore::MontageImages( first_->image(),
montageInfo,
&exceptionInfo );
if ( images != 0 )
{
insertImages( montageImages_, images );
}
// Clean up any allocated data in montageInfo
MagickCore::DestroyMontageInfo( montageInfo );
// Unlink linked image list
unlinkImages( first_, last_ );
// Report any montage error
throwException( exceptionInfo );
// Apply transparency to montage images
if ( montageImages_->size() > 0 && montageOpts_.transparentColor().isValid() )
{
for_each( first_, last_, transparentImage( montageOpts_.transparentColor() ) );
}
// Report any transparentImage() error
MagickCore::GetImageException( first_->image(), &exceptionInfo );
throwException( exceptionInfo );
(void) MagickCore::DestroyExceptionInfo( &exceptionInfo );
}
// Morph a set of images
template <class InputIterator, class Container >
void morphImages( Container *morphedImages_,
InputIterator first_,
InputIterator last_,
size_t frames_ ) {
MagickCore::ExceptionInfo exceptionInfo;
MagickCore::GetExceptionInfo( &exceptionInfo );
// Build image list
linkImages( first_, last_ );
MagickCore::Image* images = MagickCore::MorphImages( first_->image(), frames_,
&exceptionInfo);
// Unlink image list
unlinkImages( first_, last_ );
// Ensure container is empty
morphedImages_->clear();
// Move images to container
insertImages( morphedImages_, images );
// Report any error
throwException( exceptionInfo );
(void) MagickCore::DestroyExceptionInfo( &exceptionInfo );
}
// Inlay a number of images to form a single coherent picture.
template <class InputIterator>
void mosaicImages( Image *mosaicImage_,
InputIterator first_,
InputIterator last_ ) {
MagickCore::ExceptionInfo exceptionInfo;
MagickCore::GetExceptionInfo( &exceptionInfo );
linkImages( first_, last_ );
MagickCore::Image* image = MagickCore::MergeImageLayers( first_->image(),
MosaicLayer,&exceptionInfo );
unlinkImages( first_, last_ );
mosaicImage_->replaceImage( image );
throwException( exceptionInfo );
(void) MagickCore::DestroyExceptionInfo( &exceptionInfo );
}
// Quantize colors in images using current quantization settings
// Set measureError_ to true in order to measure quantization error
template <class InputIterator>
void quantizeImages( InputIterator first_,
InputIterator last_,
bool measureError_ = false ) {
MagickCore::ExceptionInfo exceptionInfo;
MagickCore::GetExceptionInfo( &exceptionInfo );
linkImages( first_, last_ );
MagickCore::QuantizeImages( first_->quantizeInfo(),
first_->image() );
MagickCore::GetImageException( first_->image(), &exceptionInfo );
if ( exceptionInfo.severity > MagickCore::UndefinedException )
{
unlinkImages( first_, last_ );
throwException( exceptionInfo );
}
MagickCore::Image* image = first_->image();
while( image != 0 )
{
// Calculate quantization error
if ( measureError_ )
MagickCore::GetImageQuantizeError( image );
// Update DirectClass representation of pixels
MagickCore::SyncImage( image );
// Next image
image=image->next;
}
unlinkImages( first_, last_ );
(void) MagickCore::DestroyExceptionInfo( &exceptionInfo );
}
// Read images into existing container (appending to container)
// FIXME: need a way to specify options like size, depth, and density.
template <class Container>
void readImages( Container *sequence_,
const std::string &imageSpec_ ) {
MagickCore::ImageInfo *imageInfo = MagickCore::CloneImageInfo(0);
imageSpec_.copy( imageInfo->filename, MaxTextExtent-1 );
imageInfo->filename[ imageSpec_.length() ] = 0;
MagickCore::ExceptionInfo exceptionInfo;
MagickCore::GetExceptionInfo( &exceptionInfo );
MagickCore::Image* images = MagickCore::ReadImage( imageInfo, &exceptionInfo );
MagickCore::DestroyImageInfo(imageInfo);
insertImages( sequence_, images);
throwException( exceptionInfo );
(void) MagickCore::DestroyExceptionInfo( &exceptionInfo );
}
template <class Container>
void readImages( Container *sequence_,
const Blob &blob_ ) {
MagickCore::ImageInfo *imageInfo = MagickCore::CloneImageInfo(0);
MagickCore::ExceptionInfo exceptionInfo;
MagickCore::GetExceptionInfo( &exceptionInfo );
MagickCore::Image *images = MagickCore::BlobToImage( imageInfo,
blob_.data(),
blob_.length(), &exceptionInfo );
MagickCore::DestroyImageInfo(imageInfo);
insertImages( sequence_, images );
throwException( exceptionInfo );
(void) MagickCore::DestroyExceptionInfo( &exceptionInfo );
}
// Write Images
template <class InputIterator>
void writeImages( InputIterator first_,
InputIterator last_,
const std::string &imageSpec_,
bool adjoin_ = true ) {
first_->adjoin( adjoin_ );
MagickCore::ExceptionInfo exceptionInfo;
MagickCore::GetExceptionInfo( &exceptionInfo );
linkImages( first_, last_ );
::ssize_t errorStat = MagickCore::WriteImages( first_->constImageInfo(),
first_->image(),
imageSpec_.c_str(),
&exceptionInfo );
unlinkImages( first_, last_ );
if ( errorStat != false )
{
(void) MagickCore::DestroyExceptionInfo( &exceptionInfo );
return;
}
throwException( exceptionInfo );
(void) MagickCore::DestroyExceptionInfo( &exceptionInfo );
}
// Write images to BLOB
template <class InputIterator>
void writeImages( InputIterator first_,
InputIterator last_,
Blob *blob_,
bool adjoin_ = true) {
first_->adjoin( adjoin_ );
linkImages( first_, last_ );
MagickCore::ExceptionInfo exceptionInfo;
MagickCore::GetExceptionInfo( &exceptionInfo );
size_t length = 2048; // Efficient size for small images
void* data = MagickCore::ImagesToBlob( first_->imageInfo(),
first_->image(),
&length,
&exceptionInfo);
blob_->updateNoCopy( data, length, Magick::Blob::MallocAllocator );
unlinkImages( first_, last_ );
throwException( exceptionInfo );
(void) MagickCore::DestroyExceptionInfo( &exceptionInfo );
}
} // namespace Magick
#endif // Magick_STL_header
|