[vtkusers] Problem using DirectX with vtkImageReslice
Randall Hand
randall.hand at gmail.com
Thu Jun 9 10:15:43 EDT 2005
I just noticed that you don't call "Initialize" for your vtkImageData
anywhere. Could that have something to do with it?
On 6/9/05, Sebastian Schuberth <s.schuberth at tu-bs.de> wrote:
>
> 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
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
--
Randall Hand
http://www.yeraze.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050609/e55e8db1/attachment.htm>
More information about the vtkusers
mailing list