Hi,
Sorry, I already posted this in the Community Forum before I realized there was a separate venue for subscribers…
I am trying to save a copy of an image loaded from the media.PhotoLibrary using display.save(). I find that this works as expected for the standard iPhone and the iPad but the iPhone 4 only saves a standard resolution image not a retina one.
e.g.
iPhone - saves 320x480 (good)
iPhone 4 - saves 320x480 (bad)
iPad - saves 682x1024 (good)
Here is my config.lua:
[lua]application =
{
content =
{
width = 320,
height = 480,
scale = “letterbox”,
},
}[/lua]
And here is the main.lua:
[lua]local dw=display.contentWidth
local dh=display.contentHeight
function onLoadComplete(event)
if event.target then
local requiredScaleX=dw/event.target.contentWidth
local requiredScaleY=dh/event.target.contentHeight
local requiredScale=math.max(requiredScaleX, requiredScaleY)
event.target:scale(requiredScale, requiredScale)
event.target.x=dw/2
event.target.y=dh/2
display.save(event.target, “myimage.png”, system.DocumentsDirectory)
print(“Loaded image width=”…event.target.width)
end
end
function onTouch(event)
if event.phase==“began” then
media.show(media.PhotoLibrary, onLoadComplete)
end
end
local button=display.newText(“Click to Load Photo”, 0, 0, native.systemFont, 16)
button:setReferencePoint(display.CenterReferencePoint)
button.x=dw/2
button.y=dh/2
button:setTextColor(255,255,255)
button:addEventListener(“touch”, onTouch)[/lua]
Note that the print statement outputs the correct widths for the object in each case, i.e. 382 (iphone), 764 (iphone4), 764 (ipad) respectively. This makes me suspect that it is display.save() that is at fault and not the loading capability of the media.show() function.
Also, I’m not sure why the variable scaling of the loaded media object is necessary using my calculated requiredScale, but this does at least get the image to fill the screen correctly.
Any help gratefully received.
Best regards
[import]uid: 11045 topic_id: 10186 reply_id: 310186[/import]