• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2
3
4
5<!DOCTYPE html>
6<html lang="en">
7<head>
8    <title>ImageMagick: MagickCore, C API for ImageMagick: Get or Set Image Pixels</title>
9  <meta charset="utf-8" />
10  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
11  <meta name="viewport" content="width=device-width, initial-scale=1" />
12  <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
13  <meta name="application-name" content="ImageMagick"/>
14  <meta name="description" content="ImageMagick® is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, JPEG-2000, GIF, WebP, Postscript, PDF, and SVG. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves."/>
15  <meta name="application-url" content="http://www.imagemagick.org"/>
16  <meta name="generator" content="PHP"/>
17  <meta name="keywords" content="magickcore, c, api, for, imagemagick:, get, or, set, image, pixels, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert"/>
18  <meta name="rating" content="GENERAL"/>
19  <meta name="robots" content="INDEX, FOLLOW"/>
20  <meta name="generator" content="ImageMagick Studio LLC"/>
21  <meta name="author" content="ImageMagick Studio LLC"/>
22  <meta name="revisit-after" content="2 DAYS"/>
23  <meta name="resource-type" content="document"/>
24  <meta name="copyright" content="Copyright (c) 1999-2016 ImageMagick Studio LLC"/>
25  <meta name="distribution" content="Global"/>
26  <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1"/>
27  <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
28  <link rel="icon" href="../images/wand.png"/>
29  <link rel="shortcut icon" href="../images/wand.ico"/>
30  <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Roboto:900,400,400italic,700,700italic,300,300italic|Open+Sans:300italic,400italic,700italic,300,400,600,700">
31  <link rel="stylesheet" href="../css/magick.html"/>
32</head>
33<body>
34<div class="main">
35<div class="magick-masthead">
36  <div class="container">
37    <script async="async" src="http://localhost/pagead/js/adsbygoogle.js"></script>    <ins class="adsbygoogle"
38         style="display:block"
39         data-ad-client="ca-pub-3129977114552745"
40         data-ad-slot="6345125851"
41         data-ad-format="auto"></ins>
42    <script>
43      (adsbygoogle = window.adsbygoogle || []).push({});
44    </script>
45    <nav class="magick-nav">
46      <a class="magick-nav-item " href="../index.html">Home</a>
47      <a class="magick-nav-item " href="../binary-releases.html">Download</a>
48      <a class="magick-nav-item " href="../command-line-tools.html">Tools</a>
49      <a class="magick-nav-item " href="../command-line-processing.html">Command-line</a>
50      <a class="magick-nav-item " href="../resources.html">Resources</a>
51      <a class="magick-nav-item " href="api.html">Develop</a>
52      <a class="magick-nav-item " href="http://www.imagemagick.org/script/search.php">Search</a>
53      <a class="magick-nav-item pull-right" href="https://www.imagemagick.org/discourse-server/">Community</a>
54    </nav>
55  </div>
56</div>
57<div class="container">
58<div class="magick-header">
59<p class="text-center"><a href="cache.html#AcquirePixelCacheNexus">AcquirePixelCacheNexus</a> &#8226; <a href="cache.html#GetAuthenticMetacontent">GetAuthenticMetacontent</a> &#8226; <a href="cache.html#GetAuthenticPixelQueue">GetAuthenticPixelQueue</a> &#8226; <a href="cache.html#GetAuthenticPixels">GetAuthenticPixels</a> &#8226; <a href="cache.html#GetOneAuthenticPixel">GetOneAuthenticPixel</a> &#8226; <a href="cache.html#GetOneVirtualPixel">GetOneVirtualPixel</a> &#8226; <a href="cache.html#GetOneVirtualPixelInfo">GetOneVirtualPixelInfo</a> &#8226; <a href="cache.html#GetVirtualMetacontent">GetVirtualMetacontent</a> &#8226; <a href="cache.html#GetVirtualPixelQueue">GetVirtualPixelQueue</a> &#8226; <a href="cache.html#GetVirtualPixels">GetVirtualPixels</a> &#8226; <a href="cache.html#QueueAuthenticPixels">QueueAuthenticPixels</a> &#8226; <a href="cache.html#SetPixelCacheVirtualMethod">SetPixelCacheVirtualMethod</a> &#8226; <a href="cache.html#SyncAuthenticPixels">SyncAuthenticPixels</a></p>
60
61<h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="AcquirePixelCacheNexus">AcquirePixelCacheNexus</a></h2>
62
63<p>AcquirePixelCacheNexus() allocates the NexusInfo structure.</p>
64
65<p>The format of the AcquirePixelCacheNexus method is:</p>
66
67<pre class="text">
68NexusInfo **AcquirePixelCacheNexus(const size_t number_threads)
69</pre>
70
71<p>A description of each parameter follows:</p>
72
73<dd>
74</dd>
75
76<dd> </dd>
77<dl class="dl-horizontal">
78<dt>number_threads</dt>
79<dd>the number of nexus threads. </dd>
80
81<dd>  </dd>
82</dl>
83<h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetAuthenticMetacontent">GetAuthenticMetacontent</a></h2>
84
85<p>GetAuthenticMetacontent() returns the authentic metacontent corresponding with the last call to QueueAuthenticPixels() or GetVirtualPixels().  NULL is returned if the associated pixels are not available.</p>
86
87<p>The format of the GetAuthenticMetacontent() method is:</p>
88
89<pre class="text">
90void *GetAuthenticMetacontent(const Image *image)
91</pre>
92
93<p>A description of each parameter follows:</p>
94
95<dd>
96</dd>
97
98<dd> </dd>
99<dl class="dl-horizontal">
100<dt>image</dt>
101<dd>the image. </dd>
102
103<dd>  </dd>
104</dl>
105<h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetAuthenticPixelQueue">GetAuthenticPixelQueue</a></h2>
106
107<p>GetAuthenticPixelQueue() returns the authentic pixels associated corresponding with the last call to QueueAuthenticPixels() or GetAuthenticPixels().</p>
108
109<p>The format of the GetAuthenticPixelQueue() method is:</p>
110
111<pre class="text">
112Quantum *GetAuthenticPixelQueue(const Image image)
113</pre>
114
115<p>A description of each parameter follows:</p>
116
117<dd>
118</dd>
119
120<dd> </dd>
121<dl class="dl-horizontal">
122<dt>image</dt>
123<dd>the image. </dd>
124
125<dd>  </dd>
126</dl>
127<h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetAuthenticPixels">GetAuthenticPixels</a></h2>
128
129<p>GetAuthenticPixels() obtains a pixel region for read/write access. If the region is successfully accessed, a pointer to a Quantum array representing the region is returned, otherwise NULL is returned.</p>
130
131<p>The returned pointer may point to a temporary working copy of the pixels or it may point to the original pixels in memory. Performance is maximized if the selected region is part of one row, or one or more full rows, since then there is opportunity to access the pixels in-place (without a copy) if the image is in memory, or in a memory-mapped file. The returned pointer must *never* be deallocated by the user.</p>
132
133<p>Pixels accessed via the returned pointer represent a simple array of type Quantum.  If the image has corresponding metacontent,call GetAuthenticMetacontent() after invoking GetAuthenticPixels() to obtain the meta-content corresponding to the region.  Once the Quantum array has been updated, the changes must be saved back to the underlying image using SyncAuthenticPixels() or they may be lost.</p>
134
135<p>The format of the GetAuthenticPixels() method is:</p>
136
137<pre class="text">
138Quantum *GetAuthenticPixels(Image *image,const ssize_t x,
139  const ssize_t y,const size_t columns,const size_t rows,
140  ExceptionInfo *exception)
141</pre>
142
143<p>A description of each parameter follows:</p>
144
145<dd>
146</dd>
147
148<dd> </dd>
149<dl class="dl-horizontal">
150<dt>image</dt>
151<dd>the image. </dd>
152
153<dd> </dd>
154<dt>x,y,columns,rows</dt>
155<dd> These values define the perimeter of a region of pixels. </dd>
156
157<dd> </dd>
158<dt>exception</dt>
159<dd>return any errors or warnings in this structure. </dd>
160
161<dd>  </dd>
162</dl>
163<h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetOneAuthenticPixel">GetOneAuthenticPixel</a></h2>
164
165<p>GetOneAuthenticPixel() returns a single pixel at the specified (x,y) location.  The image background color is returned if an error occurs.</p>
166
167<p>The format of the GetOneAuthenticPixel() method is:</p>
168
169<pre class="text">
170MagickBooleanType GetOneAuthenticPixel(const Image image,const ssize_t x,
171  const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
172</pre>
173
174<p>A description of each parameter follows:</p>
175
176<dd>
177</dd>
178
179<dd> </dd>
180<dl class="dl-horizontal">
181<dt>image</dt>
182<dd>the image. </dd>
183
184<dd> </dd>
185<dt>x,y</dt>
186<dd> These values define the location of the pixel to return. </dd>
187
188<dd> </dd>
189<dt>pixel</dt>
190<dd>return a pixel at the specified (x,y) location. </dd>
191
192<dd> </dd>
193<dt>exception</dt>
194<dd>return any errors or warnings in this structure. </dd>
195
196<dd>  </dd>
197</dl>
198<h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetOneVirtualPixel">GetOneVirtualPixel</a></h2>
199
200<p>GetOneVirtualPixel() returns a single virtual pixel at the specified (x,y) location.  The image background color is returned if an error occurs. If you plan to modify the pixel, use GetOneAuthenticPixel() instead.</p>
201
202<p>The format of the GetOneVirtualPixel() method is:</p>
203
204<pre class="text">
205MagickBooleanType GetOneVirtualPixel(const Image image,const ssize_t x,
206  const ssize_t y,Quantum *pixel,ExceptionInfo exception)
207</pre>
208
209<p>A description of each parameter follows:</p>
210
211<dd>
212</dd>
213
214<dd> </dd>
215<dl class="dl-horizontal">
216<dt>image</dt>
217<dd>the image. </dd>
218
219<dd> </dd>
220<dt>x,y</dt>
221<dd> These values define the location of the pixel to return. </dd>
222
223<dd> </dd>
224<dt>pixel</dt>
225<dd>return a pixel at the specified (x,y) location. </dd>
226
227<dd> </dd>
228<dt>exception</dt>
229<dd>return any errors or warnings in this structure. </dd>
230
231<dd>  </dd>
232</dl>
233<h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetOneVirtualPixelInfo">GetOneVirtualPixelInfo</a></h2>
234
235<p>GetOneVirtualPixelInfo() returns a single pixel at the specified (x,y) location.  The image background color is returned if an error occurs.  If you plan to modify the pixel, use GetOneAuthenticPixel() instead.</p>
236
237<p>The format of the GetOneVirtualPixelInfo() method is:</p>
238
239<pre class="text">
240MagickBooleanType GetOneVirtualPixelInfo(const Image image,
241  const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
242  const ssize_t y,PixelInfo *pixel,ExceptionInfo exception)
243</pre>
244
245<p>A description of each parameter follows:</p>
246
247<dd>
248</dd>
249
250<dd> </dd>
251<dl class="dl-horizontal">
252<dt>image</dt>
253<dd>the image. </dd>
254
255<dd> </dd>
256<dt>virtual_pixel_method</dt>
257<dd>the virtual pixel method. </dd>
258
259<dd> </dd>
260<dt>x,y</dt>
261<dd> these values define the location of the pixel to return. </dd>
262
263<dd> </dd>
264<dt>pixel</dt>
265<dd>return a pixel at the specified (x,y) location. </dd>
266
267<dd> </dd>
268<dt>exception</dt>
269<dd>return any errors or warnings in this structure. </dd>
270
271<dd>  </dd>
272</dl>
273<h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetVirtualMetacontent">GetVirtualMetacontent</a></h2>
274
275<p>GetVirtualMetacontent() returns the virtual metacontent corresponding with the last call to QueueAuthenticPixels() or GetVirtualPixels().  NULL is returned if the meta-content are not available.</p>
276
277<p>The format of the GetVirtualMetacontent() method is:</p>
278
279<pre class="text">
280const void *GetVirtualMetacontent(const Image *image)
281</pre>
282
283<p>A description of each parameter follows:</p>
284
285<dd>
286</dd>
287
288<dd> </dd>
289<dl class="dl-horizontal">
290<dt>image</dt>
291<dd>the image. </dd>
292
293<dd>  </dd>
294</dl>
295<h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetVirtualPixelQueue">GetVirtualPixelQueue</a></h2>
296
297<p>GetVirtualPixelQueue() returns the virtual pixels associated corresponding with the last call to QueueAuthenticPixels() or GetVirtualPixels().</p>
298
299<p>The format of the GetVirtualPixelQueue() method is:</p>
300
301<pre class="text">
302const Quantum *GetVirtualPixelQueue(const Image image)
303</pre>
304
305<p>A description of each parameter follows:</p>
306
307<dd>
308</dd>
309
310<dd> </dd>
311<dl class="dl-horizontal">
312<dt>image</dt>
313<dd>the image. </dd>
314
315<dd>  </dd>
316</dl>
317<h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetVirtualPixels">GetVirtualPixels</a></h2>
318
319<p>GetVirtualPixels() returns an immutable pixel region. If the region is successfully accessed, a pointer to it is returned, otherwise NULL is returned.  The returned pointer may point to a temporary working copy of the pixels or it may point to the original pixels in memory. Performance is maximized if the selected region is part of one row, or one or more full rows, since there is opportunity to access the pixels in-place (without a copy) if the image is in memory, or in a memory-mapped file.  The returned pointer must *never* be deallocated by the user.</p>
320
321<p>Pixels accessed via the returned pointer represent a simple array of type Quantum.  If the image type is CMYK or the storage class is PseudoClass, call GetAuthenticMetacontent() after invoking GetAuthenticPixels() to access the meta-content (of type void) corresponding to the the region.</p>
322
323<p>If you plan to modify the pixels, use GetAuthenticPixels() instead.</p>
324
325<p>Note, the GetVirtualPixels() and GetAuthenticPixels() methods are not thread- safe.  In a threaded environment, use GetCacheViewVirtualPixels() or GetCacheViewAuthenticPixels() instead.</p>
326
327<p>The format of the GetVirtualPixels() method is:</p>
328
329<pre class="text">
330const Quantum *GetVirtualPixels(const Image *image,const ssize_t x,
331  const ssize_t y,const size_t columns,const size_t rows,
332  ExceptionInfo *exception)
333</pre>
334
335<p>A description of each parameter follows:</p>
336
337<dd>
338</dd>
339
340<dd> </dd>
341<dl class="dl-horizontal">
342<dt>image</dt>
343<dd>the image. </dd>
344
345<dd> </dd>
346<dt>x,y,columns,rows</dt>
347<dd> These values define the perimeter of a region of pixels. </dd>
348
349<dd> </dd>
350<dt>exception</dt>
351<dd>return any errors or warnings in this structure. </dd>
352
353<dd>  </dd>
354</dl>
355<h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="QueueAuthenticPixels">QueueAuthenticPixels</a></h2>
356
357<p>QueueAuthenticPixels() queues a mutable pixel region.  If the region is successfully initialized a pointer to a Quantum array representing the region is returned, otherwise NULL is returned.  The returned pointer may point to a temporary working buffer for the pixels or it may point to the final location of the pixels in memory.</p>
358
359<p>Write-only access means that any existing pixel values corresponding to the region are ignored.  This is useful if the initial image is being created from scratch, or if the existing pixel values are to be completely replaced without need to refer to their pre-existing values. The application is free to read and write the pixel buffer returned by QueueAuthenticPixels() any way it pleases. QueueAuthenticPixels() does not initialize the pixel array values. Initializing pixel array values is the application's responsibility.</p>
360
361<p>Performance is maximized if the selected region is part of one row, or one or more full rows, since then there is opportunity to access the pixels in-place (without a copy) if the image is in memory, or in a memory-mapped file. The returned pointer must *never* be deallocated by the user.</p>
362
363<p>Pixels accessed via the returned pointer represent a simple array of type Quantum. If the image type is CMYK or the storage class is PseudoClass, call GetAuthenticMetacontent() after invoking GetAuthenticPixels() to obtain the meta-content (of type void) corresponding to the region. Once the Quantum (and/or Quantum) array has been updated, the changes must be saved back to the underlying image using SyncAuthenticPixels() or they may be lost.</p>
364
365<p>The format of the QueueAuthenticPixels() method is:</p>
366
367<pre class="text">
368Quantum *QueueAuthenticPixels(Image *image,const ssize_t x,
369  const ssize_t y,const size_t columns,const size_t rows,
370  ExceptionInfo *exception)
371</pre>
372
373<p>A description of each parameter follows:</p>
374
375<dd>
376</dd>
377
378<dd> </dd>
379<dl class="dl-horizontal">
380<dt>image</dt>
381<dd>the image. </dd>
382
383<dd> </dd>
384<dt>x,y,columns,rows</dt>
385<dd> These values define the perimeter of a region of pixels. </dd>
386
387<dd> </dd>
388<dt>exception</dt>
389<dd>return any errors or warnings in this structure. </dd>
390
391<dd>  </dd>
392</dl>
393<h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="SetPixelCacheVirtualMethod">SetPixelCacheVirtualMethod</a></h2>
394
395<p>SetPixelCacheVirtualMethod() sets the "virtual pixels" method for the pixel cache and returns the previous setting.  A virtual pixel is any pixel access that is outside the boundaries of the image cache.</p>
396
397<p>The format of the SetPixelCacheVirtualMethod() method is:</p>
398
399<pre class="text">
400VirtualPixelMethod SetPixelCacheVirtualMethod(Image *image,
401  const VirtualPixelMethod virtual_pixel_method,ExceptionInfo *exception)
402</pre>
403
404<p>A description of each parameter follows:</p>
405
406<dd>
407</dd>
408
409<dd> </dd>
410<dl class="dl-horizontal">
411<dt>image</dt>
412<dd>the image. </dd>
413
414<dd> </dd>
415<dt>virtual_pixel_method</dt>
416<dd>choose the type of virtual pixel. </dd>
417
418<dd> </dd>
419<dt>exception</dt>
420<dd>return any errors or warnings in this structure. </dd>
421
422<dd>  </dd>
423</dl>
424<h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="SyncAuthenticPixels">SyncAuthenticPixels</a></h2>
425
426<p>SyncAuthenticPixels() saves the image pixels to the in-memory or disk cache. The method returns MagickTrue if the pixel region is flushed, otherwise MagickFalse.</p>
427
428<p>The format of the SyncAuthenticPixels() method is:</p>
429
430<pre class="text">
431MagickBooleanType SyncAuthenticPixels(Image *image,
432  ExceptionInfo *exception)
433</pre>
434
435<p>A description of each parameter follows:</p>
436
437<dd>
438</dd>
439
440<dd> </dd>
441<dl class="dl-horizontal">
442<dt>image</dt>
443<dd>the image. </dd>
444
445<dd> </dd>
446<dt>exception</dt>
447<dd>return any errors or warnings in this structure. </dd>
448
449<dd>  </dd>
450</dl>
451</div>
452  <footer class="magick-footer">
453    <p><a href="../support.html">Donate</a> •
454     <a href="../sitemap.html">Sitemap</a> •
455    <a href="../links.html">Related</a> •
456    <a href="../architecture.html">Architecture</a>
457</p>
458    <p><a href="cache.html#">Back to top</a> •
459    <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&amp;search=0x89AB63D48277377A">Public Key</a> •
460    <a href="http://www.imagemagick.org/script/contact.php">Contact Us</a></p>
461        <p><small>©  1999-2016 ImageMagick Studio LLC</small></p>
462  </footer>
463</div><!-- /.container -->
464
465  <script src="https://localhost/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
466  <script src="../js/magick.html"></script>
467</div>
468</body>
469</html>
470