本文整理汇总了C++中QByteArray::fromRawData方法的典型用法代码示例。如果您正苦于以下问题:C++ QByteArray::fromRawData方法的具体用法?C++ QByteArray::fromRawData怎么用?C++ QByteArray::fromRawData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QByteArray
的用法示例。
在下文中一共展示了QByteArray::fromRawData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data_upload
BOOL CWizKMDatabaseServer::data_upload(const QString& strObjectGUID, const QString& strObjectType, const QByteArray& stream, const QString& strObjMD5, const QString& strDisplayName)
{
__int64 nStreamSize = stream.size();
if (0 == nStreamSize)
{
TOLOG(_T("fault error: stream is zero"));
return FALSE;
}
//
QString strMD5(strObjMD5);
//
QByteArray spPartStream;
//
int partSize = 500 * 1000;
int partCount = int(nStreamSize / partSize);
if (nStreamSize % partSize != 0)
{
partCount++;
}
//
for (int i = 0; i < partCount; i++)
{
spPartStream.clear();
int start = i * partSize;
int end = std::min<int>(start + partSize, int(nStreamSize));
ATLASSERT(end > start);
//
int curPartSize = end - start;
ATLASSERT(curPartSize <= partSize);
//
const char* begin = stream.data() + start;
spPartStream = spPartStream.fromRawData(begin, curPartSize);
//
int curPartStreamSize = (int)spPartStream.size();
ATLASSERT(curPartStreamSize == curPartSize);
//
if (!data_upload(strObjectGUID, strObjectType, strMD5, (int)nStreamSize, partCount, i, curPartSize, spPartStream))
{
TOLOG1(_T("Failed to upload part data: %1"), strDisplayName);
return FALSE;
}
}
//
//
return TRUE;
}
示例2: pc
int PointCloud2Renderer::fillPointList(Renderable & renderable,
std::vector<SbVec3f> &points,
std::vector<SbColor> &colors)
{
const PointCloud2 & pc(renderable.pointcloud2());
int pointNum = pc.height()*pc.width();
points.reserve(pointNum);
colors.reserve(pointNum);
QByteArray dataArray;
char * rawData = const_cast<char *>(pc.data().c_str());
for(int i = 0; i < pointNum; ++i)
{
dataArray.fromRawData(rawData,4);
float x = *reinterpret_cast<float *> (rawData);
rawData += 4;
float y = *reinterpret_cast<float *> (rawData);
rawData += 4;
float z = *reinterpret_cast<float *> (rawData);
rawData += 8;
float blue = *reinterpret_cast<unsigned char *>(rawData)/255.0;
rawData += 1;
float green = *reinterpret_cast<unsigned char *>(rawData)/255.0;
rawData += 1;
float red = *reinterpret_cast<unsigned char *>(rawData)/255.0;
rawData += 14;
if(!std::isnan(x))
{
points.push_back(SbVec3f(x, y, z));
colors.push_back(SbColor(red, green, blue));
}
}
return pointNum;
}