[prev in list] [next in list] [prev in thread] [next in thread] 

List:       vtkusers
Subject:    Re: [vtkusers] Loading images from memory *not files*
From:       David Gobbi <david.gobbi () gmail ! com>
Date:       2010-02-24 13:48:06
Message-ID: 48a17b781002240548u641e1bekc7edc06a23c8bd5 () mail ! gmail ! com
[Download RAW message or body]

Hi Robert,

Your situation is fairly rare, very few users would ever read PNG
format from memory.  So this functionality has not yet been added to
VTK.

There is a class called vtkImageImport class for reading uncompressed
images into VTK, and it would be nice if someone could write a
vtkPNGImport and vtkJPEGImport for handling compressed data.

A possible quick-and-dirty fix is to write the data to a pipe and read
it back in through the vtkPNGReader.  That way it can be decompressed
without having to go back to disk.

   David


On Wed, Feb 24, 2010 at 6:35 AM, Robert Haines <rhaines@manchester.ac.uk> wrote:
> > 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
> 
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at \
> http://www.kitware.com/opensource/opensource.html 
> Please keep messages on-topic and check the VTK FAQ at: \
> http://www.vtk.org/Wiki/VTK_FAQ 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at \
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: \
http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic