Friday, May 27, 2011

How to project the screen of iPad or iPhone to the projector

I have investigated this issue for several months, and finally come to a good solution.

1. The first simple solution without paying any money is to do it on the programming level: you can capture the screen image of the iPhone inside your app, so this is the clue that you can use to first take the screen shot and send it via TCP network connection to a remote computer which can show the screen image. You can use the following code to capture the screen and convert the image to jpeg format. Of course you should use asynchronize TCP connection to send the image data, otherwise the user interface of your app will stop working for some time while sending the image. On the remote computer, you also need to build an application which first listens to a port of the computer, and then receives an image and displays it.
// Capture Screenshot
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *data=UIImageJPEGRepresentation(screenshotImage,self.jpegCompressionRate);
NSUInteger len=[data length];

2. another solution is to use the Apple VGA cable:
http://store.apple.com/sg/product/MC552ZM/B?fnode=MTc0MjU4NjE&mco=MjEzNTM1NjI
, together with the TVOutManager as described on the following web page:
http://www.touchcentric.com/blog/archives/123
The steps of using this TVOutManager are quite clear and simple.

I first used the TVOutManager in my app on iPhone, and it works really very well.
I then used it in my app on iPad, and unfortunately it slowed down my app.
I guess the reason is that the TVOutManager needs lots of computing power to show the screen.
After investigating for a long time, I finally found the way: in the source file TVOutManager.m, you can find two lines:
// #define USE_UIGETSCREENIMAGE
// CGImageRef UIGetScreenImage();
, and you just need to let the two lines work. As a result, your app will work much faster.


3. in fact the Apple VGA cable can directly project the real-time screen output of iPad 2 to the projector, but can only show the video and pictures for the iPhone 4 or iPad 1. If you have iPad 2, then you just need to buy the cable to project anything to the projector.

6 comments:

Esay leoz said...

HDMI Ethernet Cables for Australia.

Sheamus said...

The problem is that you provide may be worth our time and also effort.httom

Jesica Alba said...

The people are very lucky to have this blog because it has better knowledge. Visible Display

jowdjbrown said...

They had fun and hopefully learnt an interesting snippet of knowledge to pass on to others.projector service toronto

Anonymous said...

I do mention at what point you should add it if desired. iPhone repair nottingham

instantfix said...

Nice blogpost get some information about iphone service center .Click here

ipad screen repair dubai
ipad repair dubai
iphone repair in dubai
iphone repair shop in dubai
phone screen repair dubai
cell phone repair shops in dubai
dubai iphone repair