Export Layered Image as .png? (solved)
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
- noeinan
- Eileen-Class Veteran
- Posts: 1153
- Joined: Sun Apr 04, 2010 10:10 pm
- Projects: Ren'Py QuickStart, Crimson Rue
- Organization: Statistically Unlikely Games
- Deviantart: noeinan
- Github: noeinan
- Location: Washington State, USA
- Contact:
Export Layered Image as .png? (solved)
Hey! I am working on a character generator and I was wondering if there is a way to export a layered image as a .png using the current view of said image. (Like, if there are multiple poses and facial expressions, you can click a button and export that specific view as a picture file.)
Last edited by noeinan on Thu Jul 12, 2018 3:29 am, edited 1 time in total.
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Export Layered Image as .png?
Not that I know of. However, since you have all the layers, you could just assemble the image you want in GIMP and export to png there.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
- noeinan
- Eileen-Class Veteran
- Posts: 1153
- Joined: Sun Apr 04, 2010 10:10 pm
- Projects: Ren'Py QuickStart, Crimson Rue
- Organization: Statistically Unlikely Games
- Deviantart: noeinan
- Github: noeinan
- Location: Washington State, USA
- Contact:
Re: Export Layered Image as .png?
Hm, that's unfortunate. I can definitely make the .png on my own, since I have the layers (I use paint.net) but I was hoping for an in-game way of doing it quickly without all the copy/paste and merging.
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3794
- Joined: Mon Dec 14, 2015 5:05 am
- itch: Imperf3kt
- Location: Your monitor
- Contact:
Re: Export Layered Image as .png?
You could use the screenshot function to capture the whole screen. Then you'd need to supply a mask for players so they can remove the background and add an alpha layer in an image editor.
I wonder if the screenshot function can capture layers instead of the whole screen.
I wonder if the screenshot function can capture layers instead of the whole screen.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Twitter
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
- noeinan
- Eileen-Class Veteran
- Posts: 1153
- Joined: Sun Apr 04, 2010 10:10 pm
- Projects: Ren'Py QuickStart, Crimson Rue
- Organization: Statistically Unlikely Games
- Deviantart: noeinan
- Github: noeinan
- Location: Washington State, USA
- Contact:
Re: Export Layered Image as .png?
Oh, that's an interesting idea! I didn't know that Ren'Py had a screenshot function, could you show me an example of how that code works? (Or a link, if there's documentation on it?)
For my generator, I luckily wouldn't need to remove the background, since it is just plain white. But it would be super helpful if I could have the game crop the image to just one frame before exporting the screenshot. I wonder if something like that would be possible...
For my generator, I luckily wouldn't need to remove the background, since it is just plain white. But it would be super helpful if I could have the game crop the image to just one frame before exporting the screenshot. I wonder if something like that would be possible...
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3794
- Joined: Mon Dec 14, 2015 5:05 am
- itch: Imperf3kt
- Location: Your monitor
- Contact:
Re: Export Layered Image as .png?
Ren'Py can take screenshots by default with the s key on your keyboard. I think the printscreen button also works, but can't actually confirm that.
Anyway, assuming you want this as a function of your game instead (say, for instance, a "capture" button), you could probably use renpy.screenshot or screenshot. Probably easiest if you use the second one, as you can call it as an action of a button. The first link is more specialised and for advanced use.
So, to use it, I assume you can do something like this:
To crop the image to a certain area, you can use config.screenshot_crop. I suspect this will crop ALL screenshots to this area (potentially including save game screenshots), so may require further research to make it separate from regular screenshots.
I haven't personally used either of these functions, so I cannot particularly help much further, but I'm more than willing to give things a go myself if you get stuck. (Time provided)
Anyway, assuming you want this as a function of your game instead (say, for instance, a "capture" button), you could probably use renpy.screenshot or screenshot. Probably easiest if you use the second one, as you can call it as an action of a button. The first link is more specialised and for advanced use.
So, to use it, I assume you can do something like this:
Code: Select all
screen myscreen():
textbutton _("Take photo") action Screenshot
label start:
show screen myscreen
"Take a photo!"
"Go on, click the button."
hide screen myscreen
return
I haven't personally used either of these functions, so I cannot particularly help much further, but I'm more than willing to give things a go myself if you get stuck. (Time provided)
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Twitter
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
- noeinan
- Eileen-Class Veteran
- Posts: 1153
- Joined: Sun Apr 04, 2010 10:10 pm
- Projects: Ren'Py QuickStart, Crimson Rue
- Organization: Statistically Unlikely Games
- Deviantart: noeinan
- Github: noeinan
- Location: Washington State, USA
- Contact:
Re: Export Layered Image as .png?
Thank you! I actually don't mind if it crops all screenshots to that area, since the generator will only display images there anyhow. This is great and I will have to test it out!
[Edit] I got it working! Thanks so much for your help!
I added this to the top of my script file:
And this textbutton to my screen:
Now I just need to figure out how to have user inputed save locations.
[Edit] I got it working! Thanks so much for your help!
I added this to the top of my script file:
Code: Select all
define config.screenshot_crop = (0.0, 0.0, 463, 970)
Code: Select all
textbutton _("Save") action Screenshot() xalign 0.99 yalign 0.95
Who is online
Users browsing this forum: Majestic-12 [Bot]