Permalink
Browse files

set bg = transparent for graphics device; turn off shadow device for …

…newPage
  • Loading branch information...
1 parent 7b3bbd6 commit 194e20d1a8b03e7249fb671d89a3ee405d1053f3 @jjallaire jjallaire committed Mar 15, 2013
@@ -300,7 +300,8 @@ Error PlotManager::savePlotAsBitmapFile(const FilePath& targetPath,
// generate code for creating bitmap file device
boost::format fmt(
"{ require(grDevices, quietly=TRUE); "
- " %1%(filename=\"%2%\", width=%3%, height=%4%, pointsize = 16 %5%); }");
+ " %1%(filename=\"%2%\", width=%3%, height=%4%, "
+ " bg = \"transparent\", pointsize = 16 %5%); }");
std::string deviceCreationCode = boost::str(fmt % bitmapFileType %
string_utils::utf8ToSystem(targetPath.absolutePath()) %
width %
@@ -93,6 +93,13 @@ void shadowDevOff(DeviceContext* pDC)
}
}
+void shadowDevOff(pDevDesc dev)
+{
+ DeviceContext* pDC = (DeviceContext*)dev->deviceSpecific;
+ if (pDC)
+ shadowDevOff(pDC);
+}
+
Error shadowDevDesc(DeviceContext* pDC, pDevDesc* pDev)
{
ShadowDeviceData* pDevData = (ShadowDeviceData*)pDC->pDeviceSpecific;
@@ -106,7 +113,9 @@ Error shadowDevDesc(DeviceContext* pDC, pDevDesc* pDev)
PreserveCurrentDeviceScope preserveCurrentDeviceScope;
// create PNG device (completely bail on error)
- boost::format fmt("grDevices:::png(\"%1%\", %2%, %3% %4%, pointsize = 16)");
+ boost::format fmt("grDevices:::png(\"%1%\", %2%, %3% %4%, "
+ "bg = \"transparent\", "
+ "pointsize = 16)");
std::string code = boost::str(fmt %
string_utils::utf8ToSystem(pDC->targetPath.absolutePath()) %
pDC->width %
@@ -486,10 +495,17 @@ void clip(double x0, double x1, double y0, double y1, pDevDesc dev)
void newPage(const pGEcontext gc, pDevDesc dev)
{
+ // close existing shadow dev (this is so that new plots don't
+ // paint transparently over old plots -- this might occur because
+ // we now set bg = transparent)
+ shadowDevOff(dev);
+
+ // create a new shadow dev
pDevDesc pngDevDesc = shadowDevDesc(dev);
if (pngDevDesc == NULL)
return;
-
+
+ // call new page
pngDevDesc->newPage(gc, pngDevDesc);
}

0 comments on commit 194e20d

Please sign in to comment.