creating an image

John Biddiscombe j.biddiscombe at
Thu Dec 16 15:15:07 EST 1999

>There is a vtkImageImport class, it didn't make it into VTK 2.4
>but it is in the nightlies.
>It allows the vtk imaging pipeline to use a block of C++ memory 
>'in place,' i.e. it simply uses a C++ pointer as the source of
>the imaging pipeline.

Since I just happened to have used this recently, here's a snippet

    Graphics::TBitmap *b = PaintCanvas->Picture->Bitmap;
    b->HandleType  = bmDIB;
    b->PixelFormat = pf8bit;
    int w = b->Width, h = b->Height;
    char *data = new char[w*h];
    for (int r=h; --r>=0; ) {
        char *row = (char*)(b->ScanLine[h-1-r]);
        for (int c=0; c<w; c++) {
            data[c + (r*w)] = row[c];
    vtkImageImport *importer = (vtkImageImport*)process;
    importer->SetImportVoidPointer(data, 0);
    importer->SetDataExtent (0, w-1, 0, h-1, 0, 0);

this tells it
    importer->SetImportVoidPointer(data, 0);
to take the data and keep the pointer I think, it is now responsible for
freeing the memory.

Works fine. Took 5 minutes. Liked it.

John B

This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.

More information about the vtkusers mailing list