高清截图
2023-01-03 11:36:47
128次阅读
0个评论

三维截图(渲染场景的过程)

ev_uint32 textureSizeW = 6000;

ev_uint32 textureSizeH = 5000;

EarthView::World::Graphic::CSceneManager* geoSceneManager = 
dynamic_cast<EarthView::World::Graphic::CSceneManager*>(ui.globeWidget->getGlobeControl()->getSceneManager());
if(NULL == geoSceneManager)
    return; 

EarthView::World::Spatial3D::CGlobeCamera* globeCamera = 
    dynamic_cast<EarthView::World::Spatial3D::CGlobeCamera*>(ui.globeWidget->getGlobeControl()->getCamera());
if(NULL == globeCamera)
    return; 

EarthView::World::Spatial3D::CGlobeCamera* myCam = 
    (EarthView::World::Spatial3D::CGlobeCamera *)geoSceneManager->createCamera(geoSceneManager->getName() + "myCam");
*myCam = *globeCamera;
ev_int32 fsaa = 4;
EarthView::World::Graphic::CTexturePtr myTex = CTextureManager::getSingleton().createManual(
    geoSceneManager->getName() + "myTex",
    CResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME,
    EarthView::World::Graphic::TEX_TYPE_2D,
    textureSizeW, 
    textureSizeH, 
    0,
    PF_A8R8G8B8,
    EarthView::World::Graphic::TU_RENDERTARGET,
    NULL,
    false,
    fsaa);
EarthView::World::Graphic::CRenderTarget* myRT = myTex->getBuffer()->getRenderTarget();
myRT->setAutoUpdated(false);
CViewport *myViewport = myRT->addViewport(myCam);
// 渲染到纹理
myRT->update();
// 将纹理上的内容写到磁盘
myRT->writeContentsToFile("H:\\201912\\pic\\" + geoSceneManager->getName() + "myTex.bmp"); //也可以通过myTex->convertToImage 将纹理导出到CImage在内存操作
myRT->removeAllViewports();
CTextureManager::getSingleton().remove(myTex->getHandle());
myTex.setNull();

geoSceneManager->destroyCamera(myCam);


二维截图(地图渲染过程)

CMapControl* pMapcontrol = ui.mapWidget->getMapControl();

IMap* map = pMapcontrol->getMap();

//准备工作
CSpatialDisplay display;
CBitmap bitmap(1024,1024);   // 绘制目标位图
display.fixDevice(&bitmap);
//重置坐标转换参数

CEnvelope devExtent(0,0, bitmap->getWidth(), bitmap->getHeight());

CEnvelope dataExtent(left, bottom, width, height); // 绘制范围,单位与坐标系单位一致
CSpatialTransformer* pTrans = (CSpatialTransformer*)display.getSpatialTransformer();   
pTrans->resetMapping(pMapcontrol->getDisplay()->getSpatialTransformer()->getDeviceExtent(),
pMapcontrol->getDisplay()->getSpatialTransformer()->getDataExtent(),
pMapcontrol->getDisplay()->getSpatialTransformer()->getRotation());
pTrans->setSpatialReference(CSpatialReference::WGS1984);// 想将地图显示到的坐标系


//绘制地图

ev_bool isBlank=true;

CRenderInformation info;

map ->draw(&display, &info, isBlank);


//绘制跟踪项
CSpatialRect mapViewport( pTrans->getDataExtent()->getMinX(),pTrans->getDataExtent()->getMinY(),
pTrans->getDataExtent()->getWidth(),pTrans->getDataExtent()->getHeight() );
//循环跟踪项,此处演示代码从跟踪层中取
CTrackingItemSet set = pMapcontrol->getTrackingLayer()->items();
for (int i = 0; i < set.count(); ++i)
{
    CTrackingItem * pItem = set.item(i);
    if( !pItem->isVisible() )
        continue;
    if( pItem->isShowAsScale() && (pTrans->getCurrentScale() > pItem->minScale() || pTrans->getCurrentScale() < pItem->maxScale() ) )
        continue;
    //判断跟踪项是否在视口内
    CSpatialRect r = pItem->boundingRect();
    pItem->transform(r,TD_ItemToMap);
    if( (mapViewport & r ).isEmpty() )
        continue;

    pItem->paint(&display,TIS_None,pItem->boundingRect());
}

收藏 0 0

登录 后评论。没有帐号? 注册 一个。

周峰

研发
  • 0 回答
  • 0 粉丝
  • 0 关注