[vtkusers] How to display image sequence at one time

Fucang Jia fcjia at ict.ac.cn
Sat May 25 03:22:29 EDT 2002


Dear all,

  I wonder to know, when there are several images to display in a renderwindow, how to update the render window? I want not use MFC. My C source code is as follows:
  
  #include "vtkRenderer.h"
  #include "vtkRenderWindow.h"
  #include "vtkRenderWindowInteractor.h"
  #include "vtkImageData.h"
  #include "vtkImageActor.h"

int main(void)
{
    int i,j,grayvalue;

    vtkRenderer *ren = vtkRenderer::New();
    vtkRenderWindow *renWin = vtkRenderWindow::New();
    renWin->AddRenderer(ren);
        
    vtkImageData *imageData = vtkImageData::New();
    imageData->SetScalarTypeToUnsignedChar();
    imageData->SetExtent(0,255,0,255,0,0);
    imageData->SetWholeExtent(0,255,0,255,0,0);
    imageData->SetUpdateExtent(0,255,0,255,0,0);
    imageData->SetUpdateExtentToWholeExtent();
    imageData->AllocateScalars();
    
    for(i=0;i<256*256;i++)
       imageData->GetPointData()->GetScalars()->SetTuple1(i,20);
    
    vtkImageActor *ia = vtkImageActor::New();
    ia->SetInput(imageData);

    ren->AddActor(ia);
    ren->SetBackground(0.1,0.2,0.4);
    renWin->SetSize(256,256);
    renWin->Render();
    
    for(int i=0;i<10;i++)
        {   
            grayvalue = i * 20;                
            for(int j=0;j<256*256;j++)
               imageData->GetPointData()->GetScalars()->SetTuple1(j,grayvalue);
            imageData->Update(); 
        }    
    
    ren->Delete();
    renWin->Delete();
    imageData->Delete();
    ia->Delete();   
    
    return 0;
}


More information about the vtkusers mailing list