Skip to main content

MgraRect

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 without rotation or fill color, or add it to a 2D graphics list.

Syntax

void MgraRect(
AIL_ID ContextGraId, //in
AIL_ID DstImageBufOrListGraId, //out
AIL_DOUBLE XStart, //in
AIL_DOUBLE YStart, //in
AIL_DOUBLE XEnd, //in
AIL_DOUBLE YEnd //in
)

Description

This function draws a rectangle destructively (raster-based) in the specified image. 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 from the top-left corner (XStart, YStart) to the bottom-right corner (XEnd, YEnd). 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 are interpreted with respect to the input coordinate system, specified using MgraControl or MgraControlListwith M_INPUT_UNITS. Note that if you set your input coordinate system to M_WORLD and you pass MgraRect an uncalibrated image, the function will generate an error.

To create a filled rectangle, use MgraRectFill. To create a rectangle that can be optionally filled and rotated, use MgraRectAngle.

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 (DstImageBufOrListGraId) 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. |

DstImageBufOrListGraId (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.

XStart (in, AIL_DOUBLE)

Specifies the X-coordinate of the top-left corner of the rectangle in the input coordinate system.

YStart (in, AIL_DOUBLE)

Specifies the Y-coordinate of the top-left corner of the rectangle in the input coordinate system.

XEnd (in, AIL_DOUBLE)

Specifies the X-coordinate of the bottom-right corner of the rectangle in the input coordinate system.

YEnd (in, AIL_DOUBLE)

Specifies the Y-coordinate of the bottom-right corner of the rectangle in the input coordinate system.

Copyright © 2026 Zebra Technologies.