当前位置: 首页>>代码示例>>C++>>正文


C++ QBitArray类代码示例

本文整理汇总了C++中QBitArray的典型用法代码示例。如果您正苦于以下问题:C++ QBitArray类的具体用法?C++ QBitArray怎么用?C++ QBitArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QBitArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: generate

    QBitArray generate(QBitArray aPayload, QBitArray aPoly)
    {
        using namespace NsConverter;

        const int n = aPoly.size();
        QBitArray shiftReg(n, false);

        for(int i=aPayload.size()-1; i>=0; i--)
        {
            if( shiftReg[n-1] != aPayload[i]  )
            {
                //qDebug()<<"--------------------";
                // qDebug()<<" poly "<<aPoly;
                //qDebug()<<" shiftxor before shift"<<shiftReg;
                shiftReg = shiftReg<<1;
                //qDebug()<<" shiftxor before xor"<<shiftReg;
                shiftReg ^= aPoly;
                // qDebug()<<" shiftxor after"<<shiftReg;
            }
            else
            {
                shiftReg = shiftReg<<1;
            }
        }

        return shiftReg;
    }
开发者ID:awaken1988,项目名称:RegisterAnalyzer,代码行数:27,代码来源:crcgenerator.cpp

示例2: fi

// Compare images:
QBitArray OKFilter::imageToVect(const QString &inputImage)
{
    // Check src file:
    QFileInfo fi(inputImage);

    // Check files:
    if (!fi.exists())
        return QBitArray();

    QImage img(inputImage);
    if (img.isNull())
        return QBitArray();
    QBitArray result;
    result.resize(img.width()*img.height());
    int c = 0;
    for (int j=0; j<img.height(); j++)
        for (int i=0; i<img.width(); i++)
        {
            QRgb color = img.pixel(i, j);
            int alpha = qAlpha(color);
            result[c++] = (alpha>0);
        }

    return result;
}
开发者ID:flegall2014,项目名称:ImageCompare,代码行数:26,代码来源:okfilter.cpp

示例3: dehuffman

QByteArray dehuffman(QByteArray data, MainWindow *mainWindow)
{
	QHash<quint8, QBitArray> codes;
	qint32 size;
	QBitArray bits;
	{
		QDataStream stream(data);
		stream >> codes >> size >> bits;
		Q_ASSERT(stream.status() == QDataStream::Ok);
	}

	QHash<QBitArray, quint8> table;
	for (int i = 0; i < tableSize; ++i)
		if (codes.contains(i))	table[codes[i]] = i;

	QByteArray result;
	result.reserve(data.size());

	int index = 0;
	for (int i = 0; i < size; ++i)
	{
		mainWindow->setProgress(qRound(static_cast<qreal>(100 * i) / size));

		QBitArray b;
		while (!table.contains(b))
		{
			b.resize(b.size() + 1);
			if (bits[index])	b.setBit(b.size() - 1);
			++index;
		}
		result.append(table[b]);
	}

	return result;
}
开发者ID:Etrnls,项目名称:etrnlabs,代码行数:35,代码来源:huffman.cpp

示例4: Q_UNUSED

void KisConvolutionFilter::process(KisConstProcessingInformation srcInfo,
                                   KisProcessingInformation dstInfo,
                                   const QSize& size,
                                   const KisFilterConfiguration* config,
                                   KoUpdater* progressUpdater
                                  ) const
{
    Q_UNUSED(config);

    const KisPaintDeviceSP src = srcInfo.paintDevice();
    KisPaintDeviceSP dst = dstInfo.paintDevice();
    QPoint dstTopLeft = dstInfo.topLeft();
    QPoint srcTopLeft = srcInfo.topLeft();
    Q_ASSERT(src != 0);
    Q_ASSERT(dst != 0);

    KisConvolutionPainter painter(dst, dstInfo.selection());

    QBitArray channelFlags;
    if (config) {
        channelFlags = config->channelFlags();
    }
    if (channelFlags.isEmpty() || !config) {
        channelFlags = QBitArray(src->colorSpace()->channelCount(), true);
    }
 
    // disable alpha channel
    channelFlags.clearBit(1);

    painter.setChannelFlags(channelFlags);
    painter.setProgress(progressUpdater);
    painter.applyMatrix(m_matrix, src, srcTopLeft, dstTopLeft, size, BORDER_REPEAT);

}
开发者ID:KDE,项目名称:calligra-history,代码行数:34,代码来源:kis_convolution_filter.cpp

