本文整理汇总了C++中FactoryResource::setBands方法的典型用法代码示例。如果您正苦于以下问题:C++ FactoryResource::setBands方法的具体用法?C++ FactoryResource::setBands怎么用?C++ FactoryResource::setBands使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FactoryResource
的用法示例。
在下文中一共展示了FactoryResource::setBands方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copyImage
bool bilinear_bayer::copyImage(RasterElement * pRaster,
RasterElement * dRaster, int i,
Progress * pProgress)
{
VERIFY(pRaster != NULL);
RasterDataDescriptor *pDesc =
dynamic_cast < RasterDataDescriptor * >(pRaster->getDataDescriptor());
VERIFY(dRaster != NULL);
RasterDataDescriptor *rDesc =
dynamic_cast < RasterDataDescriptor * >(dRaster->getDataDescriptor());
DimensionDescriptor thirdBand = pDesc->getActiveBand(i); // get active
// band
// source
FactoryResource < DataRequest > pRequest;
pRequest->setInterleaveFormat(BSQ);
pRequest->setBands(thirdBand, thirdBand);
DataAccessor thirdBandDa = pRaster->getDataAccessor(pRequest.release());
thirdBand = rDesc->getActiveBand(i);
// destination
FactoryResource < DataRequest > pResultRequest;
pResultRequest->setWritable(true);
pRequest->setInterleaveFormat(BSQ);
pResultRequest->setBands(thirdBand, thirdBand);
DataAccessor pDestAcc = dRaster->getDataAccessor(pResultRequest.release());
VERIFY(thirdBandDa.isValid());
VERIFY(pDestAcc.isValid());
for (unsigned int curRow = 0; curRow < pDesc->getRowCount(); ++curRow)
{
for (unsigned int curCol = 0; curCol < pDesc->getColumnCount();
++curCol)
{
switchOnEncoding(pDesc->getDataType(), bilinear,
pDestAcc->getColumn(), thirdBandDa, curRow,
curCol, pDesc->getRowCount(),
pDesc->getColumnCount(), i, pRaster);
pDestAcc->nextColumn();
}
pDestAcc->nextRow();
}
return true;
}
示例2: getAccessor
DataAccessor getAccessor(int band, bool writable = false) {
FactoryResource<DataRequest> pRequest = FactoryResource<DataRequest>();
pRequest->setRows(pDataDescriptor->getActiveRow(0), pDataDescriptor->getActiveRow(getRowCount() - 1));
pRequest->setColumns(pDataDescriptor->getActiveColumn(0), pDataDescriptor->getActiveColumn(getColumnCount() - 1));
pRequest->setBands(pDataDescriptor->getActiveBand(band), pDataDescriptor->getActiveBand(band));
pRequest->setWritable(writable);
return pRaster->getDataAccessor(pRequest.release());
}
示例3: getCurrentFrameAccessor
DataAccessor BackgroundSuppressionShell::getCurrentFrameAccessor() const
{
if(mpRaster == NULL)
{
return DataAccessor(NULL, NULL);
}
RasterDataDescriptor *pDesc = static_cast<RasterDataDescriptor*>(mpRaster->getDataDescriptor());
VERIFYRV(pDesc != NULL, DataAccessor(NULL, NULL));
FactoryResource<DataRequest> request;
VERIFYRV(request.get() != NULL, DataAccessor(NULL, NULL));
request->setInterleaveFormat(BSQ);
DimensionDescriptor band = pDesc->getBands()[mCurrentFrame];
request->setBands(band, band, 1);
return mpRaster->getDataAccessor(request.release());
}
示例4: getReporter
void ConvolutionFilterShell::ConvolutionFilterThread::convolve(const T*)
{
int numResultsCols = mInput.mpIterCheck->getNumSelectedColumns();
if (mInput.mpResult == NULL)
{
return;
}
const RasterDataDescriptor* pResultDescriptor = static_cast<const RasterDataDescriptor*>(
mInput.mpResult->getDataDescriptor());
// account for AOIs which extend outside the dataset
int maxRowNum = static_cast<int>(mInput.mpDescriptor->getRowCount()) - 1;
mRowRange.mFirst = std::max(0, mRowRange.mFirst);
mRowRange.mLast = std::min(mRowRange.mLast, maxRowNum);
unsigned int bandCount = mInput.mBands.size();
for (unsigned int bandNum = 0; bandNum < bandCount; ++bandNum)
{
FactoryResource<DataRequest> pResultRequest;
pResultRequest->setRows(pResultDescriptor->getActiveRow(mRowRange.mFirst),
pResultDescriptor->getActiveRow(mRowRange.mLast));
pResultRequest->setColumns(pResultDescriptor->getActiveColumn(0),
pResultDescriptor->getActiveColumn(numResultsCols - 1));
pResultRequest->setBands(pResultDescriptor->getActiveBand(bandNum),
pResultDescriptor->getActiveBand(bandNum));
pResultRequest->setWritable(true);
DataAccessor resultAccessor = mInput.mpResult->getDataAccessor(pResultRequest.release());
if (!resultAccessor.isValid())
{
return;
}
int oldPercentDone = -1;
int rowOffset = static_cast<int>(mInput.mpIterCheck->getOffset().mY);
int startRow = mRowRange.mFirst + rowOffset;
int stopRow = mRowRange.mLast + rowOffset;
int columnOffset = static_cast<int>(mInput.mpIterCheck->getOffset().mX);
int startColumn = columnOffset;
int stopColumn = numResultsCols + columnOffset - 1;
int yshift = (mInput.mKernel.Nrows() - 1) / 2;
int xshift = (mInput.mKernel.Ncols() - 1) / 2;
FactoryResource<DataRequest> pRequest;
pRequest->setRows(mInput.mpDescriptor->getActiveRow(std::max(0, startRow - yshift)),
mInput.mpDescriptor->getActiveRow(std::min(maxRowNum, stopRow + mInput.mKernel.Nrows() - yshift)));
pRequest->setColumns(mInput.mpDescriptor->getActiveColumn(startColumn),
mInput.mpDescriptor->getActiveColumn(stopColumn));
pRequest->setBands(mInput.mpDescriptor->getActiveBand(mInput.mBands[bandNum]),
mInput.mpDescriptor->getActiveBand(mInput.mBands[bandNum]));
DataAccessor accessor = mInput.mpRaster->getDataAccessor(pRequest.release());
if (!accessor.isValid())
{
return;
}
Service<ModelServices> model;
ModelServices* pModel = model.get();
int numRows = stopRow - startRow + 1;
for (int row_index = startRow; row_index <= stopRow; ++row_index)
{
int percentDone = 100 * ((bandNum * numRows) + (row_index - startRow)) / (numRows * bandCount);
if (percentDone > oldPercentDone)
{
oldPercentDone = percentDone;
getReporter().reportProgress(getThreadIndex(), percentDone);
}
if (mInput.mpAbortFlag != NULL && *mInput.mpAbortFlag)
{
break;
}
for (int col_index = startColumn; col_index <= stopColumn; ++col_index)
{
double accum = 0.0;
if (mInput.mpIterCheck->getPixel(col_index, row_index))
{
for (int kernelrow = 0; kernelrow < mInput.mKernel.Nrows(); kernelrow++)
{
int neighbor_row = row_index - yshift + kernelrow;
int real_row = std::min(std::max(0, neighbor_row),
static_cast<int>(mInput.mpDescriptor->getRowCount()) - 1);
for (int kernelcol = 0; kernelcol < mInput.mKernel.Ncols(); kernelcol++)
{
int neighbor_col = col_index - xshift + kernelcol;
int real_col = std::min(std::max(0, neighbor_col),
static_cast<int>(mInput.mpDescriptor->getColumnCount()) - 1);
accessor->toPixel(real_row, real_col);
if (accessor.isValid() == false)
{
return;
}
double val = 0.0;
pModel->getDataValue<T>(reinterpret_cast<T*>(accessor->getColumn()), COMPLEX_MAGNITUDE, 0, val);
accum += mInput.mKernel(kernelrow+1, kernelcol+1) * val / mInput.mKernel.Storage();
}
}
//.........这里部分代码省略.........
示例5: getReporter
void NormalizeData::NormalizeDataThread::run()
{
if (mInput.mpResult == NULL)
{
getReporter().reportError("No result data element.");
return;
}
EncodingType encoding = mInput.mpDescriptor->getDataType();
int numCols = mInput.mpResultDescriptor->getColumnCount();
int oldPercentDone = 0;
int startRow = mRowRange.mFirst;
int stopRow = mRowRange.mLast;
bool isBip = (mInput.mpResultDescriptor->getInterleaveFormat() == BIP);
unsigned int numBandsInLoop = isBip ? 1 : mInput.mpResultDescriptor->getBandCount();
unsigned int numBandsPerElement = isBip ? mInput.mpResultDescriptor->getBandCount() : 1;
std::vector<double> bandMaxValues;
bandMaxValues.reserve(mInput.mpDescriptor->getBandCount());
for (unsigned int band = 0; band < mInput.mpDescriptor->getBandCount(); band++)
{
bandMaxValues.push_back(mInput.mpRaster->getStatistics(mInput.mpDescriptor->getActiveBand(band))->getMax());
}
Service<ModelServices> pModel;
for(unsigned int band = 0; band < numBandsInLoop; band++)
{
FactoryResource<DataRequest> pResultRequest;
pResultRequest->setRows(mInput.mpResultDescriptor->getActiveRow(mRowRange.mFirst),
mInput.mpResultDescriptor->getActiveRow(mRowRange.mLast));
pResultRequest->setColumns(mInput.mpResultDescriptor->getActiveColumn(0),
mInput.mpResultDescriptor->getActiveColumn(numCols - 1));
if (!isBip)
{
pResultRequest->setBands(mInput.mpResultDescriptor->getActiveBand(band), mInput.mpResultDescriptor->getActiveBand(band));
}
pResultRequest->setWritable(true);
DataAccessor resultAccessor = mInput.mpResult->getDataAccessor(pResultRequest.release());
if (!resultAccessor.isValid())
{
getReporter().reportError("Invalid data access.");
return;
}
FactoryResource<DataRequest> pRequest;
pRequest->setRows(mInput.mpDescriptor->getActiveRow(mRowRange.mFirst),
mInput.mpDescriptor->getActiveRow(mRowRange.mLast));
pRequest->setColumns(mInput.mpDescriptor->getActiveColumn(0),
mInput.mpDescriptor->getActiveColumn(numCols - 1));
if (!isBip)
{
pRequest->setBands(mInput.mpResultDescriptor->getActiveBand(band), mInput.mpResultDescriptor->getActiveBand(band));
}
DataAccessor accessor = mInput.mpRaster->getDataAccessor(pRequest.release());
if (!accessor.isValid())
{
getReporter().reportError("Invalid data access.");
return;
}
for (int row_index = startRow; row_index <= stopRow; row_index++)
{
int percentDone = mRowRange.computePercent(row_index / numBandsInLoop);
if (percentDone > oldPercentDone)
{
oldPercentDone = percentDone;
getReporter().reportProgress(getThreadIndex(), percentDone);
}
if (mInput.mpAbortFlag != NULL && *mInput.mpAbortFlag)
{
getReporter().reportProgress(getThreadIndex(), 100);
break;
}
for (int col_index = 0; col_index < numCols; col_index++)
{
if (!resultAccessor.isValid())
{
getReporter().reportError("Invalid data access.");
return;
}
for (unsigned int inner = 0; inner < numBandsPerElement; inner++)
{
double val = pModel->getDataValue(encoding, accessor->getColumn(), inner);
val /= bandMaxValues[std::max(band, inner)];
reinterpret_cast<double*>(resultAccessor->getColumn())[inner] = val;
}
resultAccessor->nextColumn();
accessor->nextColumn();
}
resultAccessor->nextRow();
accessor->nextRow();
}
}
getReporter().reportCompletion(getThreadIndex());
}
示例6: execute
bool ThresholdData::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
VERIFY(pInArgList != NULL);
StepResource pStep("Execute Wizard Item", "app", "{2501975d-7cd5-49b0-a3e7-49f7106793c0}");
pStep->addProperty("Item", getName());
mpStep = pStep.get();
if (!extractInputArgs(pInArgList))
{
return false;
}
const RasterDataDescriptor* pDesc = static_cast<const RasterDataDescriptor*>(mpInputElement->getDataDescriptor());
VERIFY(pDesc);
DimensionDescriptor band;
if (mDisplayBandNumber > 0)
{
band = pDesc->getOriginalBand(mDisplayBandNumber - 1);
if (band.isValid() == false)
{
reportError("The specified band is invalid.", "{a529538b-5b82-425d-af10-385a2581beec}");
return false;
}
}
else
{
band = pDesc->getActiveBand(mDisplayBandNumber);
}
FactoryResource<DataRequest> pReq;
pReq->setInterleaveFormat(BSQ);
pReq->setBands(band, band, 1);
DataAccessor acc = mpInputElement->getDataAccessor(pReq.release());
if (!acc.isValid())
{
reportError("Unable to access data element.", "{b5f1b7dd-7cf7-4cd5-b5bc-7b747d3561b9}");
return false;
}
// If necessary, convert region units
if (mRegionUnits != RAW_VALUE)
{
Statistics* pStatistics = mpInputElement->getStatistics(band);
if (pStatistics == NULL)
{
reportError("Unable to calculate data statistics.", "{61a44ced-a4aa-4423-b379-5783137eb980}");
return false;
}
mFirstThreshold = convertToRawUnits(pStatistics, mRegionUnits, mFirstThreshold);
mSecondThreshold = convertToRawUnits(pStatistics, mRegionUnits, mSecondThreshold);
}
FactoryResource<BitMask> pBitmask;
for (unsigned int row = 0; row < pDesc->getRowCount(); ++row)
{
reportProgress("Thresholding data", 100 * row / pDesc->getRowCount(),
"{2fc3dbea-1307-471c-bba2-bf86032be518}");
for (unsigned int col = 0; col < pDesc->getColumnCount(); ++col)
{
VERIFY(acc.isValid());
double val = ModelServices::getDataValue(pDesc->getDataType(), acc->getColumn(), 0);
switch (mPassArea)
{
case UPPER:
if (val >= mFirstThreshold)
{
pBitmask->setPixel(col, row, true);
}
break;
case LOWER:
if (val <= mFirstThreshold)
{
pBitmask->setPixel(col, row, true);
}
break;
case MIDDLE:
if (val >= mFirstThreshold && val <= mSecondThreshold)
{
pBitmask->setPixel(col, row, true);
}
break;
case OUTSIDE:
if (val <= mFirstThreshold || val >= mSecondThreshold)
{
pBitmask->setPixel(col, row, true);
}
break;
default:
reportError("Unknown or invalid pass area.", "{19c92b3b-52e9-442b-a01f-b545f819f200}");
return false;
}
acc->nextColumn();
}
acc->nextRow();
}
std::string aoiName = pDesc->getName() + "_aoi";
ModelResource<AoiElement> pAoi(aoiName, mpInputElement);
if (pAoi.get() == NULL)
{
reportWarning("Overwriting existing AOI.", "{d953a030-dd63-43a1-98db-b0f491dee123}");
Service<ModelServices>()->destroyElement(
Service<ModelServices>()->getElement(aoiName, TypeConverter::toString<AoiElement>(), mpInputElement));
//.........这里部分代码省略.........
示例7:
bool adaptive_median::copyImage4(RasterElement * pRaster,
RasterElement * dRaster, int i,
Progress * pProgress)
{
int flag = 0;
int size = 3;
int sizeMax = MAX_SIZE;
VERIFY(pRaster != NULL);
RasterDataDescriptor *pDesc =
dynamic_cast < RasterDataDescriptor * >(pRaster->getDataDescriptor());
VERIFY(dRaster != NULL);
RasterDataDescriptor *rDesc =
dynamic_cast < RasterDataDescriptor * >(dRaster->getDataDescriptor());
DimensionDescriptor thirdBand = pDesc->getActiveBand(i); // get active
// band
// source
FactoryResource < DataRequest > pRequest;
pRequest->setInterleaveFormat(BSQ);
pRequest->setBands(thirdBand, thirdBand);
DataAccessor thirdBandDa = pRaster->getDataAccessor(pRequest.release());
thirdBand = rDesc->getActiveBand(i);
// destination
FactoryResource < DataRequest > pResultRequest;
pResultRequest->setWritable(true);
pRequest->setInterleaveFormat(BSQ);
pResultRequest->setBands(thirdBand, thirdBand);
DataAccessor pDestAcc = dRaster->getDataAccessor(pResultRequest.release());
VERIFY(thirdBandDa.isValid());
VERIFY(pDestAcc.isValid());
for (unsigned int curRow = 0; curRow < pDesc->getRowCount(); ++curRow)
{
for (unsigned int curCol = 0; curCol < pDesc->getColumnCount();
++curCol)
{
VERIFY(pDestAcc.isValid());
switchOnEncoding(pDesc->getDataType(), adaptivemedian,
pDestAcc->getColumn(), thirdBandDa, curRow,
curCol, pDesc->getRowCount(),
pDesc->getColumnCount(), size, sizeMax, pProgress,
&flag);
if (flag == 1 && size <= sizeMax)
{
// increase window size
size = size + 2;
curCol--;
}
else
{
pDestAcc->nextColumn();
size = 3;
flag = 0;
}
}
pDestAcc->nextRow();
}
return true;
}
示例8: parsedFile
vector<ImportDescriptor*> SampleHdf4Importer::getImportDescriptors(const string& filename)
{
vector<ImportDescriptor*> descriptors;
Hdf4File parsedFile(filename);
bool bSuccess = getFileData(parsedFile);
if (bSuccess == true)
{
const Hdf4Dataset* pDataset =
dynamic_cast<const Hdf4Dataset*>(parsedFile.getRootGroup()->getElement("EV_500_RefSB"));
if ((pDataset != NULL) && (mpModel.get() != NULL))
{
Hdf4FileResource pFile(filename.c_str());
if (pFile.get() != NULL)
{
ImportDescriptor* pImportDescriptor = mpModel->createImportDescriptor(filename, "RasterElement", NULL);
if (pImportDescriptor != NULL)
{
RasterDataDescriptor* pDescriptor =
dynamic_cast<RasterDataDescriptor*>(pImportDescriptor->getDataDescriptor());
if (pDescriptor != NULL)
{
FactoryResource<RasterFileDescriptor> pFileDescriptor;
if (pFileDescriptor.get() != NULL)
{
int32 numDims = 0;
int32 dataType = 0;
int32 numAttr = 0;
pFileDescriptor->setFilename(filename);
Hdf4DatasetResource pDataHandle(*pFile, pDataset->getName().c_str());
int32 dimSizes[MAX_VAR_DIMS] = {0};
if (pDataHandle != NULL && *pDataHandle != FAIL)
{
pFileDescriptor->setDatasetLocation(pDataset->getName());
int32 success = SDgetinfo(*pDataHandle, const_cast<char*>(pDataset->getName().c_str()),
&numDims, dimSizes, &dataType, &numAttr);
// find out what type this Dataset is
string strDataType = hdf4TypeToString(dataType, 1);
if (success == SUCCEED && numDims == 3 && strDataType == "unsigned short")
{
// Bands
vector<DimensionDescriptor> bands =
RasterUtilities::generateDimensionVector(dimSizes[0], true, false, true);
pDescriptor->setBands(bands);
pFileDescriptor->setBands(bands);
// Rows
vector<DimensionDescriptor> rows =
RasterUtilities::generateDimensionVector(dimSizes[1], true, false, true);
pDescriptor->setRows(rows);
pFileDescriptor->setRows(rows);
// Columns
vector<DimensionDescriptor> columns =
RasterUtilities::generateDimensionVector(dimSizes[2], true, false, true);
pDescriptor->setColumns(columns);
pFileDescriptor->setColumns(columns);
}
}
// Data type
EncodingType e;
pDataset->getDataEncoding(e);
pDescriptor->setDataType(e);
pFileDescriptor->setBitsPerElement(pDescriptor->getBytesPerElement() * 8);
// Interleave format
pDescriptor->setInterleaveFormat(BSQ);
pFileDescriptor->setInterleaveFormat(BSQ);
// Metadata
FactoryResource<DynamicObject> pMetadata;
if (pMetadata.get() != NULL)
{
const Hdf4Dataset::AttributeContainer& attributes = pDataset->getAttributes();
for (Hdf4Dataset::AttributeContainer::const_iterator it = attributes.begin();
it != attributes.end(); ++it)
{
Hdf4Attribute* pAttribute = it->second;
if (pAttribute != NULL)
{
const string& name = pAttribute->getName();
const DataVariant& var = pAttribute->getVariant();
const unsigned short* pValue = var.getPointerToValue<unsigned short>();
if (name == "_FillValue" && pValue != NULL)
{
// Bad values
vector<int> badValues;
badValues.push_back(*pValue);
pDescriptor->setBadValues(badValues);
}
else
{
//.........这里部分代码省略.........
示例9: if
//.........这里部分代码省略.........
// Since bands and samples are swapped, force the interleave to BIP
pField = mFields.find("interleave");
if (pField != NULL)
{
pField->mValue = "bip";
}
}
// Columns
vector<DimensionDescriptor> columns;
pField = mFields.find(samplesStr);
if (pField != NULL)
{
int numColumns = atoi(pField->mValue.c_str());
for (int i = 0; i < numColumns; ++i)
{
DimensionDescriptor columnDim;
columnDim.setOriginalNumber(static_cast<unsigned int>(columnOffset + i));
columnDim.setOnDiskNumber(static_cast<unsigned int>(i));
columns.push_back(columnDim);
}
pDescriptor->setColumns(columns);
pFileDescriptor->setColumns(columns);
}
// Bands
vector<DimensionDescriptor> bands;
pField = mFields.find(bandsStr);
if (pField != NULL)
{
int numBands = atoi(pField->mValue.c_str());
bands = RasterUtilities::generateDimensionVector(numBands, true, false, true);
pDescriptor->setBands(bands);
pFileDescriptor->setBands(bands);
}
// Description
list<GcpPoint> gcps;
pField = mFields.find("description");
if (pField != NULL)
{
// Metadata
if (pField->mChildren.empty() == false)
{
FactoryResource<DynamicObject> pMetadata;
for (unsigned int i = 0; i < pField->mChildren.size(); ++i)
{
EnviField* pChild = pField->mChildren[i];
if (pChild != NULL)
{
if (pChild->mTag == "classification")
{
// Classification
FactoryResource<Classification> pClassification;
if (pClassification.get() != NULL)
{
string classLevel;
classLevel.append(1, *(pChild->mValue.data()));
pClassification->setLevel(classLevel);
pDescriptor->setClassification(pClassification.get());
}
}
else if ((pChild->mTag == "ll") || (pChild->mTag == "lr") || (pChild->mTag == "ul") ||
示例10: pFile
//.........这里部分代码省略.........
columnDim.setOriginalNumber(sioFile.mOrigColumnNumbers[i]);
}
else
{
columnDim.setOriginalNumber(i);
}
columnDim.setOnDiskNumber(i);
columns.push_back(columnDim);
}
pDescriptor->setColumns(columns);
pFileDescriptor->setColumns(columns);
// Bands
vector<DimensionDescriptor> bands;
for (int i = 0; i < (sioFile.mBands - sioFile.mBadBands); ++i)
{
DimensionDescriptor bandDim;
// Do not set an active number since the user has not selected the rows to load
if (static_cast<unsigned int>(i) < sioFile.mOrigBandNumbers.size())
{
bandDim.setOriginalNumber(sioFile.mOrigBandNumbers[i]);
}
else
{
bandDim.setOriginalNumber(i);
}
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)
示例11: execute
bool NefImporter::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
if (pInArgList == NULL || pOutArgList == NULL)
{
return false;
}
//setting up mpRasterElement
parseInputArgList(pInArgList);
RasterElement* pRaster = getRasterElement();
VERIFY(pRaster != NULL);
RasterDataDescriptor *pDescriptor = dynamic_cast<RasterDataDescriptor*>(pRaster->getDataDescriptor());
VERIFY(pDescriptor != NULL);
FileDescriptor *pFileDescriptor = pDescriptor->getFileDescriptor();
VERIFY(pFileDescriptor != NULL);
//data accessor
//RED
DimensionDescriptor firstBand = pDescriptor->getActiveBand(0);
FactoryResource<DataRequest> pRequest;
pRequest->setInterleaveFormat(BSQ);
pRequest->setBands(firstBand, firstBand);
pRequest->setWritable(true);
DataAccessor firstBandDa = pRaster->getDataAccessor(pRequest.release());
//GREEN
DimensionDescriptor secondBand = pDescriptor->getActiveBand(1);
FactoryResource<DataRequest> qRequest;
qRequest->setInterleaveFormat(BSQ);
qRequest->setBands(secondBand, secondBand);
qRequest->setWritable(true);
DataAccessor secondBandDa = pRaster->getDataAccessor(qRequest.release());
//BLUE
DimensionDescriptor thirdBand = pDescriptor->getActiveBand(2);
FactoryResource<DataRequest> rRequest;
rRequest->setInterleaveFormat(BSQ);
rRequest->setBands(thirdBand, thirdBand);
rRequest->setWritable(true);
DataAccessor thirdBandDa = pRaster->getDataAccessor(rRequest.release());
std::string filename = pRaster->getFilename();
Progress *pProgress = getProgress();
FactoryResource<Filename> pFilename;
pFilename->setFullPathAndName(filename);
LibRaw RawProcessor;
putenv ((char*)"TZ=UTC");
#define P1 RawProcessor.imgdata.idata
#define S RawProcessor.imgdata.sizes
#define C RawProcessor.imgdata.color
#define T RawProcessor.imgdata.thumbnail
#define P2 RawProcessor.imgdata.other
#define OUT RawProcessor.imgdata.params
const char *fname=filename.c_str();
RawProcessor.open_file(fname);
// Let us unpack the image
if (RawProcessor.unpack() != LIBRAW_SUCCESS)
{
return false;
}
/*
unsigned int *r=NULL;
unsigned int *g=NULL;
unsigned int *b=NULL;
unsigned int *h=NULL;
*/
unsigned int *zero=0;
int row=0,col=0,r=0,c=0;
/*
r=(unsigned int*)(&RawProcessor.imgdata.image[i][0]);
g=(unsigned int*)(&RawProcessor.imgdata.image[i][1]);
b=(unsigned int*)(&RawProcessor.imgdata.image[i][2]);
h=(unsigned int*)(&RawProcessor.imgdata.image[i][3]);
*/
//secondBandDa->toPixel(row,col);
//thirdBandDa->toPixel(row,col);
unsigned short *pData=reinterpret_cast<unsigned short*>(pRaster->getRawData());
if (pData == NULL)
{
return NULL;
}
memcpy(pData, RawProcessor.imgdata.rawdata.raw_image, sizeof(unsigned short) * RawProcessor.imgdata.sizes.raw_height * RawProcessor.imgdata.sizes.raw_width);
//.........这里部分代码省略.........
示例12: getPage
RasterPage* ConvertToBsqPager::getPage(DataRequest* pOriginalRequest, DimensionDescriptor startRow,
DimensionDescriptor startColumn, DimensionDescriptor startBand)
{
VERIFYRV(pOriginalRequest != NULL, NULL);
if (pOriginalRequest->getWritable())
{
return NULL;
}
InterleaveFormatType requestedType = pOriginalRequest->getInterleaveFormat();
DimensionDescriptor stopRow = pOriginalRequest->getStopRow();
DimensionDescriptor stopColumn = pOriginalRequest->getStopColumn();
DimensionDescriptor stopBand = pOriginalRequest->getStopBand();
unsigned int concurrentRows = std::min(pOriginalRequest->getConcurrentRows(),
stopRow.getActiveNumber() - startRow.getActiveNumber() + 1);
unsigned int concurrentBands = pOriginalRequest->getConcurrentBands();
VERIFY(requestedType == BSQ);
VERIFY(startBand == stopBand && concurrentBands == 1);
VERIFY(mpRaster != NULL);
const RasterDataDescriptor* pDd = dynamic_cast<const RasterDataDescriptor*>(mpRaster->getDataDescriptor());
VERIFY(pDd != NULL);
InterleaveFormatType interleave = pDd->getInterleaveFormat();
VERIFY(interleave == BIL || interleave == BIP);
unsigned int numRows = pDd->getRowCount();
unsigned int numCols = pDd->getColumnCount();
unsigned int numBands = pDd->getBandCount();
if (startRow.getActiveNumber() >= numRows || stopRow.getActiveNumber() >= numRows ||
startColumn.getActiveNumber() >= numCols || stopColumn.getActiveNumber() >= numCols ||
startBand.getActiveNumber() >= numBands || stopBand.getActiveNumber() >= numBands)
{
return NULL;
}
unsigned int cols = stopColumn.getActiveNumber() - startColumn.getActiveNumber() + 1;
std::auto_ptr<ConvertToBsqPage> pPage(new ConvertToBsqPage(concurrentRows, cols, mBytesPerElement));
unsigned char* pDst = reinterpret_cast<unsigned char*>(pPage->getRawData());
if (pDst == NULL)
{
return NULL;
}
FactoryResource<DataRequest> pRequest;
pRequest->setRows(startRow, stopRow);
pRequest->setColumns(startColumn, stopColumn, cols);
pRequest->setBands(startBand, startBand, 1);
DataAccessor da = mpRaster->getDataAccessor(pRequest.release());
if (interleave == BIP)
{
for (unsigned int row = 0; row < concurrentRows; ++row)
{
for (unsigned int col = 0; col < cols; ++col)
{
if (da.isValid() == false)
{
return NULL;
}
memcpy(pDst, da->getColumn(), mBytesPerElement);
pDst += mBytesPerElement;
da->nextColumn();
}
da->nextRow();
}
}
else if (interleave == BIL)
{
for (unsigned int row = 0; row < concurrentRows; ++row)
{
if (da.isValid() == false)
{
return NULL;
}
memcpy(pDst, da->getRow(), mBytesPerElement * cols);
pDst += mBytesPerElement * cols;
da->nextRow();
}
}
return pPage.release();
}