[Ves] kiwiviewer background image not working

Walter Alejandro Diaz Reginensi wadrwadr at gmail.com
Sun Oct 7 21:25:13 EDT 2012


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/ves/attachments/20121007/541876d7/attachment.html>


More information about the Ves mailing list