Creating Facebook app for Android - quesiton

I am using letterbox so none of that should be an issue. Bottom line is that we shouldn’t need to screw around and find loop holes and have to alter the integrity of our apps to get this working, for that reason I hope Ansca can fix this bug. Otherwise developers will look else where for their dev tools, just sucks when features don’t work. [import]uid: 19620 topic_id: 32551 reply_id: 131667[/import]

@rxm, display.save works in device pixels – Letterbox mode has most (if not all) of the issues I outlined above, and depending on the devices the images were saved from, and later displayed on (both being the same letterbox app), you can get stretched/squashed images. (our config.lua settings are similar).

 content =  
 {  
 width = 640,  
 height = 960,  
 scale = "letterbox"  
 },  

Again, there’s not enough info to tell if this is what is causing your distortions, but my image processing code takes images from iphones, s3’s, nexus 7’s, motorolas, iPads etc, accounts for those factors, and the final images are distortion free (across all devices).

Also, You never answered about the pixel sizes of your images when saved from various devices. If they are all a perfect 320x480 when saved from very different devices, then you must have accounted for the issue. If they aren’t all the same sizes (320x480), you might want to reread my prior posts.

Best of luck. [import]uid: 79933 topic_id: 32551 reply_id: 131673[/import]

@mpappas,
I guess thats what I don’t understand is exactly how to resolve my issue. Can you change what resolution the screen is captured at? My phone is the galaxy SIII, so my captured image size is 1280x720. What other info do you need? [import]uid: 19620 topic_id: 32551 reply_id: 131675[/import]

The capture image size tells me you have a scaling problem. You are displaying images at your content size of 320x480 — a 2:3 pixel ratio, width to height.

However, you are capturing images from this particular device at 720x1280 — closer to a 1:2 pixel ratio.

When you call display capture with a size of 320x480, it captures IN DEVICE PIXELS… And the s3 screen is not a 2:3 aspect ratio. At this point we come up against how corona is mapping your 320x480 space onto the s3… Which will determine how many pixels you get back from the capture call… Back to that in a minute…

So — If you display a captured/saved 720x1280 image in your content space (320x480), i believe it would be squished, as the SDK crunches approx 200 pixels off the 1280 dimension when it tries to display it (as 320x480). A few taps on a calculator, and you can see the math issue…

Hopefully that part makes sense… Why does corona do it this way you might ask? The SDK allows you to capture from the display in however many pixels are possible on the device. That way, if you are using a lower content resolution, you can still opt to capture high res images (up to the displays true resolution).

Two variables that are useful in understanding how to adjust the height and width of your display.capture() height/width are:

display.contentScaleX
display.contentScaleY

You should print those out (either onscreen, or in the console) and consider multiplying your display capture width/height by them / and or other transformations to your captured photo based on, well, a variety of factors…

I believe once you multiply by those (your capture height/width), your saved images will become 320x480… From there, you’ve got more work to do, but you might gain some insight as to whats going on under the hood on various devices…
[import]uid: 79933 topic_id: 32551 reply_id: 131678[/import]

Thanks for your help first of all.
So I now understand the issue, thanks for explaining it so fully. So my question now is… are you able to use parameters with the display.capture API in regards to telling it was aspect ratio to save the image at? Or in the end do I have to still fix this by changing up my app’s config settings width and height?

for example can you do something like display.capture( 480, 320 )…? [import]uid: 19620 topic_id: 32551 reply_id: 131686[/import]

Not exactly, but changing the size of the object (the first parameter argument to display.save) effectively does the same thing, eg;If you change the image width and height you are passing, it does the same thing.

From the display.save doc page:

NOTE: When dynamic content scaling is enabled, display.save() saves the image in the device’s native resolution. For instance, if this method is used to save a 100 x 200 pixel display object, it will be saved as a 100 x 200 image on iPhone3 but it will be a 200 x 400 image on an iPhone4 (which would have the same content dimensions but more actual pixels). This is assuming that the config.lua file specifies the content width/height as 320x480 respectively.

So if you change the height and width of the image to take this into account before calling display.save, that will achieve the effect. [import]uid: 79933 topic_id: 32551 reply_id: 131687[/import]

Ahhh ok I finally get it. Only issue is that I have LOTS of display objects that get captured, is it possible to change the width and height of a display group? Or would I need to change each display object individually you think? [import]uid: 19620 topic_id: 32551 reply_id: 131688[/import]

I’m saving a group as well, and with a mask (next thing ya know, you’ll be saying you’re using a mask)…

Seems there’s a lot in common between our saving…

I’m not saving a lot of objects (just an image and a watermark in the group) so I am changing the captured images width/height directly, and adjusting the watermark font size / x/y coords in the group based on actual device pixel screen cap size dimensions. I think you can adjust the groups xscale and yscale, but not its width and height… If you scale the group (which would scale all the objects in it), not sure how that will pan out/look for scaling it up… The images might look blurry… (but downscaling should be ok)

I’m afraid text on a blog is not the best way to convey what you’re about to go through regarding this scaling… And when you get to the clipping (for odd shaped devices) you’re going to have to zag – instead of zig… But it sounds like you’re on the right track :slight_smile:

So – You’ll have to mess around with it a bit to find out some of the tricks to get everything nice and crisp looking, uploading / downloading nice and fast, and eliminate any other sources of distortion on different resolutions… [import]uid: 79933 topic_id: 32551 reply_id: 131693[/import]

Awesome, well I appreciate your tips and thoughts, I will give it a try tomorrow! I’ll make sure to let you know how it goes, thanks again! [import]uid: 19620 topic_id: 32551 reply_id: 131694[/import]

Best of luck.

Note for rxm for later: Pssstttttt… You’re gonna need a mask on the group for that. [import]uid: 79933 topic_id: 32551 reply_id: 131695[/import]

@Joshua,
Any chance the bug that I submitted a while back is going to get resolved anytime soon? Pretty much just waiting on that to release my app. [import]uid: 19620 topic_id: 32551 reply_id: 131639[/import]

@rxm - We’re taking photos, using display.save, emailing them, posting them to facebook, showing them onscreen, etc… on a galaxy s3 (4.0.1 I believe). We’re also passing the same images to a nexus 7, ipad, iphones, etc, and they look fantastic across all platforms. (wasn’t easy though)

Our content width and height is 640x960, and the app had squishing/distortion effects early on…

Images taken on some devices seemed stretched vertically, other stretched horizontally…

It turned out that there were some issues based on the apps content width/height related to the devices native resolution.

If you read the display.capture stuff carefully (the really really fine print), it says the capture stuff happens *in device pixels*… which you can compensate for easy enough (as long as you know of it).

Capturing at device pixel resolution made for some really really huge image grabbing on an ipad3, I tell ya – that had to be fixed too…

But then it got harder. When I took pictures on devices with native resolution that wasn’t as wide (or tall) as my content width/height, the display capture would just grab what it could.

But this left my image at an aspect ratio that was different than my intention (so a 640x960 intended capture, would be returned as a 540x960 capture – the best it could do on the device). Later, when the picture is displayed, my code would expand it to 640x960 and voila… It’s stretched…

It took a while (including dealing with landscape photos, etc) to get it all nice and perty, and our solutions are specific to what we’re doing, but some of this might be related (I relate all this because our images looked funky early on). [import]uid: 79933 topic_id: 32551 reply_id: 131645[/import]

@mpappas,
Thanks for sharing your experience with this. I set my own content width and height as well at the start of the project so that our app content would display well on any device possible. Its working great, but I just don’t see it as a solution to mess with our apps content area size at this point because we would have to redo almost everything in the app. our content size is a width of 320 by a height of 480. I thought that this would be a frequently used content size? isn’t that the size of the original iphone resolution? [import]uid: 19620 topic_id: 32551 reply_id: 131646[/import]

Didn’t read the entire thread but regarding Facebook, you should sandbox your app in the app settings page on Facebook. I learned that when I was playing around with facebook checkins. [import]uid: 13560 topic_id: 32551 reply_id: 131651[/import]

