Rate This Document
Findability
Accuracy
Completeness
Readability

CopyWrapBorder

Copies pixel values between two images and adds border pixels.

The function interface is declared as follows:

  • Not-in-place operation:

    HmppResult HMPPI_CopyWrapBorder_32s_C1R(const int32_t *src, int32_t srcStep, HmppiSize srcRoiSize, int32_t *dst, int32_t dstStep,HmppiSize dstRoiSize, int32_t topBorderHeight, int32_t leftBorderWidth);

    HmppResult HMPPI_CopyWrapBorder_32f_C1R(const float *src, int32_t srcStep, HmppiSize srcRoiSize, float *dst, int32_t dstStep,HmppiSize dstRoiSize, int32_t topBorderHeight, int32_t leftBorderWidth);

  • In-place operation:

    HmppResult HMPPI_CopyWrapBorder_32s_C1IR(const int32_t *src, int32_t srcDstStep, HmppiSize srcRoiSize, HmppiSize dstRoiSize,int32_t topBorderHeight, int32_t leftBorderwidth);

    HmppResult HMPPI_CopyWrapBorder_32f_C1IR(const float *src, int32_t srcDstStep, HmppiSize srcRoiSize, HmppiSize dstRoiSize,int32_t topBorderHeight, int32_t leftBorderwidth);

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

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

#define SRC_BUFFER_SIZE_T 12
#define DST_BUFFER_SIZE_T 132

int CopyWrapBorderExample()
{
    HmppiSize roiSrc = {3,4};
    int32_t src[SRC_BUFFER_SIZE_T] = { 1, 2, 3,  
                                      2, 3, 4, 
                                      3, 4, 5,  
                                      4, 5, 6 };
    int32_t dst[DST_BUFFER_SIZE_T] = {0};
    int32_t srcStep = 3 * sizeof(int32_t);
    int32_t dstStep = 11 * sizeof(int32_t);
    HmppiSize roiDst = {11,12};
    int32_t topBorderHeight = 4;
    int32_t leftBorderWidth = 4;
    HmppResult result = HMPPI_CopyWrapBorder_32s_C1R(src, srcStep, roiSrc, dst, dstStep, roiDst, topBorderHeight, leftBorderWidth);
    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;
}

Output:

result = 0
dst = 
   3   1   2   3   1   2   3   1   2   3   1
   4   2   3   4   2   3   4   2   3   4   2
   5   3   4   5   3   4   5   3   4   5   3
   6   4   5   6   4   5   6   4   5   6   4
   3   1   2   3   1   2   3   1   2   3   1
   4   2   3   4   2   3   4   2   3   4   2
   5   3   4   5   3   4   5   3   4   5   3
   6   4   5   6   4   5   6   4   5   6   4
   3   1   2   3   1   2   3   1   2   3   1
   4   2   3   4   2   3   4   2   3   4   2
   5   3   4   5   3   4   5   3   4   5   3
   6   4   5   6   4   5   6   4   5   6   4