示例5: qDebug

void Tests::haveChunks()
{
   qDebug() << "===== haveChunks() =====";

   QList<Common::Hash> hashes;
   hashes
      << Common::Hash::fromStr("f6126deaa5e1d9692d54e3bef0507721372ee7f8") // "/sharedDirs/share3/aaaa bbbb cccc.txt"
      << Common::Hash::fromStr("4c24e58c47746ea04296df9342185d9b3a447899") // "/sharedDirs/share1/v.txt"
      << Common::Hash::fromStr("954531aef8ac193ad62f4de783da9d7e6ebd59dd") // "/sharedDirs/share1/y.txt" (deleted)
      << Common::Hash::fromStr("8374d82e993012aa23b293f319eef2c21d2da3b9"); // Random hash

   QBitArray expectedResult(hashes.size());
   expectedResult[0] = true;
   expectedResult[1] = true;
   expectedResult[2] = false;
   expectedResult[3] = false;

   QBitArray result = this->fileManager->haveChunks(hashes);
   QCOMPARE(result.size(), hashes.size());

   for (int i = 0; i < result.size(); i++)
   {
      QVERIFY(result[i] == expectedResult[i]);
      qDebug() << hashes[i].toStr() << " : " << (result[i] ? "Yes" : "No");
   }
}
开发者ID:PowerKiKi,项目名称:D-LAN,代码行数:26,代码来源:Tests.cpp

示例6: validateJointSelection

	bool ARehabMainWindow::validateJointSelection(void)
	{
		bool validate = true, someBitActive = false;
		//QBitArray nullBitArray(21, false);
		//QBitArray bitArray = jointSelectorWidget->getJointSelectorModel();
		QBitArray bitArray = jointSelectorWidget->getJointSelectorModel();

		for (unsigned int i = 0; i < bitArray.size(); ++i)
		{
			someBitActive |= jointSelectorWidget->getJointSelectorModel()[i];
		}

		if (!someBitActive)
		{			
			ui.lbValidationJoints->setPixmap(QPixmap(QString::fromUtf8(":/svg/bad.svg")));
			//ui.lbValidationJoints->show();
			validate = false;
		}
		else
		{
			this->arehabFileMetadata.jointsInvolved = this->jointSelectorWidget->getJointSelectorModel();
			ui.lbValidationJoints->setPixmap(QPixmap(QString::fromUtf8(":/svg/checked.svg")));
			//ui.lbValidationJoints->show();
		}
		return validate;
	}
开发者ID:JJ,项目名称:ARehab,代码行数:26,代码来源:ARehab_vTerapeuta.cpp

示例7: qDebug

quint32 CBerBitStringStorage::deserialize(CBerByteArrayInputStream& iStream, QObject* obj, CBerLength& length, quint32 codeLength)
{
	length.decode(iStream);
	qDebug() << "CBerBitStringStorage::deserialize, length extracted: " << length.getVal();

	qint32 lenVal = length.getVal();

	QByteArray data(lenVal, Qt::Initialization::Uninitialized);

	if (data.size() > 0)
	{
		QBitArray val;

		qint32 rdLength = iStream.read(data, 0, lenVal);
		if (rdLength == lenVal)
		{
			val.resize(rdLength);
			for (qint32 i=0; i<rdLength; ++i)
			{
				if (data[i]) val.setBit(i);
				else val.clearBit(i);
			}

			codeLength += rdLength + 1;

			QBitArray* pVal = &val;
			QVariant wrvar(PtrMetaTypes::s_QBitArrayPtrMetaType, &pVal);
			obj->metaObject()->property(3).write(obj, wrvar);
		}
	}

	return codeLength;
}
开发者ID:Saotomych,项目名称:ASN1,代码行数:33,代码来源:berBitStringStorage.cpp

