So.. I have some stageWebView elements that use BitMapData to capture a screenshot of the browser to allow for other elements to animate ontop of the browser ( sharing options, etc ).
When I capture this on the new iPad ... and add the bitmap to the stage the bitmap is zoomed in twice the size it should be. Its not capturing the true viewport. its zoomed in.
This is what I'm using to capture the bitmap.
SocialbitmapData = new BitmapData(socialWebView.viewPort.width, socialWebView.viewPort.height);
socialWebView.drawViewPortToBitmapData(SocialbitmapData);
socialViewBitmap = new Bitmap(SocialbitmapData);
addChild(socialViewBitmap);
Any help is appreciated
Hi,
What you're seeing is expected behavior. The reason is, is that the StageWebView viewport is returning the actual dimensions of the new iPad view. Since SWV is actually using the native UIWebView, it's returning the high res result.
I'm guessing you didn't build the app with retina support, i.e. commandline compile with -platformsdk pointing to iOS 5.1 SDK. What you're seeing then is an image from the native browser returned at twice the resolution of what the app is returning, because the app isn't set to retina, but the browser is. To fix this, compile the app for retina display, then the image returned will be the correct proportion.
Try that and let us know.
iBrent
iBrent,
I did compile it with retina support iOS5.1SDK
On iPad2 everything is fine.
@Colin - If I set the width of the viewport to 2048 .. it will be too large on iPad2
My project stage size is still 1024 x 768 .. I've just used x2 graphics and sized them down by 50% .. this results in pixel perfect graphics for retina.
So .. if my stage size is being interpreted as 1024 x 768 and I make the viewport 2048 x 1536 ... it actually puts the viewport as double the size of the iPad even on the iPad3.
When I set viewport to 1024 x 768 for example... it renders perfect on iPad2 and iPad3 .. its just the bitmap capturing of the viewport thats the problem.
Still not what I was saying. Leave the rect as 1024x664, when you get the bitmap, set its scaleX to 1024/stageWebView.viewPort.width and its scaleY to 664/stageWebView.viewPort.height. That should have no effect on the iPad 2, but ought to scale the image to the right size on the new iPad.
I'll try that ![]()
Just a note as well. I wrote this solution ... works perfectly when tested from the IDE .. copyPixels fails to display anything on iPad2 or iPad3
bitmapdataBrowser = new BitmapData(stage.stageWidth, stage.stageHeight);
bitmapdataBrowser.draw(stage);
bitmapDataA = new BitmapData(1024, 664);
bitmapDataA.copyPixels(bitmapdataBrowser, new Rectangle(0, 42, 1024, 664), new Point(0, 0));
var screenshot = new Bitmap(bitmapDataA);
addChild(screenshot);
screenshot.x = 0;
screenshot.y = 42;
Colin,
No go on your scaleX scaleY suggestion. It does the exact same thing. It zooms in on the bitmap when viewed on an iPad3.
Here is my code.
SocialbitmapData = new BitmapData(socialWebView.viewPort.width, socialWebView.viewPort.height);
socialWebView.drawViewPortToBitmapData(SocialbitmapData);
socialViewBitmap = new Bitmap(SocialbitmapData);
shareFacebookBTN.visible = false;
socialContent_mc.y = 768;
socialViewBitmap.scaleX = 1024/socialWebView.viewPort.width;
socialViewBitmap.scaleY = 664/socialWebView.viewPort.height;
addChild(socialViewBitmap);
socialViewBitmap.x = 0;
socialViewBitmap.y = 42;
So I did a test ... change the scaleX and scaleY t0
socialViewBitmap.scaleX = .5;
socialViewBitmap.scaleY = .5;
Now on the iPad3 the capture looks fine... except its width and height is cropped at 50% obviously because of the .5
So what seems to be happening .. is that
socialWebView.drawViewPortToBitmapData(SocialbitmapData);
socialViewBitmap = new Bitmap(SocialbitmapData);
this cannot capture stageWebView at the high resolution. When it does the capture it isnt capture what you see with you eye.. its capturing at as if its non-retina. So .. if I capture my screen on the iPad3 which should be a resolution of 2048 x 1536 .... it really only captures stageWebView at 1024 x 768 .. so when you place the captured bitmap on the stage.. you get a non retina bitmap.
Hi,
I've tried a number of things and can't get it to work on the new iPad at the retina display. I don't know if it's an AIR defect, or if it's something with the way UIWebView (the native SDK implementation) is returning incorrect information.
If you're looking to release now, I'd suggest releasing without new iPad retina support, then when it's been fixed in AIR (hopefully) then release an update to address the issue.
Sorry,
iBrent
North America
Europe, Middle East and Africa
Asia Pacific