display.loadRemoteImage with different screen pixel densities.

I am wondering if I load a remote image under a different screen pixel density (see examples in Corona SDK/Sample Code/Hardware/DynamicImageResolution) how will corona know to load the correct image? Is there a way I can do my own check for this DynamicImageResolution feature.

if screen@2x then -- load different image

Thanks in advance for any advice.

display.imageSuffix (http://docs.coronalabs.com/api/library/display/imageSuffix.html) will tell you what suffix is being used.  You could base logic around that.

But you shouldn’t need to do this. If you’re using display.newImageRect() we take care of it for you.  If you want to manage this yourself, you could look at the display.contentScaleX and display.contentScaleY values and use display.newImage() to load in specific images (or some other way of determining what screen res you have)

Rob

I was wondering the same thing and was about to start a new topic until i searched and found this…

So does loadRemoteImage automatically inject the imageSuffix to the remote url?

i.e. if I had these stored on a remote server:

pic.jpg

pic@2x.jpg

pic@4x.jpg

would loadremoteimage pick the correct one and only download the version that’s needed?  I can of course use display.imageSuffix and build the correct url before ‘getting’ the image which would achieve the same but wanted to check it didnt do it out of the box first.

I understand that display.newImageRect()  works it out magically if ALL the versions are stored locally on the device but I can’t see how that would work unless you fetched all three versions from the remote server.  I don’t see the point of using bandwidth when I dont need to.

Many thanks

Dave

Hi David

That was the intention of my question to find out. I decided that based on the answer provided this was not the case. I will still try it as a test before implementing this portion of my project. If you perform a test and it works as intended before I have, then please respond in kind. 

*cheers

@david.hunt15, display.loadRemoteImage() is based on display.newImage() which does NOT support dynamic scaling.  Only display.newImageRect() does that.  Most services that you would download a photo from doesn’t understand the concept of @2x and @4x images.

Rob

Hey Rob,

No worries, I knew that 3rd parties wouldn’t get the corona suffix thing… I guess my question was behind the scenes (before grabbing the image), did the loadRemoteImage() split the URL and ‘inject’ the suffix before hand.

It is no trouble at all to build the url myself - I just wanted to check I wasn’t teaching corona to suck eggs :wink:

So to clarify and for any others reading this post, you would do something like the below?  I guess the caveat being is that the developer would have to make sure all the versions existed on the remote server and handle the cases where they didn’t

Thanks for your help guys :slight_smile:

local suffix = display.imageSuffix if suffix == nil then suffix = "" end local url = "http://coronalabs.com/images/coronalogogrey" .. suffix .. ".png" display.loadRemoteImage(url, "GET", networkListener, "coronalogogrey.png", system.TemporaryDirectory, display.contentCenterX, display.contentCenterY )

To be very clear:  we grab the exact URL you specify.  We don’t modify it in any way and make no attempt to get a device specific version.

Rob

No worries… thanks for your time helping out the newbies rob :slight_smile:

display.imageSuffix (http://docs.coronalabs.com/api/library/display/imageSuffix.html) will tell you what suffix is being used.  You could base logic around that.

But you shouldn’t need to do this. If you’re using display.newImageRect() we take care of it for you.  If you want to manage this yourself, you could look at the display.contentScaleX and display.contentScaleY values and use display.newImage() to load in specific images (or some other way of determining what screen res you have)

Rob

I was wondering the same thing and was about to start a new topic until i searched and found this…

So does loadRemoteImage automatically inject the imageSuffix to the remote url?

i.e. if I had these stored on a remote server:

pic.jpg

pic@2x.jpg

pic@4x.jpg

would loadremoteimage pick the correct one and only download the version that’s needed?  I can of course use display.imageSuffix and build the correct url before ‘getting’ the image which would achieve the same but wanted to check it didnt do it out of the box first.

I understand that display.newImageRect()  works it out magically if ALL the versions are stored locally on the device but I can’t see how that would work unless you fetched all three versions from the remote server.  I don’t see the point of using bandwidth when I dont need to.

Many thanks

Dave

Hi David

That was the intention of my question to find out. I decided that based on the answer provided this was not the case. I will still try it as a test before implementing this portion of my project. If you perform a test and it works as intended before I have, then please respond in kind. 

*cheers

@david.hunt15, display.loadRemoteImage() is based on display.newImage() which does NOT support dynamic scaling.  Only display.newImageRect() does that.  Most services that you would download a photo from doesn’t understand the concept of @2x and @4x images.

Rob

Hey Rob,

No worries, I knew that 3rd parties wouldn’t get the corona suffix thing… I guess my question was behind the scenes (before grabbing the image), did the loadRemoteImage() split the URL and ‘inject’ the suffix before hand.

It is no trouble at all to build the url myself - I just wanted to check I wasn’t teaching corona to suck eggs :wink:

So to clarify and for any others reading this post, you would do something like the below?  I guess the caveat being is that the developer would have to make sure all the versions existed on the remote server and handle the cases where they didn’t

Thanks for your help guys :slight_smile:

local suffix = display.imageSuffix if suffix == nil then suffix = "" end local url = "http://coronalabs.com/images/coronalogogrey" .. suffix .. ".png" display.loadRemoteImage(url, "GET", networkListener, "coronalogogrey.png", system.TemporaryDirectory, display.contentCenterX, display.contentCenterY )

To be very clear:  we grab the exact URL you specify.  We don’t modify it in any way and make no attempt to get a device specific version.

Rob

No worries… thanks for your time helping out the newbies rob :slight_smile: