39 #define SAVE_32BIT_BMP
46 #define BI_BITFIELDS 3
54 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
55 int alphaChannelOffset = 0;
57 int alphaChannelOffset = 3;
71 alpha = ((
Uint8*)surface->
pixels) + alphaChannelOffset;
166 biHeight = -biHeight;
178 switch (biBitCount) {
181 ExpandBMP = biBitCount;
190 Rmask = Gmask = Bmask = Amask = 0;
191 switch (biCompression) {
194 if (bfOffBits == (14 + biSize)) {
196 switch (biBitCount) {
204 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
230 switch (biBitCount) {
257 if (surface ==
NULL) {
263 palette = (surface->
format)->palette;
265 if (biClrUsed == 0) {
266 biClrUsed = 1 << biBitCount;
268 if ((
int) biClrUsed > palette->
ncolors) {
273 sizeof(*palette->
colors));
279 }
else if ((
int) biClrUsed < palette->ncolors) {
283 for (i = 0; i < (
int) biClrUsed; ++
i) {
290 for (i = 0; i < (
int) biClrUsed; ++
i) {
315 bmpPitch = (biWidth + 7) >> 3;
316 pad = (((bmpPitch) % 4) ? (4 - ((bmpPitch) % 4)) : 0);
319 bmpPitch = (biWidth + 1) >> 1;
320 pad = (((bmpPitch) % 4) ? (4 - ((bmpPitch) % 4)) : 0);
323 pad = ((surface->
pitch % 4) ? (4 - (surface->
pitch % 4)) : 0);
329 bits = end - surface->
pitch;
331 while (bits >= top && bits < end) {
336 int shift = (8 - ExpandBMP);
337 for (i = 0; i < surface->
w; ++
i) {
338 if (i % (8 / ExpandBMP) == 0) {
345 *(bits +
i) = (pixel >> shift);
358 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
361 switch (biBitCount) {
365 for (i = 0; i < surface->
w; i++)
372 for (i = 0; i < surface->
w; i++)
383 for (i = 0; i <
pad; ++
i) {
388 bits += surface->
pitch;
390 bits -= surface->
pitch;
404 if (freesrc && src) {
419 char magic[2] = {
'B',
'M' };
442 #ifdef SAVE_32BIT_BMP
513 biWidth = surface->
w;
514 biHeight = surface->
h;
518 biSizeImage = surface->
h * surface->
pitch;
548 for (i = 0; i < ncolors; ++
i) {
568 pad = ((bw % 4) ? (4 - (bw % 4)) : 0);
570 bits -= surface->
pitch;
576 const Uint8 padbyte = 0;
577 for (i = 0; i <
pad; ++
i) {
595 if (surface != saveme) {
600 if (freedst && dst) {
DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface)
DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
int32_t Sint32
A signed 32-bit integer type.
#define SDL_COPY_COLORKEY
#define SDL_RWwrite(ctx, ptr, size, n)
DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops *src)
DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size)
A collection of pixels used in software blitting.
DECLSPEC int SDLCALL SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst)
#define SDL_RWread(ctx, ptr, size, n)
GLboolean GLboolean GLboolean GLboolean a
static void CorrectAlphaChannel(SDL_Surface *surface)
DECLSPEC const char *SDLCALL SDL_GetError(void)
DECLSPEC size_t SDLCALL SDL_WriteLE32(SDL_RWops *dst, Uint32 value)
DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops *src)
#define SDL_RWseek(ctx, offset, whence)
DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops *src, int freesrc)
SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x)
uint32_t Uint32
An unsigned 32-bit integer type.
DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface)
DECLSPEC int SDLCALL SDL_Error(SDL_errorcode code)
SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x)
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum format
DECLSPEC int SDLCALL SDL_SetError(const char *fmt,...)
DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2)
DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface(SDL_Surface *src, const SDL_PixelFormat *fmt, Uint32 flags)
GLclampf GLclampf GLclampf alpha
GLfloat GLfloat GLfloat top
DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format)
#define SDL_OutOfMemory()
DECLSPEC void SDLCALL SDL_ClearError(void)
uint8_t Uint8
An unsigned 8-bit integer type.
DECLSPEC size_t SDLCALL SDL_WriteLE16(SDL_RWops *dst, Uint16 value)
GLdouble GLdouble GLdouble r
GLdouble GLdouble GLdouble b
uint16_t Uint16
An unsigned 16-bit integer type.
int64_t Sint64
A signed 64-bit integer type.
DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface *surface)
Sets up a surface for directly accessing the pixels.