CopyConstBorder
Copies pixel values between two images and adds border pixels with a fixed value.
The function interface is declared as follows:
HmppResult HMPPI_CopyConstBorder_32f_C1R(const float *src, int32_t srcStep, HmppiSize srcRoiSize, float *dst, int32_t dstStep, HmppiSize dstRoiSize, int32_t topBorderHeight, int32_t leftBorderWidth, float value);
HmppResult HMPPI_CopyConstBorder_8u_C1R(const uint8_t *src, int32_t srcStep, HmppiSize srcRoiSize, uint8_t *dst, int32_t dstStep, HmppiSize dstRoiSize, int32_t topBorderHeight, int32_t leftBorderWidth, uint8_t value);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
src |
Pointer to the source image ROI |
The value cannot be NULL. |
Input |
srcStep |
Distance between starts of consecutive lines in the source image, in bytes |
The value must be zero or a positive integer. |
Input |
dst |
Pointer to the destination image ROI |
The value cannot be NULL. |
Output |
dstStep |
Distance between starts of consecutive lines in the destination image, in bytes |
The value must be zero or a positive integer. |
Input |
srcDst |
Pointer to the ROI of the source and destination images (for in-place operations) |
The value cannot be NULL. |
Input/Output |
srcDstStep |
Distance between starts of consecutive lines in the source and destination images (in-place operation), in bytes |
The value must be zero or a positive integer. |
Input |
srcRoiSize |
Size of the source ROI, in pixels |
srcRoiSize.width ∈ (0, INT_MAX], srcRoiSize.height ∈ (0, INT_MAX] |
Input |
dstRoiSize |
Size of the destination ROI, in pixels |
dstRoiSize.width ∈ (0, INT_MAX], dstRoiSize.height ∈ (0, INT_MAX] |
Input/Output |
topBorderHeight |
Height of the top border, in pixels |
The value must be zero or a positive integer. |
Input |
leftBorderWidth |
Width of the left border, in pixels |
The value must be zero or a positive integer. |
Input |
value |
Value of border pixels |
Range of the input data type |
Input |
Return Value
- Success: HMPP_STS_NO_ERR
- Failure: An error code is returned.
Error Codes
Error Code |
Description |
|---|---|
HMPP_STS_NULL_PTR_ERR |
The value of src or dst is NULL. |
HMPP_STS_SIZE_ERR |
The value of srcRoiSize or dstRoiSize is 0 or negative. |
HMPP_STS_STEP_ERR |
The value of srcStep or dstStep is 0 or negative. |
HMPP_STS_NOT_EVEN_STEP_ERR |
The value of srcStep or dstStep cannot be exactly divided by the byte length of the data type to which src or dst belongs. |
HMPP_STS_ROI_ERR |
The value of srcRoiSize.width or dstRoiSize.width is greater than the step. |
Example
#include <stdio.h>
#include "hmppi.h"
#include "hmpp_type.h"
#define SRC_BUFFER_SIZE_T 12
#define DST_BUFFER_SIZE_T 132
int CopyConstBorderExample()
{
HmppiSize roiSrc = {3,4};
uint8_t src[SRC_BUFFER_SIZE_T] = { 1, 2, 3,
2, 3, 4,
3, 4, 5,
4, 5, 6 };
uint8_t dst[DST_BUFFER_SIZE_T] = {0};
int32_t srcStep = 3 * sizeof(uint8_t);
int32_t dstStep = 11 * sizeof(uint8_t);
HmppiSize roiDst = {11,12};
int32_t topBorderHeight = 4;
int32_t leftBorderWidth = 4;
uint8_t value = 255;
HmppResult result = HMPPI_CopyConstBorder_8u_C1R(src, srcStep, roiSrc, dst, dstStep, roiDst, topBorderHeight, leftBorderWidth, value);
printf("result = %d \ndst = \n", result);
if (result != HMPP_STS_NO_ERR) {
printf("result error: %d\n", result);
}
int32_t dstWidth = dstStep / sizeof(uint8_t);
for (int32_t i = 0; i < 12; i++){
for (int32_t j = 0; j < 11; j++){
printf("%3d ",dst[i*11+j]);
}
printf("\n");
}
return 0;
}
int main() {
CopyConstBorderExample();
return 0;
}
Output:
result = 0 dst = 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 1 2 3 255 255 255 255 255 255 255 255 2 3 4 255 255 255 255 255 255 255 255 3 4 5 255 255 255 255 255 255 255 255 4 5 6 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255