Hi there!
I use display.save() trying to save an image that i want to use later.
My problem is this: When I save the image, this one is what i see instead of watching the elements I’ve got before pressing the save button, i.e., I want to save the image but not to watch the result (image.jpg) in my iPhone screen.
Is it possible?, what am I doing wrong?
This is my code:
display.setStatusBar( display.HiddenStatusBar )
local ui=require("ui")
local width,height=display.contentWidth,display.contentHeight
local background=display.newImage("background.jpg")
local rect=display.newRect(0,(height-80),width,height)
rect:setFillColor(174,78,0)
local my\_image=display.newImage("foo.png",90,90)
local function saving()
local baseDir = system.DocumentsDirectory
local toSave=display.newGroup()
toSave:insert(background)
toSave:insert(my\_image)
display.save(toSave,"image.jpg",baseDir)
end
local save\_button = ui.newButton{
default = "save\_button.png",
over = "save\_button.png",
onRelease = saving,
emboss = true
}
save\_button.x=width/2
save\_button.y=height-35
TIA [import]uid: 44013 topic_id: 9718 reply_id: 309718[/import]
can you elaborate a bit more.
c. [import]uid: 24 topic_id: 9718 reply_id: 35450[/import]
Hello!
Thanks for your reply, Carlos!
That’s all my code.
Before pressing the save button that’s what I can see in the simulator: www.ogrove.net/before.png
And after pressing the save button, that’s what I see: www.ogrove.net/after.png
What I want is to save the image but watch the scene and work as before pressing the button.
Now, pressing the button the image is what I get and I can’t interact with the app.
Could you tell me what am I doing wrong?
TIA [import]uid: 44013 topic_id: 9718 reply_id: 35727[/import]
thats because you are creating a new group and inserting the image into the group. the stacking order of the group will put the image on top.
ergo why you can’t go back
c. [import]uid: 24 topic_id: 9718 reply_id: 35729[/import]
That’s right!, but I need to create a new group, isn’t? I think it is not possible to do it other way…
Must I send the image to the bottom of the group? Is it a good practice?
If I try to remove the image I don’t see anything at the scene.
I’m confused… I thing it would possible to save the image and don’t added it to the stack (only create a jpg file) [import]uid: 44013 topic_id: 9718 reply_id: 35730[/import]
or you could just do
toSave:insert(display.newImage("foo.jpg",0,0))
display.save(toSave,"image.jpg",baseDir)
toSave:RemoveSelf();
c
[import]uid: 24 topic_id: 9718 reply_id: 35732[/import]
Mmmmm… well, I need to save the background too (because can’t save png images), and my idea is to add more elements to the group “toSave”
I don’t know if I am understanding you well, but I think with your code I only could save my foo.png image, isn’t it?
As you have made noticed, I am a newbie and I appreciate so much your help.
This is my code now, after your instructions:
display.setStatusBar( display.HiddenStatusBar )
local ui=require("ui")
local width,height=display.contentWidth,display.contentHeight
local background=display.newImage("background.jpg")
local rect=display.newRect(0,(height-80),width,height)
rect:setFillColor(174,78,0)
local my\_image=display.newImage("foo.png",90,90)
local function saving()
local baseDir = system.DocumentsDirectory
local toSave=display.newGroup()
local my\_image2=my\_image
toSave:insert(display.newImage("background.jpg"))
toSave:insert(display.newImage("foo.png",90,90))
display.save(toSave,"image.jpg",baseDir)
toSave:removeSelf()
end
local save\_button = ui.newButton{
default = "save\_button.png",
over = "save\_button.png",
onRelease = saving,
emboss = true
}
save\_button.x=width/2
save\_button.y=height-35
[import]uid: 44013 topic_id: 9718 reply_id: 35739[/import]
On this way, it seems it is a duplication of code, isn’t it? [import]uid: 44013 topic_id: 9718 reply_id: 35740[/import]
Carlos??
Anyone?? [import]uid: 44013 topic_id: 9718 reply_id: 36117[/import]
call display.captureScreen( ) then the save the resulting image.
hide all elements that you don’t want on the screen right before calling display.captureScreen( )
thens how them
c. [import]uid: 24 topic_id: 9718 reply_id: 36167[/import]
Thanks, Carlos!
I’ll try as you say and I tell you.
[import]uid: 44013 topic_id: 9718 reply_id: 36305[/import]