Oops, I see this code is actually not available in VES master. It's on an unmerged topic branch on the stage remote. I will merge it to the 'next' branch now and send another email when it's available.<br>
<br>Pat<br><br><div class="gmail_quote">On Sun, Oct 7, 2012 at 10:06 PM, Pat Marion <span dir="ltr"><<a href="mailto:pat.marion@kitware.com" target="_blank">pat.marion@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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">
<div><div class="h5">
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></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5">
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><font color="#888888"><p>Walter</p></font></span></div></div>
<br></div></div>_______________________________________________<br>
Ves mailing list<br>
<a href="mailto:Ves@public.kitware.com" target="_blank">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>
</blockquote></div><br>