Thanks … the delay was the trick … everything was fine for me till i was testing on Android and got the dreaded black image. The delay did the trick … hope 300 is enough on all the devices
Cheers!
Thanks … the delay was the trick … everything was fine for me till i was testing on Android and got the dreaded black image. The delay did the trick … hope 300 is enough on all the devices
Cheers!
Still having this issue with build 2014.2189
Did you try the delay?
I am having the same problem
Below I have my listener for both choosing and taking a picture, and the function displayPic() that it calls:
local function displayPic() if picture ~= nil then print("pic exists") display.remove(picture) picture = nil end if picture == nil then picture = display.newImage("pet.jpg",system.TemporaryDirectory) -- Display the image from the temporary directory print("DISPLAYING NEW PIC") end print( "photo w,h = " .. picture.width .. "," .. picture.height ) local wantedHeight = H/4 local scale = wantedHeight/picture.height picture.xScale, picture.yScale = scale, scale picture.x, picture.y = W/2, 3\*H/4 addStoryGroup:insert(picture) end
Listener:
local function onPhotoComplete( event ) print("onPhotoComplete called") if ( event.completed ) then local imageGroup = display.newGroup() local image = event.target image.x, image.y = W/2, H/2 local wantedHeight = 100 local scale = wantedHeight/image.height image.xScale, image.yScale = scale,scale imageGroup:insert(image) --display.save( imageGroup, "pet.jpg", system.TemporaryDirectory ) local function delayFunc() if system.getInfo( "platformName" ) == "Mac OS X" or system.getInfo( "platformName" ) == "iPhone OS" then display.save(imageGroup, "pet.jpg", system.TemporaryDirectory) elseif system.getInfo( "platformName" ) == "Android" then display.save(image, "pet.jpg", system.TemporaryDirectory) end print("got here") displayPic() display.remove(imageGroup) imageGroup = nil end timer.performWithDelay(300, delayFunc ) --delay added to prevent black square from appearing on android end end
The image displayed on android devices results in a black rectangle. When I insert a group into the temp directory, then it is just black, vs when I insert the image on its own it is a tiny pixel inside the black rectangle.
Differing from the other posts here, I am trying to scale the image before adding it to the temp group. Before when I was adding it full resolution, it was working fine. It still works fine for iOS.
Thanks in advance for any advice!
Still having this issue with build 2014.2189
Did you try the delay?
I am having the same problem
Below I have my listener for both choosing and taking a picture, and the function displayPic() that it calls:
local function displayPic() if picture ~= nil then print("pic exists") display.remove(picture) picture = nil end if picture == nil then picture = display.newImage("pet.jpg",system.TemporaryDirectory) -- Display the image from the temporary directory print("DISPLAYING NEW PIC") end print( "photo w,h = " .. picture.width .. "," .. picture.height ) local wantedHeight = H/4 local scale = wantedHeight/picture.height picture.xScale, picture.yScale = scale, scale picture.x, picture.y = W/2, 3\*H/4 addStoryGroup:insert(picture) end
Listener:
local function onPhotoComplete( event ) print("onPhotoComplete called") if ( event.completed ) then local imageGroup = display.newGroup() local image = event.target image.x, image.y = W/2, H/2 local wantedHeight = 100 local scale = wantedHeight/image.height image.xScale, image.yScale = scale,scale imageGroup:insert(image) --display.save( imageGroup, "pet.jpg", system.TemporaryDirectory ) local function delayFunc() if system.getInfo( "platformName" ) == "Mac OS X" or system.getInfo( "platformName" ) == "iPhone OS" then display.save(imageGroup, "pet.jpg", system.TemporaryDirectory) elseif system.getInfo( "platformName" ) == "Android" then display.save(image, "pet.jpg", system.TemporaryDirectory) end print("got here") displayPic() display.remove(imageGroup) imageGroup = nil end timer.performWithDelay(300, delayFunc ) --delay added to prevent black square from appearing on android end end
The image displayed on android devices results in a black rectangle. When I insert a group into the temp directory, then it is just black, vs when I insert the image on its own it is a tiny pixel inside the black rectangle.
Differing from the other posts here, I am trying to scale the image before adding it to the temp group. Before when I was adding it full resolution, it was working fine. It still works fine for iOS.
Thanks in advance for any advice!