[Insight-users] Error using SetImportPointer
richyvr
richyvr at gmail.com
Wed Jan 19 04:21:01 EST 2011
Hi ,
I am a little new to ITK, your help is highly appreciated. Here is my
problem:
I am trying to create a function which creates a ITK::Image using the data
pointer i send to it. I even pass the variable which will set if the
importImageFilter Will Own The Buffer or not. so the function is something
like:
itk::Image< unsigned, 2>::Pointer CreateITKImageFromBuffer(unsigned char
*pDataPtr, bool mportImageWillOwnBuffer)
{
:
:
importFilter->SetImportPointer( pImageBuffer, nPixels,
importImageFilterWillOwnTheBuffer );
typedef itk::Image< T, D> ImageType;
ImageType::Pointer iImage = importFilter->GetOutput();
iImage->Update();
return iImage;
}
void main()
{
:
//Test 1:
ITK::Image::Pointer pImage1 = CreateITKImageFromBuffer(DataPtr, 0);
// Validate
WriteITKImage<PixelType, Dimension>("c:\\Test1.jpg", pImage1);
//Test 2:
ITK::Image::Pointer pImage2 = CreateITKImageFromBuffer(DataPtr, 1);
// Validate
WriteITKImage<PixelType, Dimension>("c:\\Test1.jpg", pImage2);
}
Though the Test 1 works correctly where i am not creating a memory but using
the same memory from the DataPtr, Test 2 crashes. saying BADPoniter.
Kindly help!
Regards,
Richard
--
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/Error-using-SetImportPointer-tp5938823p5938823.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.
More information about the Insight-users
mailing list