- This topic has 39 replies, 2 voices, and was last updated 5 years, 4 months ago by
Yuri Kovelenov.
-
AuthorPosts
-
2019-09-11 at 3:46 pm #18599
Manuel
CustomerHi
I want to add a button to save the current view of a object to a jpg file
Is it possible?
Thanks
2019-09-12 at 7:27 am #18604Yuri Kovelenov
StaffHi,
You can use the take screenshot puzzle for that (also need to enable screenshots with configure app puzzle). It only generates the image though. To be able to download it, you can use the following JavaScript snippet
app.ExternalInterface.downloadScreenshot = function(image) { var link = document.createElement('a'); link.setAttribute('download', 'myImage.png'); link.setAttribute('href', image); link.click(); }
and call it from Puzzles as described here.
Attached an example project.
Attachments:
You must be logged in to view attached files.2019-09-12 at 7:35 am #18609Yuri Kovelenov
StaffUpdate:
make it
app.ExternalInterface.downloadScreenshot = function(image) { var link = document.createElement('a'); document.body.appendChild(link); link.setAttribute('download', 'myImage.png'); link.setAttribute('href', image); link.click(); }
to work on Firefox.
2019-09-12 at 9:31 am #18614Manuel
CustomerThanks a lot
The only problem now, is that i get a black image :-S
Any idea that can be?
Thanks
2019-09-12 at 9:38 am #18615Yuri Kovelenov
Staffalso need to enable screenshots with configure app puzzle)
:)
2019-09-12 at 9:39 am #18616Manuel
CustomerFixed!
Sorry, i hadn’t checked the option in initialization panel ^^
Thanks
2019-09-12 at 9:44 am #18618Manuel
CustomerNow i see that, another question…
Is there any possibility to change the background automatically or make it transparent when you save the pic?
Thks again ^^
2019-09-12 at 9:46 am #18620Yuri Kovelenov
StaffTry the transparent background option in the same puzzle: https://www.soft8soft.com/docs/manual/en/puzzles/Initialization.html#configure_application
2019-09-12 at 10:12 am #18623Manuel
CustomerTry the transparent background option in the same puzzle: https://www.soft8soft.com/docs/manual/en/puzzles/Initialization.html#configure_application
As i have a sphere background, i solve it like this (look attached file)
Is there any cleaner form to do it?
Because here, i depend of cpu speed, i suppose isn’t it?
2019-09-12 at 10:18 am #18625Yuri Kovelenov
Staff2019-09-12 at 10:30 am #18628Manuel
CustomerYep, you can use 0 second time to make it lapse only 1 rendering frame.
I tested it, but i doesn’t work :-S
2019-09-12 at 10:56 am #18634Yuri Kovelenov
Staff2019-09-12 at 11:42 am #18636Manuel
CustomerWhat does it produce? non-transparent background?
Correct!
It seems that with “0” value, there’s no time to grab the transparent backgroud.
2019-09-12 at 12:56 pm #18637Yuri Kovelenov
Staff2019-09-13 at 2:40 pm #18698Manuel
Customeryou can try another approach – using the every frame puzzle with a counter to wait for 1 or 2 rendering frames.
I don’t know how to use it, as i can’t puzzle it into my “click” function :-S
-
AuthorPosts
- You must be logged in to reply to this topic.