需求:在三维场景下通过代码实现图片上图显示。
思路:通过布告板(UGGeoBillboard)添加图片(UGGeoPicture)实现。
存在问题:布告板文字显示正常,图片未显示。代码如下:
Feature3D *Layer3D::AddPicture(QString &pictureFile,OgdcPoint3D &position,QString &strID)
{
//!新建图片对象
UGGeoPicture* pPicture = new UGGeoPicture();
QImage* pImage = new QImage(pictureFile);
UGImageData* pImageData = new UGImageData();
pImageData->nHeight = pImage->height();
pImageData->nWidth = pImage->width();
pImageData->nWidthBytes = pImage->bytesPerLine();
pImageData->btBitsPixel = 32;
pImageData->pBits = new UGbyte[pImage->byteCount()];
memcpy(pImageData->pBits,pImage->bits(),pImage->byteCount());
UGArray<UGImageData*> arrImageData;
arrImageData.Add(pImageData);
UGPoint2D pntCenter(position.x,position.y);
UGSize2D szSize(1,1);
bool bIsOk = pPicture->Make(arrImageData,pntCenter,szSize);
//! 新建布告板对象
UGGeoBillboard *pUGGeoBillboard = new UGGeoBillboard();
pUGGeoBillboard->MakeWithGeometry(pPicture);
pUGGeoBillboard->SetHeight(72);
pUGGeoBillboard->SetWidth(48);
if(bIsOk)
{
pUGGeoBillboard->SetPosition(position);
return this->AddFeature(pUGGeoBillboard,strID);
}
else
return NULL;
}
可否帮忙看看,这段代码有啥问题。