SDL_Create fix in gfx_quater_image

origin
stpohle 23 years ago
parent 7457cf764b
commit 1bd676c4fa

@ -220,14 +220,12 @@ makegray_image (SDL_Surface * org)
gmask = 0x00ff0000; gmask = 0x00ff0000;
bmask = 0x0000ff00; bmask = 0x0000ff00;
amask = 0x000000ff; amask = 0x000000ff;
#else
#else /* */
rmask = 0x00ff0000; rmask = 0x00ff0000;
gmask = 0x0000ff00; gmask = 0x0000ff00;
bmask = 0x000000ff; bmask = 0x000000ff;
amask = 0xff000000; amask = 0xff000000;
#endif
#endif /* */
dest = SDL_CreateRGBSurface (SDL_SWSURFACE, org->w, org->h, 32, rmask, gmask, bmask, amask); dest = SDL_CreateRGBSurface (SDL_SWSURFACE, org->w, org->h, 32, rmask, gmask, bmask, amask);
if (dest == NULL) { if (dest == NULL) {
fprintf (stderr, "CreateRGBSurface failed: %s\n", SDL_GetError ()); fprintf (stderr, "CreateRGBSurface failed: %s\n", SDL_GetError ());
@ -273,29 +271,14 @@ makegray_image (SDL_Surface * org)
SDL_Surface * SDL_Surface *
gfx_quater_image (SDL_Surface * org1, SDL_Surface * org2, SDL_Surface * org3, SDL_Surface * org4) gfx_quater_image (SDL_Surface * org1, SDL_Surface * org2, SDL_Surface * org3, SDL_Surface * org4)
{ {
Uint32 rmask,
gmask,
bmask,
amask;
Uint32 pixel; Uint32 pixel;
SDL_Surface *dest; SDL_Surface *dest;
int y, int y,
x; x;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN dest = SDL_CreateRGBSurface (SDL_HWSURFACE, org1->w, org1->h, org1->format->BitsPerPixel,
rmask = 0xff000000; org1->format->Rmask, org1->format->Gmask,
gmask = 0x00ff0000; org1->format->Bmask, org1->format->Amask);
bmask = 0x0000ff00;
amask = 0x000000ff;
#else /* */
rmask = 0x00ff0000;
gmask = 0x0000ff00;
bmask = 0x000000ff;
amask = 0xff000000;
#endif /* */
dest = SDL_CreateRGBSurface (SDL_SWSURFACE, org1->w, org1->h, 32, rmask, gmask, bmask, amask);
if (dest == NULL) { if (dest == NULL) {
fprintf (stderr, "CreateRGBSurface failed: %s\n", SDL_GetError ()); fprintf (stderr, "CreateRGBSurface failed: %s\n", SDL_GetError ());
return NULL; return NULL;
@ -360,12 +343,14 @@ gfx_quater_image (SDL_Surface * org1,SDL_Surface * org2,SDL_Surface * org3,SDL_S
putpixel (dest, x, y, pixel); putpixel (dest, x, y, pixel);
} }
if (SDL_MUSTLOCK (org1)) SDL_UnlockSurface (org1); if (SDL_MUSTLOCK (org1))
if (SDL_MUSTLOCK (org2)) SDL_UnlockSurface (org2); SDL_UnlockSurface (org1);
if (SDL_MUSTLOCK (org3)) SDL_UnlockSurface (org3); if (SDL_MUSTLOCK (org2))
if (SDL_MUSTLOCK (org4)) SDL_UnlockSurface (org4); SDL_UnlockSurface (org2);
if (SDL_MUSTLOCK (org3))
SDL_UnlockSurface (org3);
if (SDL_MUSTLOCK (org4))
SDL_UnlockSurface (org4);
if (SDL_MUSTLOCK (dest)) { if (SDL_MUSTLOCK (dest)) {
SDL_UnlockSurface (dest); SDL_UnlockSurface (dest);
} }
@ -890,7 +875,9 @@ gfx_load_tileset (char *tilesetname)
break; break;
} }
if (i == FT_mixed) { if (i == FT_mixed) {
tmpimage=gfx_quater_image(gfx.field[FT_bomb].image,gfx.field[FT_fire].image,gfx.field[FT_death].image,gfx.field[FT_shoe].image); tmpimage =
gfx_quater_image (gfx.field[FT_bomb].image, gfx.field[FT_fire].image,
gfx.field[FT_death].image, gfx.field[FT_shoe].image);
gfx.field[i].image = SDL_DisplayFormat (tmpimage); gfx.field[i].image = SDL_DisplayFormat (tmpimage);
} }
else { else {
@ -902,7 +889,8 @@ gfx_load_tileset (char *tilesetname)
gfx.field[i].frames = tmpimage->h / GFX_IMGSIZE; gfx.field[i].frames = tmpimage->h / GFX_IMGSIZE;
tmpimage1 = scale_image (tmpimage, (tmpimage->w / GFX_IMGSIZE) * gfx.block.x, tmpimage1 = scale_image (tmpimage, (tmpimage->w / GFX_IMGSIZE) * gfx.block.x,
gfx.field[i].frames * gfx.block.y); gfx.field[i].frames * gfx.block.y);
SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, 255, 255, 255)); SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY,
SDL_MapRGB (tmpimage1->format, 255, 255, 255));
gfx.field[i].image = SDL_DisplayFormat (tmpimage1); gfx.field[i].image = SDL_DisplayFormat (tmpimage1);
SDL_FreeSurface (tmpimage); SDL_FreeSurface (tmpimage);
SDL_FreeSurface (tmpimage1); SDL_FreeSurface (tmpimage1);

Loading…
Cancel
Save