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
SDL_ConvertSurface does not convert color keys consistently #1854
Comments
sulix
added a commit
to sulix/sdl12-compat
that referenced
this issue
Sep 14, 2023
The LGP port of Hyperspace Delivery Boy has broken colour keys if run in 32-bpp mode (see bug libsdl-org#317). This is because it relies heavily on the imprecise RGB565->RGB888 conversion in earlier SDL 1.2 versions, when running in 32-bpp mode. The game's assets are all in 565 format, and the game converts these to the screen's format on load. It then sets a colour key. This presents a problem, because: - The generic BlitNToN implementation in SDL 1.2 just shifted the values, so the resulting image was not at full range. Magenta became (F800F8). - Early versions of SDL 1.2 fell back to the BlitNToN blitter very frequently: libsdl-org/SDL-1.2@6f4a75d - So, Hyperspace Delivery Boy calls SDL_MapRGB(0xF8, 0, 0xF8) to get the colour key, then sets it on the converted surface. - In SDL 2.0, the blitters now properly do a full-range conversion, so the magenta becomes (FF00FF), which now doesn't match the hardcoded (F800F8). - That being said, in general, it's not guaranteed that SDL_MapRGB() will do the same format conversion as SDL_CovertSurface(), so the "correct" way of handling this is to set the colour key before converting, which works (albeit slowly) in SDL2: libsdl-org/SDL#1854 - Since the conversion behaviour is different even between SDL 1.2 versions, it's not worth trying to imitate it here, so we just force the game to run in 16-bpp mode, which works fine. - (And the game's README recommends it, too.)
slouken
pushed a commit
to libsdl-org/sdl12-compat
that referenced
this issue
Sep 14, 2023
The LGP port of Hyperspace Delivery Boy has broken colour keys if run in 32-bpp mode (see bug #317). This is because it relies heavily on the imprecise RGB565->RGB888 conversion in earlier SDL 1.2 versions, when running in 32-bpp mode. The game's assets are all in 565 format, and the game converts these to the screen's format on load. It then sets a colour key. This presents a problem, because: - The generic BlitNToN implementation in SDL 1.2 just shifted the values, so the resulting image was not at full range. Magenta became (F800F8). - Early versions of SDL 1.2 fell back to the BlitNToN blitter very frequently: libsdl-org/SDL-1.2@6f4a75d - So, Hyperspace Delivery Boy calls SDL_MapRGB(0xF8, 0, 0xF8) to get the colour key, then sets it on the converted surface. - In SDL 2.0, the blitters now properly do a full-range conversion, so the magenta becomes (FF00FF), which now doesn't match the hardcoded (F800F8). - That being said, in general, it's not guaranteed that SDL_MapRGB() will do the same format conversion as SDL_CovertSurface(), so the "correct" way of handling this is to set the colour key before converting, which works (albeit slowly) in SDL2: libsdl-org/SDL#1854 - Since the conversion behaviour is different even between SDL 1.2 versions, it's not worth trying to imitate it here, so we just force the game to run in 16-bpp mode, which works fine. - (And the game's README recommends it, too.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This bug report was migrated from our old Bugzilla tracker.
These attachments are available in the static archive:
patch (patch_bug_2979.diff, text/plain, 2016-11-08 17:12:08 +0000, 1773 bytes)Reported in version: 2.0.2
Reported for operating system, platform: Linux, x86_64
Comments on the original bug report:
On 2015-05-10 09:39:04 +0000, Edmund Horner wrote:
On 2015-05-10 09:44:53 +0000, Ellie wrote:
On 2015-08-11 12:25:18 +0000, Pankaj wrote:
On 2016-06-23 02:55:45 +0000, Edmund Horner wrote:
On 2016-10-08 00:39:53 +0000, Sam Lantinga wrote:
On 2016-11-08 17:12:08 +0000, Sylvain wrote:
On 2016-11-08 17:53:10 +0000, Sylvain wrote:
On 2016-11-10 01:26:45 +0000, Edmund Horner wrote:
On 2017-08-12 23:59:59 +0000, Sam Lantinga wrote:
On 2017-08-13 13:15:18 +0000, Sylvain wrote:
On 2017-08-14 04:24:35 +0000, Sam Lantinga wrote:
On 2017-09-13 17:09:57 +0000, Sylvain wrote:
On 2017-09-13 21:04:41 +0000, Sylvain wrote:
On 2017-09-14 07:28:01 +0000, Sylvain wrote:
On 2017-09-14 12:33:58 +0000, Ryan C. Gordon wrote:
On 2017-09-14 12:38:18 +0000, Ryan C. Gordon wrote:
On 2020-05-17 12:24:53 +0000, Holger Schemel wrote:
On 2020-05-17 12:34:06 +0000, Holger Schemel wrote:
On 2020-05-17 18:51:43 +0000, Sylvain wrote:
On 2020-05-17 19:25:59 +0000, Sylvain wrote:
On 2020-05-19 11:11:56 +0000, Holger Schemel wrote:
On 2020-05-19 15:59:22 +0000, Sylvain wrote:
The text was updated successfully, but these errors were encountered: