[R] Bug in col2rgb?

Duncan Murdoch murdoch at stats.uwo.ca
Tue Mar 31 18:53:45 CEST 2009


On 3/31/2009 12:29 PM, hadley wickham wrote:
>> col2rgb("#00000079", TRUE)
>       [,1]
> red      0
> green    0
> blue     0
> alpha  121
>> col2rgb("#00000080", TRUE)
>       [,1]
> red    255
> green  255
> blue   255
> alpha    0
>> col2rgb("#00000081", TRUE)
>       [,1]
> red      0
> green    0
> blue     0
> alpha  129
> 
> 
> Any ideas?

The #00000080 string converts into the hex integer 0x80000000, which, by 
an unfortunate coincidence, is the NA_integer value.  Since NA_integer 
becomes the background colour, you get white instead of black with 
alpha=0x80.

This can probably be fixed (if you have a string, there's a different 
way to know you have an NA).  Want to work out a patch?  The file to 
look at is src/main/colors.c.

Duncan Murdoch




More information about the R-help mailing list