[vtkusers] Memory leak

David Doria daviddoria at gmail.com
Tue May 15 10:33:23 EDT 2012


You would keep the data and get rid of the reader like this:

#include <vtkImageData.h>
#include <vtkSmartPointer.h>
#include <vtkPNGReader.h>

int main(int argc, char *argv[])
{
  vtkPNGReader* reader = vtkPNGReader::New();
  reader->SetFileName("/home/doriad/test.png");
  vtkSmartPointer<vtkImageData> img = vtkSmartPointer<vtkImageData>::New();
  img->DeepCopy(reader->GetOutput());

  reader->Delete();

  std::cout << img->GetNumberOfScalarComponents() << std::endl;

  return 0;
}

David



More information about the vtkusers mailing list