[vtkusers] RGB to RGBA

Bryan Cole bryan.cole at teraview.com
Wed Sep 15 12:15:30 EDT 2004


1) Create a vtkUnsignedCharArray from your RGB input data (using
vtkDataArray::SetVoidArray()).
2) Then Create a new vtkUnsignedCharArray with 4 components (i.e. RGBA) and the
same number of tuples as your RGB-array.
3) Copy the RGB data into the new RGBA array using vtkDataArray::CopyComponent()


There may be a more efficient method, but this will work. 

HTH
Bryan

guernika_devel at yahoo.it wrote: 
> Hello
> I've got to "translate" an rgb unsigned char array into an RGBA image data.
> I can translate it into an RGB image data in the way as follow:
> void v4aDispImage(unsigned char* image)
> {
> 	vtkImageImport* imageImporter = vtkImageImport::New();
>   	imageImporter->SetDataScalarTypeToUnsignedChar();
>   	imageImporter->SetNumberOfScalarComponents( bpp );
>   	imageImporter->SetDataSpacing( 1,1,1 );
>   	imageImporter->SetWholeExtent(0,xsize-1,0,ysize-1,0,0);
>   	imageImporter->SetDataOrigin(-xsize/2,-ysize/2,0);
>   	imageImporter->SetImportVoidPointer( image );
>   	imageActor->SetInput( imageImporter->GetOutput() );
> 	[..]
> }
> 
> How can I get an RGBA imagedata with A = 0 instead?
> 
> thanks in advance
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 
> 




More information about the vtkusers mailing list