diff --git a/src/gfx.c b/src/gfx.c index 5cc2396..0a508ff 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -63,10 +63,10 @@ getpixel (SDL_Surface * surface, int x, int y) void putpixel (SDL_Surface * surface, int x, int y, Uint32 pixel) { - int bpp = surface->format->BytesPerPixel; - /* Here p is the address to the pixel we want to set */ + int bpp = surface->format->BytesPerPixel; Uint8 *p = (Uint8 *) surface->pixels + y * surface->pitch + x * bpp; + switch (bpp) { case 1: *p = pixel; @@ -163,6 +163,7 @@ scale_image (SDL_Surface * orginal, int newx, int newy) amask = 0xff000000; #endif /* */ + surface = SDL_CreateRGBSurface (SDL_SWSURFACE, newx, newy, 32, rmask, gmask, bmask, amask); if (surface == NULL) { fprintf (stderr, "CreateRGBSurface failed: %s\n", SDL_GetError ());