diff options
| author | Steven Fuller <relnev@icculus.org> | 2001-12-06 01:33:14 +0000 |
|---|---|---|
| committer | Patryk Obara <dreamer.tan@gmail.com> | 2019-08-20 02:22:36 +0200 |
| commit | 9a32158ae895b2be5736ecb942dcf1c1046d5033 (patch) | |
| tree | ae1ee941c2eb60039871bc86b5780afc03d5527f /src | |
| parent | 9f006f18fe497c1ef12cd2973045fadbd500aaac (diff) | |
Screenshots in software mode (menus) implemented.
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.c | 31 |
1 files changed, 30 insertions, 1 deletions
@@ -99,7 +99,36 @@ unsigned char *GetScreenShot24(int *width, int *height) glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glReadPixels(0, 0, surface->w, surface->h, GL_RGB, GL_BYTE, buf); } else { - fprintf(stderr, "GetScreenShot24: add software mode 16->24!\n"); + unsigned char *ptrd; + unsigned short int *ptrs; + int x, y; + + if (SDL_MUSTLOCK(surface)) { + if (SDL_LockSurface(surface) < 0) { + free(buf); + return NULL; /* ... */ + } + } + + ptrd = buf; + for (y = 0; y < surface->h; y++) { + ptrs = (unsigned short *)(((unsigned char *)surface->pixels) + (surface->h-y-1)*surface->pitch); + for (x = 0; x < surface->w; x++) { + unsigned int c; + + c = *ptrs; + ptrd[0] = (c & 0xF800)>>8; + ptrd[1] = (c & 0x07E0)>>3; + ptrd[2] = (c & 0x001F)<<3; + + ptrs++; + ptrd += 3; + } + } + + if (SDL_MUSTLOCK(surface)) { + SDL_UnlockSurface(surface); + } } *width = surface->w; |
