本文整理汇总了C++中FactoryResource::setHeaderBytes方法的典型用法代码示例。如果您正苦于以下问题:C++ FactoryResource::setHeaderBytes方法的具体用法?C++ FactoryResource::setHeaderBytes怎么用?C++ FactoryResource::setHeaderBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FactoryResource
的用法示例。
在下文中一共展示了FactoryResource::setHeaderBytes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
geoValues.reserve(expectedNumValues);
for (unsigned int i = 0; i < pField->mChildren.size(); i++)
{
vectorFromField(pField->mChildren.at(i), geoValues, "%lf");
}
if (geoValues.size() == expectedNumValues)
{
vector<double>::iterator iter = geoValues.begin();
GcpPoint gcp;
while (iter != geoValues.end())
{
gcp.mPixel.mX = *iter++ - 1.0; // adjust ref point for ENVI's use of
gcp.mPixel.mY = *iter++ - 1.0; // upper left corner and one-based first pixel
gcp.mCoordinate.mX = *iter++; // GcpPoint has lat as mX and Lon as mY
gcp.mCoordinate.mY = *iter++; // geo point field has lat then lon value
gcps.push_back(gcp);
}
}
}
}
// GCPs
if (gcps.empty() == false)
{
pFileDescriptor->setGcps(gcps);
}
// Header bytes
pField = mFields.find("header offset");
if (pField != NULL)
{
int headerBytes = atoi(pField->mValue.c_str());
pFileDescriptor->setHeaderBytes(static_cast<unsigned int>(headerBytes));
}
// Data type
pField = mFields.find("data type");
if (pField != NULL)
{
vector<EncodingType> validDataTypes;
switch (atoi(pField->mValue.c_str()))
{
case 1: // char
pDescriptor->setDataType(INT1UBYTE);
pFileDescriptor->setBitsPerElement(8);
// signed char cannot be represented in ENVI header so use the closest thing
validDataTypes.push_back(INT1SBYTE);
break;
case 2: // short
pDescriptor->setDataType(INT2SBYTES);
pFileDescriptor->setBitsPerElement(16);
break;
case 3: // int
pDescriptor->setDataType(INT4SBYTES);
pFileDescriptor->setBitsPerElement(32);
break;
case 4: // float
pDescriptor->setDataType(FLT4BYTES);
pFileDescriptor->setBitsPerElement(32);
break;
示例2: pFile
//.........这里部分代码省略.........
bandDim.setOnDiskNumber(i);
bands.push_back(bandDim);
}
pDescriptor->setBands(bands);
pFileDescriptor->setBands(bands);
// Bits per pixel
pFileDescriptor->setBitsPerElement(sioFile.mBitsPerElement);
// Data type
pDescriptor->setDataType(sioFile.mDataType);
pDescriptor->setValidDataTypes(vector<EncodingType>(1, sioFile.mDataType));
// Interleave format
pDescriptor->setInterleaveFormat(BIP);
pFileDescriptor->setInterleaveFormat(BIP);
// Bad values
if (sioFile.mBadValues.empty() == true)
{
if ((sioFile.mDataType != FLT4BYTES) && (sioFile.mDataType != FLT8COMPLEX) &&
(sioFile.mDataType != FLT8BYTES))
{
vector<int> badValues;
badValues.push_back(0);
pDescriptor->setBadValues(badValues);
}
}
// Header bytes
pFileDescriptor->setHeaderBytes(28);
// Trailer bytes
struct stat statBuffer;
if (stat(filename.c_str(), &statBuffer) == 0)
{
double dataBytes = 28 + (sioFile.mRows * sioFile.mColumns * (sioFile.mBands - sioFile.mBadBands) *
(sioFile.mBitsPerElement / 8));
pFileDescriptor->setTrailerBytes(static_cast<unsigned int>(statBuffer.st_size - dataBytes));
}
// Units
FactoryResource<Units> pUnits;
pUnits->setUnitType(sioFile.mUnitType);
pUnits->setUnitName(sioFile.mUnitName);
pUnits->setRangeMin(sioFile.mRangeMin);
pUnits->setRangeMax(sioFile.mRangeMax);
pUnits->setScaleFromStandard(sioFile.mScale);
pDescriptor->setUnits(pUnits.get());
pFileDescriptor->setUnits(pUnits.get());
// GCPs
GcpPoint gcpLowerLeft;
gcpLowerLeft.mPixel.mX = 0.0;
gcpLowerLeft.mPixel.mY = 0.0;
GcpPoint gcpLowerRight;
gcpLowerRight.mPixel.mX = sioFile.mColumns - 1.0;
gcpLowerRight.mPixel.mY = 0.0;
GcpPoint gcpUpperLeft;
gcpUpperLeft.mPixel.mX = 0.0;