本文整理汇总了C++中GDALColorTable::GetColorEntry方法的典型用法代码示例。如果您正苦于以下问题:C++ GDALColorTable::GetColorEntry方法的具体用法?C++ GDALColorTable::GetColorEntry怎么用?C++ GDALColorTable::GetColorEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GDALColorTable
的用法示例。
在下文中一共展示了GDALColorTable::GetColorEntry方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadLUT
void ReadLUT(GDALRasterBand* rasterBand, TeRasterParams& params)
{
GDALColorTable* colorTable = rasterBand->GetColorTable();
if(colorTable == 0)
return;
int ncolors = colorTable->GetColorEntryCount();
for(int i = 0; i < ncolors; ++i)
{
const GDALColorEntry* ce = colorTable->GetColorEntry(i);
if(ce == 0)
continue;
params.lutr_.push_back(ce->c1);
params.lutg_.push_back(ce->c2);
params.lutb_.push_back(ce->c3);
}
}
示例2: CALSWrapperSrcBand
CALSWrapperSrcBand(GDALDataset* poSrcDSIn)
{
this->poSrcDS = poSrcDSIn;
SetMetadataItem("NBITS", "1", "IMAGE_STRUCTURE");
poSrcDS->GetRasterBand(1)->GetBlockSize(&nBlockXSize, &nBlockYSize);
eDataType = GDT_Byte;
bInvertValues = TRUE;
GDALColorTable* poCT = poSrcDS->GetRasterBand(1)->GetColorTable();
if( poCT != NULL && poCT->GetColorEntryCount() >= 2 )
{
const GDALColorEntry* psEntry1 = poCT->GetColorEntry(0);
const GDALColorEntry* psEntry2 = poCT->GetColorEntry(1);
if( psEntry1->c1 == 255 && psEntry1->c2 == 255 && psEntry1->c3 == 255 &&
psEntry2->c1 == 0 && psEntry2->c2 == 0 && psEntry2->c3 == 0 )
{
bInvertValues = FALSE;
}
}
}
示例3: if
CMapRaster::CMapRaster(const QString& fn, CCanvas * parent)
: IMap(eRaster, "",parent)
, x(0)
, y(0)
, zoomlevel(1)
, zoomfactor(1.0)
, rasterBandCount(0)
{
filename = fn;
#ifdef WIN32
dataset = (GDALDataset*)GDALOpen(filename.toLocal8Bit(),GA_ReadOnly);
#else
dataset = (GDALDataset*)GDALOpen(filename.toUtf8(),GA_ReadOnly);
#endif
if(dataset == 0)
{
QMessageBox::warning(0, tr("Error..."), tr("Failed to load file: %1").arg(filename));
return;
}
rasterBandCount = dataset->GetRasterCount();
if(rasterBandCount == 1)
{
GDALRasterBand * pBand;
pBand = dataset->GetRasterBand(1);
if(pBand == 0)
{
delete dataset; dataset = 0;
QMessageBox::warning(0, tr("Error..."), tr("Failed to load file: %1").arg(filename));
return;
}
if(pBand->GetColorInterpretation() != GCI_PaletteIndex && pBand->GetColorInterpretation() != GCI_GrayIndex)
{
delete dataset; dataset = 0;
QMessageBox::warning(0, tr("Error..."), tr("File must be 8 bit palette or gray indexed."));
return;
}
if(pBand->GetColorInterpretation() == GCI_PaletteIndex )
{
GDALColorTable * pct = pBand->GetColorTable();
for(int i=0; i < pct->GetColorEntryCount(); ++i)
{
const GDALColorEntry& e = *pct->GetColorEntry(i);
colortable << qRgba(e.c1, e.c2, e.c3, e.c4);
}
}
else if(pBand->GetColorInterpretation() == GCI_GrayIndex )
{
for(int i=0; i < 256; ++i)
{
colortable << qRgba(i, i, i, 255);
}
}
else
{
delete dataset; dataset = 0;
QMessageBox::warning(0, tr("Error..."), tr("File must be 8 bit palette or gray indexed."));
return;
}
int success = 0;
double idx = pBand->GetNoDataValue(&success);
if(success)
{
QColor tmp(colortable[idx]);
tmp.setAlpha(0);
colortable[idx] = tmp.rgba();
}
}
maparea.setWidth(dataset->GetRasterXSize());
maparea.setHeight(dataset->GetRasterYSize());
}
示例4: loadImage
//.........这里部分代码省略.........
float* fa = lineBuf + (col*bandCount) + ixA;
a = *fa;
}
theImg.setPixel(px, py, qRgba(*r, *g, *b, a));
break;
}
#if QT_VERSION >= 0x040600
case GdalAdapter::Hsl:
{
float* h = lineBuf + (col*bandCount) + ixH;
float* s = lineBuf + (col*bandCount) + ixS;
float* l = lineBuf + (col*bandCount) + ixL;
int a = 255;
if (ixA != -1) {
float* fa = lineBuf + (col*bandCount) + ixA;
a = *fa;
}
QColor C = QColor::fromHsl(*h, *s, *l, a);
theImg.setPixel(px, py, C.rgba());
break;
}
#endif
case GdalAdapter::Cmyk:
{
float* c = lineBuf + (col*bandCount) + ixC;
float* m = lineBuf + (col*bandCount) + ixM;
float* y = lineBuf + (col*bandCount) + ixY;
float* k = lineBuf + (col*bandCount) + ixK;
int a = 255;
if (ixA != -1) {
float* fa = lineBuf + (col*bandCount) + ixA;
a = *fa;
}
QColor C = QColor::fromCmyk(*c, *m, *y, *k, a);
theImg.setPixel(px, py, C.rgba());
break;
}
case GdalAdapter::YUV:
{
// From http://www.fourcc.org/fccyvrgb.php
float* y = lineBuf + (col*bandCount) + ixYuvY;
float* u = lineBuf + (col*bandCount) + ixYuvU;
float* v = lineBuf + (col*bandCount) + ixYuvV;
int a = 255;
if (ixA != -1) {
float* fa = lineBuf + (col*bandCount) + ixA;
a = *fa;
}
float R = 1.164*(*y - 16) + 1.596*(*v - 128);
float G = 1.164*(*y - 16) - 0.813*(*v - 128) - 0.391*(*u - 128);
float B = 1.164*(*y - 16) + 2.018*(*u - 128);
theImg.setPixel(px, py, qRgba(R, G, B, a));
break;
}
case GdalAdapter::Palette_Gray:
{
float* ix = (lineBuf + (col*bandCount));
const GDALColorEntry* color = colTable->GetColorEntry(*ix);
theImg.setPixel(px, py, qRgb(color->c1, color->c1, color->c1));
break;
}
case GdalAdapter::Palette_RGBA:
{
float* ix = (lineBuf + (col*bandCount));
const GDALColorEntry* color = colTable->GetColorEntry(*ix);
theImg.setPixel(px, py, qRgba(color->c1, color->c2, color->c3, color->c4));
break;
}
#if QT_VERSION >= 0x040600
case GdalAdapter::Palette_HLS:
{
float* ix = (lineBuf + (col*bandCount));
const GDALColorEntry* color = colTable->GetColorEntry(*ix);
QColor C = QColor::fromHsl(color->c1, color->c2, color->c3, color->c4);
theImg.setPixel(px, py, C.rgba());
break;
}
#endif
case GdalAdapter::Palette_CMYK:
{
float* ix = (lineBuf + (col*bandCount));
const GDALColorEntry* color = colTable->GetColorEntry(*ix);
QColor C = QColor::fromCmyk(color->c1, color->c2, color->c3, color->c4);
theImg.setPixel(px, py, C.rgba());
break;
}
}
}
QCoreApplication::processEvents();
}
img.theFilename = fn;
img.theImg = QPixmap::fromImage(theImg);
theImages.push_back(img);
theBbox = theBbox.united(bbox);
GDALClose((GDALDatasetH)poDataset);
return true;
}
示例5: ProxyMain
//.........这里部分代码省略.........
poVDS->SetMetadata(papszMD, "RPC");
papszMD = ((GDALDataset*)hDataset)->GetMetadata("GEOLOCATION");
if (papszMD != NULL)
poVDS->SetMetadata(papszMD, "GEOLOCATION");
}
int nSrcBandCount = nBandCount;
if (nRGBExpand != 0)
{
GDALRasterBand *poSrcBand;
poSrcBand = ((GDALDataset*)
hDataset)->GetRasterBand(ABS(panBandList[0]));
if (panBandList[0] < 0)
poSrcBand = poSrcBand->GetMaskBand();
GDALColorTable *poColorTable = poSrcBand->GetColorTable();
if (poColorTable == NULL)
{
fprintf(stderr, "Error : band %d has no color table\n", ABS(panBandList[0]));
GDALClose(hDataset);
CPLFree(panBandList);
GDALDestroyDriverManager();
CSLDestroy(argv);
CSLDestroy(papszCreateOptions);
exit(1);
}
/* Check that the color table only contains gray levels */
/* when using -expand gray */
if (nRGBExpand == 1)
{
int nColorCount = poColorTable->GetColorEntryCount();
int nColor;
for (nColor = 0; nColor < nColorCount; nColor++)
{
const GDALColorEntry *poEntry = poColorTable->GetColorEntry(nColor);
if (poEntry->c1 != poEntry->c2 || poEntry->c1 != poEntry->c2)
{
fprintf(stderr, "Warning : color table contains non gray levels colors\n");
break;
}
}
}
if (nBandCount == 1)
nBandCount = nRGBExpand;
else if (nBandCount == 2 && (nRGBExpand == 3 || nRGBExpand == 4))
nBandCount = nRGBExpand;
else
{
fprintf(stderr, "Error : invalid use of -expand option.\n");
exit(1);
}
}
int bFilterOutStatsMetadata =
(bScale || bUnscale || !bSpatialArrangementPreserved || nRGBExpand != 0);
/* ==================================================================== */
/* Process all bands. */
/* ==================================================================== */
for (i = 0; i < nBandCount; i++)
{