Next: 3.2 File conversion Up: 3. The VImage class Previous: 3. The VImage class Contents

# 3.1 Constructors

There are two principal constructors for `VImage`:

    VImage::VImage( const char *name,
      const char *mode = "r" );
    VImage::VImage();

The first form creates a new `VImage`, linking it to the named file. `mode` sets the mode for the file: it can take the following values:

`"r"`
  The named image file is opened read-only. This is the default mode.

`"w"`
  A `VImage` is created which, when written to, will write pixels to disc in the specified file.

`"t"`
  As the `"w"` mode, but pels written to the `VImage` will be saved in a temporary memory buffer.

`"p"`
  This creates a special `partial' image. Partial images represent intermediate results, and are used to join VIPS operations together, see §3.5.

`"rw"`
  As the `"r"` mode, but the image is mapped into your address space read-write. This mode is only provided for the use of paintbox-style applications, which need to directly modify an image. See §4.8.

The second form of constructor is shorthand for:

    VImage( "VImage:1", "p" )

It is used for representing intermediate results of computations.

Two further constructors are handy for wrapping `VImage` around existing images.

    VImage( void *buffer,
      int width, int height, int bands,
      TBandFmt format );
    VImage( void *image );

The first constructor makes a `VImage` from an area of memory (perhaps from another image processing system), and the second makes a `VImage` from an `IMAGE`. See below for an explanation of `TBandFmt`.

In both these two cases, the VIPS C++ API does not assume responsibility for the resouces: it's up to you to make sure the buffer is freed.

Next: 3.2 File conversion Up: 3. The VImage class Previous: 3. The VImage class Contents