I believed the standard plotting device on R in 2.12.1 would support per-pixel alpha. It does support alpha, as
plot(1:2,type="l") polygon(c(1,1,2,2),c(1,2,2,1),col=rgb(60,100,60,60,maxColorValue=255)) plots correctly. Which device should I use then? Cheers Joris On Mon, Feb 14, 2011 at 5:30 PM, Simon Urbanek <simon.urba...@r-project.org> wrote: > Joris, > > On Feb 14, 2011, at 10:05 AM, Joris Meys wrote: > >> Dear all, >> >> I noticed in the latest R version (R.2.12.1) that the readPNG gives >> following warning when running the example code in the help file (or >> when using any other png for that matter) : >> >> 50: In rasterImage(img, 1.2, 1.27, 1.8, 1.73) : >> Per-pixel alpha not supported on this device >> >> No picture is shown, and code I used to be able to run, doesn't run any more. >> > > 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 > > > >>> sessionInfo() >> R version 2.12.1 (2010-12-16) >> Platform: i386-pc-mingw32/i386 (32-bit) >> >> locale: >> [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United >> States.1252 LC_MONETARY=English_United States.1252 >> [4] LC_NUMERIC=C LC_TIME=English_United >> States.1252 >> >> attached base packages: >> [1] grDevices datasets splines graphics stats tcltk utils >> methods base >> >> other attached packages: >> [1] png_0.1-2 svSocket_0.9-51 TinnR_1.0.3 R2HTML_2.2 >> Hmisc_3.8-3 survival_2.36-2 >> >> loaded via a namespace (and not attached): >> [1] cluster_1.13.2 grid_2.12.1 lattice_0.19-13 svMisc_0.9-61 >> tools_2.12.1 >> >> >> -- >> Joris Meys >> Statistical consultant >> >> Ghent University >> Faculty of Bioscience Engineering >> Department of Applied mathematics, biometrics and process control >> >> tel : +32 9 264 59 87 >> joris.m...@ugent.be >> ------------------------------- >> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php >> >> > > -- Joris Meys Statistical consultant Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control tel : +32 9 264 59 87 joris.m...@ugent.be ------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel