I draw many pictures in the screen and know it coordinates,it width and it height.

I want draw a line, coneccting two of the pictures, but the line have of be draw in a path which don't pass over the other pictures and the line can be break in many
others, them need going through a straight
line path.
Example:

Instead the line does it below,

************
* Picture1 *
************
\
\
\
\
\
\
************
* Picture2 *
************

The line have of does it:

************
* Picture1 *
************
|
|
|
------
|
|
|
************
* Picture2 *
************

Someone know how can I do it?