Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Just thinking here.
Is there a way instead of drawing viewport to bitmap data .. I draw the stage to bitmap data.. then crop the image produced. ? Maybe this would get around the problem ?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Or, can't you set the width and height of the bitmap to the width and height of the stageview that you created? That should scale it to 100% on the older iPads, and 50% on the new one.
Copy link to clipboard
Copied
@colin - SocialbitmapData = new BitmapData(socialWebView.viewPort.width, socialWebView.viewPort.height);
This works for iPad2 .. but doesnt work for iPad3
very strange problem
Copy link to clipboard
Copied
That wasn't what I was suggesting. What Rect do you use when creating socialWebView? Can't you set the bitmap to occupy the same rect? The viewPort.width will vary depending on whether it's Retina or not, but surely the stageWebView rect you use will remain the same.
Copy link to clipboard
Copied
the rect is 1024 x 664 ( height is reduced to allow for a toolbar I have in place )
if I double the size of this rect to 2048 x 1328
Since the project setting stage size is 1024 x 768 .. it will make the viewport run way off stage.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
Have I done something wrong in regards to your suggestion ?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Still stuck at the office working on this issue. I've tried everything imaginable. If any of you guys have any more ideas... please shoot them my way. .. Trying to meet a deadline coming up.. this is the last major bug
Copy link to clipboard
Copied
What are you using to build this, Flash CS5.5 or Flash Builder? Let me try something...
iBrent
Copy link to clipboard
Copied
Flash CS5.5
I appreciate anything you can offer.
Copy link to clipboard
Copied
iBrent,
Were you able to come up with a solution ?
Copy link to clipboard
Copied
So far I've been able to replicate the problem.
For some reason the image created from the SWV is zoomed in. I see it on
my Xoom tablet as well as the iPad. Still looking into possible
workarounds...
iBrent
Copy link to clipboard
Copied
Well I feel better that I'm not going crazy.
I have a feeling that even I there is a workaround that the image it captures wont be of retina (x2) quality.
Copy link to clipboard
Copied
iBrent ... how did the attempt for a workaround go ?
Copy link to clipboard
Copied
Brent.,
Did you have any luck with this? This is the only bug I have to get worked out before I can be confident for release. I'm desperate for a solution to this. 😞
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
😞
I'm not going live in the app store yet. We have a deadline to complete phase 1 in 2 weeks.. Phase 2 will be completed in a month. So probably will be app store ready by mid June.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I'm trying my luck by asking if any of you found a solution for this issue?