Mercurial > hg > dmlib
changeset 610:e74ad60b1e85
Add new scaled surface conversion function.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 12 Apr 2013 12:32:24 +0300 |
parents | 877dba1b8a1f |
children | 828d86cd10e0 |
files | dmblit.c dmlib.h |
diffstat | 2 files changed, 17 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/dmblit.c Fri Apr 12 11:46:17 2013 +0300 +++ b/dmblit.c Fri Apr 12 12:32:24 2013 +0300 @@ -235,3 +235,17 @@ return bfunc(src, x0, y0, dst); } + + +SDL_Surface *dmConvertScaledSurface(SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags, const int dwidth, const int dheight) +{ + // Create the target surface + SDL_Surface *result = SDL_CreateRGBSurface(flags, dwidth, dheight, fmt->BitsPerPixel, fmt->Rmask, fmt->Gmask, fmt->Bmask, fmt->Amask); + if (result == NULL) + return NULL; + + // Use scaled blitting to convert the scaled image .. + dmScaledBlitSurfaceAny(src, 0, 0, dwidth, dheight, result, DMD_NONE); + + return result; +}
--- a/dmlib.h Fri Apr 12 11:46:17 2013 +0300 +++ b/dmlib.h Fri Apr 12 12:32:24 2013 +0300 @@ -302,6 +302,9 @@ DMUnscaledBlitFunc dmGetUnscaledBlitFunc(SDL_PixelFormat *src, SDL_PixelFormat *dst, int mode); int dmUnscaledBlitSurfaceAny(SDL_Surface *src, const int x0, const int y0, SDL_Surface *dst, int mode); +SDL_Surface *dmConvertScaledSurface(SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags, const int dwidth, const int dheight); + + #define DM_HEADER #include "dmblitfunc.h" #undef DM_HEADER