/usr/share/doc/libvips-doc/html/vipsmanualse3.html is in libvips-doc 7.28.5-1+deb7u1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html >
<head><title>The VImage class</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)">
<meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)">
<!-- 3,html -->
<meta name="src" content="vipsmanual.tex">
<meta name="date" content="2012-05-07 10:17:00">
<link rel="stylesheet" type="text/css" href="vipsmanual.css">
</head><body
>
<!--l. 1--><div class="crosslinks"><p class="noindent">[<a
href="vipsmanualse4.html" >next</a>] [<a
href="vipsmanualse2.html" >prev</a>] [<a
href="vipsmanualse2.html#tailvipsmanualse2.html" >prev-tail</a>] [<a
href="#tailvipsmanualse3.html">tail</a>] [<a
href="vipsmanualch1.html#vipsmanualse3.html" >up</a>] </p></div>
<h3 class="sectionHead"><span class="titlemark">1.3 </span> <a
id="x8-110001.3"></a>The <span
class="pcrr7t-">VImage </span>class</h3>
<!--l. 3--><p class="noindent" >The <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VImage</span></span></span> class is a layer over the VIPS <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">IMAGE</span></span></span>
type. It automates almost all of the image creation and
destruction issues that complicate the C API, it automates
error handling, and it provides a convenient system for
composing operations.
<!--l. 8--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">1.3.1 </span> <a
id="x8-120001.3.1"></a>Constructors</h4>
<!--l. 10--><p class="noindent" >There are two principal constructors for <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VImage</span></span></span>:
<div class="verbatim" id="verbatim-5">
VImage::VImage( const char ⋆name,
 <br />  const char ⋆mode = "r" );
 <br />VImage::VImage();
</div>
<!--l. 16--><p class="nopar" >
<!--l. 18--><p class="indent" > The first form creates a new <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VImage</span></span></span>, linking it to the
named file. <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">mode</span></span></span> sets the mode for the file: it can take the
following values:
<dl class="description"><dt class="description">
<span
class="pcrb7t-">"r"</span> </dt><dd
class="description">The named image file is opened read-only. This is
the default mode.
</dd><dt class="description">
<span
class="pcrb7t-">"w"</span> </dt><dd
class="description">A <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VImage</span></span></span> is created which, when written to,
will write pixels to disc in the specified file. Any
existing file of this name is deleted.
</dd><dt class="description">
<span
class="pcrb7t-">"t"</span> </dt><dd
class="description">As the <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">"w"</span></span></span> mode, but pixels written to the
<span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VImage</span></span></span> will be saved in a temporary memory
buffer.
</dd><dt class="description">
<span
class="pcrb7t-">"p"</span> </dt><dd
class="description">This creates a special ‘partial’ image. Partial
images represent intermediate results, and are used
to join VIPS operations together, see <span
class="cmsy-10">§</span><a
href="#x8-160001.3.5">1.3.5<!--tex4ht:ref: sec:compute --></a>.
</dd><dt class="description">
<span
class="pcrb7t-">"rw"</span> </dt><dd
class="description">As the <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">"r"</span></span></span> mode, but the image is mapped
into your address space read-write. This mode is
useful for paintbox-style applications which need
to directly modify an image. See <span
class="cmsy-10">§</span><a
href="vipsmanualse18.html#x26-1140004.2.8">4.2.8<!--tex4ht:ref: sec:inplace --></a>.
</dd></dl>
<!--l. 46--><p class="indent" > The second form of constructor is shorthand for:
<div class="verbatim" id="verbatim-6">
VImage( "VImage:1", "p" )
</div>
<!--l. 50--><p class="nopar" >
<!--l. 52--><p class="noindent" >It is used for representing intermediate results of
computations.
<!--l. 55--><p class="indent" > Two further constructors are handy for wrapping
<span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VImage</span></span></span> around existing images.
<div class="verbatim" id="verbatim-7">
VImage( void ⋆buffer,
 <br />  int width, int height, int bands,
 <br />  TBandFmt format );
 <br />VImage( void ⋆image );
