[vtkusers] Texture Generation with alpha

jalal sadeghi jalal.sadeghy at gmail.com
Thu Jun 18 04:25:33 EDT 2009


I want to create an  4 byte image with different alpha values and   use it
as  texture .


vtkImageData*  pImage=vtkImageData::New();
pImage->SetDimensions(100,100,1);
pImage->SetScalarTypeToUnsignedChar();
pImage->SetNumberOfScalarComponents(4);
pImage->AllocateScalars();
vtkUnsignedCharArray  *ptr=(vtkUnsignedCharArray
*)pImage->GetPointData()->GetScalars();

int count=ptr->GetSize()/4;
int i=0;
while (i<count)
{
unsigned char  data[4];
data[0]=0;
data[1]=255;
data[2]=0;
data[3]=i%125;

ptr->SetTupleValue(i,(const unsigned char*)data);
i++;
}
vtkImageMapToColors* pImageColor=vtkImageMapToColors::New();
pImageColor->SetInput(pImage);
pImageColor->SetOutputFormatToRGBA();


vtkLookupTable* table=vtkLookupTable::New();
float maxColor=255;
table->SetRange(0,maxColor);
table->SetTableValue(0,1,0,0,1);
table->SetTableValue(1,0,0,1,0);

table->SetValueRange(1,0);
table->SetSaturationRange(1,0);
table->SetHueRange(1.0,0);
table->SetAlphaRange(1,0);


But the result is confusing. a red texture  is created.whats the table range
for?  one component or 4 component?
thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090618/b90eac1f/attachment.htm>


More information about the vtkusers mailing list