halcon学习之tuple按位运算

//执行数组对应值的按位’与’,’或’,’非’,’异或’,’左移’,’右移’这五种位运算

void testTupleBitLogic()
{
    HTuple tuple1;
    tuple1[0] = 1;
    tuple1[1] = 2;

    HTuple tuple2;
    tuple2[0] = 3;
    tuple2[1] = 4;

    HTuple result = tuple1.TupleBand(tuple2);//按位与
    for (int i = 0; i < 2; i++)
    {
        cout << (Hlong)result[i] << " ";
    }
    cout << endl;

    result = tuple1.TupleBor(tuple2);//按位或
    for (int i = 0; i < 2; i++)
    {
        cout << (Hlong)result[i] << " ";
    }
    cout << endl;

    result = tuple1.TupleBxor(tuple2);//按位异或
    for (int i = 0; i < 2; i++)
    {
        cout << (Hlong)result[i] << " ";
    }
    cout << endl;

    result = tuple1.TupleBnot();//按位非
    for (int i = 0; i < 2; i++)
    {
        cout << (Hlong)result[i] << " ";
    }
    cout << endl;

    result = tuple1.TupleLsh(1);//按位左移
    for (int i = 0; i < 2; i++)
    {
        cout << (Hlong)result[i] << " ";
    }
    cout << endl;

    result = tuple1.TupleRsh(1);//按位右移
    for (int i = 0; i < 2; i++)
    {
        cout << (Hlong)result[i] << " ";
    }
    cout << endl;

}

你可能感兴趣的:(位运算,Tuple,halcon)