Created attachment 2117 [details] R code writes "A" then captures with grid.cap, capture matrix last rows aren't all white I use grid.text() to write a letter "A" to a small viewport page, then use grid.cap() to capture it. The bitmap matrix returned by grid.cap() contains some garbage colors in the last 4 rows. The background is white and there are no non-white regions visible at the bottom of the image. See attachment for code.
Can you please run something like ... png("bug-16987.png") grid.raster(cap) dev.off() ... and post the resulting PNG file, PLUS a screen capture (e.g., via alt-prtscn or however you do it on your system, other than with R) of the R graphics window ?
Created attachment 2130 [details] Screen shot after running code shown in comment library("grid") dev.new(width=1, height=1) grid.newpage() grid.text("A", gp=gpar(cex=4)) cap = grid.cap() # Bottom rows of 'cap' should be all 'white', are they? apply(cap, 1, function(V) all(V == "white")) # Note four "FALSE" entries in last line above. tail(cap[, 1:7], 6) png("bug-16987.png") grid.raster(cap) dev.off()
Created attachment 2131 [details] .png file created by R code shown in previous attachment comments This .png file shows black areas at lower-left and lower-right, not present in the actual device window shown in the previous attachment screen capture.
Thanks for the PNGs. A couple of thoughts for this (and #16983): - endianness plus forced-opacity-on-capture might explain the red pixels, i.e., opaque black RGBA [0, 0, 0, 1] is (incorrectly) captured as ABGR [1, 0, 0, 1], which replays as opaque red. - pretty curved corners on the bottom-left and bottom-right of the graphics device window (as shown in your screen shots) might explain the black-grey corner pixels (especially if the pretty corners are done with transparency and the endianness idea above is correct). A test of the first supposition would be to draw the rect and text "green" so the replay would come out "blue"(?) I need to talk to Simon Urbanek (who commented in the source code about endiannes and who has an OS X machine to test on).