projects
/
rocksndiamonds.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
bdc4b96
)
fixed loading images with alpha channel or transparent color
author
Holger Schemel
<info@artsoft.org>
Mon, 27 Jun 2016 23:45:44 +0000
(
01:45
+0200)
committer
Holger Schemel
<info@artsoft.org>
Mon, 27 Jun 2016 23:45:44 +0000
(
01:45
+0200)
src/libgame/sdl.c
patch
|
blob
|
history
diff --git
a/src/libgame/sdl.c
b/src/libgame/sdl.c
index 72bbc14abe3df5abee36b2aeac94943cdfd3ff7b..30ca17949a8ad2f9192eed9fb0bd697a75207fd7 100644
(file)
--- a/
src/libgame/sdl.c
+++ b/
src/libgame/sdl.c
@@
-2232,15
+2232,23
@@
Bitmap *SDLLoadImage(char *filename)
return NULL;
}
return NULL;
}
+ /* remove alpha channel from native non-transparent surface, if defined */
+ SDLSetAlpha(new_bitmap->surface, FALSE, 0);
+
+ /* remove transparent color from native non-transparent surface, if defined */
+ SDL_SetColorKey(new_bitmap->surface, UNSET_TRANSPARENT_PIXEL, 0);
+
print_timestamp_time("SDL_DisplayFormat (opaque)");
UPDATE_BUSY_STATE();
print_timestamp_time("SDL_DisplayFormat (opaque)");
UPDATE_BUSY_STATE();
- /* create native transparent surface for current image */
- if (sdl_image_tmp->format->Amask == 0)
+ /* set black pixel to transparent if no alpha channel / transparent color */
+ if (!SDLHasAlpha(sdl_image_tmp) &&
+ !SDLHasColorKey(sdl_image_tmp))
SDL_SetColorKey(sdl_image_tmp, SET_TRANSPARENT_PIXEL,
SDL_MapRGB(sdl_image_tmp->format, 0x00, 0x00, 0x00));
SDL_SetColorKey(sdl_image_tmp, SET_TRANSPARENT_PIXEL,
SDL_MapRGB(sdl_image_tmp->format, 0x00, 0x00, 0x00));
+ /* create native transparent surface for current image */
if ((new_bitmap->surface_masked = SDLGetNativeSurface(sdl_image_tmp)) == NULL)
{
SetError("SDL_DisplayFormat(): %s", SDL_GetError());
if ((new_bitmap->surface_masked = SDLGetNativeSurface(sdl_image_tmp)) == NULL)
{
SetError("SDL_DisplayFormat(): %s", SDL_GetError());