2020-09-19 17:30:37 (UTC-03:00)
Marcel Rodrigues <marcelgmr@gmail.com>
example: handle transparent background.
diff --git a/example.c b/example.c index 8360285..c5d8c93 100644 --- a/example.c +++ b/example.c @@ -89,8 +89,13 @@ main(int argc, char *argv[]) color = frame; for (i = 0; i < gif->height; i++) { for (j = 0; j < gif->width; j++) { + if (memcmp(&gif->palette->colors[gif->bgindex*3], color, 3)) + pixel = SDL_MapRGB(surface->format, color[0], color[1], color[2]); + else if (((i >> 2) + (j >> 2)) & 1) + pixel = SDL_MapRGB(surface->format, 0x7F, 0x7F, 0x7F); + else + pixel = SDL_MapRGB(surface->format, 0x00, 0x00, 0x00); addr = surface->pixels + (i * surface->pitch + j * sizeof(pixel)); - pixel = SDL_MapRGB(surface->format, color[0], color[1], color[2]); memcpy(addr, &pixel, sizeof(pixel)); color += 3; }