From: Holger Schemel Date: Sun, 26 Jan 2003 03:01:46 +0000 (+0100) Subject: rnd-20030126-3-src X-Git-Tag: 3.0.0^2~158 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=92204d79d159df0be4bd05c4b4e4dabbcaefe805;p=rocksndiamonds.git rnd-20030126-3-src --- diff --git a/Makefile b/Makefile index 03809fd4..ba491935 100644 --- a/Makefile +++ b/Makefile @@ -49,8 +49,8 @@ CROSS_PATH_WIN32=/usr/local/cross-tools/i386-mingw32msvc SRC_DIR = src MAKE_CMD = $(MAKE) -C $(SRC_DIR) -# DEFAULT_TARGET = x11 -DEFAULT_TARGET = sdl +DEFAULT_TARGET = x11 +# DEFAULT_TARGET = sdl all: @$(MAKE_CMD) TARGET=$(DEFAULT_TARGET) diff --git a/src/conftime.h b/src/conftime.h index 9f661ab5..6ea5bc86 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-01-26 02:06]" +#define COMPILE_DATE_STRING "[2003-01-26 04:01]" diff --git a/src/init.c b/src/init.c index 34673f37..27088af6 100644 --- a/src/init.c +++ b/src/init.c @@ -263,9 +263,6 @@ static void ReinitializeGraphics() /* !!! TEST ONLY !!! */ - -#if 1 - { Bitmap *tst_bitmap = graphic_info[IMG_SAND].bitmap; Bitmap *tmp_bitmap = ZoomBitmap(tst_bitmap, @@ -276,31 +273,6 @@ static void ReinitializeGraphics() FreeBitmap(tmp_bitmap); } - -#else -#ifdef TARGET_SDL - - { - Bitmap tmp_bitmap; - SDL_Surface *dst = SDLZoomSurface(graphic_info[IMG_SAND].bitmap->surface, - 0.5, 0.5); - tmp_bitmap.surface = dst; - - BlitBitmap(&tmp_bitmap, graphic_info[IMG_SAND].bitmap, - 0, 0, 256, 224, 0, 448); - - SDL_FreeSurface(dst); - } - -#elif defined(PLATFORM_MSDOS) - - stretch_blit((BITMAP *)(graphic_info[IMG_SAND].bitmap->drawable), - (BITMAP *)(graphic_info[IMG_SAND].bitmap->drawable), - 0, 0, 512, 448, - 0, 448, 256, 224); - -#endif -#endif } static void ReinitializeSounds() diff --git a/src/libgame/image.c b/src/libgame/image.c index 31975e04..f7bf538f 100644 --- a/src/libgame/image.c +++ b/src/libgame/image.c @@ -443,8 +443,8 @@ XImageInfo *Image_to_Pixmap(Display *display, int screen, Visual *visual, display_bits_per_pixel = bitsPerPixelAtDepth(display, screen, depth); display_bytes_per_pixel = (display_bits_per_pixel + 7) / 8; - ximage = XCreateImage(display, visual, depth, ZPixmap, 0, - NULL, image->width, image->height, + ximage = XCreateImage(display, visual, depth, ZPixmap, + 0, NULL, image->width, image->height, 8, image->width * display_bytes_per_pixel); ximage->data = checked_malloc(image->width * image->height * display_bytes_per_pixel); @@ -565,6 +565,62 @@ XImageInfo *Image_to_Pixmap(Display *display, int screen, Visual *visual, return ximageinfo; } +/* + ----------------------------------------------------------------------------- + ZoomPixmap + + Important note: The scaling code currently only supports scaling down the + image by a power of 2 -- scaling up is currently not supported at all! + ----------------------------------------------------------------------------- +*/ + +void ZoomPixmap(Display *display, GC gc, Pixmap src_pixmap, Pixmap dst_pixmap, + int src_width, int src_height, + int dst_width, int dst_height) +{ + XImage *src_ximage, *dst_ximage; + byte *src_ptr, *dst_ptr; + int bits_per_pixel; + int bytes_per_pixel; + int x, y, i; + int zoom_factor = src_width / dst_width; /* currently very limited! */ + int row_skip, col_skip; + + /* copy source pixmap to temporary image */ + src_ximage = XGetImage(display, src_pixmap, 0, 0, + src_width, src_height, AllPlanes, ZPixmap); + + bits_per_pixel = src_ximage->bits_per_pixel; + bytes_per_pixel = (bits_per_pixel + 7) / 8; + + dst_ximage = XCreateImage(display, visual, src_ximage->depth, ZPixmap, + 0, NULL, dst_width, dst_height, + 8, dst_width * bytes_per_pixel); + dst_ximage->data = + checked_malloc(dst_width * dst_height * bytes_per_pixel); + dst_ximage->byte_order = src_ximage->byte_order; + + src_ptr = (byte *)src_ximage->data; + dst_ptr = (byte *)dst_ximage->data; + + col_skip = (zoom_factor - 1) * bytes_per_pixel; + row_skip = col_skip * src_width; + + /* scale image down by scaling factor 'zoom_factor' */ + for (y=0; y < src_height; y += zoom_factor, src_ptr += row_skip) + for (x=0; x < src_width; x += zoom_factor, src_ptr += col_skip) + for (i=0; iindex != NULL && ximageinfo->no > 0) diff --git a/src/libgame/image.h b/src/libgame/image.h index 6b9e6459..d372a468 100644 --- a/src/libgame/image.h +++ b/src/libgame/image.h @@ -67,6 +67,9 @@ typedef struct Image *newImage(unsigned int, unsigned int, unsigned int); void freeImage(Image *); void freeXImage(Image *, XImageInfo *); + +void ZoomPixmap(Display *, GC, Pixmap, Pixmap, int, int, int, int); + int Read_PCX_to_Pixmap(Display *, Window, GC, char *, Pixmap *, Pixmap *); #endif /* TARGET_X11 */ diff --git a/src/libgame/x11.c b/src/libgame/x11.c index d8e51863..6f14c37f 100644 --- a/src/libgame/x11.c +++ b/src/libgame/x11.c @@ -232,10 +232,6 @@ 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) @@ -243,7 +239,10 @@ void X11ZoomBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap) src_bitmap->width, src_bitmap->height, dst_bitmap->width, dst_bitmap->height); #else - X11NativeZoomBitmap(src_bitmap, dst_bitmap); + ZoomPixmap(display, src_bitmap->gc, + src_bitmap->drawable, dst_bitmap->drawable, + src_bitmap->width, src_bitmap->height, + dst_bitmap->width, dst_bitmap->height); #endif }