[vtkusers] Loading images from memory *not files*

Kenneth Porter shiva at sewingwitch.com
Wed Feb 24 09:03:19 EST 2010


--On Wednesday, February 24, 2010 10:06 AM +0000 Robert Haines 
<rhaines at manchester.ac.uk> wrote:

> Subject says it all really. I have an image (a PNG in this case but I'd
> like to be general here really) in memory and I'd like to use it in the
> normal VTK way - as if it had been read in by vtkPNGReader, for example.
> Is this possible? I've looked at the code for vtkPNGReader and it looks
> like the only way to read a PNG is from a file, which seems crazy! Have I
> missed something? Is there another way to do what I want?

vtkPNGReader under the hood uses libpng. You can hook directly into that. 
It supports reading from sources other than files, but you have to supply a 
suitable "input" routine. Search for "png_init_io" on this page:

<http://www.libpng.org/pub/png/libpng-manual.txt>





More information about the vtkusers mailing list