示例8: sendPieceList

// Sends the complete list of pieces that we have downloaded.
void PeerWireClient::sendPieceList(const QBitArray &bitField)
{
    // The bitfield message may only be sent immediately after the
    // handshaking sequence is completed, and before any other
    // messages are sent.
    if (!sentHandShake)
        sendHandShake();

    // Don't send the bitfield if it's all zeros.
    if (bitField.count(true) == 0)
	return;

    int bitFieldSize = bitField.size();
    int size = (bitFieldSize + 7) / 8;
    QByteArray bits(size, '\0');
    for (int i = 0; i < bitFieldSize; ++i) {
        if (bitField.testBit(i)) {
            quint32 byte = quint32(i) / 8;
            quint32 bit = quint32(i) % 8;
            bits[byte] = uchar(bits.at(byte)) | (1 << (7 - bit));
        }
    }

    char message[] = {0, 0, 0, 1, 5};
    toNetworkData(bits.size() + 1, &message[0]);
    write(message, sizeof(message));
    write(bits);
}
开发者ID:SfietKonstantin,项目名称:radeon-qt5-qtbase-kms,代码行数:29,代码来源:peerwireclient.cpp

示例9: while

QList<QWidget *> FatherBlock::GetEnableBlocksWidget(int theStatusIndex)
{
    QList<QWidget *>theBlockWidgets;
    if(theStatusIndex == -1)
    {
        theStatusIndex = m_current_status_index;
    }
    if(theStatusIndex < m_status_list.count())
    {
        QBitArray theStatus = m_status_list[theStatusIndex];
        int count = theStatus.count()-1;
        while(count >= 0)
        {
            if(theStatus.testBit(count) == true)
            {
                QWidget *ChildBlockWidget = GetSingleBlock(m_block_type);
                ChildBlockWidget->setStyleSheet(m_BlockStyleSheet);
                ChildBlockWidget->setGeometry(m_blocks_list[count]->geometry());
                ChildBlockWidget->setGeometry(ChildBlockWidget->x()+this->x(),ChildBlockWidget->y()+this->y(),ChildBlockWidget->width(),ChildBlockWidget->height());
                theBlockWidgets.append(ChildBlockWidget);
            }
            count--;
        }
    }
    return theBlockWidgets;
}
开发者ID:FIRECONTER,项目名称:RussiaBlocks,代码行数:26,代码来源:FatherBlock.cpp

示例10: ok

bool PropertyBitmaskConverter::applyMaskWithInValues_helper(QVariant &inVariant, QVariant &outVariant)
{
    bool ok(true);
    QBitArray inBitRepres = variantToBitArray(inVariant, ok);
    qDebug()<<"In value \t"<<inBitRepres;
    if (!ok)
        return ok;
    QBitArray outBitRepres = variantToBitArray(outVariant, ok);
    qDebug()<<"Out value \t"<<outBitRepres;
    if (!ok)
        return ok;
    Q_ASSERT(!_bitmaskFromInternal.isNull());
    QBitArray maskCopy = _bitmaskFromInternal;
    if (outBitRepres.count() != 0)
        maskCopy.truncate(outBitRepres.size());
    else
        outBitRepres.resize(maskCopy.count());
    inBitRepres.truncate(maskCopy.count());
    qDebug()<<"Mask (mod)\t"<<maskCopy;

    //! \todo optimize and beautify it
    if (inVariant.type() == QVariant::Bool)
        inBitRepres = maskCopy;
    else
        inBitRepres &= (maskCopy);//get only masked bits
    outBitRepres &= (~maskCopy);//clear mask bits
    outBitRepres |= inBitRepres;//set relevant bits from mask
    qDebug()<<"Out res\t"<<outBitRepres;

    return variantFromBitArray(outVariant, outBitRepres);
}
开发者ID:Krzysztow,项目名称:proto-gateway,代码行数:31,代码来源:propertyconverter.cpp

示例11: Q_UNUSED

