Skip to main content

MgraRectAngle

BoardSupported
Host SystemYes
V4L2Yes
Clarity UHDYes
Concord PoENo
GenTLYes
GevIQYes
GigE VisionYes
IndioNo
Iris GTXYes
Radient eV-CLYes
Rapixo CLYes
Rapixo CoFYes
Rapixo CXPYes
USB3 VisionYes

Draw a rectangle in an image with optional rotation and fill color, or add it to a 2D graphics list.

Syntax

void MgraRectAngle(
AIL_ID ContextGraId, //in
AIL_ID DestImageBufIdOrGraListId, //out
AIL_DOUBLE XPos, //in
AIL_DOUBLE YPos, //in
AIL_DOUBLE Width, //in
AIL_DOUBLE Height, //in
AIL_DOUBLE Angle, //in
AIL_INT64 ControlFlag //in
)

Description

This function draws a rectangle destructively (raster-based) in the specified image with an optional rotation and fill color. Alternatively, this function can add a vector-based version of a rectangle to the specified 2D graphics list, allowing you to, for example, non-destructively annotate a display without pixelation effects upon scaling.

The rectangle is created using a point (XPos, YPos), a width (Width), a height (Height), and an angle of rotation (Angle). The rectangle inherits all the relevant settings of the specified 2D graphics context, such as the foreground color (see MgraAlloc for default context settings). If part of the rectangle falls outside of the specified area (image or display), that part is clipped off.

To modify or inquire 2D graphics context settings, use MgraControl or MgraInquire. To modify or inquire 2D graphics list settings, use MgraControlList or MgraInquireList.

A rectangle's coordinates, dimensions, and angle are interpreted with respect to the input coordinate system, specified using MgraControl or MgraControlList with M_INPUT_UNITS. An angle interpreted with respect to the pixel coordinate system is always measured counter-clockwise. For information on the angle's direction of rotation when interpreting the angle with respect to the relative coordinate system, see Angle convention in Aurora Imaging Library. Note that if you set your input coordinate system to M_WORLD and you pass MgraRectAngle an uncalibrated image or the drawing target of the 2D graphics list is uncalibrated, the function will generate an error.

To create a filled rectangle that is not rotated, use MgraRectFill. To create a rectangle that is not rotated or filled, use MgraRect.

Note: Unlike most other functions that modify an Aurora Imaging Library object, you can call this function concurrently from multiple threads on the same Aurora Imaging Library 2D graphics list (DestImageBufIdOrGraListId) without using an M_MUTEX object, as long as all the other parameters of the concurrent calls do not also share data.

Parameters

ContextGraId (in, AIL_ID)

Specifies the identifier of the 2D graphics context. This parameter must be set to one of the following values:

For specifying the 2D graphics context

ValueDescription
M_DEFAULTSpecifies that the default 2D graphics context of the current Aurora Imaging Library application is used.

Note: Note that there is a different default 2D graphics context for each thread. | | 2D graphics context identifier | Specifies a valid 2D graphics context identifier, which you have allocated using MgraAlloc. |

DestImageBufIdOrGraListId (out, AIL_ID)

Specifies the identifier of a valid image buffer in which to draw the rectangle or the identifier of a valid 2D graphics list in which to add the rectangle. You must have allocated the image buffer or the 2D graphics list using MbufAlloc... or MgraAllocList, respectively.

XPos (in, AIL_DOUBLE)

Specifies the X-coordinate of the rectangle's position in the input coordinate system.

YPos (in, AIL_DOUBLE)

Specifies the Y-coordinate of the rectangle's position in the input coordinate system.

Width (in, AIL_DOUBLE)

Specifies the width of the rectangle, relative to the input coordinate system.

Height (in, AIL_DOUBLE)

Specifies the height of the rectangle, relative to the input coordinate system.

Angle (in, AIL_DOUBLE)

Specifies the angle with which to rotate the rectangle, in degrees, relative to the input coordinate system. The rectangle will either be rotated around its center (when using M_CENTER_AND_DIMENSION) or its top-left corner (when using M_CORNER_AND_DIMENSION).

ControlFlag (in, AIL_INT64)

Specifies how to draw the rectangle in the image or add the rectangle to the 2D graphics list.

For specifying how to draw or add the rectangle

ValueDescription
M_DEFAULTSame as M_CORNER_AND_DIMENSION.
M_CENTER_AND_DIMENSIONSpecifies that the rectangle is drawn according to its center position, as defined by the specified coordinates. Coordinates are set with the XPos and YPos parameters.
M_CORNER_AND_DIMENSIONSpecifies that the rectangle is drawn according to the position of its top-left corner, as defined by the specified coordinates. Coordinates are set with the XPos and YPos parameters.

For specifying whether the rectangle is filled

ValueDescription
M_FILLEDSpecifies that the rectangle is filled with specified foreground color (MgraControl or MgraControlList with M_COLOR).
Copyright © 2026 Zebra Technologies.