Go to the documentation of this file.
21 #include "../SDL_internal.h"
41 #define SAVE_32BIT_BMP
48 #define BI_BITFIELDS 3
52 #ifndef LCS_WINDOWS_COLOR_SPACE
54 #define LCS_WINDOWS_COLOR_SPACE 0x57696E20
61 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
62 int alphaChannelOffset = 0;
64 int alphaChannelOffset = 3;
128 (
void) haveAlphaMask;
164 }
else if (biSize >= 40) {
225 if (biSize > headerSize) {
231 biHeight = -biHeight;
243 switch (biBitCount) {
246 ExpandBMP = biBitCount;
255 switch (biCompression) {
261 switch (biBitCount) {
269 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
311 palette = (
surface->format)->palette;
314 if (biClrUsed == 0) {
315 biClrUsed = 1 << biBitCount;
317 if ((
int) biClrUsed > palette->
ncolors) {
319 int ncolors = biClrUsed;
323 sizeof(*palette->
colors));
331 }
else if ((
int) biClrUsed < palette->ncolors) {
335 for (
i = 0;
i < (int) biClrUsed; ++
i) {
342 for (
i = 0;
i < (int) biClrUsed; ++
i) {
367 bmpPitch = (biWidth + 7) >> 3;
368 pad = (((bmpPitch) % 4) ? (4 - ((bmpPitch) % 4)) : 0);
371 bmpPitch = (biWidth + 1) >> 1;
372 pad = (((bmpPitch) % 4) ? (4 - ((bmpPitch) % 4)) : 0);
388 int shift = (8 - ExpandBMP);
390 if (
i % (8 / ExpandBMP) == 0) {
397 *(
bits +
i) = (pixel >> shift);
410 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
413 switch (biBitCount) {
435 for (
i = 0;
i < pad; ++
i) {
456 if (freesrc &&
src) {
473 char magic[2] = {
'B',
'M' };
498 Sint32 bV4Endpoints[3 * 3] = {0};
506 #ifdef SAVE_32BIT_BMP
582 biBitCount =
surface->format->BitsPerPixel;
587 if (
surface->format->palette) {
588 biClrUsed =
surface->format->palette->ncolors;
595 if (save32bit && !saveLegacyBMP) {
599 bV4RedMask = 0x00ff0000;
600 bV4GreenMask = 0x0000ff00;
601 bV4BlueMask = 0x000000ff;
602 bV4AlphaMask = 0xff000000;
623 if (save32bit && !saveLegacyBMP) {
629 for (
i = 0;
i < 3 * 3;
i++) {
638 if (
surface->format->palette) {
643 ncolors =
surface->format->palette->ncolors;
644 for (
i = 0;
i < ncolors; ++
i) {
664 pad = ((bw % 4) ? (4 - (bw % 4)) : 0);
672 const Uint8 padbyte = 0;
673 for (
i = 0;
i < pad; ++
i) {
696 if (freedst &&
dst) {
#define SDL_UnlockSurface
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
#define SDL_RWwrite(ctx, ptr, size, n)
A collection of pixels used in software blitting.
SDL_Surface * SDL_LoadBMP_RW(SDL_RWops *src, int freesrc)
GLboolean GLboolean GLboolean b
SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x)
int SDL_SaveBMP_RW(SDL_Surface *saveme, SDL_RWops *dst, int freedst)
GLdouble GLdouble GLdouble r
#define SDL_ConvertSurface
GLdouble GLdouble GLdouble GLdouble top
#define SDL_COPY_COLORKEY
GLboolean GLboolean GLboolean GLboolean a
#define SDL_RWread(ctx, ptr, size, n)
#define SDL_RWseek(ctx, offset, whence)
GLfloat GLfloat GLfloat alpha
#define SDL_GetHintBoolean
SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x)
#define LCS_WINDOWS_COLOR_SPACE
#define SDL_HINT_BMP_SAVE_LEGACY_FORMAT
Prevent SDL from using version 4 of the bitmap header when saving BMPs.
#define SDL_assert(condition)
static void CorrectAlphaChannel(SDL_Surface *surface)
#define SDL_OutOfMemory()
#define SDL_CreateRGBSurface
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const void * bits
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format)