### Class

# Vips Region

#### Description [src]

    class Vips.Region : Vips.Object
    {
      VipsImage* im,
      VipsRect valid
    }

A `VipsRegion` represents a small, rectangular part of an image.

You use regions to read pixels out of images without having to have the whole image in memory at once.

A region can be a memory buffer, part of a memory-mapped file, part of some other image, or part of some other region.

Regions must be created, used and freed all within the same thread, since they can reference private per-thread caches. libvips sanity-checks region ownership in various places, so you are likely to see `g_assert()` errors if you don’t follow this rule.

There is API to transfer ownership of regions between threads, but (hopefully) this is only needed within libvips, so we don’t expose it.

#### Hierarchy

#### Ancestors

- VipsObject
- GObject

#### Constructors

###### vips_region_new

Create a region. `VipsRegion` start out empty, you need to call `vips_region_prepare()` to fill them with pixels.

#### Instance methods

###### vips_region_black

Paints 0 into the valid part of `reg`.

###### vips_region_buffer

The region is transformed so that at least `r` pixels are available as a memory buffer that can be written to.

###### vips_region_copy

Copy from one region to another. Copy area `r` from inside `reg` to `dest`, positioning the area of pixels at `x`, `y`. The two regions must have pixels which are the same size.

###### vips_region_equalsregion

Do two regions point to the same piece of image? ie.

###### vips_region_fetch

Generate an area of pixels and return a copy. The result must be freed with `g_free()`. The requested area must be completely inside the image.

###### vips_region_height

No description available.

###### vips_region_image

The region is transformed so that at least `r` pixels are available to be read from the image. The image needs to be a memory buffer or represent a file on disc that has been mapped or can be mapped.

###### vips_region_invalidate

Mark a region as containing invalid pixels. Calling this function means that the next time `vips_region_prepare()` is called, the region will be recalculated.

###### vips_region_paint

Paints `value` into `reg` covering rectangle `r`. `r` is clipped against `reg`->valid.

###### vips_region_paint_pel

Paints `ink` into `reg` covering rectangle `r`. `r` is clipped against `reg`->valid.

###### vips_region_position

Set the position of a region. This only affects reg->valid, ie. the way pixels are addressed, not reg->data, the pixels which are addressed. Clip against the size of the image. Do not allow negative positions, or positions outside the image.

###### vips_region_prepare

`vips_region_prepare()` fills `reg` with pixels. After calling, you can address at least the area `r` with `VIPS_REGION_ADDR()` and get valid pixels.

###### vips_region_prepare_to

Like `vips_region_prepare()`: fill `reg` with the pixels in area `r`.

###### vips_region_region

Make `VIPS_REGION_ADDR()` on `reg` go to `dest` instead.

###### vips_region_shrink

Write the pixels `target` in `to` from the x2 larger area in `from`. Non-complex uncoded images and LABQ only. Images with alpha (see `vips_image_hasalpha()`) shrink with pixels scaled by alpha to avoid fringing.

###### vips_region_shrink_method

Write the pixels `target` in `to` from the x2 larger area in `from`. Non-complex uncoded images and LABQ only.

###### vips_region_width

No description available.

##### Methods inherited from VipsObject (27)

Please see VipsObject for a full list of methods.

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Properties

##### Properties inherited from VipsObject (2)

###### Vips.Object:description

No description available.

###### Vips.Object:nickname

No description available.

#### Signals

##### Signals inherited from VipsObject (4)

###### VipsObject::close

The ::close signal is emitted once during object close. The object is dying and may not work.

###### VipsObject::postbuild

The ::postbuild signal is emitted once just after successful object construction. Return non-zero to cause object construction to fail.

###### VipsObject::postclose

The ::postclose signal is emitted once after object close. The object pointer is still valid, but nothing else.

###### VipsObject::preclose

The ::preclose signal is emitted once just before object close starts. The object is still alive.

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

#### Class structure

    struct VipsRegionClass {
      VipsObjectClass parent_class;

    }

No description available.

###### Class members

`parent_class: VipsObjectClass`

  No description available.