1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-28 07:29:45 +00:00

Merge pull request #504 from TomHarte/SDLBMPByteOrder

Ensures SDL is properly informed of buffer byte order.
This commit is contained in:
Thomas Harte 2018-07-27 18:53:16 -04:00 committed by GitHub
commit 689850d698
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -632,7 +632,16 @@ int main(int argc, char *argv[]) {
}
// Create a suitable SDL surface and save the thing.
SDL_Surface *const surface = SDL_CreateRGBSurfaceFrom(pixels.data(), proportional_width, window_height, 8*4, proportional_width*4, 0, 0, 0, 0);
const bool is_big_endian = SDL_BYTEORDER == SDL_BIG_ENDIAN;
SDL_Surface *const surface = SDL_CreateRGBSurfaceFrom(
pixels.data(),
proportional_width, window_height,
8*4,
proportional_width*4,
is_big_endian ? 0xff000000 : 0x000000ff,
is_big_endian ? 0x00ff0000 : 0x0000ff00,
is_big_endian ? 0x0000ff00 : 0x00ff0000,
0);
SDL_SaveBMP(surface, target.c_str());
SDL_FreeSurface(surface);
break;