Hi,<br><br>Sorry for the missing code in vesKiwiViewerApp::setBackgroundTexture(). The feature was broken for a while so the code was commented out. It is working now, so I'll update the method with the correct code. You should just need to do this:<br>
<br><br>// load image (could be a jpg or png)<br>vtkSmartPointer<vtkImageData> image = vtkImageData::SafeDownCast(this->Internal->DataLoader.loadDataset(filename));<br><br>// convert vtk image to ves image<br>
vesImage::Ptr image = vesKiwiDataConversionTools::ConvertImage(reader->GetOutput());<br><br>// set background image on renderer<br>this->renderer()->background()->setImage(image);<br><br><br>Pat<br><br><br><div class="gmail_quote">
On Sun, Oct 7, 2012 at 9:25 PM, Walter Alejandro Diaz Reginensi <span dir="ltr"><<a href="mailto:wadrwadr@gmail.com" target="_blank">wadrwadr@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<div>Very nice to join the mail list!!</div><div>I started studying kiviwiewer and ves/vtk just a few days ago trying to put an image as background in kiwiviewer.</div><div><div>I found the function that should do it</div>
<div><br></div><div>KiwiviewerApp::setBackgroundTexture(const std:string & fileName);</div><div><br></div><div>but has no code inside it, so I tried this :</div><div><br></div><div>
<p><span>void</span> vesKiwiViewerApp::setBackgroundTexture(<span>const</span> std::string& filename)</p>
<p>{ </p>
<p><span> </span> vtkSmartPointer<vtkJPEGReader> reader = vtkSmartPointer<vtkJPEGReader>::New();</p><p> reader->SetFileName(filename);</p>
<p> reader->Update();</p>
<p> vtkSmartPointer<vtkImageData> image = reader->GetOutput();</p>
<p> assert(image);</p>
<p> vtkSmartPointer<vtkUnsignedCharArray> pixels = vtkUnsignedCharArray::SafeDownCast(image->GetPointData()->GetScalars());</p>
<p> <span>int</span> width = image->GetDimensions()[<span>0</span>];</p>
<p> <span>int</span> height = image->GetDimensions()[<span>1</span>];</p>
<p> assert(pixels);</p>
<p> assert(pixels->GetNumberOfTuples() == width*height);</p>
<p> <span>this</span>->Image = vesImage::Ptr(<span>new</span> vesImage());</p>
<p> <span>this</span>->Image->setWidth(width);</p>
<p> <span>this</span>->Image->setHeight(height);</p>
<p> <span>this</span>->Image->setPixelFormat(pixels->GetNumberOfComponents() == <span>4</span> ? vesColorDataType::RGBA</p>
<p> : pixels->GetNumberOfComponents() == <span>3</span> ? vesColorDataType::RGB</p>
<p> : vesColorDataType::Luminance);</p>
<p> <span>this</span>->Image->setPixelDataType(vesColorDataType::UnsignedByte);</p>
<p> <span>this</span>->Image->setData(pixels->WriteVoidPointer(<span>0</span>, <span>0</span>), pixels->GetSize());</p>
<p> <span>this</span>->renderer()->background()->setImage(<span>this</span>->Image);</p>
<p>}</p><p><br></p><p>The code above is based from a test file inside the repository called TestTexturedBackground.cpp</p><p>This should work but doesn't, the functions did not return any errors so I assume that I'm configuring all ok, but the background is not rendered at all.</p>
<p>Can you please help me?</p><p>Thanks in advance.</p><span class="HOEnZb"><font color="#888888"><p>Walter</p></font></span></div></div>
<br>_______________________________________________<br>
Ves mailing list<br>
<a href="mailto:Ves@public.kitware.com">Ves@public.kitware.com</a><br>
<a href="http://public.kitware.com/cgi-bin/mailman/listinfo/ves" target="_blank">http://public.kitware.com/cgi-bin/mailman/listinfo/ves</a><br>
<br></blockquote></div><br>