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

Saving to PNG broken in anything but the default renderer #80

Closed
processing-bot opened this issue Mar 28, 2020 · 10 comments
Closed

Saving to PNG broken in anything but the default renderer #80

processing-bot opened this issue Mar 28, 2020 · 10 comments

Comments

@processing-bot
Copy link
Collaborator

Created by: sampottinger

It looks like the tiff extension is always appended even if the requested filename ends in .png when using JAVA2D. Looks related to the recent refactor on AWT related code.

@processing-bot
Copy link
Collaborator Author

Created by: sampottinger

PImage:save doesn't check for png. I see that recent edits are trying to reduce library dependency. I looked into it a bit more though and I'm not sure if there are many super great alternatives to using ImageIO.

@processing-bot
Copy link
Collaborator Author

Created by: sampottinger

Cross-posting from #81: Just a quick update here... It looks like even in JavaFX and JOGL, BufferedImage is still the canonical solution. There might not be a way to avoid using it.

@processing-bot
Copy link
Collaborator Author

Created by: benfry

Ah, this is something we need to handle differently in the renderers themselves… i.e. if they're using AWT objects (i.e. Image or BufferedImage) they need to create ImageAWT objects. The refactor was about moving all that AWT cruft out of the main classes so that we have little or no AWT in the main processing.core package.

JOGL and JavaFX also have their own more efficient ways of handling image objects, our use of AWT in those was just a crutch to get things working quickly; this would provide a pathway for others to build out that improved image support.

@processing-bot
Copy link
Collaborator Author

Created by: sampottinger

Thanks @benfry. I'm sorry could you say more about how JavaFX / JOGL would handle this? Maybe just taking JavaFX first... looking around online, it's not clear how to do this in JavaFX without using the AWT Image classes. I may be missing something obvious though.

@processing-bot
Copy link
Collaborator Author

Created by: sampottinger

In the meantime, @benfry opened PR #97 for just AWT.

@processing-bot
Copy link
Collaborator Author

Created by: sampottinger

Also, if you did want that for FX2D, see #98

@processing-bot
Copy link
Collaborator Author

Created by: benfry

I'm sorry could you say more about how JavaFX / JOGL would handle this? Maybe just taking JavaFX first... looking around online, it's not clear how to do this in JavaFX without using the AWT Image classes. I may be missing something obvious though.

Nope, not missing anything, sorry for the confusion… For now it's necessary to use PImageAWT. But the idea is that we get the AWT-specific code out of the main classes, and then the usage of AWT is determined independently by individual renderers… i.e. for now, JavaFX and JOGL just need to create PImageAWT objects instead of PImage if they want to do saving or have access to the AWT code.

However, this way, in the future, when someone wants to/has time to excise AWT from JOGL or JavaFX, that can be done as an independent thing. It's also then clearer in the JFX/GL code bases where AWT is being used, rather than introducing a surprise when a user calls save(). Does that make sense?

AWT has some weird performance bottlenecks that are avoided by more modern approaches for JavaFX, JOGL (i.e. NEWT or whatever it's called now), and LWJGL. So in an ideal world, those renderers would never touch/initalize AWT. In the real world, I've not had time to maintain all those renderers independently, so we're still relying on AWT for some things around the edges (like image i/o).

In a similar fashion, loadImage() is part of the renderer/surface level… So a better option for me at the moment might be to move saving images into ShimAWT, but I need to take a closer look… (Don't worry about doing anythign yet—will get back to you)

For now, the band-aid of using new PImageAWT in JavaFX and JOGL to replace new PImage, and on save() rewrapping the PImage as a PImageAWT if it's not one already should do.

@processing-bot
Copy link
Collaborator Author

Created by: sampottinger

Great! Thanks this makes sense @benfry. Just checking, do PRs #97 and #98 go in the right direction for this?

@processing-bot
Copy link
Collaborator Author

Created by: benfry

Trying to gather all this in-progress discussion: https://github.com/processing/processing4/wiki/Exorcising-AWT

@processing-bot
Copy link
Collaborator Author

Created by: github-actions[bot]

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant