mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-30 05:18:13 +08:00
Fail blits between indexed and RGB surfaces if there is no palette set
This commit is contained in:
@@ -1379,17 +1379,17 @@ static Uint8 *Map1toN(const SDL_Palette *pal, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod
|
|||||||
int i;
|
int i;
|
||||||
int bpp;
|
int bpp;
|
||||||
|
|
||||||
|
if (!pal) {
|
||||||
|
SDL_SetError("src does not have a palette set");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
bpp = ((SDL_BYTESPERPIXEL(dst->format) == 3) ? 4 : SDL_BYTESPERPIXEL(dst->format));
|
bpp = ((SDL_BYTESPERPIXEL(dst->format) == 3) ? 4 : SDL_BYTESPERPIXEL(dst->format));
|
||||||
map = (Uint8 *)SDL_calloc(256, bpp);
|
map = (Uint8 *)SDL_calloc(256, bpp);
|
||||||
if (!map) {
|
if (!map) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* An all-zero map for surfaces without a palette. */
|
|
||||||
if (!pal) {
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We memory copy to the pixel map so the endianness is preserved */
|
/* We memory copy to the pixel map so the endianness is preserved */
|
||||||
for (i = 0; i < pal->ncolors; ++i) {
|
for (i = 0; i < pal->ncolors; ++i) {
|
||||||
Uint8 R = (Uint8)((pal->colors[i].r * Rmod) / 255);
|
Uint8 R = (Uint8)((pal->colors[i].r * Rmod) / 255);
|
||||||
@@ -1410,7 +1410,7 @@ static Uint8 *MapNto1(const SDL_PixelFormatDetails *src, const SDL_Palette *pal,
|
|||||||
SDL_Color colors[256];
|
SDL_Color colors[256];
|
||||||
|
|
||||||
if (!pal) {
|
if (!pal) {
|
||||||
*identical = 1;
|
SDL_SetError("dst does not have a palette set");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user