[vtkusers] alpha value in vtkImageActor
francesco caruso
guernika_devel at yahoo.it
Wed Sep 8 04:32:14 EDT 2004
Hello
I'd like to set the alpha-value pixel by pixel in a vtkImageActor
I can render a vtkImageActor in which UnsignedCharArray is of type
(RGBRGBRGB....)
but I can't render a vtkImageActor in which UnsignedCharArray is of type
(RGBARGBARGBA....)
why?
Here are the sources...
Thanks in advance to anyone try to help me!
def RawFileToUnsignedChar(filename,xsize,ysize,bpp):#function to get an
unsigned char array
print"raw file parsing..."
f=open(filename,"r")
f.seek(0)
image = vtk.vtkUnsignedCharArray()
image.SetNumberOfComponents(bpp+1)
for i in range(xsize*ysize):
image.InsertNextTuple4(ord(f.read(1)),ord(f.read(1)),ord(f.read(1)),1)
print "done."
print image.GetTuple4(1)#check if it works
return image
def UnsignedCharArrayToImageActor( array,xsize,ysize,bpp ):
imageImporter = vtk.vtkImageImport()
imageImporter.SetDataScalarTypeToUnsignedChar()
imageImporter.SetNumberOfScalarComponents(bpp+1)
imageImporter.SetDataSpacing(1,1,1)
imageImporter.SetWholeExtent(0,xsize-1,0,ysize-1,0,0)
imageImporter.SetImportVoidPointer( array.GetVoidPointer(0) )
imageImporter.SetDataOrigin(-(xsize-1)/2,-(ysize-1)/2,0)
imageActor = vtk.vtkImageActor()
imageActor.SetInput( imageImporter.GetOutput() )
return imageActor
More information about the vtkusers
mailing list