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

Some PNG files display red areas in part of the image #320

Closed
64kramsystem opened this issue May 27, 2022 · 8 comments
Closed

Some PNG files display red areas in part of the image #320

64kramsystem opened this issue May 27, 2022 · 8 comments

Comments

@64kramsystem
Copy link

64kramsystem commented May 27, 2022

If I open some images, either via Fyrox (in a game) or in Fyroxed, red areas are displayed as part of the image. Such corruption only displays in Fyrox; other programs/libraries (Eye of MATE, GIMP, Github web interface, the PyGame library) don't have this problem.

This is an example:

image

This is how the image looks when opened on Gimp:

image

This is a link to the image file.

@mrDIMAS
Copy link
Member

mrDIMAS commented May 28, 2022

That's a bug in image compression, you can disable it using

 engine
            .resource_manager
            .state()
            .containers_mut()
            .textures
            .set_default_import_options(
                TextureImportOptions::default().with_compression(CompressionOptions::NoCompression),
            );

Add these lines right after you obtained a ref to engine (if you're using Framework, then in the beginning of on_init)

@64kramsystem
Copy link
Author

Hello!

I still experience the issue. I've put the command at the very top of GameState#init:

impl GameState for GameGlobal {
    fn init(engine: &mut Engine) -> Self {
        // As of Fyrox v0.26, there's a bug in the images compression.
        // See https://github.com/FyroxEngine/Fyrox/issues/320.
        //
        engine
            .resource_manager
            .state()
            .containers_mut()
            .textures
            .set_default_import_options(
                TextureImportOptions::default().with_compression(CompressionOptions::NoCompression),
            );

this runs before any texture is loaded.

I also notice that those images flicker, I don't know if it's related.

@64kramsystem
Copy link
Author

If I convert the image(s) to GIF, I don't experience the problem (even without workaround).

@mrDIMAS
Copy link
Member

mrDIMAS commented May 28, 2022

Ok, maybe I shouldn't check bugs like this early in the morning 😄 . It could be relate to image loader, it is based on image crate. I'll check it.

64kramsystem added a commit to rust-gamedev/rust-game-ports that referenced this issue Jun 5, 2022
64kramsystem added a commit to rust-gamedev/rust-game-ports that referenced this issue Jun 5, 2022
@64kramsystem
Copy link
Author

I'm also having other problems (possibly related) with transparency. This is a sample of how a PNG with multiple levels of transparency renders:

image

What is black should be transparent, and what is green inside the square, should be much darker.

PNG here: players00.png

@mrDIMAS
Copy link
Member

mrDIMAS commented Aug 8, 2022

Some of your images are in LuminanceAlpha8 format which is interpreted by the engine as RedGreen8 which results in R, G, R, G color when fetching the texture.

@64kramsystem
Copy link
Author

64kramsystem commented Aug 8, 2022

Some of your images are in LuminanceAlpha8 format which is interpreted by the engine as RedGreen8 which results in R, G, R, G color when fetching the texture.

Is this considered an issue with the engine (I don't have the technical knowledge)? With all the tools i've tried (Firefox, GNOME default image viewer, GIMP, Feh), the example above displays the transparency correctly.

@mrDIMAS mrDIMAS closed this as completed in d576afa Aug 8, 2022
@64kramsystem
Copy link
Author

Oh wow. Thanks! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants