Skip to content

Commit

Permalink
set bg = transparent for graphics device; turn off shadow device for …
Browse files Browse the repository at this point in the history
…newPage
  • Loading branch information
jjallaire committed Mar 15, 2013
1 parent 7b3bbd6 commit 194e20d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/cpp/r/session/graphics/RGraphicsPlotManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 %
Expand Down
20 changes: 18 additions & 2 deletions src/cpp/r/session/graphics/RShadowPngGraphicsHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 %
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 194e20d

Please sign in to comment.