[vtkusers] reading a bmp file into a lookup table

Steve Chall stevec at renci.org
Thu Jun 7 18:16:27 EDT 2007


Dear fellow vtk fans:

I'm trying to read a 255x1 24-bit bitmap and convert it into a lookup table
so I don't have to manually input 255 rgb values.

 

  vtkLookupTable *lut = vtkLookupTable::New;  // or no ::New():  doesn't
seem to matter

  vtkBMPReader *bmpReader = vtkBMPReader::New();

  char bmpFileName[] = "topo-bathy255x1.bmp";

  bmpReader->SetFileName(bmpFileName);

  lut = bmpReader->GetLookupTable();

  //lut->Build(); // ????????

 

This doesn't do it, because nothing is forcing the reader to execute reading
the file.   I could write a subclass of vtkBMPReader and call the parent
class's protected Execute() method in a public function, but that's at best
a kludge.  When I look at lut, it's got its default 256-element size and all
the r, g, and b values are 0.  How can I force a read?  

 

The more general question is:  why are we restricted to employing this lazy
evaluation approach?  What are the drawbacks to providing a public
ReadFile() method for vtkBMPReader (as a specific example)? Thanks, both for
helping me to see what may be an obvious solution to my immediate problem,
and for helping me to understand the underlying rationale.

 

-Steve

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070607/d225bfda/attachment.htm>


More information about the vtkusers mailing list