</div>
<!--l. 63--><p class="nopar" >
<!--l. 65--><p class="noindent" >The first constructor makes a <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VImage</span></span></span> from an area
of memory (perhaps from another image processing
system), and the second makes a <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VImage</span></span></span> from an
<span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">IMAGE</span></span></span>.
<!--l. 70--><p class="indent" > In both these two cases, the VIPS C++ API does not
assume responsibility for the resources: it’s up to you to
make sure the buffer is freed.
<!--l. 73--><p class="indent" > The Python interface adds the usual <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">frombuffer</span></span></span> and
<span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">fromstring</span></span></span> methods.
<div class="verbatim" id="verbatim-8">
VImage.fromstring (string,
 <br />  width, height, bands, format) ->
 <br />  VImage
</div>
<!--l. 80--><p class="nopar" >
<div class="verbatim" id="verbatim-9">
VImage.frombuffer (buffer,
 <br />  width, height, bands, format) ->
 <br />  VImage
</div>
<!--l. 86--><p class="nopar" >
<!--l. 88--><p class="noindent" >Use <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">fromstring</span></span></span> to avoid worries about object lifetime,
but you’ll see a lot of copies and high memory use. Use
<span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">frombuffer</span></span></span> for speed, but you have to manage object
lifetime yourself.
<!--l. 93--><p class="indent" > They are useful for moving images into VIPS from other
image processing libraries. There’s also a utility function,
<span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">vips_from_PIL_mode</span></span></span>, which turns a PIL mode into a
VIPS band, format, type triple.
<div class="verbatim" id="verbatim-10">
VImage.vips_from_PIL_mode (mode) ->
 <br />  (bands, format, type)
</div>
<!--l. 100--><p class="nopar" >
<!--l. 102--><p class="indent" > See also <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">tobuffer</span></span></span> and <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">tostring</span></span></span> below.
<!--l. 104--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">1.3.2 </span> <a
id="x8-130001.3.2"></a>File conversion</h4>
<!--l. 106--><p class="noindent" >VIPS can read and write a number of different file formats.
Information about file format conversion is taken from the
filename. For example:
<div class="verbatim" id="verbatim-11">
VImage jim( "fred.jpg" );
</div>
<!--l. 111--><p class="nopar" >
<!--l. 113--><p class="noindent" >This will decompress the file <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">fred.jpg</span></span></span> to a memory
buffer, wrap a VIPS image around the buffer and build a
reference to it called <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">jim</span></span></span>.
<!--l. 117--><p class="indent" > Options are passed to the file format converters embedded
in the filename. For example:
<div class="verbatim" id="verbatim-12">
VImage out( "jen.tif:deflate", "w" );
</div>
<!--l. 122--><p class="nopar" >
<!--l. 124--><p class="noindent" >Writing to the descriptor <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">out</span></span></span> will cause a TIFF image to be
written to disc with deflate compression.
<!--l. 128--><p class="indent" > See the manual page for <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">im_open(3)</span></span></span> for details of all
the file formats and conversions available. See the man page
for <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VipsFormat(3)</span></span></span> for a lower-level API which lets you
control more of the detail of reading and writing data and is
more suitable for large files.
<!--l. 133--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">1.3.3 </span> <a
id="x8-140001.3.3"></a>Projection functions</h4>
<!--l. 135--><p class="noindent" >A set of member functions of <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VImage</span></span></span> provide access to the
fields in the header:
<div class="verbatim" id="verbatim-13">
int Xsize();
 <br />int Ysize();
 <br />int Bands();
 <br />TBandFmt BandFmt();
 <br />TCoding Coding();
 <br />TType Type();
 <br />float Xres();
 <br />float Yres();
 <br />int Length();
 <br />TCompression Compression();
 <br />short Level();
 <br />int Xoffset();
 <br />int Yoffset();
