VipsRegion

VipsRegion — small, rectangular parts of images

Stability Level

Stable, unless otherwise indicated

Synopsis

#include <vips/vips.h>

#define             VIPS_REGION_ADDR                    (R,
                                                         X,
                                                         Y)
#define             VIPS_REGION_ADDR_TOPLEFT            (R)
#define             VIPS_REGION_LSKIP                   (R)
#define             VIPS_REGION_N_ELEMENTS              (R)
#define             VIPS_REGION_SIZEOF_LINE             (R)
                    VipsRegion;
                    VipsRegionClass;
void                vips_region_black                   (VipsRegion *reg);
int                 vips_region_buffer                  (VipsRegion *reg,
                                                         VipsRect *r);
void                vips_region_copy                    (VipsRegion *reg,
                                                         VipsRegion *dest,
                                                         VipsRect *r,
                                                         int x,
                                                         int y);
int                 vips_region_equalsregion            (VipsRegion *reg1,
                                                         VipsRegion *reg2);
int                 vips_region_image                   (VipsRegion *reg,
                                                         VipsRect *r);
VipsRegion *        vips_region_new                     (VipsImage *image);
void                vips_region_paint                   (VipsRegion *reg,
                                                         VipsRect *r,
                                                         int value);
void                vips_region_paint_pel               (VipsRegion *reg,
                                                         VipsRect *r,
                                                         VipsPel *ink);
int                 vips_region_position                (VipsRegion *reg,
                                                         int x,
                                                         int y);
int                 vips_region_prepare                 (VipsRegion *reg,
                                                         VipsRect *r);
int                 vips_region_prepare_many            (VipsRegion **reg,
                                                         VipsRect *r);
int                 vips_region_prepare_to              (VipsRegion *reg,
                                                         VipsRegion *dest,
                                                         VipsRect *r,
                                                         int x,
                                                         int y);
int                 vips_region_region                  (VipsRegion *reg,
                                                         VipsRegion *dest,
                                                         VipsRect *r,
                                                         int x,
                                                         int y);

Object Hierarchy

  GObject
   +----VipsObject
         +----VipsRegion

Description

A VipsRegion is a small part of an image and some pixels. 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. VIPS 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 VIPS, so we don't expose it. Hopefully.

Details

VIPS_REGION_ADDR()

#define             VIPS_REGION_ADDR( R, X, Y )

This macro returns a pointer to a pixel in a region. The (x, y) coordinates need to be within the VipsRect (R->valid).

If DEBUG is defined, you get a version that checks bounds for you.

R :

a VipsRegion

X :

x coordinate

Y :

y coordinate

Returns :

The address of pixel (x,y) in the region.

VIPS_REGION_ADDR_TOPLEFT()

#define VIPS_REGION_ADDR_TOPLEFT( R ) ((R)->data)

This macro returns a pointer to the top-left pixel in the VipsRegion, that is, the pixel at (R->valid.left, R->valid.top).

R :

a VipsRegion

Returns :

The address of the top-left pixel in the region.

VIPS_REGION_LSKIP()

#define             VIPS_REGION_LSKIP( R )

R :

a VipsRegion

Returns :

The number of bytes to add to move down a scanline.

VIPS_REGION_N_ELEMENTS()

#define             VIPS_REGION_N_ELEMENTS( R )

R :

a VipsRegion

Returns :

The number of band elements across a region.

VIPS_REGION_SIZEOF_LINE()

#define             VIPS_REGION_SIZEOF_LINE( R )

R :

a VipsRegion

Returns :

The number of bytes across a region.

VipsRegion

typedef struct {
	/* Users may read these two fields.
	 */
	VipsImage *im;		/* Link back to parent image */
	VipsRect valid;		/* Area of parent we can see */

	/* The rest of VipsRegion is private.
	 */
} VipsRegion;

A small part of a VipsImage. valid holds the left/top/width/height of the area of pixels that are available from the region.

See also: VIPS_REGION_ADDR(), vips_region_new(), vips_region_prepare().

VipsImage *im;

the VipsImage that this region is defined on

VipsRect valid;

the VipsRect of pixels that this region represents

VipsRegionClass

typedef struct {
	VipsObjectClass parent_class;
} VipsRegionClass;


vips_region_black ()

void                vips_region_black                   (VipsRegion *reg);

Paints 0 into the valid part of reg.

See also: vips_region_paint().

reg :

region to operate upon

vips_region_buffer ()

int                 vips_region_buffer                  (VipsRegion *reg,
                                                         VipsRect *r);

The region is transformed so that at least r pixels are available as a memory buffer.

reg :

region to operate upon

r :

VipsRect of pixels you need to be able to address

Returns :

0 on success, or -1 for error.

vips_region_copy ()

void                vips_region_copy                    (VipsRegion *reg,
                                                         VipsRegion *dest,
                                                         VipsRect *r,
                                                         int x,
                                                         int y);

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.

See also: vips_region_paint().

reg :

source region

dest :

destination region

r :

VipsRect of pixels you need to copy

x :

postion of r in dest

y :

postion of r in dest

vips_region_equalsregion ()

int                 vips_region_equalsregion            (VipsRegion *reg1,
                                                         VipsRegion *reg2);

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

1
2
3
4
5
6