8 <meta charset="utf-8" />
9 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
10 <title>MagickCore, C API: Get or Set Image Pixels @ ImageMagick</title>
11 <meta name="application-name" content="ImageMagick" />
12 <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." />
13 <meta name="application-url" content="https://www.imagemagick.org" />
14 <meta name="generator" content="PHP" />
15 <meta name="keywords" content="magickcore, c, api:, get, or, set, image, pixels, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert" />
16 <meta name="rating" content="GENERAL" />
17 <meta name="robots" content="INDEX, FOLLOW" />
18 <meta name="generator" content="ImageMagick Studio LLC" />
19 <meta name="author" content="ImageMagick Studio LLC" />
20 <meta name="revisit-after" content="2 DAYS" />
21 <meta name="resource-type" content="document" />
22 <meta name="copyright" content="Copyright (c) 1999-2018 ImageMagick Studio LLC" />
23 <meta name="distribution" content="Global" />
24 <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1" />
25 <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
26 <link href="https://www.imagemagick.org/api/cache.html" rel="canonical" />
27 <link href="../images/wand.png" rel="icon" />
28 <link href="../images/wand.ico" rel="shortcut icon" />
29 <link href="../css/magick.html" rel="stylesheet" />
32 <div class="magick-masthead">
33 <div class="container">
34 <script async="async" src="http://localhost/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle"
36 data-ad-client="ca-pub-3129977114552745"
37 data-ad-slot="6345125851"
38 data-ad-format="auto"></ins>
40 (adsbygoogle = window.adsbygoogle || []).push({});
42 <nav class="nav magick-nav">
43 <a class="nav-link " href="../index.html">Home</a>
44 <a class="nav-link " href="../download.html">Download</a>
45 <a class="nav-link " href="../command-line-tools.html">Tools</a>
46 <a class="nav-link " href="../command-line-processing.html">Command-line</a>
47 <a class="nav-link " href="../resources.html">Resources</a>
48 <a class="nav-link " href="../develop.html">Develop</a>
49 <a class="nav-link " href="https://www.imagemagick.org/script/search.php">Search</a>
50 <a class="nav-link float-right" href="https://www.imagemagick.org/discourse-server/">Community</a>
54 <div class="container">
55 <div class="magick-header">
56 <p class="text-center"><a href="cache.html#AcquirePixelCacheNexus">AcquirePixelCacheNexus</a> • <a href="cache.html#GetAuthenticMetacontent">GetAuthenticMetacontent</a> • <a href="cache.html#GetAuthenticPixelQueue">GetAuthenticPixelQueue</a> • <a href="cache.html#GetAuthenticPixels">GetAuthenticPixels</a> • <a href="cache.html#GetOneAuthenticPixel">GetOneAuthenticPixel</a> • <a href="cache.html#GetOneVirtualPixel">GetOneVirtualPixel</a> • <a href="cache.html#GetOneVirtualPixelInfo">GetOneVirtualPixelInfo</a> • <a href="cache.html#GetVirtualMetacontent">GetVirtualMetacontent</a> • <a href="cache.html#GetVirtualPixelQueue">GetVirtualPixelQueue</a> • <a href="cache.html#GetVirtualPixels">GetVirtualPixels</a> • <a href="cache.html#QueueAuthenticPixels">QueueAuthenticPixels</a> • <a href="cache.html#SetPixelCacheVirtualMethod">SetPixelCacheVirtualMethod</a> • <a href="cache.html#SyncAuthenticPixels">SyncAuthenticPixels</a></p>
58 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="AcquirePixelCacheNexus">AcquirePixelCacheNexus</a></h2>
60 <p>AcquirePixelCacheNexus() allocates the NexusInfo structure.</p>
62 <p>The format of the AcquirePixelCacheNexus method is:</p>
65 NexusInfo **AcquirePixelCacheNexus(const size_t number_threads)
68 <p>A description of each parameter follows:</p>
74 <dl class="dl-horizontal">
75 <dt>number_threads</dt>
76 <dd>the number of nexus threads. </dd>
80 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetAuthenticMetacontent">GetAuthenticMetacontent</a></h2>
82 <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>
84 <p>The format of the GetAuthenticMetacontent() method is:</p>
87 void *GetAuthenticMetacontent(const Image *image)
90 <p>A description of each parameter follows:</p>
96 <dl class="dl-horizontal">
102 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetAuthenticPixelQueue">GetAuthenticPixelQueue</a></h2>
104 <p>GetAuthenticPixelQueue() returns the authentic pixels associated corresponding with the last call to QueueAuthenticPixels() or GetAuthenticPixels().</p>
106 <p>The format of the GetAuthenticPixelQueue() method is:</p>
109 Quantum *GetAuthenticPixelQueue(const Image image)
112 <p>A description of each parameter follows:</p>
118 <dl class="dl-horizontal">
124 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetAuthenticPixels">GetAuthenticPixels</a></h2>
126 <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>
128 <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>
130 <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>
132 <p>The format of the GetAuthenticPixels() method is:</p>
135 Quantum *GetAuthenticPixels(Image *image,const ssize_t x,
136 const ssize_t y,const size_t columns,const size_t rows,
137 ExceptionInfo *exception)
140 <p>A description of each parameter follows:</p>
146 <dl class="dl-horizontal">
151 <dt>x,y,columns,rows</dt>
152 <dd> These values define the perimeter of a region of pixels. </dd>
156 <dd>return any errors or warnings in this structure. </dd>
160 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetOneAuthenticPixel">GetOneAuthenticPixel</a></h2>
162 <p>GetOneAuthenticPixel() returns a single pixel at the specified (x,y) location. The image background color is returned if an error occurs.</p>
164 <p>The format of the GetOneAuthenticPixel() method is:</p>
167 MagickBooleanType GetOneAuthenticPixel(const Image image,const ssize_t x,
168 const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
171 <p>A description of each parameter follows:</p>
177 <dl class="dl-horizontal">
183 <dd> These values define the location of the pixel to return. </dd>
187 <dd>return a pixel at the specified (x,y) location. </dd>
191 <dd>return any errors or warnings in this structure. </dd>
195 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetOneVirtualPixel">GetOneVirtualPixel</a></h2>
197 <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>
199 <p>The format of the GetOneVirtualPixel() method is:</p>
202 MagickBooleanType GetOneVirtualPixel(const Image image,const ssize_t x,
203 const ssize_t y,Quantum *pixel,ExceptionInfo exception)
206 <p>A description of each parameter follows:</p>
212 <dl class="dl-horizontal">
218 <dd> These values define the location of the pixel to return. </dd>
222 <dd>return a pixel at the specified (x,y) location. </dd>
226 <dd>return any errors or warnings in this structure. </dd>
230 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetOneVirtualPixelInfo">GetOneVirtualPixelInfo</a></h2>
232 <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>
234 <p>The format of the GetOneVirtualPixelInfo() method is:</p>
237 MagickBooleanType GetOneVirtualPixelInfo(const Image image,
238 const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
239 const ssize_t y,PixelInfo *pixel,ExceptionInfo exception)
242 <p>A description of each parameter follows:</p>
248 <dl class="dl-horizontal">
253 <dt>virtual_pixel_method</dt>
254 <dd>the virtual pixel method. </dd>
258 <dd> these values define the location of the pixel to return. </dd>
262 <dd>return a pixel at the specified (x,y) location. </dd>
266 <dd>return any errors or warnings in this structure. </dd>
270 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetVirtualMetacontent">GetVirtualMetacontent</a></h2>
272 <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>
274 <p>The format of the GetVirtualMetacontent() method is:</p>
277 const void *GetVirtualMetacontent(const Image *image)
280 <p>A description of each parameter follows:</p>
286 <dl class="dl-horizontal">
292 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetVirtualPixelQueue">GetVirtualPixelQueue</a></h2>
294 <p>GetVirtualPixelQueue() returns the virtual pixels associated corresponding with the last call to QueueAuthenticPixels() or GetVirtualPixels().</p>
296 <p>The format of the GetVirtualPixelQueue() method is:</p>
299 const Quantum *GetVirtualPixelQueue(const Image image)
302 <p>A description of each parameter follows:</p>
308 <dl class="dl-horizontal">
314 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetVirtualPixels">GetVirtualPixels</a></h2>
316 <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>
318 <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>
320 <p>If you plan to modify the pixels, use GetAuthenticPixels() instead.</p>
322 <p>Note, the GetVirtualPixels() and GetAuthenticPixels() methods are not thread- safe. In a threaded environment, use GetCacheViewVirtualPixels() or GetCacheViewAuthenticPixels() instead.</p>
324 <p>The format of the GetVirtualPixels() method is:</p>
327 const Quantum *GetVirtualPixels(const Image *image,const ssize_t x,
328 const ssize_t y,const size_t columns,const size_t rows,
329 ExceptionInfo *exception)
332 <p>A description of each parameter follows:</p>
338 <dl class="dl-horizontal">
343 <dt>x,y,columns,rows</dt>
344 <dd> These values define the perimeter of a region of pixels. </dd>
348 <dd>return any errors or warnings in this structure. </dd>
352 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="QueueAuthenticPixels">QueueAuthenticPixels</a></h2>
354 <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>
356 <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>
358 <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>
360 <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>
362 <p>The format of the QueueAuthenticPixels() method is:</p>
365 Quantum *QueueAuthenticPixels(Image *image,const ssize_t x,
366 const ssize_t y,const size_t columns,const size_t rows,
367 ExceptionInfo *exception)
370 <p>A description of each parameter follows:</p>
376 <dl class="dl-horizontal">
381 <dt>x,y,columns,rows</dt>
382 <dd> These values define the perimeter of a region of pixels. </dd>
386 <dd>return any errors or warnings in this structure. </dd>
390 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="SetPixelCacheVirtualMethod">SetPixelCacheVirtualMethod</a></h2>
392 <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>
394 <p>The format of the SetPixelCacheVirtualMethod() method is:</p>
397 VirtualPixelMethod SetPixelCacheVirtualMethod(Image *image,
398 const VirtualPixelMethod virtual_pixel_method,ExceptionInfo *exception)
401 <p>A description of each parameter follows:</p>
407 <dl class="dl-horizontal">
412 <dt>virtual_pixel_method</dt>
413 <dd>choose the type of virtual pixel. </dd>
417 <dd>return any errors or warnings in this structure. </dd>
421 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="SyncAuthenticPixels">SyncAuthenticPixels</a></h2>
423 <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>
425 <p>The format of the SyncAuthenticPixels() method is:</p>
428 MagickBooleanType SyncAuthenticPixels(Image *image,
429 ExceptionInfo *exception)
432 <p>A description of each parameter follows:</p>
438 <dl class="dl-horizontal">
444 <dd>return any errors or warnings in this structure. </dd>
449 <footer class="magick-footer">
450 <p><a href="../support.html">Donate</a> •
451 <a href="../sitemap.html">Sitemap</a> •
452 <a href="../links.html">Related</a> •
453 <a href="../security-policy.html">Security</a> •
454 <a href="../architecture.html">Architecture</a>
456 <p><a href="cache.html#">Back to top</a> •
457 <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x89AB63D48277377A">Public Key</a> •
458 <a href="https://www.imagemagick.org/script/contact.php">Contact Us</a></p>
459 <p><small>© 1999-2018 ImageMagick Studio LLC</small></p>
461 </div><!-- /.container -->
463 <script src="https://localhost/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
464 <script src="../js/magick.html"></script>