From 3d52a86d358f5b1a4b36b80df5d659bce1f5a3a6 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sun, 26 Jan 2003 02:08:30 +0100 Subject: [PATCH] rnd-20030126-2-src --- src/conftime.h | 2 +- src/init.c | 15 +++++++++++++ src/libgame/msdos.c | 8 +++++++ src/libgame/msdos.h | 2 ++ src/libgame/sdl.c | 53 +++++++++++++------------------------------- src/libgame/sdl.h | 2 +- src/libgame/system.c | 13 +++++++++++ src/libgame/system.h | 2 ++ src/libgame/x11.c | 15 +++++++++++++ src/libgame/x11.h | 3 +++ 10 files changed, 76 insertions(+), 39 deletions(-) diff --git a/src/conftime.h b/src/conftime.h index ec7ca768..9f661ab5 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-01-26 00:14]" +#define COMPILE_DATE_STRING "[2003-01-26 02:06]" diff --git a/src/init.c b/src/init.c index 448a2876..34673f37 100644 --- a/src/init.c +++ b/src/init.c @@ -264,6 +264,20 @@ static void ReinitializeGraphics() /* !!! TEST ONLY !!! */ +#if 1 + + { + Bitmap *tst_bitmap = graphic_info[IMG_SAND].bitmap; + Bitmap *tmp_bitmap = ZoomBitmap(tst_bitmap, + tst_bitmap->width / 2, + tst_bitmap->height / 2); + + BlitBitmap(tmp_bitmap, tst_bitmap, 0, 0, 256, 224, 0, 448); + + FreeBitmap(tmp_bitmap); + } + +#else #ifdef TARGET_SDL { @@ -285,6 +299,7 @@ static void ReinitializeGraphics() 0, 0, 512, 448, 0, 448, 256, 224); +#endif #endif } diff --git a/src/libgame/msdos.c b/src/libgame/msdos.c index 29cc0360..9cd4ddcc 100644 --- a/src/libgame/msdos.c +++ b/src/libgame/msdos.c @@ -917,6 +917,14 @@ Pixel AllegroGetPixel(Drawable d, int x, int y) return getpixel((BITMAP *)d, x, y); } +void AllegroZoomBitmap(Drawable src, Drawable dst, + int src_width, int src_height, + int dst_width, int dst_height) +{ + stretch_blit((BITMAP *)src, (BITMAP *)dst, + 0, 0, src_width, src_height, 0, 0, dst_width, dst_height); +} + void MSDOSOpenAudio(void) { if (allegro_init_audio()) diff --git a/src/libgame/msdos.h b/src/libgame/msdos.h index 5ddb3eef..e976420e 100644 --- a/src/libgame/msdos.h +++ b/src/libgame/msdos.h @@ -747,6 +747,8 @@ void XAutoRepeatOff(Display *); void AllegroDrawLine(Drawable, int, int, int, int, Pixel); Pixel AllegroGetPixel(Drawable, int, int); +void AllegroZoomBitmap(Drawable, Drawable, int, int, int, int); + void MSDOSOpenAudio(void); void MSDOSCloseAudio(void); diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index c6f4da02..46e41d78 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,14 @@ 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); + int dst_width = dst_bitmap->width; + int dst_height = dst_bitmap->height; + + SDL_FreeSurface(dst_bitmap->surface); + + dst_bitmap->surface = zoomSurface(src_bitmap->surface, dst_width,dst_height); } diff --git a/src/libgame/sdl.h b/src/libgame/sdl.h index 8d9f0941..4b4f34d3 100644 --- a/src/libgame/sdl.h +++ b/src/libgame/sdl.h @@ -330,7 +330,7 @@ inline void SDLDrawSimpleLine(Bitmap *, int, int, int, int, unsigned int); inline void SDLDrawLine(Bitmap *, int, int, int, int, Uint32); inline Pixel SDLGetPixel(Bitmap *, int, int); -SDL_Surface *SDLZoomSurface(SDL_Surface *, float, float); +void SDLZoomBitmap(Bitmap *, Bitmap *); Bitmap *SDLLoadImage(char *); diff --git a/src/libgame/system.c b/src/libgame/system.c index 301cb271..1fbafd78 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -865,6 +865,19 @@ void ReloadCustomImage(Bitmap *bitmap, char *basename) free(new_bitmap); } +Bitmap *ZoomBitmap(Bitmap *src_bitmap, int zoom_width, int zoom_height) +{ + Bitmap *dst_bitmap = CreateBitmap(zoom_width, zoom_height, DEFAULT_DEPTH); + +#if defined(TARGET_SDL) + SDLZoomBitmap(src_bitmap, dst_bitmap); +#else + X11ZoomBitmap(src_bitmap, dst_bitmap); +#endif + + return dst_bitmap; +} + /* ========================================================================= */ /* audio functions */ diff --git a/src/libgame/system.h b/src/libgame/system.h index a08edfc6..086b5afa 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -651,6 +651,8 @@ Bitmap *LoadImage(char *); Bitmap *LoadCustomImage(char *); void ReloadCustomImage(Bitmap *, char *); +Bitmap *ZoomBitmap(Bitmap *, int, int); + inline void OpenAudio(void); inline void CloseAudio(void); inline void SetAudioMode(boolean); diff --git a/src/libgame/x11.c b/src/libgame/x11.c index 6c2942d1..d8e51863 100644 --- a/src/libgame/x11.c +++ b/src/libgame/x11.c @@ -232,6 +232,21 @@ static DrawWindow *X11InitWindow() return new_window; } +inline void X11NativeZoomBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap) +{ +} + +void X11ZoomBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap) +{ +#if defined(TARGET_ALLEGRO) + AllegroZoomBitmap(src_bitmap->drawable, dst_bitmap->drawable, + src_bitmap->width, src_bitmap->height, + dst_bitmap->width, dst_bitmap->height); +#else + X11NativeZoomBitmap(src_bitmap, dst_bitmap); +#endif +} + static void SetImageDimensions(Bitmap *bitmap) { #if defined(TARGET_ALLEGRO) diff --git a/src/libgame/x11.h b/src/libgame/x11.h index c643dc72..3db9bae3 100644 --- a/src/libgame/x11.h +++ b/src/libgame/x11.h @@ -304,6 +304,9 @@ struct XY inline void X11InitVideoDisplay(void); inline void X11InitVideoBuffer(DrawBuffer **, DrawWindow **); + +void X11ZoomBitmap(Bitmap *, Bitmap *); + Bitmap *X11LoadImage(char *); #endif /* X11_H */ -- 2.34.1