[vtkusers] Loading images from memory *not files*

Robert Haines rhaines at manchester.ac.uk
Wed Feb 24 08:35:39 EST 2010


> PNG is a file format and PNGReader implements it. Nothing crazy here.

No, PNG is a data format. A PNG file is simply a file with that data format in it. I have some PNG data in memory that I would like to decode and use rather than load it from a file. Given that when you load a PNG file you would load it into memory to decode it I was hoping that you could do that with PNGReader or similar, that's why I thought I was going crazy when I thought that the only way of loading PNG data into vtk was to have it in a file on disk.

So my question was, can I do this with vtk?

> You need to create a vtkImage and populate its data via write pointer.

I can't see a vtkImage class (5.4.0) but if I was to use something like that (vtkImageData?) then it looks like I would have to do the PNG decode myself. Is that right? Even when vtk already links libpng and can do this if it's in a file?

Cheers,
Rob

> Robert Haines wrote:
>> Hi all,
>> 
>> 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?
>> 
>> Thank you,
>> Rob




More information about the vtkusers mailing list