</div>
<!--l. 152--><p class="nopar" >
<!--l. 154--><p class="noindent" >Where <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">TBandFmt</span></span></span>, <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">TCoding</span></span></span>, <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">TType</span></span></span> and <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">TCompression</span></span></span>
are <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">enum</span></span></span>s for the types in the VIPS file header. See
section <span
class="cmsy-10">§</span><a
href="vipsmanualse2.html#x7-80001.2.1">1.2.1<!--tex4ht:ref: sec:header --></a> for an explanation of all of these fields.
<!--l. 159--><p class="indent" > Two functions give access to the filename and history
fields maintained by the VIPS IO system.
<div class="verbatim" id="verbatim-14">
char ⋆filename();
 <br />char ⋆Hist();
</div>
<!--l. 165--><p class="nopar" >
<!--l. 167--><p class="indent" > You can get and set extra metadata fields with
<span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">meta_get()</span></span></span> and <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">meta_set()</span></span></span>. They read and write
<span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">GValue</span></span></span> objects, see <span
class="cmsy-10">§</span><a
href="vipsmanualse8.html#x14-430002.2.6">2.2.6<!--tex4ht:ref: sec:meta --></a>.
<div class="verbatim" id="verbatim-15">
void meta_set( const char ⋆field, GValue ⋆value );
 <br />void meta_get( const char ⋆field, GValue ⋆value_copy );
 <br />GType meta_get_type( const char ⋆field );
</div>
<!--l. 175--><p class="nopar" >
<!--l. 177--><p class="indent" > A set of convenience functions build on these two to
provide accessors for common types.
<div class="verbatim" id="verbatim-16">
int meta_get_int( const char ⋆field )
 <br />double meta_get_double( const char ⋆field )
 <br />const char ⋆meta_get_string( const char ⋆field )
 <br />void ⋆meta_get_area( const char ⋆field )
 <br />void ⋆meta_get_blob( const char ⋆field, size_t ⋆length )
 <br />
 <br />void meta_set( const char ⋆field, int value )
 <br />void meta_set( const char ⋆field, double value )
 <br />void meta_set( const char ⋆field, const char ⋆value )
 <br />void meta_set( const char ⋆field,
 <br />VCallback free_fn, void ⋆value )
 <br />void meta_set( const char ⋆field,
 <br />VCallback free_fn, void ⋆value, size_t length )
</div>
<!--l. 194--><p class="nopar" >
<!--l. 196--><p class="indent" > The <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">image()</span></span></span> member function provides access to the
<span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">IMAGE</span></span></span> descriptor underlying the C++ API. See the <span
class="cmsy-10">§</span><a
href="vipsmanualse7.html#x13-360002.1">2.1<!--tex4ht:ref: sec:appl --></a> for
details.
<div class="verbatim" id="verbatim-17">
void ⋆image();
</div>
<!--l. 201--><p class="nopar" >
<!--l. 203--><p class="indent" > The <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">data()</span></span></span> member function returns a pointer to an
array of pixel data for the image.
<div class="verbatim" id="verbatim-18">
void ⋆data() const;
</div>
<!--l. 208--><p class="nopar" >
<!--l. 210--><p class="noindent" >This can be very slow and use huge amounts of RAM.
<!--l. 213--><p class="indent" > The Python interface adds <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">tobuffer</span></span></span> and <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">tostring</span></span></span>.
These operations call <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">data()</span></span></span> to generate the image pixels
and then either copy it and return the copy as a string, or
wrap the pixels up as a Python buffer object.
<!--l. 218--><p class="indent" > Use <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">tostring</span></span></span> to avoid worries about object lifetime,
but you’ll see a lot of copies and high memory use. Use
<span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">tobuffer</span></span></span> for speed, but you have to manage object
lifetime yourself.
<!--l. 222--><p class="indent" > They are useful for moving images from VIPS into other
image processing libraries. There’s also a utility function,
<span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">PIL_mode_from_vips</span></span></span>, which makes a PIL mode from
a VIPS image.
<div class="verbatim" id="verbatim-19">
VImage.PIL_mode_from_vips (vips-image) ->
 <br />  mode
