mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-02-20 10:28:23 +00:00
Add SDL_PIXELFORMAT_INDEX2LSB and SDL_PIXELFORMAT_INDEX2MSB
This commit is contained in:
committed by
Sam Lantinga
parent
fda69e5e79
commit
753bbd199e
@@ -11,6 +11,8 @@
|
||||
static const Uint32 g_AllFormats[] = {
|
||||
SDL_PIXELFORMAT_INDEX1LSB,
|
||||
SDL_PIXELFORMAT_INDEX1MSB,
|
||||
SDL_PIXELFORMAT_INDEX2LSB,
|
||||
SDL_PIXELFORMAT_INDEX2MSB,
|
||||
SDL_PIXELFORMAT_INDEX4LSB,
|
||||
SDL_PIXELFORMAT_INDEX4MSB,
|
||||
SDL_PIXELFORMAT_INDEX8,
|
||||
@@ -56,6 +58,8 @@ static const int g_numAllFormats = SDL_arraysize(g_AllFormats);
|
||||
static const char *g_AllFormatsVerbose[] = {
|
||||
"SDL_PIXELFORMAT_INDEX1LSB",
|
||||
"SDL_PIXELFORMAT_INDEX1MSB",
|
||||
"SDL_PIXELFORMAT_INDEX2LSB",
|
||||
"SDL_PIXELFORMAT_INDEX2MSB",
|
||||
"SDL_PIXELFORMAT_INDEX4LSB",
|
||||
"SDL_PIXELFORMAT_INDEX4MSB",
|
||||
"SDL_PIXELFORMAT_INDEX8",
|
||||
|
||||
@@ -660,6 +660,34 @@ static int surface_testOverflow(void *arg)
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_DestroySurface(surface);
|
||||
|
||||
/* SDL_PIXELFORMAT_INDEX2* needs 1 byte per 4 pixels. */
|
||||
surface = SDL_CreateSurfaceFrom(buf, 12, 1, 3, SDL_PIXELFORMAT_INDEX2LSB);
|
||||
SDLTest_AssertCheck(surface != NULL, "12px * 2 bits per px fits in 3 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_DestroySurface(surface);
|
||||
surface = SDL_CreateSurfaceFrom(buf, 12, 1, 3, SDL_PIXELFORMAT_INDEX2MSB);
|
||||
SDLTest_AssertCheck(surface != NULL, "12px * 2 bits per px fits in 3 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_DestroySurface(surface);
|
||||
|
||||
surface = SDL_CreateSurfaceFrom(buf, 13, 1, 3, SDL_PIXELFORMAT_INDEX2LSB);
|
||||
SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp (%d)", surface ? surface->pitch : 0);
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
surface = SDL_CreateSurfaceFrom(buf, 13, 1, 3, SDL_PIXELFORMAT_INDEX2MSB);
|
||||
SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
|
||||
surface = SDL_CreateSurfaceFrom(buf, 13, 1, 4, SDL_PIXELFORMAT_INDEX2LSB);
|
||||
SDLTest_AssertCheck(surface != NULL, "13px * 2 bits per px fits in 4 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_DestroySurface(surface);
|
||||
surface = SDL_CreateSurfaceFrom(buf, 13, 1, 4, SDL_PIXELFORMAT_INDEX2MSB);
|
||||
SDLTest_AssertCheck(surface != NULL, "13px * 2 bits per px fits in 4 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_DestroySurface(surface);
|
||||
|
||||
/* SDL_PIXELFORMAT_INDEX1* needs 1 byte per 8 pixels. */
|
||||
surface = SDL_CreateSurfaceFrom(buf, 16, 1, 2, SDL_PIXELFORMAT_INDEX1LSB);
|
||||
SDLTest_AssertCheck(surface != NULL, "16px * 1 bit per px fits in 2 bytes: %s",
|
||||
|
||||
Reference in New Issue
Block a user