X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsdl.c;h=5184b088c94b6cdd9f23f4db35bcd0e7b102a21a;hb=601cca5b35649856ff49e1bcb3806592b736662c;hp=c6f4da020f4defcf35b43eb20f2bdd331ddcb9d1;hpb=8d93b043cc23f5a580363763ad459913127a8664;p=rocksndiamonds.git diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index c6f4da02..5184b088 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -829,14 +829,6 @@ void sge_LineRGB(SDL_Surface *Surface, Sint16 x1, Sint16 y1, Sint16 x2, /* http://www.ferzkopp.net/Software/SDL_gfx-2.0/index.html */ /* ========================================================================= */ -typedef struct -{ - Uint8 r; - Uint8 g; - Uint8 b; - Uint8 a; -} tColorRGBA; - /* ----------------------------------------------------------------------------- 32 bit zoomer @@ -845,6 +837,14 @@ typedef struct ----------------------------------------------------------------------------- */ +typedef struct +{ + Uint8 r; + Uint8 g; + Uint8 b; + Uint8 a; +} tColorRGBA; + int zoomSurfaceRGBA(SDL_Surface *src, SDL_Surface *dst) { int x, y, sx, sy, *sax, *say, *csax, *csay, csx, csy; @@ -1028,32 +1028,10 @@ int zoomSurfaceY(SDL_Surface * src, SDL_Surface * dst) ----------------------------------------------------------------------------- */ -void zoomSurfaceSize(int width, int height, float zoom_x, float zoom_y, - int *dst_width, int *dst_height) -{ - const float value_limit = 0.001; - - /* sanity check zoom factors */ - if (zoom_x < value_limit) - zoom_x = value_limit; - if (zoom_y < value_limit) - zoom_y = value_limit; - - /* calculate target size */ - *dst_width = (int) ((float) width * zoom_x); - *dst_height = (int) ((float) height * zoom_y); - - if (*dst_width < 1) - *dst_width = 1; - if (*dst_height < 1) - *dst_height = 1; -} - -SDL_Surface *zoomSurface(SDL_Surface *src, float zoom_x, float zoom_y) +SDL_Surface *zoomSurface(SDL_Surface *src, int dst_width, int dst_height) { SDL_Surface *zoom_src = NULL; SDL_Surface *zoom_dst = NULL; - int dst_width, dst_height; boolean is_converted = FALSE; boolean is_32bit; int i; @@ -1079,10 +1057,6 @@ SDL_Surface *zoomSurface(SDL_Surface *src, float zoom_x, float zoom_y) is_converted = TRUE; } - /* get size of destination surface */ - zoomSurfaceSize(zoom_src->w, zoom_src->h, zoom_x, zoom_y, - &dst_width, &dst_height); - /* allocate surface to completely contain the zoomed surface */ if (is_32bit) { @@ -1131,9 +1105,23 @@ SDL_Surface *zoomSurface(SDL_Surface *src, float zoom_x, float zoom_y) return zoom_dst; } -SDL_Surface *SDLZoomSurface(SDL_Surface *src, float zoom_x, float zoom_y) +void SDLZoomBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap) { - return zoomSurface(src, zoom_x, zoom_y); + SDL_Surface *sdl_surface_tmp; + int dst_width = dst_bitmap->width; + int dst_height = dst_bitmap->height; + + /* throw away old destination surface */ + SDL_FreeSurface(dst_bitmap->surface); + + /* create zoomed temporary surface from source surface */ + sdl_surface_tmp = zoomSurface(src_bitmap->surface, dst_width, dst_height); + + /* create native format destination surface from zoomed temporary surface */ + dst_bitmap->surface = SDL_DisplayFormat(sdl_surface_tmp); + + /* free temporary surface */ + SDL_FreeSurface(sdl_surface_tmp); }