When using display.save to save an image. Modifying the original object modifies the saved image - confused

I take a picture using the built in camera on iOS

display.save( photo, "CameraShot.jpg", system.TemporaryDirectory )

I want to show the user a preview before they upload it so I scale the object

photo:scale (.5,.5)

I’m confused, as scaling the original object also scales my saved image, which I don’t want to do.

Is this normal behavior, or am I missing something. Do I need to copy the object and display a scaled version of the original? Why does scaling the original also scale the saved image?

so many questions, so little time :wink: [import]uid: 74957 topic_id: 31862 reply_id: 331862[/import]

Here’s my guess. Taking the picture is probably an asynchronous action and so your scale operation is actually happening before the screen is being saved. Try waiting a short amount of time, maybe just a few hundred milliseconds, before you do the scale operation and see if that makes a difference.

Jay [import]uid: 9440 topic_id: 31862 reply_id: 127168[/import]

You are correct. I added timer.performWithDelay to do the scaling and it now saves at the original size.

My application hides the status bar. I noticed that, even though the full captured image is shown, the saved image is cropped ever so slightly, about the size the status bar would take up. [import]uid: 74957 topic_id: 31862 reply_id: 127245[/import]

I know that you can hide the statusbar with code in build.settings and also in the main.lua file – what I don’t know is if they do the exact same thing or if there’s a difference between the two under the hood.

In build.settings in the plist section:
UIStatusBarHidden = true

In your code (usually main.lua):
display.setStatusBar(display.HiddenStatusBar)

So first thing to check is if you’re hiding it both ways – if not, try that and see if it makes a difference. It’s quite likely they both do the same thing on the back end, but I’ve seen weirder things. :wink:

Jay
[import]uid: 9440 topic_id: 31862 reply_id: 127268[/import]

Here’s my guess. Taking the picture is probably an asynchronous action and so your scale operation is actually happening before the screen is being saved. Try waiting a short amount of time, maybe just a few hundred milliseconds, before you do the scale operation and see if that makes a difference.

Jay [import]uid: 9440 topic_id: 31862 reply_id: 127168[/import]

You are correct. I added timer.performWithDelay to do the scaling and it now saves at the original size.

My application hides the status bar. I noticed that, even though the full captured image is shown, the saved image is cropped ever so slightly, about the size the status bar would take up. [import]uid: 74957 topic_id: 31862 reply_id: 127245[/import]

I know that you can hide the statusbar with code in build.settings and also in the main.lua file – what I don’t know is if they do the exact same thing or if there’s a difference between the two under the hood.

In build.settings in the plist section:
UIStatusBarHidden = true

In your code (usually main.lua):
display.setStatusBar(display.HiddenStatusBar)

So first thing to check is if you’re hiding it both ways – if not, try that and see if it makes a difference. It’s quite likely they both do the same thing on the back end, but I’ve seen weirder things. :wink:

Jay
[import]uid: 9440 topic_id: 31862 reply_id: 127268[/import]