CaptureImage.padCenterWithColor Method

Module: CaptureImage

Definition

Pads the image at its center with a custom background color to match the specified aspect ratio.

The function computes the smallest padded image that contains the input image while maintaining

the target aspect ratio. The original image is centered with the specified color padding.

Note

Only BGR 24-bit, RGB 24-bit, and Grayscale 8-bit images are supported.

For grayscale images, the padding color is the red component.

CaptureImage padCenterWithColor(double aspectRatio, int colorRed, int colorGreen, int colorBlue)

Parameters

aspectRatio double
in Target aspect ratio (width/height) for the padded image. Must be positive.

colorRed int
in Padding color red component (0 to 255).

colorGreen int
in Padding color green component (0 to 255).

colorBlue int
in Padding color blue component (0 to 255).

Returns

The padded image with the specified aspect ratio.

Exceptions

An error has occurred during Devices Library execution.