Set
Initializes image pixel values to a specified value.
The function interface is declared as follows:
HmppResult HMPPI_Set_64f_C1R(double value, double *dst, HmppiSize dstSize);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
dst |
Pointer to the destination image ROI |
The value cannot be NULL. |
Input/Output |
value |
Pixel value to be initialized. |
Value within the data type range |
Input |
dstSize |
Size of the destination image ROI |
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 dst is NULL. |
HMPP_STS_SIZE_ERR |
The value of dstSize is 0 or negative. |
HMPP_STS_NO_ERR |
No error occurs. |
Example
#include <stdio.h>
#include "hmppi.h"
#include "hmpp_type.h"
void SetExample()
{
double value = 0.0;
HmppiSize dstSize = {4, 4};
double *dst = (double *)malloc(dstSize.height * dstSize.width * sizeof(double));
HmppResult result = HMPPI_Set_64f_C1R(value, dst, dstSize);
printf("result = %d\n", result);
if (result != HMPP_STS_NO_ERR) {
return;
}
for (int y = 0; y < dstSize.height; ++y) {
for (int x = 0; x < dstSize.width; ++x) {
printf("%f ", dst[y * dstSize.width + x]);
}
}
printf("\n");
}
int main()
{
SetExample();
return 0;
}
Output:
result = 0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
Parent topic: Basic Operations