display.newSnapshot( ) black image!

hi.

i’ve done app that picks a image from the internet and then i crop it and save it to the temp dir, so i can use the croped image later.

in windows simulator worsk fine. image is downloaded fine and croped image is created like i wanted.

in android nexus 7 is downloaded fine but the snapshot appears a black image not the downloaded. i’ve tried adding timers with no luck. 

ive build 2607.

i’m doing something wrong? why it works on simulator and not in the device? Do i need to put anything in build.settings?

local img = display.newImageRect(original,dir, w\*.25,h\*.25) local snapshot = display.newSnapshot( w, c ) snapshot.group:insert( img ) snapshot:invalidate() -- tried with or without snapshot.width = w\*display.contentScaleX snapshot.height = c\*display.contentScaleY display.save( snapshot, { filename=croped, baseDir=dir, isFullResolution=false, jpegQuality=0.8 } ) snapshot:removeSelf() snapshot=nil

Just to ask the obvious…  Devices are case sensitive while the simulator is not. That’s the first thing I would check.  Next would be to make sure you’re not exceeding the device’s maxTextureSize.

Rob

thx for the reply rob.

the image is downloaded fine. i then create a display.image with that image just fine (no sensity problem here). the problem starts when i insert that image in the snapshot group.

i will isolate the code to check if its a corona problem, device problem or code problem (most likely).

images i download are 1280x690 so i guess maxTextureSize is not a problem.

found the problem.

the image like i said is 1280x690. since i only have the big image (4x) what i do is divide by 4 the original image so i get the 1X.

local img = display.newImageRect(original,dir, w\*.25,h\*.25)

this works fine in the simulator and in the device works fine to. but if i snapshot it

local snapshot = display.newSnapshot( w, c ) snapshot.group:insert( img )

…it doesnt respect my new image size (*.25), because he thinks 1280x690 is 1X. snapshot should not respect my img created with display.newimage???

if i create 3 images with sizes 1x(320x173) 2x(640x345) 4x(1280x690). and i change my code to

local img = display.newImageRect(original,dir, w,h)

code work in simulator and android. now the problem is…i dont have 1x in the remote server. i download the larger on thats why i just create a img with *.25.

You could take that 1x image and do a display.save() on it to save a temporary 1x version out and load it into the snapshot…  I’ll see if I can get a response from Engineering.

Rob

Can we get some screen shots or some visuals as to what’s happening?

rob, thx again for the replies. the 1x was made just for tests in paint to track the problem :slight_smile: yes it works with the 1x version (320x173). all goes fine, the snapshot and the display.save of the croped image created with the snapshot.  i don’t have access of then in the app. the server only have 4x versions…i download them…i create a .25 version of it with display.newImageRect and try to snapshot it and display.save it…don’t work because snapshot ignores my .25 version.

screen shots will be a blank screen…still much explanatory :slight_smile: (in the device, on simulator works fine)

it’s pretty easy to mimic my problem, just create a 1280x690 image in paint…and copy paste the code i put in first post.

code missing are declarations:

local w=1280 local h=690 local c=500 -- cropped hight local original="filename.jpg" local dir=system.TemporaryDirectory -- where filename.jpg is local croped="newFilenameCroped.jpg"

You will need to create this demo.  Engineering can’t afford the time to try and figure out what you’re trying to do.  Please create a demo, complete with build.settings, config.lua and the images needed and put it in a .zip file and use the Report a bug link above.  When you get the email back from the bug tracker, post the Case ID Number back in this thread.   Once I have that we can take a look at what you’re trying to do. 

Rob

ok thx for the help.

Hi Guys,

i’m having the same problem, but i did not understand the solution…

i’m using snapshots to simulate water fluid … actually simulation happens without snapshots, but snapshots make it look smoother

game is working on simulator, on device it is working as well but showing an entire black screen, and if you tap buttons will respond!!

this is the code for the game which is a free game for an NGO for Green Building

i had to remove the snapshot to publish it on a phone

any ideas … the snapshots are used in level0.lua

https://drive.google.com/file/d/0B0jaMsSVUQ4Aa0xHeGtkZHk3ZzQ/view?usp=sharing

Just to ask the obvious…  Devices are case sensitive while the simulator is not. That’s the first thing I would check.  Next would be to make sure you’re not exceeding the device’s maxTextureSize.

Rob

thx for the reply rob.

the image is downloaded fine. i then create a display.image with that image just fine (no sensity problem here). the problem starts when i insert that image in the snapshot group.

i will isolate the code to check if its a corona problem, device problem or code problem (most likely).

images i download are 1280x690 so i guess maxTextureSize is not a problem.

found the problem.

the image like i said is 1280x690. since i only have the big image (4x) what i do is divide by 4 the original image so i get the 1X.

local img = display.newImageRect(original,dir, w\*.25,h\*.25)

this works fine in the simulator and in the device works fine to. but if i snapshot it

local snapshot = display.newSnapshot( w, c ) snapshot.group:insert( img )

…it doesnt respect my new image size (*.25), because he thinks 1280x690 is 1X. snapshot should not respect my img created with display.newimage???

if i create 3 images with sizes 1x(320x173) 2x(640x345) 4x(1280x690). and i change my code to

local img = display.newImageRect(original,dir, w,h)

code work in simulator and android. now the problem is…i dont have 1x in the remote server. i download the larger on thats why i just create a img with *.25.

You could take that 1x image and do a display.save() on it to save a temporary 1x version out and load it into the snapshot…  I’ll see if I can get a response from Engineering.

Rob

Can we get some screen shots or some visuals as to what’s happening?

rob, thx again for the replies. the 1x was made just for tests in paint to track the problem :slight_smile: yes it works with the 1x version (320x173). all goes fine, the snapshot and the display.save of the croped image created with the snapshot.  i don’t have access of then in the app. the server only have 4x versions…i download them…i create a .25 version of it with display.newImageRect and try to snapshot it and display.save it…don’t work because snapshot ignores my .25 version.

screen shots will be a blank screen…still much explanatory :slight_smile: (in the device, on simulator works fine)

it’s pretty easy to mimic my problem, just create a 1280x690 image in paint…and copy paste the code i put in first post.

code missing are declarations:

local w=1280 local h=690 local c=500 -- cropped hight local original="filename.jpg" local dir=system.TemporaryDirectory -- where filename.jpg is local croped="newFilenameCroped.jpg"

You will need to create this demo.  Engineering can’t afford the time to try and figure out what you’re trying to do.  Please create a demo, complete with build.settings, config.lua and the images needed and put it in a .zip file and use the Report a bug link above.  When you get the email back from the bug tracker, post the Case ID Number back in this thread.   Once I have that we can take a look at what you’re trying to do. 

Rob

ok thx for the help.

Hi Guys,

i’m having the same problem, but i did not understand the solution…

i’m using snapshots to simulate water fluid … actually simulation happens without snapshots, but snapshots make it look smoother

game is working on simulator, on device it is working as well but showing an entire black screen, and if you tap buttons will respond!!

this is the code for the game which is a free game for an NGO for Green Building

i had to remove the snapshot to publish it on a phone

any ideas … the snapshots are used in level0.lua

https://drive.google.com/file/d/0B0jaMsSVUQ4Aa0xHeGtkZHk3ZzQ/view?usp=sharing