# TikZ - Is it possible to draw this block diagram?

I have problems with a presentation with beamer.

I can open the original slide (pdf) with LibreOffice and I can retrieve the diagram's structure. Can I start from this and put it (not the image but the structure) on my beamer presentation?

I have tried to put the image on the frame directly but the image has a blurry effect. Can someone help me with the TikZ version of this diagram?

MWE

\documentclass{beamer}
\title{TITLE}
\author{ME}
\date{TODAY}
\usetheme{Berlin}
\setbeamercovered{dynamic}

\begin{document}

\begin{frame}
\maketitle
\end{frame}

\begin{frame}
\frametitle{Sistemi Crittografici}
\framesubtitle{Proteggere i contenuti}
\begin{figure}[t]
\includegraphics[opts.]{the image of the diagram}
\end{figure}
\begin{itemize}[<+->]
\item{bla}
\item{bla bla bla}
\item{bla bla bla bla bla}
\end{itemize}
\end{frame}

\end{document}

-
Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier to help you draw the diagram when we can start from a working presentation, starting with \documentclass{...} and ending with \end{document}. –  darthbith Jul 8 '14 at 16:03
In terms of the original image, when did the loss of resolution occur? Did you have to edit the pdf to extract the image? –  John Kormylo Jul 8 '14 at 16:03
@JohnKormylo The diagram is a diagram not an image. I simply made a screenshot of the pdf. I can't save it as image from the pdf because is not an image. It's an object with a structure. –  Firaja Jul 8 '14 at 16:12
Screenshots are almost always 76dpi (ugly!). –  John Kormylo Jul 8 '14 at 16:15
My approach in these cases is to generate a pdf “image” from the original pdf by extracting the page with the figure, removing all unnecessary content and removing the white borders, but you would need a pdf editor such as adobe acrobat for this. But if file size does not matter and you can live with content from the original pdf being hidden but accessible in your presentation, you could use the clip, trim and page options of the \includegraphics command from the graphicx package to include the original pdf. –  Chris Jul 8 '14 at 16:35

One possibility:

The code (requires PGF/TikZ version 3.0):

\documentclass[border=3pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,fit,patterns}

\tikzset{
pics/media/.style ={
code = { %
\node[text width=2cm,minimum height=2cm,#1] (back) {};
\node[draw,anchor=center,fill=white] at ([yshift=5pt]back.center) {Media};
\draw[dashed] (back.north west) rectangle (back.south east);
}
},
pics/media/.default={pattern=north east lines},
aes/.style={
draw,
fill=red!30
},
rsa/.style={
draw,
rounded corners,
fill=blue!30
},
ar/.style={
->,
>=latex,
shorten >= 3pt,
shorten <= 3pt,
},
ar2/.style={
->,
>=latex,
line width=2pt,
shorten >= 3pt,
shorten <= 3pt,
}
}

\newcommand\mediaencryptedbox[3][1cm]{
\node[
draw,
thick,
rounded corners,
#2,
text width=3.5cm,
minimum height=4.5cm,
anchor=north west,
yshift=#1
]
(#3)
{};
\node[
aes,
anchor=north
]
at (#3.north)
{AES key};
\pic at (#3.center) (sm3) {media};
\node[
anchor=south
]
(rsa)
at (sm3back.north)
{Encrypted with RSA};
\node[
anchor=north
]
at (sm3back.south)
{Encrypted with AES};
\draw
(#3.west|-rsa.south) -- (#3.east|-rsa.south);
}

\begin{document}

\begin{tikzpicture}

% The Server
\pic (sm1) {media={fill=gray!30}};
\pic[right=of sm1back] (sm2) {media};
\mediaencryptedbox{right=of sm2back}{box1}
\node[
aes,
anchor=north,
above=of sm2back.north
]
(aes1)
{AES key};
\draw[ar]
(aes1) -- (sm2back.north) ;
\draw[ar]
(aes1.south east) to[out=-60,in=180] coordinate (aux1) (box1.north west) ;
\node[
anchor=west,
rsa
]
at (aux1|-aes1)
(rsa1)
{RSA public key};

\draw[ar]
(rsa1) -- (aux1) ;

\draw[ar2]
(sm1back.east) -- (sm2back.west);
\draw[ar2]
(sm2back.east) -- (box1.west|-sm2back.east);

\node[
inner sep=10pt,
draw,
dashed,fit={(sm1back.north west) (box1.south east) (aes1)}
]
(server)
{};
\node[
anchor=south west,
font=\Large
]
at ([shift={(15pt,5pt)}]server.north west)
{Server};

% The Player
\mediaencryptedbox[2.2cm]{right=6cm of box1}{box2}
\node[
anchor=north west,
rsa,
above left=of box2
]
(rsa2)
{RSA public key};
\draw[ar]
(rsa2.south)
to[out=-80,in=160]
node[align=center,anchor=east,shift={(10pt,-20pt)}] {RSA decryption \\ (slow)}
([yshift=-20pt]box2.north west);
\draw[ar]
([yshift=-10pt]box2.north east)
to[out=0,in=0]
node[align=center,anchor=west,shift={(5pt,0pt)}] (AESd) {AES decryption \\ (fast)}
(sm3back.east);
\node[
inner sep=10pt,
draw,
dashed,fit={(rsa2) (box2.south east) (AESd)}
]
(player)
{};
\node[
anchor=south west,
font=\Large
]
at ([shift={(15pt,5pt)}]player.north west)
{Player};

\draw[ar2]
(server.east) -- (player.west|-server.east);
\draw[ar2]
([yshift=10pt]sm3back.south east) -- ++(3cm,0) node[near end,anchor=south west] {Streaming};
\end{tikzpicture}

\end{document}

-
Thanks! Now I can start from this! –  Firaja Jul 8 '14 at 16:45
@Firaja You're welcome. In the meantime I completed the diagram and introduced some improvements to the code, in case you are interested. –  Gonzalo Medina Jul 8 '14 at 17:06

To startup, Have a look (with TikZ):

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage[left=0in,right=0in]{geometry}
\begin{document}
\begin{tikzpicture}
\draw[dashed, color=blue] (-3,0) rectangle (4,4);
\filldraw[color=blue!20] (-2.5,1.2) rectangle (-0.5,2.7);
\end{tikzpicture}
\end{document}


-