void KisConvolutionFilter::process(KisPaintDeviceSP device,
                                  const QRect& applyRect,
                                  const KisFilterConfiguration* config,
                                  KoUpdater* progressUpdater) const
{
    Q_UNUSED(config);

    QPoint srcTopLeft = applyRect.topLeft();
    Q_ASSERT(device != 0);

    KisConvolutionPainter painter(device);

    QBitArray channelFlags;
    if (config) {
        channelFlags = config->channelFlags();
    }
    if (channelFlags.isEmpty() || !config) {
        channelFlags = QBitArray(device->colorSpace()->channelCount(), true);
    }
 
    painter.setChannelFlags(channelFlags);
    painter.setProgress(progressUpdater);
    painter.applyMatrix(m_matrix, device, srcTopLeft, srcTopLeft, applyRect.size(), BORDER_REPEAT);

}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:25,代码来源:kis_convolution_filter.cpp

示例12: Number

 Number(const QBitArray &bitArray)
 {
     bits = bitArray.size();
     value = 0;
     for (quint8 i=0; i<bits; i++)
         if (bitArray.at(i)) value += 1 << (bits-i-1);
 }
开发者ID:jklontz,项目名称:AMillionRandomDigits,代码行数:7,代码来源:main.cpp

示例13: img

// Run:
bool OKFilter::execute(const QList<QDir> &directories, const QString &srcFile)
{
    if (directories.size() < 2)
        return false;
    // Get reference file:
    QString refFile = directories.first().absoluteFilePath(srcFile);
    QImage img(refFile);
    int nPixels = img.width()*img.height();
    int threshold = qRound(.5*nPixels);

    // Get reference state:
    QBitArray refState = imageToVect(refFile);
    for (int i=1; i<directories.size(); i++)
    {
        // Exists?
        QString file = directories[i].absoluteFilePath(srcFile);
        QBitArray currentState = imageToVect(file);

        QBitArray tmp = (~refState & currentState) | (refState & ~currentState);
        int nErrors = tmp.count(true);
        if (nErrors > threshold)
            return false;
    }

    return true;
}
开发者ID:flegall2014,项目名称:ImageCompare,代码行数:27,代码来源:okfilter.cpp

示例14: getNextTable

//! Compute hidden value according to stegotable
bool StegoTable::computeValue(float miv, bool next)
{
    QBitArray stegoTable = next ? getNextTable() : _stTables[_indexTable[_currentTable]];
    int index = floor(miv / (double)_k);
    /*m_logger->debug("miv: " + QString::number(miv)
                    + "=> stegotable index: " + QString::number(index));*/
    return stegoTable.at(index);
}
开发者ID:jso0,项目名称:silenteye,代码行数:9,代码来源:stegotable.cpp

示例15: growRegion

QRect ImageOverlayRegionFinder::growRegion(int row, int column, QBitArray &mask)
{
    QRect region;
    region.setCoords(column, row, column, row);

    QQueue<int> queue;
    queue.enqueue(getDataIndex(row, column));

    while (!queue.isEmpty())
    {
        int i = queue.dequeue();

        if (m_overlay.getData()[i] > 0 && !mask.testBit(i))
        {
            mask.setBit(i);
            row = getRowIndex(i);
            column = getColumnIndex(i);
            
            if (row < region.top())
            {
                region.setTop(row);
            }
            if (row > region.bottom())
            {
                region.setBottom(row);
            }
            if (column < region.left())
            {
                region.setLeft(column);
            }
            if (column > region.right())
            {
                region.setRight(column);
            }

            if (column - 1 >= 0)
            {
                queue.enqueue(getDataIndex(row, column - 1));
            }
            if (column + 1 < static_cast<signed>(m_overlay.getColumns()))
            {
                queue.enqueue(getDataIndex(row, column + 1));
            }
            if (row - 1 >= 0)
            {
                queue.enqueue(getDataIndex(row - 1, column));
            }
            if (row + 1 < static_cast<signed>(m_overlay.getRows()))
            {
                queue.enqueue(getDataIndex(row + 1, column));
            }
        }
    }

    return region;
}
开发者ID:151706061,项目名称:starviewer,代码行数:56,代码来源:imageoverlayregionfinder.cpp


注:本文中的QBitArray类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。