---
name: "im_rect_normalise"
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_rect_marginadjust"
---

# im\_rect\_normalise(3)

rectangle algebra functions

Part of [im\_rect\_marginadjust(3)](/im_rect_marginadjust/3.md).

## NAME

im\_rect\_marginadjust, im\_rect\_includespoint, im\_rect\_includesrect, im\_rect\_intersectrect, im\_rect\_isempty, im\_rect\_unionrect, im\_rect\_normalise, im\_rect\_equalsrect, im\_rect\_dup, IM\_RECT\_RIGHT, IM\_RECT\_BOTTOM, IM\_RECT\_HCENTRE, IM\_RECT\_VCENTRE - rectangle algebra functions

## SYNOPSIS

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

typedef struct {\
\
 	int left, top, width, height;\
 } Rect;

\#define IM\_RECT\_RIGHT(R) ((R)-\>left + (R)-\>width)\
 \#define IM\_RECT\_BOTTOM(R) ((R)-\>top + (R)-\>height)\
 \#define IM\_RECT\_HCENTRE(R) ((R)-\>left + (R)-\>width / 2)\
 \#define IM\_RECT\_VCENTRE(R) ((R)-\>top + (R)-\>height / 2)

void im\_rect\_marginadjust( Rect \*r, int n );\
 int im\_rect\_includespoint( Rect \*r, int x, int y );\
 int im\_rect\_includesrect( Rect \*r1, Rect \*r2 );\
 void im\_rect\_intersectrect( Rect \*r1, Rect \*r2, Rect \*r3 );\
 int im\_rect\_isempty( Rect \*r );\
 void im\_rect\_unionrect( Rect \*r1, Rect \*r2, Rect \*r3 );\
 int im\_rect\_equalsrect( Rect \*r1, Rect \*r2 );\
 Rect \*im\_rect\_dup( Rect \*r );\
 void im\_rect\_normalise( Rect \*r );

## DESCRIPTION

These functions perform simple algebra on Rect structs. There should also be a set of functions to do rectlist algebra.

[im\_rect\_marginadjust(3)](/im_rect_marginadjust/3.md) expands a Rect by n units up, down, left and right. Negative expansions shrink the Rect.

[im\_rect\_includespoint(3)](/im_rect_includespoint/3.md) returns non-zero if point (x,y) lies within Rect r.

[im\_rect\_includesrect(3)](/im_rect_includesrect/3.md) returns non-zero if Rect r2 lies completely within Rect r1.

[im\_rect\_intersectrect(3)](/im_rect_intersectrect/3.md) fills Rect r3 with the intersection of Rects r1 and r2.

[im\_rect\_isempty(3)](/im_rect_isempty/3.md) returns non-zero if Rect r has either width less than or equal to 0 or height less than or equal to 0.

[im\_rect\_unionrect(3)](/im_rect_unionrect/3.md) fills Rect r3 with the bounding box of Rect r1 and Rect r2. A proper union operation requires lists of rectangles, sadly.

[im\_rect\_equalsrect(3)](/im_rect_equalsrect/3.md) returns non-zero if r1 and r2 are identical.

[im\_rect\_dup(3)](/im_rect_dup/3.md) allocates memory for a new Rect structure and copies the elements of r into it. It returns a pointer to the new struct, or NULL on error.

[im\_rect\_normalise(3)](/im_rect_normalise/3.md) flips r so that the same pixels are enclosed,  but width and height are guaranteed \>=0.

## SEE ALSO

[im\_prepare(3)](/im_prepare/3.md), [im\_region\_create(3)](/im_region_create/3.md)

## COPYRIGHT

National Gallery, 1992

## AUTHOR

J. Cupitt
