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;
78 alpha = ((
Uint8*)surface->
pixels) + alphaChannelOffset;
161 }
else if (biSize >= 40) {
222 if (biSize > headerSize) {
228 biHeight = -biHeight;
240 switch (biBitCount) {
243 ExpandBMP = biBitCount;
252 switch (biCompression) {
258 switch (biBitCount) {
266 #if SDL_BYTEORDER == SDL_BIG_ENDIAN 302 if (surface ==
NULL) {
308 palette = (surface->
format)->palette;
311 if (biClrUsed == 0) {
312 biClrUsed = 1 << biBitCount;
314 if ((
int) biClrUsed > palette->
ncolors) {
316 int ncolors = biClrUsed;
320 sizeof(*palette->
colors));
328 }
else if ((
int) biClrUsed < palette->ncolors) {
332 for (i = 0; i < (int) biClrUsed; ++
i) {
339 for (i = 0; i < (int) biClrUsed; ++
i) {
364 bmpPitch = (biWidth + 7) >> 3;
365 pad = (((bmpPitch) % 4) ? (4 - ((bmpPitch) % 4)) : 0);
368 bmpPitch = (biWidth + 1) >> 1;
369 pad = (((bmpPitch) % 4) ? (4 - ((bmpPitch) % 4)) : 0);
372 pad = ((surface->
pitch % 4) ? (4 - (surface->
pitch % 4)) : 0);
378 bits = end - surface->
pitch;
380 while (bits >= top && bits < end) {
385 int shift = (8 - ExpandBMP);
386 for (i = 0; i < surface->
w; ++
i) {
387 if (i % (8 / ExpandBMP) == 0) {
394 *(bits +
i) = (pixel >> shift);
407 #if SDL_BYTEORDER == SDL_BIG_ENDIAN 410 switch (biBitCount) {
414 for (i = 0; i < surface->
w; i++)
421 for (i = 0; i < surface->
w; i++)
432 for (i = 0; i < pad; ++
i) {
437 bits += surface->
pitch;
439 bits -= surface->
pitch;
453 if (freesrc && src) {
470 char magic[2] = {
'B',
'M' };
495 Sint32 bV4Endpoints[3 * 3] = {0};
503 #ifdef SAVE_32BIT_BMP 576 biWidth = surface->
w;
577 biHeight = surface->
h;
581 biSizeImage = surface->
h * surface->
pitch;
592 if (save32bit && !saveLegacyBMP) {
596 bV4RedMask = 0x00ff0000;
597 bV4GreenMask = 0x0000ff00;
598 bV4BlueMask = 0x000000ff;
599 bV4AlphaMask = 0xff000000;
620 if (save32bit && !saveLegacyBMP) {
626 for (i = 0; i < 3 * 3; i++) {
641 for (i = 0; i < ncolors; ++
i) {
661 pad = ((bw % 4) ? (4 - (bw % 4)) : 0);
663 bits -= surface->
pitch;
669 const Uint8 padbyte = 0;
670 for (i = 0; i < pad; ++
i) {
688 if (surface != saveme) {
693 if (freedst && dst) {
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
#define SDL_UnlockSurface
GLdouble GLdouble GLdouble r
#define SDL_COPY_COLORKEY
#define LCS_WINDOWS_COLOR_SPACE
#define SDL_RWwrite(ctx, ptr, size, n)
#define SDL_ConvertSurface
A collection of pixels used in software blitting.
#define SDL_RWread(ctx, ptr, size, n)
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const void * bits
uint32_t Uint32
An unsigned 32-bit integer type.
static void CorrectAlphaChannel(SDL_Surface *surface)
GLdouble GLdouble GLdouble GLdouble top
GLfloat GLfloat GLfloat alpha
#define SDL_GetHintBoolean
#define SDL_RWseek(ctx, offset, whence)
SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x)
uint8_t Uint8
An unsigned 8-bit integer type.
#define SDL_HINT_BMP_SAVE_LEGACY_FORMAT
Prevent SDL from using version 4 of the bitmap header when saving BMPs.
SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x)
int32_t Sint32
A signed 32-bit integer type.
int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format)
int SDL_SaveBMP_RW(SDL_Surface *saveme, SDL_RWops *dst, int freedst)
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)
#define SDL_assert(condition)
#define SDL_OutOfMemory()
SDL_Surface * SDL_LoadBMP_RW(SDL_RWops *src, int freesrc)
#define SDL_CreateRGBSurface
uint16_t Uint16
An unsigned 16-bit integer type.
int64_t Sint64
A signed 64-bit integer type.
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean GLboolean b