\Header{dev2}{Copy Graphics Between Multiple Devices}
\alias{dev.copy}{dev2}
\alias{dev.print}{dev2}
\alias{dev.control}{dev2}
\keyword{device}{dev2}
\begin{Usage}
\begin{verbatim}
dev.copy(device, ..., which=dev.next())
dev.print(device=postscript, ...)
dev.control(displaylist)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\texttt{device}] A device function (e.g., \texttt{x11},
\texttt{postscript}, \ldots)
\item[\texttt{...}] Arguments to the \texttt{device} function above.
For \texttt{dev.print}, this includes \texttt{which} and by default any
\texttt{\Link{postscript}} arguments.
\item[\texttt{which}] A device number specifying the device to copy to
\item[\texttt{displaylist}] A character string
\end{ldescription}
\end{Arguments}
\begin{Description}
\texttt{dev.copy} copies the graphics contents of the current device
to the device specified by \texttt{which} or to a new device which has
been created by the function specified by \texttt{device} (it is an
error to specify both \texttt{which} and \texttt{device}).

\texttt{dev.print} copies the graphics contents of the current device
to a new device which has been created by the function specified by
\texttt{device} and then shuts the new device.  This is most useful
for producing a postscript copy from an on-screen device.

\texttt{dev.control} allows the user to control the recording of
graphics operations in a device.  If \texttt{displaylist} is "inhibit"
then recording is turned off.\end{Description}
\begin{Value}
\texttt{dev.copy} returns the name and number of the device which has
been copied to.

\texttt{dev.print} returns the name and number of the device which has
been copied from.\end{Value}
\begin{Note}
Every device has a display list which records all of the graphics
operations that occur in the device.  \texttt{dev.copy} and
\texttt{dev.print} copy graphics contents by copying the display list
from one device to another device.  Also, automatic redrawing of
graphics contents following the resizing of a device depends on the
contents of the display list.

After the command \texttt{dev.control("inhibit")}, graphics operations
are not recorded in the display list so that \texttt{dev.copy} and
\texttt{dev.print} will not copy anything and the contents of a device
will not be redrawn automatically if the device is resized.

The recording of graphics operations is relatively expensive in
terms of memory so the command \texttt{dev.control("inhibit")} can be
useful if memory usage is an issue.\end{Note}
\begin{SeeAlso}
\texttt{\Link{dev.cur}} and other \texttt{dev.xxx} functions\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}

x11()
plot(rnorm(10), main="Plot 1")
dev.copy(device=x11)
mtext("Copy 1", 3)
dev.print(width=6, height=6, horizontal=FALSE)
dev.off(dev.prev())
dev.off()

\end{ExampleCode}
\end{Examples}