</div>
<!--l. 229--><p class="nopar" >
<!--l. 231--><p class="indent" > See also <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">frombuffer</span></span></span> and <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">fromstring</span></span></span> above.
<!--l. 233--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">1.3.4 </span> <a
id="x8-150001.3.4"></a>Assignment</h4>
<!--l. 235--><p class="noindent" ><span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VImage</span></span></span> defines copy and assignment, with reference-counted,
pointer-style semantics. For example, if you write:
<div class="verbatim" id="verbatim-20">
VImage fred( "fred.v" );
 <br />VImage jim( "jim.v" );
 <br />
 <br />fred = jim;
</div>
<!--l. 243--><p class="nopar" >
<!--l. 245--><p class="indent" > This will automatically close the file <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">fred.v</span></span></span>, and make
the variable <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">fred</span></span></span> point to the image <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">jim.v</span></span></span> instead. Both
<span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">jim</span></span></span> and <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">fred</span></span></span> now point to the same underlying image
object.
<!--l. 249--><p class="indent" > Internally, a <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VImage</span></span></span> object is just a pointer to a
reference-counting block, which in turn holds a pointer to
the underlying VIPS <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">IMAGE</span></span></span> type. You can therefore
efficiently pass <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VImage</span></span></span> objects to functions by value, and
return <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VImage</span></span></span> objects as function results.
<!--l. 254--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">1.3.5 </span> <a
id="x8-160001.3.5"></a>Computing with <span
class="pcrr7t-">VImage</span>s</h4>
<!--l. 257--><p class="noindent" >All VIPS image processing operations are member
functions of the <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VImage</span></span></span> class. For example:
<div class="verbatim" id="verbatim-21">
VImage fred( "fred.v" );
 <br />VImage jim( "jim.v" );
 <br />
 <br />VImage result = fred.cos() + jim;
