[vtkusers] Problem about vtkImageViewer2

Wenlong Wang scc.wwl at gmail.com
Tue Nov 15 14:17:36 EST 2011


Dear all,

I'm using vtkImageViewer2, vtkImageBlender and vtkJPEGReader to show the
effect of overlap images. Here is the function I wrote to carry it out.

void CVTKDialogDlg::ShowMarkedTargetImage(char* filename)
{
    CRect rect;
    CWnd* p = GetDlgItem(IDC_SHOW_TARGET_IMAGE);
    p->GetClientRect(&rect);

    jr->SetFileName(filename);                                      //jr
and jr2 are vtkJPEGReader objects
    jr->SetDataExtent(0, 600, 0, 600, 0, 0);
    jr->Update();

    jr2->SetFileName("C:\\Users\\Wenlong\\Desktop\\screenshot.jpeg");
    jr2->SetDataExtent(0, 600, 0, 600, 0, 0);
    jr2->Update();

    ib->AddInputConnection(jr->GetOutputPort());            //ib is a
vtkImageBlender object
    ib->AddInputConnection(jr2->GetOutputPort());
    ib->SetOpacity(0, 0.5);
    ib->SetOpacity(1, 0.5);

    iv->SetInputConnection(ib->GetOutputPort());             //iv is a
vtkImageBlender object
    iv->SetupInteractor(wrwi);
//wrwi is a vtkWin32RenderWindowInteractor object
    iv->GetRenderer()->ResetCamera();
    iv->SetParentId(p->m_hWnd);
    iv->SetSize(rect.right-rect.left, rect.bottom-rect.top);
    iv->Render();
}

The problem is, for the first time I call this function, everything goes
right and the render window is fullfiled by image. But the next time I call
this function, the image is zoom out and there is a black margin between
the image border and the render window edge.

How can I solve this problem? I really appreciate any advice.

Thank you very much.

Best wishes
Long
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111115/7bbcceb4/attachment.htm>


More information about the vtkusers mailing list