MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / SDLTest_ScreenShot

Function SDLTest_ScreenShot

deps/SDL2/src/test/SDL_test_common.c:1519–1554  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1517}
1518
1519static void
1520SDLTest_ScreenShot(SDL_Renderer *renderer)
1521{
1522 SDL_Rect viewport;
1523 SDL_Surface *surface;
1524
1525 if (!renderer) {
1526 return;
1527 }
1528
1529 SDL_RenderGetViewport(renderer, &viewport);
1530 surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24,
1531#if SDL_BYTEORDER == SDL_LIL_ENDIAN
1532 0x00FF0000, 0x0000FF00, 0x000000FF,
1533#else
1534 0x000000FF, 0x0000FF00, 0x00FF0000,
1535#endif
1536 0x00000000);
1537 if (!surface) {
1538 SDL_Log("Couldn't create surface: %s\n", SDL_GetError());
1539 return;
1540 }
1541
1542 if (SDL_RenderReadPixels(renderer, NULL, surface->format->format,
1543 surface->pixels, surface->pitch) < 0) {
1544 SDL_Log("Couldn't read screen: %s\n", SDL_GetError());
1545 SDL_free(surface);
1546 return;
1547 }
1548
1549 if (SDL_SaveBMP(surface, "screenshot.bmp") < 0) {
1550 SDL_Log("Couldn't save screenshot.bmp: %s\n", SDL_GetError());
1551 SDL_free(surface);
1552 return;
1553 }
1554}
1555
1556static void
1557FullscreenTo(int index, int windowId)

Callers 1

SDLTest_CommonEventFunction · 0.85

Calls 6

SDL_RenderGetViewportFunction · 0.85
SDL_CreateRGBSurfaceFunction · 0.85
SDL_LogFunction · 0.85
SDL_GetErrorFunction · 0.85
SDL_RenderReadPixelsFunction · 0.85
SDL_freeFunction · 0.85

Tested by

no test coverage detected