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 ());
@ -271,31 +269,16 @@ 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, Uint32 pixel;
gmask,
bmask,
amask;
Uint32 pixel;
SDL_Surface *dest; SDL_Surface *dest;
int y, int y,
x; x;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0xff000000;
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
#else /* */
rmask = 0x00ff0000;
gmask = 0x0000ff00;
bmask = 0x000000ff;
amask = 0xff000000;
#endif /* */ dest = SDL_CreateRGBSurface (SDL_HWSURFACE, org1->w, org1->h, org1->format->BitsPerPixel,
dest = SDL_CreateRGBSurface (SDL_SWSURFACE, org1->w, org1->h, 32, rmask, gmask, bmask, amask); org1->format->Rmask, org1->format->Gmask,
org1->format->Bmask, org1->format->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;
@ -339,34 +322,36 @@ gfx_quater_image (SDL_Surface * org1,SDL_Surface * org2,SDL_Surface * org3,SDL_S
} }
return NULL; return NULL;
} }
for (x = 0; x < org1->w/2; x++) for (x = 0; x < org1->w / 2; x++)
for (y = 0; y < org1->h/2; y++) { for (y = 0; y < org1->h / 2; y++) {
pixel = getpixel (org1, x, y); pixel = getpixel (org1, x, y);
putpixel (dest, x, y, pixel); putpixel (dest, x, y, pixel);
} }
for (x = org1->w/2; x < org1->w; x++) for (x = org1->w / 2; x < org1->w; x++)
for (y = 0; y < org1->h/2; y++) { for (y = 0; y < org1->h / 2; y++) {
pixel = getpixel (org2, x, y); pixel = getpixel (org2, x, y);
putpixel (dest, x, y, pixel); putpixel (dest, x, y, pixel);
} }
for (x = 0; x < org1->w/2; x++) for (x = 0; x < org1->w / 2; x++)
for (y = org1->h/2; y < org1->h; y++) { for (y = org1->h / 2; y < org1->h; y++) {
pixel = getpixel (org3, x, y); pixel = getpixel (org3, x, y);
putpixel (dest, x, y, pixel); putpixel (dest, x, y, pixel);
} }
for (x = org1->w/2; x < org1->w; x++) for (x = org1->w / 2; x < org1->w; x++)
for (y = org1->h/2; y < org1->h; y++) { for (y = org1->h / 2; y < org1->h; y++) {
pixel = getpixel (org4, x, y); pixel = getpixel (org4, x, y);
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 (dest)) { if (SDL_MUSTLOCK (org4))
SDL_UnlockSurface (org4);
if (SDL_MUSTLOCK (dest)) {
SDL_UnlockSurface (dest); SDL_UnlockSurface (dest);
} }
return dest; return dest;
@ -889,25 +874,28 @@ gfx_load_tileset (char *tilesetname)
sprintf (filename, "%s/tileset/%s/fieldshoe.bmp", bman.datapath, tileset); sprintf (filename, "%s/tileset/%s/fieldshoe.bmp", bman.datapath, tileset);
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.field[i].image = SDL_DisplayFormat (tmpimage); gfx_quater_image (gfx.field[FT_bomb].image, gfx.field[FT_fire].image,
} gfx.field[FT_death].image, gfx.field[FT_shoe].image);
else { gfx.field[i].image = SDL_DisplayFormat (tmpimage);
tmpimage = SDL_LoadBMP (filename);
if (tmpimage == NULL) {
printf ("Can't load image: %s\n", SDL_GetError ());
exit (1);
} }
gfx.field[i].frames = tmpimage->h / GFX_IMGSIZE; else {
tmpimage1 = scale_image (tmpimage, (tmpimage->w / GFX_IMGSIZE) * gfx.block.x, tmpimage = SDL_LoadBMP (filename);
gfx.field[i].frames * gfx.block.y); if (tmpimage == NULL) {
SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, 255, 255, 255)); printf ("Can't load image: %s\n", SDL_GetError ());
gfx.field[i].image = SDL_DisplayFormat (tmpimage1); exit (1);
SDL_FreeSurface (tmpimage); }
SDL_FreeSurface (tmpimage1); gfx.field[i].frames = tmpimage->h / GFX_IMGSIZE;
} tmpimage1 = scale_image (tmpimage, (tmpimage->w / GFX_IMGSIZE) * gfx.block.x,
} gfx.field[i].frames * gfx.block.y);
SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY,
SDL_MapRGB (tmpimage1->format, 255, 255, 255));
gfx.field[i].image = SDL_DisplayFormat (tmpimage1);
SDL_FreeSurface (tmpimage);
SDL_FreeSurface (tmpimage1);
}
}
UpdateRects_nr = 0; UpdateRects_nr = 0;
}; };

Loading…
Cancel
Save