@rxm - there’s a lot of sizes these days, but a couple questions…

What size are the saved images? For things to not look squished/stretched, they need to be captured at the same ratio as your content dimensions, eg; 2:3 (320:480)

But come to think of it, one thing I didn’t consider is a content mode of zoom stretch (or any other mode that would stretch things one way or another).

If you’re doing a content stretch, then your likely to have a rough time getting your captured images to look nice on various devices… (I would steer away from that…)

Either way, you should check your saved image sizes on various devices, and consider the impact of displaying then on at your content resolution (and then, on top of that, factor in zoom stretching or any other mode like that you might be using).
[import]uid: 79933 topic_id: 32551 reply_id: 131656[/import]

I am using letterbox so none of that should be an issue. Bottom line is that we shouldn’t need to screw around and find loop holes and have to alter the integrity of our apps to get this working, for that reason I hope Ansca can fix this bug. Otherwise developers will look else where for their dev tools, just sucks when features don’t work. [import]uid: 19620 topic_id: 32551 reply_id: 131667[/import]

@rxm, display.save works in device pixels – Letterbox mode has most (if not all) of the issues I outlined above, and depending on the devices the images were saved from, and later displayed on (both being the same letterbox app), you can get stretched/squashed images. (our config.lua settings are similar).

 content =  
 {  
 width = 640,  
 height = 960,  
 scale = "letterbox"  
 },  

Again, there’s not enough info to tell if this is what is causing your distortions, but my image processing code takes images from iphones, s3’s, nexus 7’s, motorolas, iPads etc, accounts for those factors, and the final images are distortion free (across all devices).

Also, You never answered about the pixel sizes of your images when saved from various devices. If they are all a perfect 320x480 when saved from very different devices, then you must have accounted for the issue. If they aren’t all the same sizes (320x480), you might want to reread my prior posts.

Best of luck. [import]uid: 79933 topic_id: 32551 reply_id: 131673[/import]

@mpappas,
I guess thats what I don’t understand is exactly how to resolve my issue. Can you change what resolution the screen is captured at? My phone is the galaxy SIII, so my captured image size is 1280x720. What other info do you need? [import]uid: 19620 topic_id: 32551 reply_id: 131675[/import]

The capture image size tells me you have a scaling problem. You are displaying images at your content size of 320x480 — a 2:3 pixel ratio, width to height.

However, you are capturing images from this particular device at 720x1280 — closer to a 1:2 pixel ratio.

When you call display capture with a size of 320x480, it captures IN DEVICE PIXELS… And the s3 screen is not a 2:3 aspect ratio. At this point we come up against how corona is mapping your 320x480 space onto the s3… Which will determine how many pixels you get back from the capture call… Back to that in a minute…

So — If you display a captured/saved 720x1280 image in your content space (320x480), i believe it would be squished, as the SDK crunches approx 200 pixels off the 1280 dimension when it tries to display it (as 320x480). A few taps on a calculator, and you can see the math issue…

Hopefully that part makes sense… Why does corona do it this way you might ask? The SDK allows you to capture from the display in however many pixels are possible on the device. That way, if you are using a lower content resolution, you can still opt to capture high res images (up to the displays true resolution).

Two variables that are useful in understanding how to adjust the height and width of your display.capture() height/width are:

display.contentScaleX
display.contentScaleY

You should print those out (either onscreen, or in the console) and consider multiplying your display capture width/height by them / and or other transformations to your captured photo based on, well, a variety of factors…

I believe once you multiply by those (your capture height/width), your saved images will become 320x480… From there, you’ve got more work to do, but you might gain some insight as to whats going on under the hood on various devices…
[import]uid: 79933 topic_id: 32551 reply_id: 131678[/import]

Thanks for your help first of all.
So I now understand the issue, thanks for explaining it so fully. So my question now is… are you able to use parameters with the display.capture API in regards to telling it was aspect ratio to save the image at? Or in the end do I have to still fix this by changing up my app’s config settings width and height?

for example can you do something like display.capture( 480, 320 )…? [import]uid: 19620 topic_id: 32551 reply_id: 131686[/import]