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

macOS: rotated JPEGs aren't handled well #935

Open
dos1 opened this Issue Oct 12, 2018 · 9 comments

Comments

Projects
None yet
5 participants
@dos1
Copy link
Contributor

dos1 commented Oct 12, 2018

I have a JPEG file that has a rotation tag applied to it and I display it with Allegro.

Effect on GNU/Linux (it ignores the rotation tag, which is accidentally what I wanted there):

Effect on macOS 10.13.2:

(the grain comes from an applied shader, but the red tint does not; the bitmap is slightly letterboxed in-game)

The displayed file: https://dosowisko.net/DSC_1263.JPG

@fatcerberus

This comment has been minimized.

Copy link
Contributor

fatcerberus commented Oct 13, 2018

I'm going to guess that the red tint is because it's reading the colors in the wrong order, i.e. BGR instead of RGB, or vice versa. Kind of strange that it honors the rotation flag but then gets the colors wrong like that.

@SiegeLord

This comment has been minimized.

Copy link
Member

SiegeLord commented Oct 13, 2018

I'm confused. So there's two issues:

  • The image is not rotated on Linux (OSX does it correctly)
  • On OSX, something's off with the color channels?

Is that right?

@dos1

This comment has been minimized.

Copy link
Contributor Author

dos1 commented Oct 13, 2018

@SiegeLord Yup. Plus the rotation on macOS behaves badly in another regard as well - the Allegro bitmap gets the pre-rotation dimensions and its content is rotated, resulting in black stripes at sides and cut content on top and bottom. I left the grain shader on when making those screenshots so you can easily see where the drawn bitmap ends.

(IOW: the rotated bitmap should be 1080x1920, but it's not - it's still 1920x1080 and cropped inside)

@fatcerberus

This comment has been minimized.

Copy link
Contributor

fatcerberus commented Oct 13, 2018

Oh, I didn't even notice that - I assumed you were just centering the bitmap and then letterboxing so it got cut off in the rendering process. If it's actually being cropped like that on load, that's a really bad bug 😦

@elias-pschernig

This comment has been minimized.

Copy link
Member

elias-pschernig commented Oct 15, 2018

Is it perhaps using the native image loader on OSX? I suggest we disable those by default - you really want to use libjpeg (and libpng) to load pictures, never the native loader.

@dos1

This comment has been minimized.

Copy link
Contributor Author

dos1 commented Oct 15, 2018

Looking at the code of the image addon, it seems that if both native loader and libjpeg/libpng are enabled, the native loader takes precedence. I think just swapping it around would be enough, and WANT_NATIVE_IMAGE_LOADER could still default to ON, as it might support some additional formats.

Additionally, on macOS I'm using binaries from Macports. As far as I can see there are no libpng nor libjpeg dependences listed in the Portfile.

@elias-pschernig

This comment has been minimized.

Copy link
Member

elias-pschernig commented Oct 15, 2018

Supporting additional formats is the original reason to have the native image loaders I guess - but the problem is how that's not portable at all. Someone unaware of the implications could develop a game on OSX and have some pictures in some strange OSX only format - and then later find out that for Windows users for their game those pictures can't load.

So I feel it would be safer to make it an explicit choice you have to enable at your own risk.

We just debugged an issue in #allegro where someone could load almost all of their .png files, except a few specific pictures resulted in garbage instead. Turns out the native OSX .png loader (or the Allegro code converting to ALLEGRO_BITMAP) can't handled some special indexed formats. Switching to the libpng loader made everything work - he just had no idea that even exists.

I don't know who builds the Macports binaries, but I would feel better if they were using libpng and libjpeg.

@elias-pschernig

This comment has been minimized.

Copy link
Member

elias-pschernig commented Oct 15, 2018

Btw. I have no idea if the JPEG issue here is related to the native loaders so this might be a bit off topic - something we should confirm first.

@beoran

This comment has been minimized.

Copy link
Contributor

beoran commented Oct 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.