[vtk-developers] RGBA to RGB

Amy Squillacote amy.squillacote at kitware.com
Thu Mar 15 08:06:23 EDT 2007


Hi Andreas,

Try using vtkImageExtractComponents. Call the version of the 
SetComponents method that takes 3 parameters, and give it the values 0, 
1, and 2 so it will extract the 1st three components of your 4-component 
dataset.

- Amy

Andreas Gamber wrote:
> Hello everyone,
>  
> does anyone know a possibility to convert RGBA-vtkImageData to 
> RGB-vtkImageData?
>  
> I have to connect an OpenGL-application with a VTK-client.
>  
>
> On OpenGL-side:
> unsigned char pdata = new unsigned char[width*height*4];
> glReadPixels(0,0,width,height,GL_RGBA,GL_UNSIGNED_BYTE,pdata);
>  
> The pdata-array holds the pixel-data as RGBA.
>  
>  
>
> The VTK-application-side:
> vtkImageImport *imageImport = vtkImageImport::New();
>     imageImport->SetNumberOfScalarComponents(4);
>     imageImport->SetWholeExtent(0,width-1,0,height-1,0,0);
>     imageImport->SetDataExtentToWholeExtent();
>     imageImport->SetDataScalarTypeToUnsignedChar();
>     imageImport->SetImportVoidPointer(pdata);
>  
>
> imageImport->GetOutput() delivers RGBA-vtkImageData but the VTK-client 
> is only able to handle RGB vtkImageData.
>  
> The client-application is supposed to work in real time, so a simple 
> reorganisation of the data-array
> is impossible because it takes to much time.
>  
> Does VTK provide a method to get rid of the Alpha-part?
>  
>
> Thanks,
> Andreas
> ------------------------------------------------------------------------
>
> _______________________________________________
> vtk-developers mailing list
> vtk-developers at vtk.org
> http://www.vtk.org/mailman/listinfo/vtk-developers
>   

-- 
Amy Squillacote
Kitware, Inc.
28 Corporate Drive
Clifton Park, NY 12065
Phone: (518) 371-3971 x106




More information about the vtk-developers mailing list