Html程序  |  214行  |  10.29 KB





<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8"  />
  <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1,shrink-to-fit=no"  />
  <title>Magick++, C++ API @ ImageMagick</title>
  <meta name="application-name" content="ImageMagick" />
  <meta name="description" content="Use ImageMagick® to create, edit, compose, or convert bitmap images. You can resize your image, crop it, change its shades and colors, add captions, among other operations." />
  <meta name="application-url" content="https://imagemagick.org" />
  <meta name="generator" content="PHP" />
  <meta name="keywords" content="magick++, c++, api, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert" />
  <meta name="rating" content="GENERAL" />
  <meta name="robots" content="INDEX, FOLLOW" />
  <meta name="generator" content="ImageMagick Studio LLC" />
  <meta name="author" content="ImageMagick Studio LLC" />
  <meta name="revisit-after" content="2 DAYS" />
  <meta name="resource-type" content="document" />
  <meta name="copyright" content="Copyright (c) 1999-2019 ImageMagick Studio LLC" />
  <meta name="distribution" content="Global" />
  <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1" />
  <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
  <link href="magick++.html" rel="canonical" />
  <link href="../images/wand.png" rel="icon" />
  <link href="../images/wand.ico" rel="shortcut icon" />
  <link href="assets/magick.css" rel="stylesheet" />
</head>
<body>
  <header>
  <nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
    <a class="navbar-brand" href="../"><img class="d-block" id="icon" alt="ImageMagick" width="32" height="32" src="../images/wand.ico"/></a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsMagick" aria-controls="navbarsMagick" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>

    <div class="navbar-collapse collapse" id="navbarsMagick" style="">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item ">
        <a class="nav-link" href="api/quantize.html">Home <span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item ">
        <a class="nav-link" href="../www/download.html">Download</a>
      </li>
      <li class="nav-item ">
        <a class="nav-link" href="../www/command-line-tools.html">Tools</a>
      </li>
      <li class="nav-item ">
        <a class="nav-link" href="../www/command-line-processing.html">Command-line</a>
      </li>
      <li class="nav-item ">
        <a class="nav-link" href="../www/resources.html">Resources</a>
      </li>
      <li class="nav-item ">
        <a class="nav-link" href="../www/develop.html">Develop</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" target="_blank" href="https://imagemagick.org/discourse-server/">Community</a>
      </li>
    </ul>
    <form class="form-inline my-2 my-lg-0" action="https://imagemagick.org/script/search.php">
      <input class="form-control mr-sm-2" type="text" name="q" placeholder="Search" aria-label="Search">
      <button class="btn btn-outline-success my-2 my-sm-0" type="submit" name="sa">Search</button>
    </form>
    </div>
  </nav>
  <div class="container">
   <script async="async" src="https://localhost/pagead/js/adsbygoogle.js"></script>    <ins class="adsbygoogle"
         style="display:block"
         data-ad-client="ca-pub-3129977114552745"
         data-ad-slot="6345125851"
         data-ad-format="auto"></ins>
    <script>
      (adsbygoogle = window.adsbygoogle || []).push({});
    </script>

  </div>
  </header>
  <main class="container">
    <div class="magick-template">
<div class="magick-header">
<p class="text-center"><a href="magick++.html#documentation">Documentation</a> • <a href="magick++.html#get">Obtaining Magick++</a> • <a href="magick++.html#install">Installation</a> • <a href="magick++.html#bugs">Reporting Bugs</a></p>

<a class="anchor" id="intro"></a>
<p class="lead magick-description"><a href="api/Magick++/index.html">Magick++ API</a> is the object-oriented C++ API to the <a href="../">ImageMagick</a> image-processing library.</p>
<p>Magick++ supports an object model which is inspired by <a href="perl-magick.html">PerlMagick</a>.
Images support implicit reference counting so that copy constructors
and assignment incur almost no cost. The cost of actually copying an
image (if necessary) is done just before modification and this copy
is managed automagically by Magick++. De-referenced copies are
automagically deleted. The image objects support value (rather than
pointer) semantics so it is trivial to support multiple generations
of an image in memory at one time. 
</p>
<p>Magick++ provides integrated support for the <a href="http://www.sgi.com/tech/stl/">Standard
Template Library</a> (STL) so that the powerful containers available
(e.g. <a href="http://www.sgi.com/tech/stl/Deque.html">deque</a>,
<a href="http://www.sgi.com/tech/stl/Vector.html">vector</a>, <a href="http://www.sgi.com/tech/stl/List.html">list</a>,
and <a href="http://www.sgi.com/tech/stl/Map.html">map</a>)  can
be used to write programs similar to those possible with PERL &amp;
PerlMagick. STL-compatible template versions of ImageMagick's
list-style operations are provided so that operations may be
performed on multiple images stored in STL containers. 
</p>
<h2>Documentation</h2>
<a class="anchor" id="documentation"></a>
<p>Detailed <a href="api/magick++-classes.html">documentation</a> is
provided for all Magick++ classes, class methods, and template
functions which comprise the API.  See a <a href="../Magick++/tutorial/Magick++_tutorial.pdf">  Gentle Introduction to Magick++</a> for an introductory tutorial to Magick++.  We include the <a href="../Magick++/tutorial/Magick++_tutorial.odt" >source</a> if you want to correct, enhance, or expand the tutorial.</p>
<h2>Obtaining Magick++</h2>
<a class="anchor" id="get"></a>
<p>Magick++ is included as part of <a href="api/quantize.html">ImageMagick</a>
source releases and may be retrieved via <a href="../www/download.html">HTTP</a>
or <a href="https://github.com/ImageMagick/ImageMagick/tree/master/Magick%2B%2B">GitHub</a>.
</p>
<h2>Installation</h2>
<a class="anchor" id="install"></a>
<p>Once you have the Magick++ sources available, follow these detailed
<a href="../Magick++/Install.html">installation instructions</a> for UNIX and
Windows. 
</p>
<h2>Usage</h2>
<p>A helper script named <code>Magick++-config</code> is installed
under Unix which assists with recalling compilation options required
to compile and link programs which use Magick++. For example, the
following command compiles and links the source file <code>demo.cpp</code>
to produce the executable <code>demo</code> (notice that quotes are
backward quotes): 
</p>
<pre class="highlight"><code>c++ `Magick++-config --cxxflags --cppflags` -O2 -o demo demo.cpp \
  `Magick++-config --ldflags --libs`
