[vtkusers] Why does VTK use doubles for color?

David Thompson dcthomp at sandia.gov
Tue Sep 7 13:46:22 EDT 2010


> Is there a reason that unsigned chars are not used for all things  
> related to color? For example
> vtkProperty::SetColor(double,double,double) //expects values from  
> 0.0 to 1.0
> http://www.vtk.org/doc/nightly/html/classvtkProperty.html#aa591fc54d4e2d21e2c7a97ef7cd2a993
> vtkViewPort::SetBackground(double,double,double) //expects values  
> from 0.0 to 1.0
> http://www.vtk.org/doc/nightly/html/classvtkViewport.html#a85eaf3ee2b0e49423efbaa41de17112d
> Wouldn't it be more natural to define these as
> vtkProperty::SetColor(unsigned char,unsigned char,unsigned char) // 
> expects values from 0 to 255
> vtkViewPort::SetBackground(unsigned char,unsigned char,unsigned  
> char) //expects values from 0 to 255
> ?

Hi David,

Using double instead of unsigned char allows for display devices that  
have more than 24-bit color depth and makes image processing (such as  
tone mapping, sharpening, blurring, etc.) less susceptible to the  
accumulation of trunctation errors when many steps are involved.

	David





More information about the vtkusers mailing list