Beta 3 - Zoomstretch issue in config.lua

This is an iPad app and since I don’t have an iPad local (my tester is remote), I like to test most things out on my phone. So the config.lua is a huge win for me as I don’t need to scale my stuff internally anymore!

My config.lua:

application = { content = { width = 768, height = 1024, scale = "zoomStretch", }, }

I specifically set it to zoomStretch because I want to see/test the whole of the app and not miss anything, even if the graphics are little wonky due to the aspect ratio.

Everything works as expected except my background images. I have two of them, one for my “portrait” view and one for my “landscape” view. These are 768x1024 and 1024x768, respectively.

On my iPhone, they show up centered in the window (as they should), but they are about 50% of the background space… It’s like they get shrunk down twice.

The launch image is the same way (and the same resolution).

The same behavior is seen in all scale modes except none (for obvious reasons). All my other graphics are just fine and the scaling is all correct for dealing with mouse/finger interaction. So it’s related to the size of the image in some fashion.

My ISP is down tonite so I can’t upload any code, but it should be easy to reproduce some images (768x1024) to test it with.

[code]-- This is needed because in “portrait” orientation, you do not receive an orientation event
– on startup. I’m going to log this as a separate bug as it’s quite annoying when trying to find out
– what the starting orientation is…
_currentOrientation = “portrait”;

local function updateOrientation(delta)
local rot = {
portrait = 0,
landscapeLeft = 90,
portraitUpsideDown = 180,
landscapeRight = 270,
};

if (_currentOrientation == “portrait” or _currentOrientation == “portraitUpsideDown”) then
_bgNarrow.isVisible = true;
_bgWide.isVisible = false;
transition.to(_bgNarrow, {
time = 150,
rotation = rot[_currentOrientation],
x = 384,
y = 512,
});
else
_bgNarrow.isVisible = false;
_bgWide.isVisible = true;
transition.to(_bgWide, {
time = 150,
rotation = rot[_currentOrientation],
x = 384,
y = 512,
});
end
end

local function orientationHandler(event)
if (event.name == “orientation”) then
if (event.type == “portrait” or event.type == “portraitUpsideDown” or event.type == “landscapeLeft” or event.type == “landscapeRight”) then
_currentOrientation = event.type;
else
return;
end
updateOrientation(event.delta);
end
end

_bgNarrow = display.newImage(“bg-portrait.png”);
_bgWide = display.newImage(“bg-landscape.png”);
display.setStatusBar(display.HiddenStatusBar);

Runtime:addEventListener(“orientation”, orientationHandler);

updateOrienation(0);
[/code]
[import]uid: 5659 topic_id: 1006 reply_id: 301006[/import]

I had noticed the following with larger images in 1.1, 2.0 beta 1 and 2:

  1. If you don’t turn off scaling when you load the image, it will be scaled down to the displays/content size.
  2. In beta 2 with zoomstretch and on a smaller device than your content definition, I imagine it to be further scaled down, that is why you see it even smaller.
  3. Normaly xreference and yreference is in the middle of an image, so it appears with its center in the top left corner. With large images that are scaled down, the center is allready at the top left corner of the image so it appears centered in the display.

All this scaling is very difficult to understand I think. I hope the scaling parameter of display.newImage now works correctly in beta 3. [import]uid: 5712 topic_id: 1006 reply_id: 2453[/import]

Yes, the difference is that on iPhone, display.newImage (by default) downscales the image to 512x512 if the original image is larger — this is to conserve texture memory.

In the 3.0 beta, you can override auto-scaling using a new parameter to display.newImage. See “Image Autoscaling Override” in the 2.0 Beta guide for more information:

http://developer.anscamobile.com/demo/2.0BetaGuide.pdf [import]uid: 26 topic_id: 1006 reply_id: 2454[/import]

Excellent Walter!! That fixed the iPhone background. :slight_smile:

Of course, I’m releasing on the iPad, but even still this is great info to have.

Thanks so much!

Scott [import]uid: 5659 topic_id: 1006 reply_id: 2462[/import]