---
name: "IM_REGION_N_ELEMENTS"
section: "3"
platform: "linux"
package: "libvips-dev"
version: "7.20.7-1+b3"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/IM_REGION_ADDR"
---

# IM\_REGION\_N\_ELEMENTS(3)

macros for regions

Part of [IM\_REGION\_ADDR(3)](/IM_REGION_ADDR/3.md).

## NAME

IM\_REGION\_ADDR,  IM\_REGION\_LSKIP, IM\_REGION\_N\_ELEMENTS, IM\_REGION\_SIZEOF\_LINE -  macros for regions

## SYNOPSIS

**#include \<vips/vips.h\>**

int IM\_REGION\_LSKIP( reg ) \
 REGION \*reg;

int IM\_REGION\_N\_ELEMENTS( reg ) \
 REGION \*reg;

int IM\_REGION\_SIZEOF\_LINE( reg ) \
 REGION \*reg;

char \*IM\_REGION\_ADDR( reg, x, y ) \
 REGION \*reg;\
 int x, y;

## DESCRIPTION

These macros help to simplify address arithmetic for regions.

[IM\_REGION\_LSKIP(3)](/IM_REGION_LSKIP/3.md) returns the number of \*bytes\* you should add to move down a scan line.  Remember that if your pointer has been cast to the type of the image pels, this will not be the correct amount to add! The value lskip returns can be changed by a call to [im\_prepare(3)](/im_prepare/3.md).

[IM\_REGION\_N\_ELEMENTS(3)](/IM_REGION_N_ELEMENTS/3.md) returns the number of band elements across the region.

[IM\_REGION\_SIZEOF\_LINE(3)](/IM_REGION_SIZEOF_LINE/3.md) returns sizeof( horizontal line across region ).

[IM\_REGION\_ADDR(3)](/IM_REGION_ADDR/3.md) returns a pointer to the pixel at position (x,y) in the image on which reg has been defined. The point (x,y) should lie within the valid area for this region.

If the macro DEBUG has been defined, then [IM\_REGION\_ADDR(3)](/IM_REGION_ADDR/3.md) will also perform bounds checking. If you ask for the address of a pel outside the rect reg-\>valid, then [IM\_REGION\_ADDR(3)](/IM_REGION_ADDR/3.md) will print an error message of the form:

    IM\_REGION\_ADDR: point out of bounds, file "test.c", line 18\
     (point x=50, y=0 \
      should have been within Rect left=0, top=0, width=50, height=50)

and call [abort(3)](/abort/3.md).

DEBUG needs to be defined \*before\* region.h is included. Either define DEBUG with -D in your Makefile, or have a #define DEBUG right at the top of your file.

## COPYRIGHT

National Gallery, 1993

## SEE ALSO

[IM\_IMAGE\_ADDR(3)](/IM_IMAGE_ADDR/3.md), [im\_malloc(3)](/im_malloc/3.md), [im\_open\_local(3)](/im_open_local/3.md).

## AUTHOR

J. Cupitt - 23/7/93
