You can do just what your asking but you have to jailbreak in order to do it.
There's are a slew of apps to do this; just not from the iTunes app store.
Read this thread for more info:
Resolution is dependant on which cable set you use. I choose to use the vga output cable for the ipad on my iphone 4, then convert it to dvi with a simple adapter. However you could also use one of the vastly available composite to 30 pin dock connection cables available on the market.