图像的随机填充

template <typename T>
void Test_SetVal(T*pSrc, int32_t iSize, int32_t type)
{
    switch(type)
    {
    case ZERO_VAL: 
        {
            memset(pSrc, 0, iSize * sizeof(T*));
            break;
        }
    case MAX_VAL:
        {
            memset(pSrc, UCHAR_MAX * sizeof(T), iSize * sizeof(T*));
            break;
        }
    case RAND_VAL:
        {
            int32_t randMax = UCHAR_MAX * sizeof(T);
            for (int32_t i = 0; i < iSize; i++)
            {
                pSrc[i] = random(randMax);
            }
            break;
        }
    default:
        cout<<"invalid type..please key the type of Test_randVal with 0, 1, 2"<<endl;
        system("pause");
    }
}

猜你喜欢

转载自blog.csdn.net/myzhouwang/article/details/85242517