本文整理汇总了C++中quint8函数的典型用法代码示例。如果您正苦于以下问题:C++ quint8函数的具体用法?C++ quint8怎么用?C++ quint8使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了quint8函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: int
void HairyBrush::paintParticle(QPointF pos, const KoColor& color, qreal weight)
{
// opacity top left, right, bottom left, right
quint8 opacity = color.opacityU8();
opacity *= weight;
int ipx = int (pos.x());
int ipy = int (pos.y());
qreal fx = pos.x() - ipx;
qreal fy = pos.y() - ipy;
quint8 btl = qRound((1.0 - fx) * (1.0 - fy) * opacity);
quint8 btr = qRound((fx) * (1.0 - fy) * opacity);
quint8 bbl = qRound((1.0 - fx) * (fy) * opacity);
quint8 bbr = qRound((fx) * (fy) * opacity);
const KoColorSpace * cs = m_dab->colorSpace();
m_dabAccessor->moveTo(ipx , ipy);
btl = quint8(qBound<quint16>(OPACITY_TRANSPARENT_U8, btl + cs->opacityU8(m_dabAccessor->rawData()), OPACITY_OPAQUE_U8));
memcpy(m_dabAccessor->rawData(), color.data(), cs->pixelSize());
cs->setOpacity(m_dabAccessor->rawData(), btl, 1);
m_dabAccessor->moveTo(ipx + 1, ipy);
btr = quint8(qBound<quint16>(OPACITY_TRANSPARENT_U8, btr + cs->opacityU8(m_dabAccessor->rawData()), OPACITY_OPAQUE_U8));
memcpy(m_dabAccessor->rawData(), color.data(), cs->pixelSize());
cs->setOpacity(m_dabAccessor->rawData(), btr, 1);
m_dabAccessor->moveTo(ipx, ipy + 1);
bbl = quint8(qBound<quint16>(OPACITY_TRANSPARENT_U8, bbl + cs->opacityU8(m_dabAccessor->rawData()), OPACITY_OPAQUE_U8));
memcpy(m_dabAccessor->rawData(), color.data(), cs->pixelSize());
cs->setOpacity(m_dabAccessor->rawData(), bbl, 1);
m_dabAccessor->moveTo(ipx + 1, ipy + 1);
bbr = quint8(qBound<quint16>(OPACITY_TRANSPARENT_U8, bbr + cs->opacityU8(m_dabAccessor->rawData()), OPACITY_OPAQUE_U8));
memcpy(m_dabAccessor->rawData(), color.data(), cs->pixelSize());
cs->setOpacity(m_dabAccessor->rawData(), bbr, 1);
}
示例2: m_device
/*!
* Создание транспортного пакета.
*
* \param stream output stream.
* \param packets raw virtual packets.
* \param sequence packet sequence.
* \param timestamp отметка времени.
* \param options packet options.
* \param type packet type.
* \param subversion packet subversion.
*/
TransportWriter::TransportWriter(QDataStream *stream, const QList<QByteArray> &packets, quint64 sequence, qint64 timestamp, quint8 options, quint8 type, quint8 subversion)
: m_device(stream->device()),
m_size(16)
{
m_device->seek(0);
quint32 size = packets.size();
bool huge = options & Protocol::HugePackets;
// Расчёт размера пакета и составление карты размеров виртуальных пакетов.
if (huge)
m_size += (size * 4);
else
m_size += (size * 2);
quint32 *map = new quint32[size];
quint32 s = 0;
for (quint32 i = 0; i < size; ++i) {
s = packets.at(i).size();
map[i] = s;
m_size += s;
}
if (timestamp != 0) {
options |= Protocol::TimeStamp;
m_size += 8;
}
// Запись заголовка пакета.
*stream << m_size << type << quint8(Protocol::V4) << subversion << options << sequence;
if (timestamp != 0)
*stream << timestamp;
*stream << size;
// Запись карты размеров виртуальных пакетов.
if (huge) {
for (quint32 i = 0; i < size; ++i)
*stream << map[i];
} else {
for (quint32 i = 0; i < size; ++i)
*stream << quint16(map[i]);
}
// Запись тел виртуальных пакетов.
for (quint32 i = 0; i < size; ++i) {
stream->writeRawData(packets.at(i).constData(), map[i]);
}
delete [] map;
}
示例3: request
void PlayerSocket::sendEnemyConnectionInf(const QSharedPointer<PlayerSocket>& enemy, bool serverFlag)
{
QByteArray bytes;
QDataStream request(&bytes, QIODevice::ReadWrite);
request.setVersion(Protocol::QDataStreamVersion);
request << quint16(0) << quint8(Protocol::GAME_FOUND) << serverFlag;
request << enemy->getServerPort() << enemy->getHostName().toLatin1().data();
request.device()->seek(0);
request << quint16(bytes.size());
socket->write(bytes);
socket->flush();
}
示例4: QBluetoothServer
void ChatServer::startServer(const QBluetoothAddress& localAdapter)
{
if (rfcommServer)
return;
rfcommServer = new QBluetoothServer(QBluetoothServiceInfo::RfcommProtocol, this);
connect(rfcommServer, SIGNAL(newConnection()), this, SLOT(clientConnected()));
bool result = rfcommServer->listen(localAdapter);
if (!result) {
qWarning() << "Cannot bind chat server to" << localAdapter.toString();
return;
}
//serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceRecordHandle, (uint)0x00010010);
QBluetoothServiceInfo::Sequence classId;
classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort));
serviceInfo.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList,
classId);
classId.prepend(QVariant::fromValue(QBluetoothUuid(serviceUuid)));
serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId);
serviceInfo.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList,classId);
serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceName, tr("Bt Chat Server"));
serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceDescription,
tr("Example bluetooth chat server"));
serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceProvider, tr("qt-project.org"));
serviceInfo.setServiceUuid(QBluetoothUuid(serviceUuid));
serviceInfo.setAttribute(QBluetoothServiceInfo::BrowseGroupList,
QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
QBluetoothServiceInfo::Sequence protocolDescriptorList;
QBluetoothServiceInfo::Sequence protocol;
protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::L2cap));
protocolDescriptorList.append(QVariant::fromValue(protocol));
protocol.clear();
protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm))
<< QVariant::fromValue(quint8(rfcommServer->serverPort()));
protocolDescriptorList.append(QVariant::fromValue(protocol));
serviceInfo.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList,
protocolDescriptorList);
serviceInfo.registerService(localAdapter);
}
示例5: QByteArray
Shred::~Shred() {
QByteArray * const shred_data = new QByteArray();
shred_data->reserve(30000);
QDataStream outstr(shred_data, QIODevice::WriteOnly);
outstr << CURRENT_SHRED_FORMAT_VERSION;
outstr.setVersion(DATASTREAM_VERSION);
outstr << quint8(GetTypeOfShred()) << quint8(weather);
for (int x=0; x<SHRED_WIDTH; ++x)
for (int y=0; y<SHRED_WIDTH; ++y) {
int height = HEIGHT-2;
for ( ; blocks[x][y][height]->Sub()==AIR; --height);
for (int z=1; z <= height; ++z) {
Block * const block = blocks[x][y][z];
if ( block == Normal(block->Sub()) ) {
block->SaveNormalToFile(outstr);
} else {
block->SaveToFile(outstr);
delete block; // without unregistering.
}
}
blocks[x][y][HEIGHT-1]->SaveNormalToFile(outstr);
}
GetWorld()->SetShredData(shred_data, longitude, latitude);
}
示例6: out
void Client::sendRegistration()
{
QByteArray datagram;
QDataStream out(&datagram, QIODevice::WriteOnly);
out.setVersion(QDataStream::Qt_4_7);
out << quint16(0) << quint8('R');
out << DeviceManager::getDeviceMac() << DeviceManager::getDeviceIP();
out << 0xFFFF;
//out.device()->seek(0);
//out << quint16(block->size() - sizeof(quint16));
udpSocket.writeDatagram(datagram, QHostAddress::Broadcast, 6178);
}
示例7: out
void Client::sendSearchInfo(){
QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly);
out.setVersion(QDataStream::Qt_4_1);
//if(!userLineEdit->text().isEmpty()){
out << quint16(0) << quint8('S') << userLineEdit->text();
out.device()->seek(0);
out << quint16(block.size() - sizeof(quint16));
tcpSocket->write(block);
//}else{
// statusLabel->setText("Please enter a file to search for");
//}
//ui.label->setText(tr("Sending request..."));
//printf("Sending Request...\n");
}
示例8: QFETCH
void tst_QAsn1Element::octetString()
{
QFETCH(QByteArray, encoded);
QFETCH(QByteArray, value);
// read
QAsn1Element elem;
QVERIFY(elem.read(encoded));
QCOMPARE(elem.type(), quint8(QAsn1Element::OctetStringType));
QCOMPARE(elem.value(), value);
// write
QByteArray buffer;
QDataStream stream(&buffer, QIODevice::WriteOnly);
elem.write(stream);
QCOMPARE(buffer, encoded);
}
示例9: CHECK_SIZE_EQUALS
QModbusResponse QModbusServerPrivate::processGetCommEventLogRequest(const QModbusRequest &request)
{
CHECK_SIZE_EQUALS(request);
const QVariant tmp = q_func()->value(QModbusServer::DeviceBusy);
if (tmp.isNull() || (!tmp.isValid())) {
return QModbusExceptionResponse(request.functionCode(),
QModbusExceptionResponse::ServerDeviceFailure);
}
const quint16 deviceBusy = tmp.value<quint16>();
QVector<quint8> eventLog(int(m_commEventLog.size()));
std::copy(m_commEventLog.cbegin(), m_commEventLog.cend(), eventLog.begin());
// 6 -> 3 x 2 Bytes (Status, Event Count and Message Count)
return QModbusResponse(request.functionCode(), quint8(eventLog.size() + 6), deviceBusy,
m_counters[Counter::CommEvent], m_counters[Counter::BusMessage], eventLog);
}
示例10: window
void QDirectFBWindowSurface::flush(QWidget *widget, const QRegion ®ion,
const QPoint &offset)
{
QWidget *win = window();
if (!win)
return;
#if !defined(QT_NO_QWS_PROXYSCREEN) && !defined(QT_NO_GRAPHICSVIEW)
QWExtra *extra = qt_widget_private(widget)->extraData();
if (extra && extra->proxyWidget)
return;
#else
Q_UNUSED(widget);
#endif
const quint8 windowOpacity = quint8(win->windowOpacity() * 0xff);
const QRect windowGeometry = geometry();
#ifdef QT_DIRECTFB_WM
quint8 currentOpacity;
Q_ASSERT(dfbWindow);
dfbWindow->GetOpacity(dfbWindow, ¤tOpacity);
if (currentOpacity != windowOpacity) {
dfbWindow->SetOpacity(dfbWindow, windowOpacity);
}
screen->flipSurface(dfbSurface, flipFlags, region, offset);
#else
setOpaque(windowOpacity == 0xff);
if (mode == Offscreen) {
screen->exposeRegion(region.translated(offset + geometry().topLeft()), 0);
} else {
screen->flipSurface(dfbSurface, flipFlags, region, offset);
}
#endif
#ifdef QT_DIRECTFB_TIMING
enum { Secs = 3 };
++frames;
if (timer.elapsed() >= Secs * 1000) {
qDebug("%d fps", int(double(frames) / double(Secs)));
frames = 0;
timer.restart();
}
#endif
flushPending = false;
}
示例11: quint8
void KisColor::initHSX(Type type, float h, float s, float x, float a)
{
// an offset that is added to the m_coreData buffer to make sure
// the struct created with the placement new operator is aligned at 16 bytes
// this is required by Eigen for vectorization
m_offset = quint8(16 - (reinterpret_cast<size_t>(m_coreData) % 16)) % 16;
switch(type)
{
case HSY: { new (m_coreData + m_offset) CoreImpl<HSYType>; } break;
case HSV: { new (m_coreData + m_offset) CoreImpl<HSVType>; } break;
case HSL: { new (m_coreData + m_offset) CoreImpl<HSLType>; } break;
case HSI: { new (m_coreData + m_offset) CoreImpl<HSIType>; } break;
}
core()->type = type;
core()->setHSX(h, s, x, a);
}
示例12: Coach
void WorldSession::SendCoachInformation()
{
Coach* coach = new Coach(this);
if (!coach->LoadFromDB())
{
delete coach;
OnClose();
return;
}
WorldPacket data(SMSG_COACH_INFORMATIONS);
// unserializeIdAndName
data << coach->GetGuid();
data.WriteString(coach->GetName());
// unserializeLook
data << coach->GetSkinColorIndex();
data << coach->GetHairColorIndex();
data << coach->GetGender();
// unserializeEquipment
data << quint16(0); // length
// todo
// unserializeCardInventory
data << quint16(0); // length
// todo
// unserializeLockedSet
data << quint16(0); // length
// unserializeLaddersStrength
data << quint8(0); // count
// todo
SendPacket(data);
// World login
SendEnterInstance();
}
示例13: testQOfonoCallVolume
void testQOfonoCallVolume()
{
QSignalSpy mutedChanged(m, SIGNAL(mutedChanged(const bool)));
QSignalSpy speakerVolumeChanged(m, SIGNAL(speakerVolumeChanged(const quint8)));
QSignalSpy microphoneVolumeChanged(m, SIGNAL(microphoneVolumeChanged(const quint8)));
QSignalSpy spfail(m, SIGNAL(setSpeakerVolumeFailed()));
QSignalSpy mvfail(m, SIGNAL(setMicrophoneVolumeFailed()));
QOfonoModem modem;
modem.setModemPath(m->modemPath());
modem.setPowered(false);
QTest::qWait(5000);
modem.setPowered(true);
QTest::qWait(5000);
modem.setOnline(true);
QTest::qWait(5000);
m->setMuted(true);
QTest::qWait(2000);
QCOMPARE(mutedChanged.count(), 1);
QVERIFY(mutedChanged.takeFirst().at(0).toBool()==bool(true));
QVERIFY(m->muted()==bool(true));
m->setMuted(false);
QTest::qWait(2000);
QCOMPARE(mutedChanged.count(), 1);
QVERIFY(mutedChanged.takeFirst().at(0).toBool()==bool(false));
QVERIFY(m->muted()==bool(false));
m->setSpeakerVolume(quint8(15));
QTest::qWait(2000);
QCOMPARE(speakerVolumeChanged.count(), 1);
QCOMPARE(quint8(speakerVolumeChanged.takeFirst().at(0).toUInt()), quint8(15));
QCOMPARE(m->speakerVolume(),quint8(15));
m->setSpeakerVolume(quint8(250));
QTest::qWait(2000);
QCOMPARE(spfail.count(), 1);
m->setMicrophoneVolume(quint8(10));
QTest::qWait(2000);
QCOMPARE(mvfail.count(), 1);
}
示例14: getSeatNO
void Client::sendOrder()
{
quint16 seatNO = getSeatNO();
block = new QByteArray();
QDataStream out(block, QIODevice::WriteOnly);
out.setVersion(QDataStream::Qt_4_7);
out << quint16(0) << quint8('O');
QSqlQuery query;
query.exec("SELECT * FROM unsentModel");
quint32 orderNO = 0;
QString name = "";
QString image = "";
float price = 0;
quint16 num = 0;
while (query.next()) {
if (orderNO == 0) {
orderNO = query.value(0).toUInt();
out << quint32(orderNO) << quint16(seatNO) << DeviceManager::getDeviceMac();
}
name = query.value(1).toString();
image = query.value(2).toString();
price = query.value(3).toFloat();
num = query.value(4).toUInt();
out << 0x1111 << name << price << num;
}
query.exec("DELETE FROM unsentModel");
out << 0xFFFF;
out.device()->seek(0);
out << quint16(block->size() - sizeof(quint16));
QString serverIP = DeviceManager::getServerIP();
connectToServer(serverIP);
emit sendOrderComplete();
}
示例15: stream
void VoxelFile::save_fp(QFile & fp)
{
QDataStream stream(&fp);
stream.setByteOrder(QDataStream::LittleEndian);
stream << x_size;
stream << y_size;
stream << z_size;
stream << x_offset;
stream << y_offset;
stream << z_offset;
stream.writeRawData((char*)data, x_size * y_size * z_size);
stream.writeRawData((char*)global_palette, 256 * 3);
stream << quint8(points.size());
ReferencePoints::const_iterator it;
for (it = points.begin(); it != points.end(); it++) {
const ReferencePoint & point = *it;
write_cstring(stream, point.name);
stream << point.x;
stream << point.y;
stream << point.z;
}
save_palette();
}