[vtkusers] Problem using DirectX with vtkImageReslice
Sebastian Schuberth
s.schuberth at tu-bs.de
Thu Jun 9 10:08:44 EDT 2005
Hi all,
I'm having some strange issues with the following code:
----(begin)----
float *pImageData; // Pointer to a floating-point grayscale image.
int nWidth=512,nHeight=721; // Width and height of the image.
vtkImageReslice *pImageReslice = vtkImageReslice::New();
vtkImageData *pvtkImageData = vtkImageData::New();
pvtkImageData->SetDimensions(nWidth,nHeight,1);
pvtkImageData->SetScalarType(VTK_FLOAT);
pvtkImageData->SetNumberOfScalarComponents(1);
memcpy(pvtkImageData->GetScalarPointer(),pImageData,nWidth*nHeight*sizeof(float));
pImageReslice->SetInput(pvtkImageData);
// Some image transformations were omitted here for simplicity.
pImageReslice->Update();
float *pfData = (float*)pImageReslice->GetOutput()->GetScalarPointer();
memcpy(pImageData,pfData,sizeof(float)*nWidth*nHeight);
pvtkImageData->Delete();
pvtkImageData= NULL;
pImageReslice->Delete();
pImageReslice = NULL;
----(end)----
Because I've omitted some transformation operations, the code above just
copies the image from and back to pImageData. It works just fine until I
create a DirectX device *before* the code above:
----(begin)----
HWND m_window_handle=::GetDesktopWindow();
IDirect3D9 *m_d3d9_object=Direct3DCreate9(D3D_SDK_VERSION);
if (!m_d3d9_object)
return;
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp,sizeof(d3dpp));
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD,
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
d3dpp.EnableAutoDepthStencil = FALSE;
IDirect3DDevice9 *m_d3d9_device;
if
(FAILED(m_d3d9_object->CreateDevice(0,D3DDEVTYPE_HAL,m_window_handle,D3DCREATE_HARDWARE_VERTEXPROCESSING,&d3dpp,
&m_d3d9_device))) return;
----(end)----
If I comment out the line which contains the call to CreateDevice all
works fine again. Any ideas what happening? Does vtkImageReslice
internally even use DirectX in any way?
Thanks for any hints.
--
Sebastian Schuberth
More information about the vtkusers
mailing list