Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing Renpy to Output Images #5440

Open
SoDaRa opened this issue Mar 27, 2024 · 3 comments
Open

Allowing Renpy to Output Images #5440

SoDaRa opened this issue Mar 27, 2024 · 3 comments
Labels
duration - day Resolving this is estimated to a day of development enhancement A proposed or requested enhancement or improvement to renpy's features.

Comments

@SoDaRa
Copy link

SoDaRa commented Mar 27, 2024

This is my first time writing an issue for a project, so I apologize if I don't know the etiquette for this kind of thing. But I've been working on a project where the creator would like there to be a way to export a sprite. This is because they'd like there to be a way for players to get the sprites as pngs outside the game, without having them open up the archive file and try to piece it together themselves. Especially if a sprite has a lot of layers and components. This would be useful for players if they wanted to have the sprite for reference or were making a video on the game and wanted to use it for editing.

I've been looking into the source code for days to try and accomplish this but have encountered one issue I cannot overcome. The main way I've found that kinda works is by making use of the screenshot functions. Sending it a render to get a surface with the actual pixels on it, and using it to output a file like renpy does to make screenshots normally. This has come with several caveats, however.

  1. The screenshot function uses the draw_screen function in gl2Draw to get what would normally be a screenshot. This uses a clear_color that is always opaque, so can't do transparency. The best I can do is change the clear_color to something like green so it can be keyed out.
  2. The screenshot is always the size of the screen. The project I'm working on uses 1280x720 (it started a while ago), but I'm on several projects that do have sprites larger than the screen is tall even at 1920x1080. This results in the sprite being clipped off unless I have the render resizing them to be smaller than they normally would be, which is not ideal. I've even gone as far as trying to change the virtual_size of the gl2draw class by redoing the init function, but you can imagine his has several undesirable side effects and looks jank even if it doesn't cause the rendering to fail.

My wish is for a method to be added to gl2draw (and I suppose gldraw as well but I'm not as worried about that), that can do what the screenshot function does, but with transparency and using the surface given to it as the screen size instead of the default gui.size. From what I can tell, this wouldn't be too difficult. Just copying most of what the screenshot already does, copying in some of draw_screen to get the call to GL2DrawingContext setup, and should be good from there.

I've done my best to look into alternatives to this problem that could be used in more games that might desire this functionality as well, but I don't see a way of doing this without modifying the .pyx files myself, and that feels like more of a hack that people wouldn't feel comfortable doing themselves.

I will also say I will understand if the decision is made that this is undesirable as well, or could enable people to get around archive files. I don't know if I fully agree with this given far I've managed to get with this already. But I understand if this would be a step too far.

I hope I've made a good argument for this feature and if you would have any questions for me, I'd be more than happy to answer.

@Gouvernathor
Copy link
Member

I don't think, for now, that this should be a feature of the renpy engine, but I'm sure it would be a very interesting add-in feature.
I know of a renpy game which exports png files which come from a screenshot, granted, but which are also cropped (I think) and added with arbitrary metadata in the file. Maybe seeing how it does it would help you. I won't link the game here but I could give you the reference if you ask on Discord.

@renpytom
Copy link
Member

Let me think about it - I can see a use for this, but I'm not sure I can make it work without a ton of complexity.

@renpytom renpytom added enhancement A proposed or requested enhancement or improvement to renpy's features. duration - day Resolving this is estimated to a day of development labels Mar 28, 2024
@furudean
Copy link

furudean commented Apr 5, 2024

One odd but valid use-case I can think of is to generate a bunch of images based on composited layeredimages. Could be useful for fans who want to use the sprites for fan work or the like. A little out there, but not an unprecedented use case. I've been wanting to bundle my games with these but the manual labor required to remake them in photoshop can be extra work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duration - day Resolving this is estimated to a day of development enhancement A proposed or requested enhancement or improvement to renpy's features.
Projects
None yet
Development

No branches or pull requests

4 participants