1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.13.1: http://docutils.sourceforge.net/" />
<title>constitute</title>
<link rel="stylesheet" href="../docutils-api.css" type="text/css" />
</head>
<body>
<div class="banner">
<img src="../images/gm-107x76.png" alt="GraphicMagick logo" width="107" height="76" />
<span class="title">GraphicsMagick</span>
<form action="http://www.google.com/search">
<input type="hidden" name="domains" value="www.graphicsmagick.org" />
<input type="hidden" name="sitesearch" value="www.graphicsmagick.org" />
<span class="nowrap"><input type="text" name="q" size="25" maxlength="255" /> <input type="submit" name="sa" value="Search" /></span>
</form>
</div>
<div class="navmenu">
<ul>
<li><a href="../index.html">Home</a></li>
<li><a href="../project.html">Project</a></li>
<li><a href="../download.html">Download</a></li>
<li><a href="../README.html">Install</a></li>
<li><a href="../Hg.html">Source</a></li>
<li><a href="../NEWS.html">News</a> </li>
<li><a href="../utilities.html">Utilities</a></li>
<li><a href="../programming.html">Programming</a></li>
<li><a href="../reference.html">Reference</a></li>
</ul>
</div>
<div class="document" id="constitute">
<h1 class="title">constitute</h1>
<h2 class="subtitle" id="read-or-write-an-image">Read or write an image</h2>
<div class="contents topic" id="contents">
<p class="topic-title first">Contents</p>
<ul class="simple">
<li><a class="reference internal" href="#constituteimage" id="id15">ConstituteImage</a></li>
<li><a class="reference internal" href="#dispatchimage" id="id16">DispatchImage</a></li>
<li><a class="reference internal" href="#pingimage" id="id17">PingImage</a></li>
<li><a class="reference internal" href="#readimage" id="id18">ReadImage</a></li>
<li><a class="reference internal" href="#readinlineimage" id="id19">ReadInlineImage</a></li>
<li><a class="reference internal" href="#writeimage" id="id20">WriteImage</a></li>
<li><a class="reference internal" href="#writeimages" id="id21">WriteImages</a></li>
<li><a class="reference internal" href="#writeimagesfile" id="id22">WriteImagesFile</a></li>
</ul>
</div>
<div class="section" id="constituteimage">
<h1><a class="toc-backref" href="#id15">ConstituteImage</a></h1>
<div class="section" id="synopsis">
<h2>Synopsis</h2>
<pre class="literal-block">
<a class="reference external" href="../api/types.html#image">Image</a> *ConstituteImage( const unsigned long width, const unsigned long height,
const char *map, const <a class="reference external" href="../api/types.html#storagetype">StorageType</a> type, const void *pixels,
<a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
</pre>
</div>
<div class="section" id="description">
<h2>Description</h2>
<p>ConstituteImage() returns an Image corresponding to an image stored
in a raw memory array format. The pixel data must be in scanline order
top-to-bottom. The data can be unsigned char, unsigned short int, unsigned
int, unsigned long, float, or double. Float and double require the pixels
to be normalized to the range [0..1], otherwise the range is [0..MaxVal]
where MaxVal is the maximum possible value for that type.</p>
<p>Note that for most 32-bit architectures the size of an unsigned long is
the same as unsigned int, but for 64-bit architectures observing the LP64
standard, an unsigned long is 64 bits, while an unsigned int remains 32
bits. This should be considered when deciding if the data should be
described as "Integer" or "Long".</p>
<p>For example, to create a 640x480 image from unsigned red-green-blue
character data, use</p>
<p>image=ConstituteImage(640,480,"RGB",CharPixel,pixels,&exception);</p>
<p>The format of the Constitute method is:</p>
<pre class="literal-block">
<a class="reference external" href="../api/types.html#image">Image</a> *ConstituteImage( const unsigned long width, const unsigned long height,
const char *map, const <a class="reference external" href="../api/types.html#storagetype">StorageType</a> type, const void *pixels,
<a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
</pre>
<dl class="docutils">
<dt>width:</dt>
<dd>width in pixels of the image.</dd>
<dt>height:</dt>
<dd>height in pixels of the image.</dd>
<dt>map:</dt>
<dd>This string reflects the expected ordering of the pixel array.
It can be any combination or order of R = red, G = green, B = blue,
A = alpha (same as Transparency), O = Opacity, T = Transparency,
C = cyan, Y = yellow, M = magenta, K = black, or I = intensity
(for grayscale). Specify "P" = pad, to skip over a quantum which is
intentionally ignored. Creation of an alpha channel for CMYK images
is currently not supported.</dd>
<dt>type:</dt>
<dd>Define the data type of the pixels. Float and double types are
expected to be normalized [0..1] otherwise [0..MaxRGB]. Choose from
these types: CharPixel, ShortPixel, IntegerPixel, LongPixel, FloatPixel,
or DoublePixel.</dd>
<dt>pixels:</dt>
<dd>This array of values contain the pixel components as defined by
map and type. You must preallocate this array where the expected
length varies depending on the values of width, height, map, and type.</dd>
<dt>exception:</dt>
<dd>Return any errors or warnings in this structure.</dd>
</dl>
</div>
</div>
<div class="section" id="dispatchimage">
<h1><a class="toc-backref" href="#id16">DispatchImage</a></h1>
<div class="section" id="id1">
<h2>Synopsis</h2>
<pre class="literal-block">
MagickPassFail DispatchImage( const <a class="reference external" href="../api/types.html#image">Image</a> *image, const long x_offset, const long y_offset,
const unsigned long columns, const unsigned long rows,
const char *map, const <a class="reference external" href="../api/types.html#storagetype">StorageType</a> type, void *pixels,
<a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
</pre>
</div>
<div class="section" id="id2">
<h2>Description</h2>
<p>DispatchImage() extracts pixel data from an Image into a raw memory array.
The pixel data is written in scanline order top-to-bottom using an
arbitrary quantum order specified by 'map', and with quantum size
specified by 'type'.</p>
<p>The output array data may be unsigned char, unsigned short int, unsigned
int, unsigned long, float, or double. Float and double require the pixels
to be normalized to the range [0..1], otherwise the range is [0..MaxVal]
where MaxVal is the maximum possible value for that type.</p>
<p>The method returns MagickPass on success or MagickFail if an error is
encountered.</p>
<p>Suppose we want want to extract the first scanline of a 640x480 image as
character data in red-green-blue order:</p>
<p>DispatchImage(image,0,0,640,1,"RGB",0,pixels,exception);</p>
<p>The format of the DispatchImage method is:</p>
<pre class="literal-block">
MagickPassFail DispatchImage( const <a class="reference external" href="../api/types.html#image">Image</a> *image, const long x_offset, const long y_offset,
const unsigned long columns, const unsigned long rows,
const char *map, const <a class="reference external" href="../api/types.html#storagetype">StorageType</a> type, void *pixels,
<a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
</pre>
<dl class="docutils">
<dt>image:</dt>
<dd>The image.</dd>
<dt>x_offset, y_offset, columns, rows:</dt>
<dd>These values define the perimeter
of a region of pixels you want to extract.</dd>
<dt>map:</dt>
<dd>This string reflects the expected ordering of the pixel array.
It can be any combination or order of R = red, G = green, B = blue,
A = alpha (same as Transparency), O = Opacity, T = Transparency,
C = cyan, Y = yellow, M = magenta, K = black, I = intensity (for
grayscale). Specify "P" = pad, to output a pad quantum. Pad quantums
are zero-value.</dd>
<dt>type:</dt>
<dd>Define the data type of the pixels. Float and double types are
expected to be normalized [0..1] otherwise [0..MaxRGB]. Choose from
these types: CharPixel, ShortPixel, IntegerPixel, LongPixel, FloatPixel,
or DoublePixel.</dd>
<dt>pixels:</dt>
<dd>This array of values contain the pixel components as defined by
map and type. You must preallocate this array where the expected
length varies depending on the values of width, height, map, and type.</dd>
<dt>exception:</dt>
<dd>Return any errors or warnings in this structure.</dd>
</dl>
</div>
</div>
<div class="section" id="pingimage">
<h1><a class="toc-backref" href="#id17">PingImage</a></h1>
<div class="section" id="id3">
<h2>Synopsis</h2>
<pre class="literal-block">
<a class="reference external" href="../api/types.html#image">Image</a> *PingImage( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
</pre>
</div>
<div class="section" id="id4">
<h2>Description</h2>
<p>PingImage() returns all the attributes of an image or image sequence
except for the pixels. It is much faster and consumes far less memory
than ReadImage(). On failure, a NULL image is returned and exception
describes the reason for the failure.</p>
<p>The format of the PingImage method is:</p>
<pre class="literal-block">
<a class="reference external" href="../api/types.html#image">Image</a> *PingImage( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
</pre>
<p>A description of each parameter follows:</p>
<dl class="docutils">
<dt>image_info:</dt>
<dd>Ping the image defined by the file or filename members of
this structure.</dd>
<dt>exception:</dt>
<dd>Return any errors or warnings in this structure.</dd>
</dl>
</div>
</div>
<div class="section" id="readimage">
<h1><a class="toc-backref" href="#id18">ReadImage</a></h1>
<div class="section" id="id5">
<h2>Synopsis</h2>
<pre class="literal-block">
<a class="reference external" href="../api/types.html#image">Image</a> *ReadImage( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
</pre>
</div>
<div class="section" id="id6">
<h2>Description</h2>
<p>ReadImage() reads an image or image sequence from a file or file handle.
The method returns a NULL if there is a memory shortage or if the image
cannot be read. On failure, a NULL image is returned and exception
describes the reason for the failure.</p>
<p>The format of the ReadImage method is:</p>
<pre class="literal-block">
<a class="reference external" href="../api/types.html#image">Image</a> *ReadImage( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
</pre>
<p>A description of each parameter follows:</p>
<dl class="docutils">
<dt>image_info:</dt>
<dd>Read the image defined by the file or filename members of
this structure.</dd>
<dt>exception:</dt>
<dd>Return any errors or warnings in this structure.</dd>
</dl>
</div>
</div>
<div class="section" id="readinlineimage">
<h1><a class="toc-backref" href="#id19">ReadInlineImage</a></h1>
<div class="section" id="id7">
<h2>Synopsis</h2>
<pre class="literal-block">
<a class="reference external" href="../api/types.html#image">Image</a> *ReadInlineImage( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, const char *content,
<a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
</pre>
</div>
<div class="section" id="id8">
<h2>Description</h2>
<p>ReadInlineImage() reads a Base64-encoded inline image or image sequence.
The method returns a NULL if there is a memory shortage or if the image
cannot be read. On failure, a NULL image is returned and exception
describes the reason for the failure.</p>
<p>The format of the ReadInlineImage method is:</p>
<pre class="literal-block">
<a class="reference external" href="../api/types.html#image">Image</a> *ReadInlineImage( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, const char *content,
<a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
</pre>
<dl class="docutils">
<dt>image_info:</dt>
<dd>The image info.</dd>
<dt>content:</dt>
<dd>The image encoded in Base64.</dd>
<dt>exception:</dt>
<dd>Return any errors or warnings in this structure.</dd>
</dl>
</div>
</div>
<div class="section" id="writeimage">
<h1><a class="toc-backref" href="#id20">WriteImage</a></h1>
<div class="section" id="id9">
<h2>Synopsis</h2>
<pre class="literal-block">
MagickPassFail WriteImage( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, <a class="reference external" href="../api/types.html#image">Image</a> *image );
</pre>
</div>
<div class="section" id="id10">
<h2>Description</h2>
<p>Use WriteImage() to write an image or an image sequence to a file or
filehandle. If writing to a file on disk, the name is defined by the
filename member of the image structure. WriteImage() returns
MagickFailure is there is a memory shortage or if the image cannot be
written. Check the exception member of image to determine the cause
for any failure.</p>
<p>The format of the WriteImage method is:</p>
<pre class="literal-block">
MagickPassFail WriteImage( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, <a class="reference external" href="../api/types.html#image">Image</a> *image );
</pre>
<p>A description of each parameter follows:</p>
<dl class="docutils">
<dt>image_info:</dt>
<dd>The image info.</dd>
<dt>image:</dt>
<dd>The image.</dd>
</dl>
</div>
</div>
<div class="section" id="writeimages">
<h1><a class="toc-backref" href="#id21">WriteImages</a></h1>
<div class="section" id="id11">
<h2>Synopsis</h2>
<pre class="literal-block">
MagickPassFail WriteImages( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, <a class="reference external" href="../api/types.html#image">Image</a> *image,
const char *filename, <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
</pre>
</div>
<div class="section" id="id12">
<h2>Description</h2>
<p>WriteImages() writes an image sequence into one or more files. While
WriteImage() will also write an image sequence, it is limited to writing
the sequence into a single file using a format which supports multiple
frames. WriteImages() does not have that limitation since it will
generate multiple output files if necessary (or when requested). When
ImageInfo's adjoin flag is set to MagickFalse, the file name is expected
to include a printf-style formatting string for the frame number (e.g.
"image%02d.miff") so that the frames may be written.</p>
<p>The format of the WriteImages method is:</p>
<pre class="literal-block">
MagickPassFail WriteImages( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, <a class="reference external" href="../api/types.html#image">Image</a> *image,
const char *filename, <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
</pre>
<dl class="docutils">
<dt>image_info:</dt>
<dd>The image info.</dd>
<dt>images:</dt>
<dd>The image list.</dd>
<dt>filename:</dt>
<dd>The image filename.</dd>
<dt>exception:</dt>
<dd>Return any errors or warnings in this structure.</dd>
</dl>
</div>
</div>
<div class="section" id="writeimagesfile">
<h1><a class="toc-backref" href="#id22">WriteImagesFile</a></h1>
<div class="section" id="id13">
<h2>Synopsis</h2>
<pre class="literal-block">
unsigned int WriteImagesFile( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, <a class="reference external" href="../api/types.html#image">Image</a> *image, FILE *file,
<a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
</pre>
</div>
<div class="section" id="id14">
<h2>Description</h2>
<p>WriteImagesFile() writes an image or image sequence to a stdio
FILE handle. This may be used to append an encoded image to an already
existing appended image sequence if the file seek position is at the end
of an existing file.</p>
<p>The format of the WriteImagesFile method is:</p>
<pre class="literal-block">
unsigned int WriteImagesFile( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, <a class="reference external" href="../api/types.html#image">Image</a> *image, FILE *file,
<a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
</pre>
<dl class="docutils">
<dt>image_info:</dt>
<dd>The image info.</dd>
<dt>images:</dt>
<dd>The image list.</dd>
<dt>file:</dt>
<dd>The open (and positioned) file handle.</dd>
<dt>exception:</dt>
<dd>Return any errors or warnings in this structure.</dd>
</dl>
</div>
</div>
</div>
</body>
</html>
|