blob: 15ab20c27f2f595587b3e08a05cc0de91eac21d5 [file] [log] [blame]
cristy3eaa0ef2010-03-06 20:35:26 +00001
cristydcca3fa2010-12-29 21:50:07 +00002<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr">
cristy3eaa0ef2010-03-06 20:35:26 +00005<head>
cristy3c98a4f2010-08-13 20:09:41 +00006 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
7 <meta name="verify-v1" content="g222frIIxcQTrvDR3NBRUSKP3AnMNoqxOkIniCEkV7U="/>
cristyffb69ed2010-12-25 00:06:48 +00008 <title>ImageMagick: MagickCore, Low-level C API for ImageMagick</title>
cristy3ed852e2009-09-05 21:47:34 +00009 <meta http-equiv="Content-Language" content="en-US"/>
10 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
11 <meta http-equiv="Reply-to" content="magick-users@imagemagick.org"/>
cristy3c98a4f2010-08-13 20:09:41 +000012 <meta name="Application-name" content="ImageMagick"/>
cristydcca3fa2010-12-29 21:50:07 +000013 <meta name="Description" content="ImageMagick is a software suite to create, edit, compose, or convert bitmap images in a variety of formats. Use ImageMagick to scale, rotate, shear, distort and transform images."/>
cristy3c98a4f2010-08-13 20:09:41 +000014 <meta name="Application-url" content="http://www.imagemagick.org"/>
cristy3ed852e2009-09-05 21:47:34 +000015 <meta name="Generator" content="PHP"/>
16 <meta name="Keywords" content="magickcore, low-level, c, api, for, imagemagick, ImageMagick, ImageMagic, MagickCore, MagickWand, PerlMagick, Magick++, RMagick, PythonMagick, JMagick, TclMagick, Image, Magick, Magic, Wand, ImageMagickObject, Swiss, Army, Knife, Image, Processing"/>
cristy3ed852e2009-09-05 21:47:34 +000017 <meta name="Rating" content="GENERAL"/>
18 <meta name="Robots" content="INDEX, FOLLOW"/>
19 <meta name="Generator" content="ImageMagick Studio LLC"/>
20 <meta name="Author" content="ImageMagick Studio LLC"/>
21 <meta name="Revisit-after" content="2 DAYS"/>
22 <meta name="Resource-type" content="document"/>
cristy7e41fe82010-12-04 23:12:08 +000023 <meta name="Copyright" content="Copyright (c) 1999-2011 ImageMagick Studio LLC"/>
cristy3ed852e2009-09-05 21:47:34 +000024 <meta name="Distribution" content="Global"/>
cristydcca3fa2010-12-29 21:50:07 +000025 <link rel="icon" href="../images/wand.png"/>
cristy3c98a4f2010-08-13 20:09:41 +000026 <link rel="shortcut icon" href="../images/wand.ico" type="images/x-icon"/>
27 <link rel="meta" type="application/rdf+xml" title="ICI" href="http://imagemagick.org/ici.rdf"/>
28 <style type="text/css" media="all">
29 @import url("../www/magick.css");
30 </style>
cristydcca3fa2010-12-29 21:50:07 +000031 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
32 <script type="text/javascript" src="../fancybox/jquery.fancybox-1.3.4.pack.js"></script>
33 <link rel="stylesheet" type="text/css" href="../fancybox/jquery.fancybox-1.3.4.css" media="screen" />
34 <script type="text/javascript">
35 $(document).ready(function() {
36 $("a[href$=.jpg],a[href$=.png],a[href$=.gif]").fancybox({
37 'transitionIn' : 'elastic',
38 'transitionOut' : 'elastic',
39 'overlayShow' : false,
40 'opacity' : true
41 });
42 });
43 </script>
cristy3eaa0ef2010-03-06 20:35:26 +000044</head>
45
46<body id="www-imagemagick-org">
47<div class="titlebar">
48<a href="../index.html">
49 <img src="../images/script.png" alt="[ImageMagick]"
50 style="width: 350px; height: 60px; margin: 28px auto; float: left;" /></a>
51<a href="http://www.networkredux.com">
52 <img src="../images/networkredux.png" alt="[sponsor]"
53 style="margin: 45px auto; border: 0px; float: left;" /></a>
54<a href="http://www.imagemagick.org/discourse-server/">
55 <img src="../images/logo.jpg" alt=""
56 style="width: 114px; height: 118px; border: 0px; float: right;" /></a>
57<a href="../index.html">
58 <img src="../images/sprite.jpg" alt=""
59 style="width: 114px; height: 118px; border: 0px; float: right;" /></a>
60</div>
61
cristyce69bb02010-07-27 19:49:46 +000062<div class="westbar">
cristy3eaa0ef2010-03-06 20:35:26 +000063
cristy3ed852e2009-09-05 21:47:34 +000064<div class="menu">
cristy83a272e2010-05-07 20:40:35 +000065 <a title="About ImageMagick" href="../index.html">About ImageMagick</a>
cristy3ed852e2009-09-05 21:47:34 +000066</div>
cristy3eaa0ef2010-03-06 20:35:26 +000067<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +000068<div class="menu">
cristybb503372010-05-27 20:51:26 +000069 <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
70</div>
71<div class="sub">
72 <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
73</div>
74<div class="sub">
75 <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
76</div>
77<div class="sub">
78 <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
79</div>
80<div class="sep"></div>
81<div class="menu">
cristy83a272e2010-05-07 20:40:35 +000082 <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
cristy3ed852e2009-09-05 21:47:34 +000083</div>
84<div class="sub">
cristy83a272e2010-05-07 20:40:35 +000085 <a title="Command-line Tools: Processing" href="../www/command-line-processing.html">Processing</a>
cristy3ed852e2009-09-05 21:47:34 +000086</div>
87<div class="sub">
cristy83a272e2010-05-07 20:40:35 +000088 <a title="Command-line Tools: Options" href="../www/command-line-options.html">Options</a>
cristy3ed852e2009-09-05 21:47:34 +000089</div>
90<div class="sub">
cristy83a272e2010-05-07 20:40:35 +000091 <a title="Command-line Tools: Usage" href="http://www.imagemagick.org/Usage/">Usage</a>
cristy3ed852e2009-09-05 21:47:34 +000092</div>
93<div class="menu">
cristy83a272e2010-05-07 20:40:35 +000094 <a title="Program Interfaces" href="../www/api.html">Program Interfaces</a>
cristy3ed852e2009-09-05 21:47:34 +000095</div>
96<div class="sub">
cristy83a272e2010-05-07 20:40:35 +000097 <a title="Program Interface: MagickWand" href="../www/magick-wand.html">MagickWand</a>
cristy3ed852e2009-09-05 21:47:34 +000098</div>
99<div class="sub">
cristy83a272e2010-05-07 20:40:35 +0000100 <a title="Program Interface: MagickCore" href="../www/magick-core.html">MagickCore</a>
cristy3ed852e2009-09-05 21:47:34 +0000101</div>
102<div class="sub">
cristy83a272e2010-05-07 20:40:35 +0000103 <a title="Program Interface: PerlMagick" href="../www/perl-magick.html">PerlMagick</a>
cristy3ed852e2009-09-05 21:47:34 +0000104</div>
105<div class="sub">
cristydcca3fa2010-12-29 21:50:07 +0000106 <a title="Program Interface: Magick++" href="../www/magick++.html">Magick++</a>
cristy3ed852e2009-09-05 21:47:34 +0000107</div>
cristy3eaa0ef2010-03-06 20:35:26 +0000108<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +0000109<div class="menu">
cristy83a272e2010-05-07 20:40:35 +0000110 <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
cristy3ed852e2009-09-05 21:47:34 +0000111</div>
112<div class="sub">
cristy83a272e2010-05-07 20:40:35 +0000113 <a title="Install from Source: Unix" href="../www/install-source.html#unix">Unix</a>
cristy3ed852e2009-09-05 21:47:34 +0000114</div>
115<div class="sub">
cristy83a272e2010-05-07 20:40:35 +0000116 <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
cristy3ed852e2009-09-05 21:47:34 +0000117 </div>
118<div class="menu">
cristy83a272e2010-05-07 20:40:35 +0000119 <a title="Resources" href="../www/resources.html">Resources</a>
cristy3ed852e2009-09-05 21:47:34 +0000120</div>
cristybb503372010-05-27 20:51:26 +0000121<div class="menu">
122 <a title="Architecture" href="../www/architecture.html">Architecture</a>
123</div>
cristy3ed852e2009-09-05 21:47:34 +0000124<div class="menu">
cristy83a272e2010-05-07 20:40:35 +0000125 <a title="Download" href="../www/download.html">Download</a>
cristy3ed852e2009-09-05 21:47:34 +0000126</div>
cristy3eaa0ef2010-03-06 20:35:26 +0000127<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +0000128<div class="menu">
cristy83a272e2010-05-07 20:40:35 +0000129 <a title="Search" href="http://www.imagemagick.org/script/search.php">Search</a>
cristy3ed852e2009-09-05 21:47:34 +0000130</div>
cristy3eaa0ef2010-03-06 20:35:26 +0000131<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +0000132<div class="menu">
cristyffb69ed2010-12-25 00:06:48 +0000133 <a title="Site Map" href="../www/sitemap.html">Site Map</a>
cristy3ed852e2009-09-05 21:47:34 +0000134</div>
135<div class="sub">
cristyffb69ed2010-12-25 00:06:48 +0000136 <a title="Site Map: Links" href="../www/links.html">Links</a>
cristy3ed852e2009-09-05 21:47:34 +0000137</div>
cristy3eaa0ef2010-03-06 20:35:26 +0000138<div class="sep"></div>
cristy3ed852e2009-09-05 21:47:34 +0000139<div class="menu">
cristy83a272e2010-05-07 20:40:35 +0000140 <a title="Sponsors" href="../www/sponsors.html">Sponsors:</a>
cristy3ed852e2009-09-05 21:47:34 +0000141
142<div class="sponsbox">
143<div class="sponsor">
cristydcca3fa2010-12-29 21:50:07 +0000144 <a title="Sponsor: Webdesign" href="http://www.renehornig.com/">Webdesign</a><!-- 20111001000240 -->
cristy7d52cd62010-10-01 17:26:59 +0000145</div>
146<div class="sponsor">
147 <a title="Sponsor: Druckerei" href="http://print24.com/de/">Druckerei</a><!-- 201110010720 -->
cristy73fd1cd2010-09-12 19:14:25 +0000148</div>
149<div class="sponsor">
cristyc5baf4f2010-08-31 15:05:33 +0000150 <a title="Sponsor: Image Converter" href="http://www.batchphoto.com">Image Converter</a><!-- 201103010900 Bits Coffee-->
151</div>
152<div class="sponsor">
cristy851dbce2010-08-06 21:40:00 +0000153 <a title="Sponsor: Flyer drucken" href="http://www.online-druck.biz">Flyer drucken</a><!-- 201109010900 Floeter-->
154</div>
cristy3ed852e2009-09-05 21:47:34 +0000155</div>
156</div>
cristyce69bb02010-07-27 19:49:46 +0000157</div>
cristy3eaa0ef2010-03-06 20:35:26 +0000158
cristyce69bb02010-07-27 19:49:46 +0000159<div class="eastbar">
160 <script type="text/javascript">
161 <!--
162 google_ad_client = "pub-3129977114552745";
cristyce69bb02010-07-27 19:49:46 +0000163 google_ad_slot = "0574824969";
164 google_ad_width = 160;
165 google_ad_height = 600;
166 //-->
167 </script>
168 <script type="text/javascript"
169 src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
170 </script>
cristy3eaa0ef2010-03-06 20:35:26 +0000171</div>
172
173<div class="main">
174
cristydcca3fa2010-12-29 21:50:07 +0000175<h1>MagickCore C API</h1>
176
177<div class="doc-section">
cristy3ed852e2009-09-05 21:47:34 +0000178
179<p>The <a href="../www/api/MagickCore/index.html">MagickCore API</a> is a low-level interface between the C programming language and the ImageMagick image processing libraries and is recommended for wizard-level programmers only. Unlike the <a href="../www/magick-wand.html">MagickWand</a> C API which uses only a few opaque types and accessors, with MagickCore you almost exlusively access the structure members directly. A description of the MagickCore public methods are found here:</p>
180
181<ul>
182 <li><a href="../www/api/magick.html">Initialize or Destroy the ImageMagick Environment</a></li>
183 <li><a href="../www/api/constitute.html">Constitute an Image</a></li>
184 <li><a href="../www/api/composite.html">Composite an Image</a></li>
185 <li><a href="../www/api/image.html">Image Methods</a></li>
186 <li><a href="../www/api/color.html">Count the Colors in an Image</a></li>
cristy43d0f4d2009-09-17 19:35:37 +0000187 <li><a href="../www/api/colormap.html">Colormap Methods</a></li>
cristy3ed852e2009-09-05 21:47:34 +0000188 <li><a href="../www/api/distort.html">Image Distortions</a></li>
189 <li><a href="../www/api/layer.html">Dealing with Image Layers</a></li>
190 <li><a href="../www/api/profile.html">Dealing with Image Profiles</a></li>
191 <li><a href="../www/api/quantize.html">Reduce the Number of Unique Colors in an Image</a></li>
192 <li><a href="../www/api/histogram.html">Image Histograms</a></li>
193 <li><a href="../www/api/segment.html">Segment an Image with Thresholding Fuzzy c-Means</a></li>
194 <li><a href="../www/api/resize.html">Resize an Image</a></li>
195 <li><a href="../www/api/transform.html">Transform an Image</a></li>
196 <li><a href="../www/api/shear.html">Shear or Rotate an Image by an Arbitrary Angle</a></li>
197 <li><a href="../www/api/enhance.html">Enhance an Image</a></li>
198 <li><a href="../www/api/effect.html">Add an Effect</a></li>
cristyd43a46b2010-01-21 02:13:41 +0000199 <li><a href="../www/api/morphology.html">Morphological Erosions, Dilations, Openings, and Closings</a></li>
cristy3ed852e2009-09-05 21:47:34 +0000200 <li><a href="../www/api/fx.html">Add a Special Effect</a></li>
201 <li><a href="../www/api/decorate.html">Decorate an Image</a></li>
cristy83543962009-10-16 19:04:28 +0000202 <li><a href="../www/api/attribute.html">Get/Set an Image Attribute</a></li>
cristy3ed852e2009-09-05 21:47:34 +0000203 <li><a href="../www/api/property.html">Get/Set Image Properties</a></li>
cristy3e2860c2010-01-24 01:36:30 +0000204 <li><a href="../www/api/statistic.html">Get Image Statistics</a></li>
205 <li><a href="../www/api/feature.html">Get Image Features</a></li>
cristy3ed852e2009-09-05 21:47:34 +0000206 <li><a href="../www/api/annotate.html">Annotate an Image</a></li>
207 <li><a href="../www/api/paint.html">Paint on an Image</a></li>
208 <li><a href="../www/api/draw.html">Draw on an Image</a></li>
209 <li><a href="../www/api/montage.html">Create an Image Thumbnail</a></li>
210 <li><a href="../www/api/fourier.html">Compute the discrete Fourier transform (DFT)</a></li>
211 <li><a href="../www/api/compare.html">Compare an Image to a Reconstructed Image</a></li>
212 <li><a href="../www/api/display.html">Interactively Display and Edit an Image</a></li>
213 <li><a href="../www/api/animate.html">Interactively Animate an Image Sequence</a></li>
214 <li><a href="../www/api/cipher.html">Convert to and from Cipher Pixels</a></li>
215 <li><a href="../www/api/list.html">Working with Image Lists</a></li>
cristy10c87152010-06-26 16:12:21 +0000216 <li><a href="../www/api/image-view.html">Image View Methods</a></li>
cristy3ed852e2009-09-05 21:47:34 +0000217 <li><a href="../www/api/cache.html">Get or Set Image Pixels</a></li>
218 <li><a href="../www/api/cache-view.html">Working with Cache Views</a></li>
219 <li><a href="../www/api/stream.html">The Pixel FIFO</a></li>
220 <li><a href="../www/api/blob.html">Read or Write Binary Large OBjects</a></li>
221 <li><a href="../www/api/module.html">Loadable Modules</a></li>
222 <li><a href="../www/api/signature.html">Compute a Message Digest for an Image</a></li>
223 <li><a href="../www/api/registry.html">The Image Registry</a></li>
224 <li><a href="../www/api/exception.html">Dealing with Exceptions</a></li>
225 <li><a href="../www/api/memory.html">Memory Allocation</a></li>
226 <li><a href="../www/api/resource.html">Monitor or Limit Resource Consumption</a></li>
227 <li><a href="../www/api/monitor.html">Monitor the Progress of an Image Operation</a></li>
228 <li><a href="../www/api/version.html">Get the Version and Copyrights</a></li>
229 <li><a href="../www/api/deprecate.html">Deprecated Methods</a></li>
230 <li><a href="../www/exception.html">Error and Warning Codes</a></li>
231</ul>
232
233<p>After you write your MagickCore program, compile it like this:</p>
234
cristyd4d64ed2010-08-22 22:19:33 +0000235<p class='crt'><span class="crtprompt"> $magick&gt; </span><span class='crtin'>cc `MagickCore-config --cflags --cppflags` -O2 core.c \ <br/> `MagickCore-config --ldflags --libs`</span></p>
cristy3ed852e2009-09-05 21:47:34 +0000236<p>Here is a example program that utilizes the MagickCore API to get you started, <a href="../www/source/core.c">core.c</a>. It reads a GIF image, creates a thumbnail, and writes it to disk in the PNG image format.</p>
237
238<div class="viewport">
239<pre class="code">
240 #include &lt;stdio.h>
241 #include &lt;stdlib.h>
242 #include &lt;string.h>
243 #include &lt;time.h>
244 #include &lt;magick/MagickCore.h>
245
246 int main(int argc,char **argv)
247 {
248 ExceptionInfo
249 *exception;
250
251 Image
252 *image,
253 *images,
254 *resize_image,
255 *thumbnails;
256
257 ImageInfo
258 *image_info;
259
260 if (argc != 3)
261 {
262 (void) fprintf(stdout,"Usage: %s image thumbnail\n",argv[0]);
263 exit(0);
264 }
265 /*
266 Initialize the image info structure and read an image.
267 */
268 MagickCoreGenesis(*argv,MagickTrue);
269 exception=AcquireExceptionInfo();
270 image_info=CloneImageInfo((ImageInfo *) NULL);
271 (void) strcpy(image_info-&gt;filename,argv[1]);
272 images=ReadImage(image_info,exception);
273 if (exception-&gt;severity != UndefinedException)
274 CatchException(exception);
275 if (images == (Image *) NULL)
276 exit(1);
277 /*
278 Convert the image to a thumbnail.
279 */
280 thumbnails=NewImageList();
281 while ((image=RemoveFirstImageFromList(&amp;images)) != (Image *) NULL)
282 {
283 resize_image=ResizeImage(image,106,80,LanczosFilter,1.0,exception);
284 if (resize_image == (Image *) NULL)
285 MagickError(exception-&gt;severity,exception-&gt;reason,exception-&gt;description);
286 (void) AppendImageToList(&amp;thumbnails,resize_image);
287 DestroyImage(image);
288 }
289 /*
290 Write the image thumbnail.
291 */
292 (void) strcpy(thumbnails-&gt;filename,argv[2]);
293 WriteImage(image_info,thumbnails);
294 /*
295 Destroy the image thumbnail and exit.
296 */
297 thumbnails=DestroyImageList(thumbnails);
298 image_info=DestroyImageInfo(image_info);
299 exception=DestroyExceptionInfo(exception);
300 MagickCoreTerminus();
301 return(0);
302 }
303</pre>
304</div>
cristydcca3fa2010-12-29 21:50:07 +0000305<p><a id="image-view"></a>Now lets perform the same contrast enhancement while taking advantage of our dual or quad-core processing system by running the algorithm in parallel utilizing wand views. The <a href="../www/source/core/sigmoidal-contrast.c">sigmoidal-contrast.c</a> module reads an image, applies sigmoidal non-linearity contrast control, and writes the result to disk just like the previous contrast enhancement program, but now it does its work in parallel (assumes ImageMagick is built with OpenMP support).</p>
cristy10c87152010-06-26 16:12:21 +0000306
307<div class="viewport">
308<pre class="code">
309#include &lt;stdio.h>
310#include &lt;stdlib.h>
311#include &lt;math.h>
cristy73b7d4c2010-06-27 00:31:00 +0000312#include &lt;magick/MagickCore.h>
cristy10c87152010-06-26 16:12:21 +0000313
cristy73b7d4c2010-06-27 00:31:00 +0000314static MagickBooleanType SigmoidalContrast(ImageView *contrast_view,
cristyc3ebda22010-06-27 17:11:57 +0000315 const ssize_t y,const int id,void *context)
cristy10c87152010-06-26 16:12:21 +0000316{
317#define QuantumScale ((MagickRealType) 1.0/(MagickRealType) QuantumRange)
318#define SigmoidalContrast(x) \
319 (QuantumRange*(1.0/(1+exp(10.0*(0.5-QuantumScale*x)))-0.0066928509)*1.0092503)
320
cristyc3ebda22010-06-27 17:11:57 +0000321 RectangleInfo
322 extent;
323
cristy73b7d4c2010-06-27 00:31:00 +0000324 register IndexPacket
325 *indexes;
cristy10c87152010-06-26 16:12:21 +0000326
cristy73b7d4c2010-06-27 00:31:00 +0000327 register PixelPacket
328 *pixels;
cristy10c87152010-06-26 16:12:21 +0000329
cristy73b7d4c2010-06-27 00:31:00 +0000330 register ssize_t
cristy10c87152010-06-26 16:12:21 +0000331 x;
332
cristyc3ebda22010-06-27 17:11:57 +0000333 extent=GetImageViewExtent(contrast_view);
cristy73b7d4c2010-06-27 00:31:00 +0000334 pixels=GetImageViewAuthenticPixels(contrast_view);
cristyc3ebda22010-06-27 17:11:57 +0000335 for (x=0; x &lt; (ssize_t) (extent.width-extent.x); x++)
cristy10c87152010-06-26 16:12:21 +0000336 {
cristy73b7d4c2010-06-27 00:31:00 +0000337 pixels[x].red=RoundToQuantum(SigmoidalContrast(pixels[x].red));
338 pixels[x].green=RoundToQuantum(SigmoidalContrast(pixels[x].green));
339 pixels[x].blue=RoundToQuantum(SigmoidalContrast(pixels[x].blue));
340 pixels[x].opacity=RoundToQuantum(SigmoidalContrast(pixels[x].opacity));
cristy10c87152010-06-26 16:12:21 +0000341 }
cristy73b7d4c2010-06-27 00:31:00 +0000342 indexes=GetImageViewAuthenticIndexes(contrast_view);
343 if (indexes != (IndexPacket *) NULL)
cristyc3ebda22010-06-27 17:11:57 +0000344 for (x=0; x &lt; (ssize_t) (extent.width-extent.x); x++)
cristy73b7d4c2010-06-27 00:31:00 +0000345 indexes[x]=(IndexPacket) RoundToQuantum(SigmoidalContrast(indexes[x]));
cristy10c87152010-06-26 16:12:21 +0000346 return(MagickTrue);
347}
348
349int main(int argc,char **argv)
350{
351#define ThrowImageException(image) \
352{ \
cristy10c87152010-06-26 16:12:21 +0000353 \
cristy73b7d4c2010-06-27 00:31:00 +0000354 CatchException(exception); \
355 if (contrast_image != (Image *) NULL) \
356 contrast_image=DestroyImage(contrast_image); \
cristyc3ebda22010-06-27 17:11:57 +0000357 exit(-1); \
358}
359#define ThrowViewException(view) \
360{ \
361 char \
362 *description; \
363 \
364 ExceptionType \
365 severity; \
366 \
cristydcca3fa2010-12-29 21:50:07 +0000367 description=GetImageViewException(view,&amp;severity); \
cristyc3ebda22010-06-27 17:11:57 +0000368 (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); \
369 description=DestroyString(description); \
cristy10c87152010-06-26 16:12:21 +0000370 exit(-1); \
371}
372
cristy73b7d4c2010-06-27 00:31:00 +0000373 ExceptionInfo
374 *exception;
375
376 Image
377 *contrast_image;
378
379 ImageInfo
380 *image_info;
381
cristy10c87152010-06-26 16:12:21 +0000382 ImageView
383 *contrast_view;
384
385 MagickBooleanType
386 status;
387
cristy10c87152010-06-26 16:12:21 +0000388 if (argc != 3)
389 {
390 (void) fprintf(stdout,"Usage: %s image sigmoidal-image\n",argv[0]);
391 exit(0);
392 }
393 /*
394 Read an image.
395 */
cristy73b7d4c2010-06-27 00:31:00 +0000396 MagickCoreGenesis(*argv,MagickTrue);
397 image_info=AcquireImageInfo();
398 (void) CopyMagickString(image_info->filename,argv[1],MaxTextExtent);
399 exception=AcquireExceptionInfo();
400 contrast_image=ReadImage(image_info,exception);
401 if (contrast_image == (Image *) NULL)
402 ThrowImageException(contrast_image);
cristy10c87152010-06-26 16:12:21 +0000403 /*
404 Sigmoidal non-linearity contrast control.
405 */
406 contrast_view=NewImageView(contrast_image);
407 if (contrast_view == (ImageView *) NULL)
cristy73b7d4c2010-06-27 00:31:00 +0000408 ThrowImageException(contrast_image);
cristy10c87152010-06-26 16:12:21 +0000409 status=UpdateImageViewIterator(contrast_view,SigmoidalContrast,(void *) NULL);
410 if (status == MagickFalse)
cristy73b7d4c2010-06-27 00:31:00 +0000411 ThrowImageException(contrast_image);
cristy10c87152010-06-26 16:12:21 +0000412 contrast_view=DestroyImageView(contrast_view);
413 /*
414 Write the image then destroy it.
415 */
cristy73b7d4c2010-06-27 00:31:00 +0000416 status=WriteImages(image_info,contrast_image,argv[2],exception);
cristy10c87152010-06-26 16:12:21 +0000417 if (status == MagickFalse)
cristy73b7d4c2010-06-27 00:31:00 +0000418 ThrowImageException(contrast_image);
419 contrast_image=DestroyImage(contrast_image);
420 exception=DestroyExceptionInfo(exception);
421 image_info=DestroyImageInfo(image_info);
cristy10c87152010-06-26 16:12:21 +0000422 MagickCoreTerminus();
423 return(0);
424}
425</pre>
426</div>
cristydcca3fa2010-12-29 21:50:07 +0000427</div>
cristy3eaa0ef2010-03-06 20:35:26 +0000428
429</div>
430
431<div id="linkbar">
cristyce69bb02010-07-27 19:49:46 +0000432 <span id="linkbar-west">&nbsp;</span>
cristy3eaa0ef2010-03-06 20:35:26 +0000433 <span id="linkbar-center">
434 <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;
cristya8902942010-07-30 00:49:52 +0000435 <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>
cristy3eaa0ef2010-03-06 20:35:26 +0000436 </span>
437 <span id="linkbar-east">&nbsp;</span>
438 </div>
439 <div class="footer">
cristy7e41fe82010-12-04 23:12:08 +0000440 <span id="footer-west">&copy; 1999-2011 ImageMagick Studio LLC</span>
cristy3eaa0ef2010-03-06 20:35:26 +0000441 <span id="footer-east"> <a href="http://www.imagemagick.org/script/contact.php">Contact the Wizards</a></span>
442 </div>
443 <div style="clear: both; margin: 0; width: 100%; "></div>
cristya8902942010-07-30 00:49:52 +0000444 <script type="text/javascript">
445 var _gaq = _gaq || [];
446 _gaq.push(['_setAccount', 'UA-17690367-1']);
447 _gaq.push(['_trackPageview']);
448
449 (function() {
450 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
451 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
452 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
453 })();
454 </script>
cristy3eaa0ef2010-03-06 20:35:26 +0000455</body>
456</html>