]> granicus.if.org Git - imagemagick/blob - www/api/cache.html
...
[imagemagick] / www / api / cache.html
1
2
3
4
5 <!DOCTYPE html>
6 <html lang="en">
7 <head>
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" />
30 </head>
31 <body>
32 <div class="magick-masthead">
33   <div class="container">
34     <script async="async" src="http://localhost/pagead/js/adsbygoogle.js"></script>    <ins class="adsbygoogle"
35          style="display:block"
36          data-ad-client="ca-pub-3129977114552745"
37          data-ad-slot="6345125851"
38          data-ad-format="auto"></ins>
39     <script>
40       (adsbygoogle = window.adsbygoogle || []).push({});
41     </script>
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>
51     </nav>
52   </div>
53 </div>
54 <div class="container">
55 <div class="magick-header">
56 <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>
57
58 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="AcquirePixelCacheNexus">AcquirePixelCacheNexus</a></h2>
59
60 <p>AcquirePixelCacheNexus() allocates the NexusInfo structure.</p>
61
62 <p>The format of the AcquirePixelCacheNexus method is:</p>
63
64 <pre class="text">
65 NexusInfo **AcquirePixelCacheNexus(const size_t number_threads)
66 </pre>
67
68 <p>A description of each parameter follows:</p>
69
70 <dd>
71 </dd>
72
73 <dd> </dd>
74 <dl class="dl-horizontal">
75 <dt>number_threads</dt>
76 <dd>the number of nexus threads. </dd>
77
78 <dd>  </dd>
79 </dl>
80 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetAuthenticMetacontent">GetAuthenticMetacontent</a></h2>
81
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>
83
84 <p>The format of the GetAuthenticMetacontent() method is:</p>
85
86 <pre class="text">
87 void *GetAuthenticMetacontent(const Image *image)
88 </pre>
89
90 <p>A description of each parameter follows:</p>
91
92 <dd>
93 </dd>
94
95 <dd> </dd>
96 <dl class="dl-horizontal">
97 <dt>image</dt>
98 <dd>the image. </dd>
99
100 <dd>  </dd>
101 </dl>
102 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetAuthenticPixelQueue">GetAuthenticPixelQueue</a></h2>
103
104 <p>GetAuthenticPixelQueue() returns the authentic pixels associated corresponding with the last call to QueueAuthenticPixels() or GetAuthenticPixels().</p>
105
106 <p>The format of the GetAuthenticPixelQueue() method is:</p>
107
108 <pre class="text">
109 Quantum *GetAuthenticPixelQueue(const Image image)
110 </pre>
111
112 <p>A description of each parameter follows:</p>
113
114 <dd>
115 </dd>
116
117 <dd> </dd>
118 <dl class="dl-horizontal">
119 <dt>image</dt>
120 <dd>the image. </dd>
121
122 <dd>  </dd>
123 </dl>
124 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetAuthenticPixels">GetAuthenticPixels</a></h2>
125
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>
127
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>
129
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>
131
132 <p>The format of the GetAuthenticPixels() method is:</p>
133
134 <pre class="text">
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)
138 </pre>
139
140 <p>A description of each parameter follows:</p>
141
142 <dd>
143 </dd>
144
145 <dd> </dd>
146 <dl class="dl-horizontal">
147 <dt>image</dt>
148 <dd>the image. </dd>
149
150 <dd> </dd>
151 <dt>x,y,columns,rows</dt>
152 <dd> These values define the perimeter of a region of pixels. </dd>
153
154 <dd> </dd>
155 <dt>exception</dt>
156 <dd>return any errors or warnings in this structure. </dd>
157
158 <dd>  </dd>
159 </dl>
160 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetOneAuthenticPixel">GetOneAuthenticPixel</a></h2>
161
162 <p>GetOneAuthenticPixel() returns a single pixel at the specified (x,y) location.  The image background color is returned if an error occurs.</p>
163
164 <p>The format of the GetOneAuthenticPixel() method is:</p>
165
166 <pre class="text">
167 MagickBooleanType GetOneAuthenticPixel(const Image image,const ssize_t x,
168   const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
169 </pre>
170
171 <p>A description of each parameter follows:</p>
172
173 <dd>
174 </dd>
175
176 <dd> </dd>
177 <dl class="dl-horizontal">
178 <dt>image</dt>
179 <dd>the image. </dd>
180
181 <dd> </dd>
182 <dt>x,y</dt>
183 <dd> These values define the location of the pixel to return. </dd>
184
185 <dd> </dd>
186 <dt>pixel</dt>
187 <dd>return a pixel at the specified (x,y) location. </dd>
188
189 <dd> </dd>
190 <dt>exception</dt>
191 <dd>return any errors or warnings in this structure. </dd>
192
193 <dd>  </dd>
194 </dl>
195 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetOneVirtualPixel">GetOneVirtualPixel</a></h2>
196
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>
198
199 <p>The format of the GetOneVirtualPixel() method is:</p>
200
201 <pre class="text">
202 MagickBooleanType GetOneVirtualPixel(const Image image,const ssize_t x,
203   const ssize_t y,Quantum *pixel,ExceptionInfo exception)
204 </pre>
205
206 <p>A description of each parameter follows:</p>
207
208 <dd>
209 </dd>
210
211 <dd> </dd>
212 <dl class="dl-horizontal">
213 <dt>image</dt>
214 <dd>the image. </dd>
215
216 <dd> </dd>
217 <dt>x,y</dt>
218 <dd> These values define the location of the pixel to return. </dd>
219
220 <dd> </dd>
221 <dt>pixel</dt>
222 <dd>return a pixel at the specified (x,y) location. </dd>
223
224 <dd> </dd>
225 <dt>exception</dt>
226 <dd>return any errors or warnings in this structure. </dd>
227
228 <dd>  </dd>
229 </dl>
230 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetOneVirtualPixelInfo">GetOneVirtualPixelInfo</a></h2>
231
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>
233
234 <p>The format of the GetOneVirtualPixelInfo() method is:</p>
235
236 <pre class="text">
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)
240 </pre>
241
242 <p>A description of each parameter follows:</p>
243
244 <dd>
245 </dd>
246
247 <dd> </dd>
248 <dl class="dl-horizontal">
249 <dt>image</dt>
250 <dd>the image. </dd>
251
252 <dd> </dd>
253 <dt>virtual_pixel_method</dt>
254 <dd>the virtual pixel method. </dd>
255
256 <dd> </dd>
257 <dt>x,y</dt>
258 <dd> these values define the location of the pixel to return. </dd>
259
260 <dd> </dd>
261 <dt>pixel</dt>
262 <dd>return a pixel at the specified (x,y) location. </dd>
263
264 <dd> </dd>
265 <dt>exception</dt>
266 <dd>return any errors or warnings in this structure. </dd>
267
268 <dd>  </dd>
269 </dl>
270 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetVirtualMetacontent">GetVirtualMetacontent</a></h2>
271
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>
273
274 <p>The format of the GetVirtualMetacontent() method is:</p>
275
276 <pre class="text">
277 const void *GetVirtualMetacontent(const Image *image)
278 </pre>
279
280 <p>A description of each parameter follows:</p>
281
282 <dd>
283 </dd>
284
285 <dd> </dd>
286 <dl class="dl-horizontal">
287 <dt>image</dt>
288 <dd>the image. </dd>
289
290 <dd>  </dd>
291 </dl>
292 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetVirtualPixelQueue">GetVirtualPixelQueue</a></h2>
293
294 <p>GetVirtualPixelQueue() returns the virtual pixels associated corresponding with the last call to QueueAuthenticPixels() or GetVirtualPixels().</p>
295
296 <p>The format of the GetVirtualPixelQueue() method is:</p>
297
298 <pre class="text">
299 const Quantum *GetVirtualPixelQueue(const Image image)
300 </pre>
301
302 <p>A description of each parameter follows:</p>
303
304 <dd>
305 </dd>
306
307 <dd> </dd>
308 <dl class="dl-horizontal">
309 <dt>image</dt>
310 <dd>the image. </dd>
311
312 <dd>  </dd>
313 </dl>
314 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="GetVirtualPixels">GetVirtualPixels</a></h2>
315
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>
317
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>
319
320 <p>If you plan to modify the pixels, use GetAuthenticPixels() instead.</p>
321
322 <p>Note, the GetVirtualPixels() and GetAuthenticPixels() methods are not thread- safe.  In a threaded environment, use GetCacheViewVirtualPixels() or GetCacheViewAuthenticPixels() instead.</p>
323
324 <p>The format of the GetVirtualPixels() method is:</p>
325
326 <pre class="text">
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)
330 </pre>
331
332 <p>A description of each parameter follows:</p>
333
334 <dd>
335 </dd>
336
337 <dd> </dd>
338 <dl class="dl-horizontal">
339 <dt>image</dt>
340 <dd>the image. </dd>
341
342 <dd> </dd>
343 <dt>x,y,columns,rows</dt>
344 <dd> These values define the perimeter of a region of pixels. </dd>
345
346 <dd> </dd>
347 <dt>exception</dt>
348 <dd>return any errors or warnings in this structure. </dd>
349
350 <dd>  </dd>
351 </dl>
352 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="QueueAuthenticPixels">QueueAuthenticPixels</a></h2>
353
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>
355
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>
357
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>
359
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>
361
362 <p>The format of the QueueAuthenticPixels() method is:</p>
363
364 <pre class="text">
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)
368 </pre>
369
370 <p>A description of each parameter follows:</p>
371
372 <dd>
373 </dd>
374
375 <dd> </dd>
376 <dl class="dl-horizontal">
377 <dt>image</dt>
378 <dd>the image. </dd>
379
380 <dd> </dd>
381 <dt>x,y,columns,rows</dt>
382 <dd> These values define the perimeter of a region of pixels. </dd>
383
384 <dd> </dd>
385 <dt>exception</dt>
386 <dd>return any errors or warnings in this structure. </dd>
387
388 <dd>  </dd>
389 </dl>
390 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="SetPixelCacheVirtualMethod">SetPixelCacheVirtualMethod</a></h2>
391
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>
393
394 <p>The format of the SetPixelCacheVirtualMethod() method is:</p>
395
396 <pre class="text">
397 VirtualPixelMethod SetPixelCacheVirtualMethod(Image *image,
398   const VirtualPixelMethod virtual_pixel_method,ExceptionInfo *exception)
399 </pre>
400
401 <p>A description of each parameter follows:</p>
402
403 <dd>
404 </dd>
405
406 <dd> </dd>
407 <dl class="dl-horizontal">
408 <dt>image</dt>
409 <dd>the image. </dd>
410
411 <dd> </dd>
412 <dt>virtual_pixel_method</dt>
413 <dd>choose the type of virtual pixel. </dd>
414
415 <dd> </dd>
416 <dt>exception</dt>
417 <dd>return any errors or warnings in this structure. </dd>
418
419 <dd>  </dd>
420 </dl>
421 <h2><a href="http://www.imagemagick.org/api/MagickCore/cache_8c.html" id="SyncAuthenticPixels">SyncAuthenticPixels</a></h2>
422
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>
424
425 <p>The format of the SyncAuthenticPixels() method is:</p>
426
427 <pre class="text">
428 MagickBooleanType SyncAuthenticPixels(Image *image,
429   ExceptionInfo *exception)
430 </pre>
431
432 <p>A description of each parameter follows:</p>
433
434 <dd>
435 </dd>
436
437 <dd> </dd>
438 <dl class="dl-horizontal">
439 <dt>image</dt>
440 <dd>the image. </dd>
441
442 <dd> </dd>
443 <dt>exception</dt>
444 <dd>return any errors or warnings in this structure. </dd>
445
446 <dd>  </dd>
447 </dl>
448 </div>
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>
455 </p>
456     <p><a href="cache.html#">Back to top</a> •
457     <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&amp;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>
460   </footer>
461 </div><!-- /.container -->
462
463   <script src="https://localhost/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
464   <script src="../js/magick.html"></script>
465 </body>
466 </html>