Hi Simon,
I detected a possible bug in the current version of Cairo. Descriptions and possible solutions are given below.
Description:
CairoPNG() creates wrong number of images. The problem can be reproduced by the following code:
library(Cairo)
CairoPNG()
for(i in 1:5) plot(1, main = i)
dev.off()
It turns out that only four images are created, and the last image but one (i.e., the 4th image in the loop) is missing.
Possible reason:
In cairotalk.c => CairoGD_Close(), xd->npages doesn't increase by one as it does in CairoGD_NewPage(). So when the device is closing, the last image overwrites the previous one.
Solution:
Add one line of xd->npages++ before xd->cb->save_page(xd->cb,xd->npages);. I already created a pull request.
Hi Simon, I detected a possible bug in the current version of
Cairo
. Descriptions and possible solutions are given below.Description:
CairoPNG()
creates wrong number of images. The problem can be reproduced by the following code:It turns out that only four images are created, and the last image but one (i.e., the 4th image in the loop) is missing.
Possible reason:
In
cairotalk.c
=>CairoGD_Close()
,xd->npages
doesn't increase by one as it does inCairoGD_NewPage()
. So when the device is closing, the last image overwrites the previous one.Solution:
Add one line of
xd->npages++
beforexd->cb->save_page(xd->cb,xd->npages);
. I already created a pull request.