</code></pre>
<p>Set the <code>PKG_CONFIG_PATH</code> environment variable if ImageMagick is not in your default system path:</p>

<pre class="highlight"><code>export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
</code></pre>

<p>Windows users may get started by manually editing a project file
for one of the Magick++ demo programs. 
</p>
<p>Note, under Windows (and possibly the Mac) it may be necessary to initialize the ImageMagick library prior to using the Magick++ library. This initialization is performed by passing the path to the ImageMagick DLLs (assumed to be in the same directory as your program) to the InitializeMagick() function call. This is commonly performed by providing the path to your program (argv[0]) as shown in the following example: </p>
<pre class="highlight"><code>int main( int argc, char ** argv) {
  InitializeMagick(*argv);
  ...
</code></pre>
<p>This initialization step is not required under Unix, Linux,
Cygwin, or any other operating environment that supports the notion
of <var>installing</var> ImageMagick in a known location.  </p>
<p>Here is a example program that utilizes the Magick++ API to get you started, <a href="https://imagemagick.org/source/magick++.cpp">magick++.cpp</a>. It reads an image, crops it, and writes it to disk in the PNG image format.</p>

<pre class="pre-scrollable"><code>
#include &lt;Magick++.h> 
#include &lt;iostream> 

using namespace std; 
using namespace Magick; 

int main(int argc,char **argv) 
{ 
  InitializeMagick(*argv);

  // Construct the image object. Seperating image construction from the 
  // the read operation ensures that a failure to read the image file 
  // doesn't render the image object useless. 
  Image image;
  try { 
    // Read a file into image object 
    image.read( "logo:" );

    // Crop the image to specified size (width, height, xOffset, yOffset)
    image.crop( Geometry(100,100, 100, 100) );

    // Write the image to a file 
    image.write( "logo.png" ); 
  } 
  catch( Exception &amp;error_ ) 
    { 
      cout &lt;&lt; "Caught exception: " &lt;&lt; error_.what() &lt;&lt; endl; 
      return 1; 
    } 
  return 0; 
}
</code></pre>
<h2>Reporting Bugs</h2>
<a class="anchor" id="bugs"></a>
<p>Questions regarding usage should be directed to or to report any bugs go to
<a href="https://imagemagick.org/discourse-server//viewforum.html?f=23">Magick++ bug tracking forum</a>.
</p>
</div>
    </div>
  </main><!-- /.container -->
  <footer class="magick-footer">
    <p><a href="../www/security-policy.html">Security</a> •
    <a href="../www/architecture.html">Architecture</a> •
    <a href="../www/links.html">Related</a> •
     <a href="../www/sitemap.html">Sitemap</a>
       
    <a href="magick++.html#"><img class="d-inline" id="wand" alt="And Now a Touch of Magick" width="16" height="16" src="../images/wand.ico"/></a>
       
    <a href="http://pgp.mit.edu/pks/lookup?op=get&amp;search=0x89AB63D48277377A">Public Key</a> •
    <a href="../www/support.html">Donate</a> •
    <a href="../www/https://imagemagick.org/script/contact.php">Contact Us</a>
    <br/>
    <small>© 1999-2019 ImageMagick Studio LLC</small></p>
  </footer>

  <!-- Javascript assets -->
  <script src="assets/magick.js" crossorigin="anonymous"></script>
  <script>window.jQuery || document.write('<script src="https://localhost/ajax/libs/jquery/3.3.1/jquery.min.js"><\/script>')</script>
</body>
</html>