Fixed bug 3352 - Adding alpha mask support to SDL_SaveBMP_RW
Simon Hug The current SDL_SaveBMP_RW function that saves surfaces to a BMP uses an old bitmap header which doesn't officially support alpha channels. Applications just ignore the byte where the alpha is stored. This can easily be extended by using a newer header version and setting the alpha mask. The attached patch has these changes: - Extending the description of the function in the SDL_surface.h header with the supported formats. - Refining when surfaces get stored to a 32-bit BMP. (Must have bit depth of 8 or higher and must have an alpha mask or colorkey.) - Fixing a small bug that saves 24-bit BGR surfaces with a colorkey in a 24-bit BMP. - Adding code that switches to the bitmap header version 4 if the surface has an alpha mask or colorkey. (I chose version 4 because Microsoft didn't lose its documentation behind a file cabinet like they did with version 3.) - Adding a hint that can disable the use of the version 4 header. This is for people that need the legacy header or like the old behavior better. (I'm not sure about the hint name, though. May need changing if there are any rules to that.)
This commit is contained in:
parent
53e22e4be8
commit
9fff05f8d6
3 changed files with 84 additions and 4 deletions
|
@ -669,6 +669,25 @@ extern "C" {
|
|||
*/
|
||||
#define SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4 "SDL_WINDOWS_NO_CLOSE_ON_ALT_F4"
|
||||
|
||||
/**
|
||||
* \brief Prevent SDL from using version 4 of the bitmap header when saving BMPs.
|
||||
*
|
||||
* The bitmap header version 4 is required for proper alpha channel support and
|
||||
* SDL will use it when required. Should this not be desired, this hint can
|
||||
* force the use of the 40 byte header version which is supported everywhere.
|
||||
*
|
||||
* The variable can be set to the following values:
|
||||
* "0" - Surfaces with a colorkey or an alpha channel are saved to a
|
||||
* 32-bit BMP file with an alpha mask. SDL will use the bitmap
|
||||
* header version 4 and set the alpha mask accordingly.
|
||||
* "1" - Surfaces with a colorkey or an alpha channel are saved to a
|
||||
* 32-bit BMP file without an alpha mask. The alpha channel data
|
||||
* will be in the file, but applications are going to ignore it.
|
||||
*
|
||||
* The default value is "0".
|
||||
*/
|
||||
#define SDL_HINT_BMP_SAVE_LEGACY_FORMAT "SDL_BMP_SAVE_LEGACY_FORMAT"
|
||||
|
||||
/**
|
||||
* \brief An enumeration of hint priorities
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue