[vtkusers] vtkImageMapper error

Neil Killeen Neil.Killeen at atnf.csiro.au
Tue Apr 1 22:39:02 EST 2003


Hello

some time ago, our student posted a message

http://public.kitware.com/pipermail/vtkusers/2003-February/016105.html

requesting help with vtkImageMapper.

He received no reply, and the problem still exists in VTK 4.2

The enclosed test program, stretch.cxx, will generate a Bus Error under
Solaris.    Under Linux, where he was working, the behaviour was
un-useful (see message above).

Run the program with the provided jpg image as input.

./stretch tycho.jpg


The basic function causing the trouble is

    vtkImageMapper::RenderToRectangleOn();

when this function call is commented out, the program runs successfully.
We assume his usage of the funciton is correct but would be delighted
to learn otherwise !


Would somebody respond please ?

thanks
Neil Killeen




// stretch.cxx

#include <vtkActor.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkJPEGReader.h>
#include <vtkImageMapper.h>
#include <vtkImageData.h>
#include <vtkActor2D.h>

#include <iostream>
#include <math.h>
using namespace std;

#define WINWIDTH 300
#define WINHEIGHT 300

int main(int argc, char **argv)
{
    int dims[3];

    vtkJPEGReader *jpeg = vtkJPEGReader::New();{
        jpeg->SetFileName(argv[1]);
        jpeg->Update();
        jpeg->GetOutput()->GetDimensions(dims);
    }
    vtkImageMapper *mapper = vtkImageMapper::New();{
        mapper->SetInput(jpeg->GetOutput());
        mapper->RenderToRectangleOn();              // Trouble maker
    }

    vtkActor2D *actor = vtkActor2D::New();{
        actor->SetMapper(mapper);
        actor->GetPosition2Coordinate()->SetCoordinateSystemToViewport();
        actor->SetPosition(0,0);
        actor->SetPosition2(dims[0],dims[1]);
    }

    vtkRenderer *ren = vtkRenderer::New();{
        ren->AddActor(actor);
    }

    vtkRenderWindow *win = vtkRenderWindow::New();{
        win->AddRenderer(ren);
        win->SetSize(dims[0],dims[1]);
    }

    vtkRenderWindowInteractor *rwi = vtkRenderWindowInteractor::New();{
        rwi->SetRenderWindow(win);
        rwi->Start();
    }

    return 0;
}



-------------- next part --------------
A non-text attachment was scrubbed...
Name: tycho.jpg
Type: image/jpeg
Size: 12221 bytes
Desc: 
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20030402/eb7e76ba/attachment.jpg>


More information about the vtkusers mailing list