21 #include "../SDL_internal.h" 40 #define SAVE_32BIT_BMP 47 #define BI_BITFIELDS 3 55 #if SDL_BYTEORDER == SDL_BIG_ENDIAN 56 int alphaChannelOffset = 0;
58 int alphaChannelOffset = 3;
72 alpha = ((
Uint8*)surface->
pixels) + alphaChannelOffset;
155 }
else if (biSize >= 40) {
216 if (biSize > headerSize) {
222 biHeight = -biHeight;
234 switch (biBitCount) {
237 ExpandBMP = biBitCount;
246 switch (biCompression) {
252 switch (biBitCount) {
260 #if SDL_BYTEORDER == SDL_BIG_ENDIAN 296 if (surface ==
NULL) {
302 palette = (surface->
format)->palette;
305 if (biClrUsed == 0) {
306 biClrUsed = 1 << biBitCount;
308 if ((
int) biClrUsed > palette->
ncolors) {
310 int ncolors = biClrUsed;
314 sizeof(*palette->
colors));
322 }
else if ((
int) biClrUsed < palette->ncolors) {
326 for (i = 0; i < (int) biClrUsed; ++
i) {
333 for (i = 0; i < (int) biClrUsed; ++
i) {
358 bmpPitch = (biWidth + 7) >> 3;
359 pad = (((bmpPitch) % 4) ? (4 - ((bmpPitch) % 4)) : 0);
362 bmpPitch = (biWidth + 1) >> 1;
363 pad = (((bmpPitch) % 4) ? (4 - ((bmpPitch) % 4)) : 0);
366 pad = ((surface->
pitch % 4) ? (4 - (surface->
pitch % 4)) : 0);
372 bits = end - surface->
pitch;
374 while (bits >= top && bits < end) {
379 int shift = (8 - ExpandBMP);
380 for (i = 0; i < surface->
w; ++
i) {
381 if (i % (8 / ExpandBMP) == 0) {
388 *(bits +
i) = (pixel >> shift);
401 #if SDL_BYTEORDER == SDL_BIG_ENDIAN 404 switch (biBitCount) {
408 for (i = 0; i < surface->
w; i++)
415 for (i = 0; i < surface->
w; i++)
426 for (i = 0; i < pad; ++
i) {
431 bits += surface->
pitch;
433 bits -= surface->
pitch;
447 if (freesrc && src) {
462 char magic[2] = {
'B',
'M' };
485 #ifdef SAVE_32BIT_BMP 560 biWidth = surface->
w;
561 biHeight = surface->
h;
565 biSizeImage = surface->
h * surface->
pitch;
595 for (i = 0; i < ncolors; ++
i) {
615 pad = ((bw % 4) ? (4 - (bw % 4)) : 0);
617 bits -= surface->
pitch;
623 const Uint8 padbyte = 0;
624 for (i = 0; i < pad; ++
i) {
642 if (surface != saveme) {
647 if (freedst && dst) {
GLdouble GLdouble GLdouble r
#define SDL_UnlockSurface
#define SDL_COPY_COLORKEY
uint32_t Uint32
An unsigned 32-bit integer type.
#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
static void CorrectAlphaChannel(SDL_Surface *surface)
#define SDL_RWseek(ctx, offset, whence)
SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x)
uint8_t Uint8
An unsigned 8-bit integer type.
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
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
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
GLdouble GLdouble GLdouble GLdouble top
enum blit_table::@26 alpha