2015-02-06 124 views
0

如何通過渲染器來計算圖像每個角的座標?計算圖像每個角的座標

實施例:

double* pBounds = pImageData->GetBounds(); 
TRACE("%f.%f.%f.%f.%f.%f\n", pBounds[0], pBounds[1], pBounds[2], pBounds[3], pBounds[4], pBounds[5]); 

結果:

-228.552734.0.000000.-228.552734.0.000000.0.000000.0.000000 

使用vtkCoordinate?但是如何?

回答

0

我想我做到了:

double* pBounds = pImageData->GetBounds(); 
vtkCoordinate* pCoordinate = vtkCoordinate::New(); 
pCoordinate->SetValue(0, 0, 0); 
pCoordinate->SetValue(pBounds[0], pBounds[2], 0); 
int* pValueInt = pCoordinate->GetComputedDisplayValue(m_pRenderer); 
TRACE("BottomLeft:x:%d - y:%d\n", pValueInt[0], pValueInt[1]); 
pCoordinate->SetValue(pBounds[1], pBounds[3], 0); 
pValueInt = pCoordinate->GetComputedDisplayValue(m_pRenderer); 
TRACE("TopRight:x:%d - y:%d\n", pValueInt[0], pValueInt[1]); 
pCoordinate->SetValue(pBounds[2], pBounds[4], 0); 
pValueInt = pCoordinate->GetComputedDisplayValue(m_pRenderer); 
TRACE("TopLeft:x:%d - y:%d\n", pValueInt[0], pValueInt[1]); 
pCoordinate->SetValue(pBounds[4], pBounds[2], 0); 
pValueInt = pCoordinate->GetComputedDisplayValue(m_pRenderer); 
TRACE("BottomRight:x:%d - y:%d\n", pValueInt[0], pValueInt[1]); 
pCoordinate->Delete(); 

我奇怪的是,如果以正確的方式來獲得圖像的角落...