[Ves] kiwiviewer background image not working
Pat Marion
pat.marion at kitware.com
Sun Oct 7 22:06:47 EDT 2012
Hi,
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:
// load image (could be a jpg or png)
vtkSmartPointer<vtkImageData> image =
vtkImageData::SafeDownCast(this->Internal->DataLoader.loadDataset(filename));
// convert vtk image to ves image
vesImage::Ptr image =
vesKiwiDataConversionTools::ConvertImage(reader->GetOutput());
// set background image on renderer
this->renderer()->background()->setImage(image);
Pat
On Sun, Oct 7, 2012 at 9:25 PM, Walter Alejandro Diaz Reginensi <
wadrwadr at gmail.com> wrote:
> Hello,
> Very nice to join the mail list!!
> I started studying kiviwiewer and ves/vtk just a few days ago trying to
> put an image as background in kiwiviewer.
> I found the function that should do it
>
> KiwiviewerApp::setBackgroundTexture(const std:string & fileName);
>
> but has no code inside it, so I tried this :
>
> void vesKiwiViewerApp::setBackgroundTexture(const std::string& filename)
>
> {
>
> vtkSmartPointer<vtkJPEGReader> reader =
> vtkSmartPointer<vtkJPEGReader>::New();
>
> reader->SetFileName(filename);
>
> reader->Update();
>
> vtkSmartPointer<vtkImageData> image = reader->GetOutput();
>
> assert(image);
>
> vtkSmartPointer<vtkUnsignedCharArray> pixels =
> vtkUnsignedCharArray::SafeDownCast(image->GetPointData()->GetScalars());
>
> int width = image->GetDimensions()[0];
>
> int height = image->GetDimensions()[1];
>
> assert(pixels);
>
> assert(pixels->GetNumberOfTuples() == width*height);
>
> this->Image = vesImage::Ptr(new vesImage());
>
> this->Image->setWidth(width);
>
> this->Image->setHeight(height);
>
> this->Image->setPixelFormat(pixels->GetNumberOfComponents() == 4 ?
> vesColorDataType::RGBA
>
> : pixels->GetNumberOfComponents() == 3 ?
> vesColorDataType::RGB
>
> : vesColorDataType::Luminance);
>
> this->Image->setPixelDataType(vesColorDataType::UnsignedByte);
>
> this->Image->setData(pixels->WriteVoidPointer(0, 0),
> pixels->GetSize());
>
> this->renderer()->background()->setImage(this->Image);
>
> }
>
>
> The code above is based from a test file inside the repository
> called TestTexturedBackground.cpp
>
> 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.
>
> Can you please help me?
>
> Thanks in advance.
>
> Walter
>
> _______________________________________________
> Ves mailing list
> Ves at public.kitware.com
> http://public.kitware.com/cgi-bin/mailman/listinfo/ves
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/ves/attachments/20121007/1a961329/attachment-0001.html>
More information about the Ves
mailing list