Skip to content
Prev 67273 / 398503 Next

hex format

....

    David> I think R has the hex to decimal OK, but might be
    David> lacking in the decimal to hex case

    David> zz<-function(x){ x<-as.numeric(sub("#",'0x',x));
    David> c(x%/%256^2, x%/%256%%256, x%%256) }

    >> zz('#0f0e0d')
    David> [1] 15 14 13
    >> zz('#ff0080')
    David> [1] 255 0 128

I think you have overlooked  the  col2rgb() function
which does this (and more).

    David> If you already have the 3 byte triplet in read in as
    David> a binary, the same integer arithmetic does the
    David> extraction.