mirror of https://github.com/encounter/SDL.git
Fixed bug 2441 - SDL_DuplicateSurface
Rainer Deyke I've written a small patch that adds a small SDL_DuplicateSurface function to SDL. I've written the function as part of a larger (as yet unfinished) patch, but I think this function is useful enough that it merits inclusion in SDL on its own.
This commit is contained in:
parent
362d549690
commit
f142a7961e
|
@ -359,6 +359,11 @@ extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface,
|
||||||
extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface,
|
extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface,
|
||||||
SDL_Rect * rect);
|
SDL_Rect * rect);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates a new surface identical to the existing surface
|
||||||
|
*/
|
||||||
|
extern DECLSPEC SDL_Surface *SDLCALL SDL_DuplicateSurface(SDL_Surface * surface);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new surface of the specified format, and then copies and maps
|
* Creates a new surface of the specified format, and then copies and maps
|
||||||
* the given surface to it so the blit of the converted surface will be as
|
* the given surface to it so the blit of the converted surface will be as
|
||||||
|
|
|
@ -628,3 +628,4 @@
|
||||||
#define SDL_LoadFile_RW SDL_LoadFile_RW_REAL
|
#define SDL_LoadFile_RW SDL_LoadFile_RW_REAL
|
||||||
#define SDL_wcscmp SDL_wcscmp_REAL
|
#define SDL_wcscmp SDL_wcscmp_REAL
|
||||||
#define SDL_ComposeCustomBlendMode SDL_ComposeCustomBlendMode_REAL
|
#define SDL_ComposeCustomBlendMode SDL_ComposeCustomBlendMode_REAL
|
||||||
|
#define SDL_DuplicateSurface SDL_DuplicateSurface_REAL
|
||||||
|
|
|
@ -660,3 +660,4 @@ SDL_DYNAPI_PROC(size_t,SDL_utf8strlen,(const char *a),(a),return)
|
||||||
SDL_DYNAPI_PROC(void*,SDL_LoadFile_RW,(SDL_RWops *a, size_t *b, int c),(a,b,c),return)
|
SDL_DYNAPI_PROC(void*,SDL_LoadFile_RW,(SDL_RWops *a, size_t *b, int c),(a,b,c),return)
|
||||||
SDL_DYNAPI_PROC(int,SDL_wcscmp,(const wchar_t *a, const wchar_t *b),(a,b),return)
|
SDL_DYNAPI_PROC(int,SDL_wcscmp,(const wchar_t *a, const wchar_t *b),(a,b),return)
|
||||||
SDL_DYNAPI_PROC(SDL_BlendMode,SDL_ComposeCustomBlendMode,(SDL_BlendFactor a, SDL_BlendFactor b, SDL_BlendOperation c, SDL_BlendFactor d, SDL_BlendFactor e, SDL_BlendOperation f),(a,b,c,d,e,f),return)
|
SDL_DYNAPI_PROC(SDL_BlendMode,SDL_ComposeCustomBlendMode,(SDL_BlendFactor a, SDL_BlendFactor b, SDL_BlendOperation c, SDL_BlendFactor d, SDL_BlendFactor e, SDL_BlendOperation f),(a,b,c,d,e,f),return)
|
||||||
|
SDL_DYNAPI_PROC(SDL_Surface*,SDL_DuplicateSurface,(SDL_Surface *a),(a),return)
|
||||||
|
|
|
@ -870,6 +870,15 @@ SDL_UnlockSurface(SDL_Surface * surface)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates a new surface identical to the existing surface
|
||||||
|
*/
|
||||||
|
SDL_Surface *
|
||||||
|
SDL_DuplicateSurface(SDL_Surface * surface)
|
||||||
|
{
|
||||||
|
return SDL_ConvertSurface(surface, surface->format, surface->flags);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert a surface into the specified pixel format.
|
* Convert a surface into the specified pixel format.
|
||||||
*/
|
*/
|
||||||
|
@ -882,6 +891,15 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
|
||||||
SDL_Color copy_color;
|
SDL_Color copy_color;
|
||||||
SDL_Rect bounds;
|
SDL_Rect bounds;
|
||||||
|
|
||||||
|
if (!surface) {
|
||||||
|
SDL_InvalidParamError("surface");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (!format) {
|
||||||
|
SDL_InvalidParamError("format");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check for empty destination palette! (results in empty image) */
|
/* Check for empty destination palette! (results in empty image) */
|
||||||
if (format->palette != NULL) {
|
if (format->palette != NULL) {
|
||||||
int i;
|
int i;
|
||||||
|
|
Loading…
Reference in New Issue