[R] Bug in col2rgb?

Duncan Murdoch murdoch at stats.uwo.ca
Sun Apr 12 18:20:28 CEST 2009


On 31/03/2009 12:53 PM, Duncan Murdoch wrote:
> 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.

I've added a fix for this to R-devel.  After 2.9.0 is released, I'll 
move it into R-patched.

Duncan Murdoch




More information about the R-help mailing list