Skip to content
Prev 39166 / 63424 Next

readPNG gives warnings and doesn't execute sample code from help files

Joris,
On Feb 14, 2011, at 10:05 AM, Joris Meys wrote:

            
You may want to use a device that supports alpha. The R logo in the example uses alpha so are probably the images you are using. If you don't want to (or can't) use a device that supports alpha, you'll have to flatten the alpha, - i.e. plot just img[,,1:3]
However, most images don't have color where alpha is zero, so you'll have to replace it with the background color, e.g.:
r = as.raster(img[,,1:3])
r[img[,,4] == 0] = "white"

Cheers,
Simon