Implemented SDL_LoadBMP() and SDL_SaveBMP() as functions

Fixes https://github.com/libsdl-org/SDL/issues/7902
This commit is contained in:
Sam Lantinga
2023-07-01 23:59:21 -07:00
parent e264bb5178
commit 50b6e5eb7e
5 changed files with 49 additions and 16 deletions

View File

@@ -867,6 +867,8 @@ SDL3_0.0.0 {
SDL_HasWindowSurface;
SDL_DestroyWindowSurface;
SDL_GetNaturalDisplayOrientation;
SDL_LoadBMP;
SDL_SaveBMP;
# extra symbols go here (don't modify this line)
local: *;
};

View File

@@ -893,3 +893,5 @@
#define SDL_HasWindowSurface SDL_HasWindowSurface_REAL
#define SDL_DestroyWindowSurface SDL_DestroyWindowSurface_REAL
#define SDL_GetNaturalDisplayOrientation SDL_GetNaturalDisplayOrientation_REAL
#define SDL_LoadBMP SDL_LoadBMP_REAL
#define SDL_SaveBMP SDL_SaveBMP_REAL

View File

@@ -938,3 +938,5 @@ SDL_DYNAPI_PROC(int,SDL_hid_get_report_descriptor,(SDL_hid_device *a, unsigned c
SDL_DYNAPI_PROC(SDL_bool,SDL_HasWindowSurface,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_DestroyWindowSurface,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_DisplayOrientation,SDL_GetNaturalDisplayOrientation,(SDL_DisplayID a),(a),return)
SDL_DYNAPI_PROC(SDL_Surface*,SDL_LoadBMP,(const char *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_SaveBMP,(SDL_Surface *a, const char *b),(a,b),return)

View File

@@ -624,6 +624,11 @@ done:
return surface;
}
SDL_Surface *SDL_LoadBMP(const char *file)
{
return SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1);
}
int SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst)
{
/* !!! FIXME: this calls SDL_ClearError() and then checks if an error happened during this function to
@@ -869,3 +874,8 @@ int SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst)
}
return (SDL_strcmp(SDL_GetError(), "") == 0) ? 0 : -1;
}
int SDL_SaveBMP(SDL_Surface *surface, const char *file)
{
return SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1);
}