### Method

# Vips Image cast

#### Declaration [src]

    int
    vips_cast (
      VipsImage* in,
      VipsImage** out,
      VipsBandFormat format,
      ...
    )

#### Description [src]

Convert `in` to `format`. You can convert between any pair of formats. Floats are truncated (not rounded). Out of range values are clipped.

Casting from complex to real returns the real part.

If `shift` is `TRUE`, integer values are shifted up and down. For example, casting from unsigned 8 bit to unsigned 16 bit would shift every value left by 8 bits. The bottom bit is copied into the new bits, so 255 would become 65535.

Optional arguments

- `shift`: `gboolean`, integer values are shifted

See also

`vips_scale()`, `vips_complexform()`, `vips_real()`, `vips_imag()`, `vips_cast_uchar()`, `vips_msb()`.

This method is not directly available to language bindings.

#### Parameters

`out`

  Type: `VipsImage`

  Output image.

  The argument will be set by the function.
  The caller of the method takes ownership of the returned data, and is responsible for freeing it.

`format`

  Type: `VipsBandFormat`

  Format to convert to.

`...`

  Type: ``

  `NULL`-terminated list of optional named arguments.

#### Return value

Type: `int`

0 on success, -1 on error.