本文整理汇总了C++中SpatialDataView::getLayerImage方法的典型用法代码示例。如果您正苦于以下问题:C++ SpatialDataView::getLayerImage方法的具体用法?C++ SpatialDataView::getLayerImage怎么用?C++ SpatialDataView::getLayerImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpatialDataView
的用法示例。
在下文中一共展示了SpatialDataView::getLayerImage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSessionItemImage
bool ImageHandler::getSessionItemImage(SessionItem* pItem, QBuffer& buffer, const QString& format, int band, int* pBbox)
{
if (format.isEmpty())
{
return false;
}
bool success = true;
QImage image;
Layer* pLayer = dynamic_cast<Layer*>(pItem);
View* pView = dynamic_cast<View*>(pItem);
if (pLayer != NULL)
{
SpatialDataView* pSDView = dynamic_cast<SpatialDataView*>(pLayer->getView());
if (pSDView != NULL)
{
UndoLock ulock(pSDView);
DimensionDescriptor cur;
DisplayMode mode;
RasterLayer* pRasterLayer = dynamic_cast<RasterLayer*>(pLayer);
if (band >= 0 && pRasterLayer != NULL)
{
RasterElement* pRaster = pRasterLayer->getDisplayedRasterElement(GRAY);
DimensionDescriptor bandDesc =
static_cast<RasterDataDescriptor*>(pRaster->getDataDescriptor())->getActiveBand(band);
cur = pRasterLayer->getDisplayedBand(GRAY);
mode = pRasterLayer->getDisplayMode();
pRasterLayer->setDisplayedBand(GRAY, bandDesc);
pRasterLayer->setDisplayMode(GRAYSCALE_MODE);
}
int bbox[4] = {0, 0, 0, 0};
ColorType transparent(255, 255, 254);
success = pSDView->getLayerImage(pLayer, image, transparent, bbox);
if (pBbox != NULL)
{
memcpy(pBbox, bbox, sizeof(bbox));
}
QImage alphaChannel(image.size(), QImage::Format_Indexed8);
if (image.hasAlphaChannel())
{
alphaChannel = image.alphaChannel();
}
else
{
alphaChannel.fill(0xff);
}
QRgb transColor = COLORTYPE_TO_QCOLOR(transparent).rgb();
for (int y = 0; y < image.height(); y++)
{
for (int x = 0; x < image.width(); x++)
{
if (image.pixel(x, y) == transColor)
{
alphaChannel.setPixel(x, y, 0x00);
}
}
}
image.setAlphaChannel(alphaChannel);
if (mode.isValid())
{
pRasterLayer->setDisplayedBand(GRAY, cur);
pRasterLayer->setDisplayMode(mode);
}
}
}
else if (pView != NULL)
{
success = pView->getCurrentImage(image);
}
else
{
success = false;
}
if (success)
{
buffer.open(QIODevice::WriteOnly);
QImageWriter writer(&buffer, format.toAscii());
success = writer.write(image);
}
return success;
}