[vtkusers] Loading images in a memory efficient way
John Eke
tonee47 at yahoo.com
Tue Sep 22 23:41:22 EDT 2009
Hi Guys/Girls,
Please take a look at the simple code snippet below:
int main ()
{
vtkRenderer *ren = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
renWin->SetInteractor(iren);
renWin->AddRenderer (ren);
vtkPNGReader*imageReader = vtkPNGReader::New();
imageReader->SetFileName("image.png");
imageReader->Update();
vtkImageActor *actor = vtkImageActor::New();
actor->SetInput(imageReader->GetOutput());
ren->AddActor(actor);
iren->Initialize();
iren->Start();
imageReader->Delete();
actor->Delete();
}
It simply loads an image (image.png) and displays it. In memory, it takes up about 16MB of memory. When I strip away the image loading part and just leave in the render window, interactor, and renderer.. the program uses about 6.5MB of memory.
The image I had used is about 3.2MB in size. So from my calculations, just loading and displaying the image used just over 9MB, which is about three times he original image size!!
Is this accurate? Am I doing something wrong? Is there a more efficient way to do this?
Any help is much appreciated.
Thanks,
John E
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090922/b7d023e1/attachment.htm>
More information about the vtkusers
mailing list