</div>
<!--l. 265--><p class="nopar" >
<!--l. 267--><p class="indent" > Will apply <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">im_costra()</span></span></span> to <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">fred.v</span></span></span>, making an
image where each pixel is the cosine of the corresponding
pixel in <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">fred.v</span></span></span>; then add that image to <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">jim.v</span></span></span>. Finally,
the result will be held in <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">result</span></span></span>.
<!--l. 271--><p class="indent" > VIPS is a demand-driven image processing system:
when it computes expressions like this, no actual pixels
are calculated (although you can use the projection
functions on images — <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">result.BandFmt()</span></span></span> for
example). When you finally write the result to a file (or
use some operation that needs pixel values, such as
<span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">min()</span></span></span>, find minimum value), VIPS evaluates all of the
operations you have called to that point in parallel. If you
have more than one CPU in your machine, the load
is spread over the available processors. This means
that there is no limit to the size of the images you can
process.
<!--l. 280--><p class="indent" > <span
class="cmsy-10">§</span><a
href="vipsmanualse18.html#x26-1060004.2">4.2<!--tex4ht:ref: sec:packages --></a> lists all of the VIPS packages. These general rules
apply:
<ul class="itemize1">
<li class="itemize">VIPS operation names become C++ member
function names by dropping the <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">im_</span></span></span> prefix, and
if present, the <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">tra</span></span></span> postfix, the <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">const</span></span></span> postfix and
the <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">_vec</span></span></span> postfix. For example, the VIPS operation
<span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">im_extract()</span></span></span> becomes <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">extract()</span></span></span>, and
<span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">im_costra()</span></span></span> becomes <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">cos()</span></span></span>.
</li>
<li class="itemize">The <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VImage</span></span></span> object to which you apply the
member function is the first input image, the
member function returns the first output. If there is
no image input, the member is declared <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">static</span></span></span>.
<!--l. 297--><p class="noindent" >For example, <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">im_project(3)</span></span></span> returns two
images. You can call it from Python like this:
<div class="verbatim" id="verbatim-22">
hout = VImage.VImage ()
 <br />vout = im.project (hout)
</div>
<!--l. 303--><p class="nopar" >
<!--l. 305--><p class="noindent" >In other words, <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">.project()</span></span></span> writes the second result
to the <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VImage</span></span></span> you pass as an argument.
</li>
<li class="itemize"><span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">INTMASK</span></span></span> and <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">DOUBLEMASK</span></span></span> types become <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VMask</span></span></span>
objects, <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">im_col_display</span></span></span> types become <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VDisplay</span></span></span>
objects.
</li>
<li class="itemize">Several C API functions can map to the same
C++ API member. For example, <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">im_andimage</span></span></span>,
<span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">im_andimage_vec</span></span></span> and <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">im_andimageconst</span></span></span> all
map to the member <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">andimage</span></span></span>. The API relies on
overloading to discriminate between these functions.
</li></ul>
<!--l. 321--><p class="indent" > This part of the C++ API is generated automatically
from the VIPS function database, so it should all be
up-to-date.
<!--l. 324--><p class="indent" > There are a set of arithmetic operators defined for your
convenience. You can generally write any arithmetic
expression and include <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VImage</span></span></span> in there.
<div class="verbatim" id="verbatim-23">
VImage fred( "fred.v" );
 <br />VImage jim( "jim.v" );
 <br />
 <br />Vimage v = int((fred + jim) / 2);
</div>
<!--l. 332--><p class="nopar" >
<!--l. 334--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">1.3.6 </span> <a
id="x8-170001.3.6"></a>Writing results</h4>
<!--l. 336--><p class="noindent" >Once you have computed some result, you can write it to a
file with the member <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">write()</span></span></span>. It takes the following
forms:
<div class="verbatim" id="verbatim-24">
VImage write( const char ⋆name );
 <br />VImage write( VImage out );
 <br />VImage write();
</div>
<!--l. 343--><p class="nopar" >
<!--l. 345--><p class="indent" > The first form simply writes the image to the named file.
The second form writes the image to the specified <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VImage</span></span></span>
object, for example:
<div class="verbatim" id="verbatim-25">
VImage fred( "fred.v" );
 <br />VImage jim( "jim buffer", "t" );
 <br />
 <br />Vimage v = (fred + 42).write( jim );
</div>
<!--l. 353--><p class="nopar" >
<!--l. 355--><p class="noindent" >This creates a temporary memory buffer called <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">jim</span></span></span>, and
fills it with the result of adding 42 to every pixel in
<span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">fred.v</span></span></span>.
<!--l. 359--><p class="indent" > The final form of <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">write()</span></span></span> writes the image to a
memory buffer, and returns that.
<!--l. 362--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">1.3.7 </span> <a
id="x8-180001.3.7"></a>Type conversions</h4>
<!--l. 364--><p class="noindent" >Two type conversions are defined: you can cast <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VImage</span></span></span> to
a <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VDMask</span></span></span> and to a <span class="obeylines-h"><span class="verb"><span
class="pcrr7t-">VIMask</span></span></span>.
<div class="verbatim" id="verbatim-26">
operator VDMask();
 <br />operator VIMask();
</div>
<!--l. 370--><p class="nopar" >
<!--l. 372--><p class="indent" > These operations are slow and need a lot of memory!
Emergencies only.
<!--l. 1--><div class="crosslinks"><p class="noindent">[<a
href="vipsmanualse4.html" >next</a>] [<a
href="vipsmanualse2.html" >prev</a>] [<a
href="vipsmanualse2.html#tailvipsmanualse2.html" >prev-tail</a>] [<a
href="vipsmanualse3.html" >front</a>] [<a
href="vipsmanualch1.html#vipsmanualse3.html" >up</a>] </p></div>
<!--l. 1--><p class="indent" > <a
id="tailvipsmanualse3.html"></a>
</body></html>
|