How can I stack a series of bmp image into 3D view

I read a series of bmp image ,and then appending 2D (XY) images along
the Z axis to form a 3D volume, but there is only the lastest picture.How can I get a 3D view of those series of image?

void MainWindow::imageappend(){

    vtkSmartPointer<vtkImageAppend > append =
           vtkSmartPointer<vtkImageAppend >::New();
    append->SetAppendAxis(2);

    for(int i = 1; i < 31; i++)
    {
        vtkSmartPointer<vtkBMPReader>reader =
               vtkSmartPointer<vtkBMPReader>::New();
           char fileName[128];
           sprintf(fileName,"/home/yanghantao/Documents/ruxian/%03d_R.bmp", i);
           reader->SetFileName(fileName);
           append->AddInputConnection(reader->GetOutputPort());
    }
    append->Update();
    vtkSmartPointer <vtkImageActor> actor=vtkSmartPointer <vtkImageActor>::New();
              actor->SetInputData(append->GetOutput());
    vtkSmartPointer <vtkRenderer> render=vtkSmartPointer <vtkRenderer>::New();
       //render->SetBackground(0.1,0.1,0.5);
            render->AddActor(actor);
    vtkSmartPointer <vtkRenderWindow> rw=vtkSmartPointer <vtkRenderWindow>::New();
       rw->AddRenderer(render);
    vtkSmartPointer <vtkRenderWindowInteractor> rwi=vtkSmartPointer <vtkRenderWindowInteractor>::New();
       rwi->SetRenderWindow(rw);
    rw->Render();
    rwi->Initialize();
    rwi->Start();

}

image

vtkSmartPointer <vtkImageActor> actor=vtkSmartPointer <vtkImageActor>::New();

vtkImageActor is designed for images (2D data). Check this example https://kitware.github.io/vtk-examples/site/Cxx/VolumeRendering/SmartVolumeMapper/ for setting up volume rendering for the result of your filter.

With using the method given by this example, I have successfully stacked a series of jpg image into 3D view. However when I use the bmp image, some other problems arosed.

void MainWindow::ImageVolume(){
//        vtkSmartPointer< vtkStringArray > fileArray = vtkSmartPointer< vtkStringArray >::New();
//        char fileName[128];
//        for(int i = 1; i < 100; i++)
//        {
//            sprintf(fileName, "/home/yanghantao/Documents/QtProject/VTK_test/Head/head%03d.jpg", i);
//            std::string fileStr(fileName);
//            fileArray->InsertNextValue(fileStr);
//        }

//        //read JPG image
//        vtkSmartPointer<vtkJPEGReader> reader = vtkSmartPointer<vtkJPEGReader>::New();
//        reader->SetFileNames(fileArray);
//        reader->Update();

     //read bmp
        vtkSmartPointer< vtkStringArray > fileArray = vtkSmartPointer< vtkStringArray >::New();
        char fileName[128];
        for(int i = 1; i < 31; i++)
        {
            sprintf(fileName, "/home/yanghantao/Documents/ruxian/%03d_R.bmp", i);
            std::string fileStr(fileName);
            fileArray->InsertNextValue(fileStr);
        }


        vtkSmartPointer<vtkBMPReader> reader = vtkSmartPointer<vtkBMPReader>::New();
        reader->SetFileNames(fileArray);
       // reader->SetAllow8BitBMP(16);
        reader->Update();


    vtkSmartPointer <vtkSmartVolumeMapper> volumeMapper=
                    vtkSmartPointer <vtkSmartVolumeMapper>::New();
        volumeMapper->SetBlendModeToComposite();
        volumeMapper->SetInputData(reader->GetOutput());

    vtkSmartPointer <vtkVolumeProperty> volumeProperty=
                    vtkSmartPointer <vtkVolumeProperty>::New();
        volumeProperty->ShadeOff();
        volumeProperty->SetInterpolationType(VTK_LINEAR_INTERPOLATION);

    vtkSmartPointer <vtkPiecewiseFunction> compositeOpacity=
                    vtkSmartPointer <vtkPiecewiseFunction>::New();
          compositeOpacity->AddPoint(0.0, 0.0);
          compositeOpacity->AddPoint(80.0, 1.0);
          compositeOpacity->AddPoint(80.1, 0.0);
          compositeOpacity->AddPoint(255.0, 0.0);
          volumeProperty->SetScalarOpacity(compositeOpacity);

    vtkSmartPointer <vtkVolume> volume=
                    vtkSmartPointer <vtkVolume>::New();
            volume->SetMapper(volumeMapper);
            volume->SetProperty(volumeProperty);

    vtkSmartPointer <vtkRenderer> render=vtkSmartPointer <vtkRenderer>::New();
            render->SetBackground(0.1, 0.4, 0.2);
            render->AddVolume(volume);


    vtkSmartPointer <vtkRenderWindow> rw=vtkSmartPointer <vtkRenderWindow>::New();
       //rw->SetSize(512,512);
       rw->AddRenderer(render);


    vtkSmartPointer <vtkRenderWindowInteractor> rwi=vtkSmartPointer <vtkRenderWindowInteractor>::New();
       rwi->SetRenderWindow(rw);

    rw->Render();
    rwi->Initialize();
    rwi->Start();

}

The result of jpg image:
image

The preoblem of bmp image:

ERROR: In /home/yanghantao/Documents/VTK-8.2.0/Rendering/VolumeOpenGL2/vtkVolumeTexture.cxx, line 755
vtkVolumeTexture (0x12e0600): Capabilities check via proxy texture 3D allocation failed!

if I reduce a half number of images,the program can run correctly. Maybe out of memory?If I still want to use all of the image,how can I get it? The bmp image is 2048x2048. The jpg image is 256x256.