21#include "../SDL_internal.h"
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) {
229 if (biWidth <= 0 || biHeight == 0) {
230 SDL_SetError(
"BMP file with bad dimensions (%dx%d)", biWidth, biHeight);
236 biHeight = -biHeight;
248 switch (biBitCount) {
251 ExpandBMP = biBitCount;
259 SDL_SetError(
"%d-bpp BMP images are not supported", biBitCount);
268 switch (biCompression) {
274 switch (biBitCount) {
282#if SDL_BYTEORDER == SDL_BIG_ENDIAN
324 palette = (
surface->format)->palette;
327 if (biClrUsed == 0) {
328 biClrUsed = 1 << biBitCount;
329 }
else if (biClrUsed > (
Uint32)(1 << biBitCount)) {
330 SDL_SetError(
"BMP file has an invalid number of colors");
334 if ((
int) biClrUsed > palette->
ncolors) {
336 int ncolors = biClrUsed;
340 sizeof(*palette->
colors));
348 }
else if ((
int) biClrUsed < palette->ncolors) {
352 for (
i = 0;
i < (int) biClrUsed; ++
i) {
359 for (
i = 0;
i < (int) biClrUsed; ++
i) {
384 bmpPitch = (biWidth + 7) >> 3;
385 pad = (((bmpPitch) % 4) ? (4 - ((bmpPitch) % 4)) : 0);
388 bmpPitch = (biWidth + 1) >> 1;
389 pad = (((bmpPitch) % 4) ? (4 - ((bmpPitch) % 4)) : 0);
405 int shift = (8 - ExpandBMP);
407 if (
i % (8 / ExpandBMP) == 0) {
414 bits[
i] = (pixel >> shift);
415 if (
bits[
i] >= biClrUsed) {
416 SDL_SetError(
"A BMP image contains a pixel with a color out of the palette");
431 if (biBitCount == 8 && palette && biClrUsed < (
Uint32)(1 << biBitCount)) {
433 if (
bits[
i] >= biClrUsed) {
434 SDL_SetError(
"A BMP image contains a pixel with a color out of the palette");
440#if SDL_BYTEORDER == SDL_BIG_ENDIAN
443 switch (biBitCount) {
465 for (
i = 0;
i < pad; ++
i) {
486 if (freesrc &&
src) {
503 char magic[2] = {
'B',
'M' };
528 Sint32 bV4Endpoints[3 * 3] = {0};
612 biBitCount =
surface->format->BitsPerPixel;
617 if (
surface->format->palette) {
618 biClrUsed =
surface->format->palette->ncolors;
625 if (save32bit && !saveLegacyBMP) {
629 bV4RedMask = 0x00ff0000;
630 bV4GreenMask = 0x0000ff00;
631 bV4BlueMask = 0x000000ff;
632 bV4AlphaMask = 0xff000000;
653 if (save32bit && !saveLegacyBMP) {
659 for (
i = 0;
i < 3 * 3;
i++) {
668 if (
surface->format->palette) {
673 ncolors =
surface->format->palette->ncolors;
674 for (
i = 0;
i < ncolors; ++
i) {
694 pad = ((bw % 4) ? (4 - (bw % 4)) : 0);
702 const Uint8 padbyte = 0;
703 for (
i = 0;
i < pad; ++
i) {
726 if (freedst &&
dst) {
#define SDL_assert(condition)
#define SDL_COPY_COLORKEY
int SDL_SaveBMP_RW(SDL_Surface *saveme, SDL_RWops *dst, int freedst)
SDL_Surface * SDL_LoadBMP_RW(SDL_RWops *src, int freesrc)
static void CorrectAlphaChannel(SDL_Surface *surface)
#define LCS_WINDOWS_COLOR_SPACE
#define SDL_UnlockSurface
#define SDL_GetHintBoolean
#define SDL_CreateRGBSurface
#define SDL_ConvertSurface
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
SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x)
SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x)
#define SDL_OutOfMemory()
#define SDL_HINT_BMP_SAVE_LEGACY_FORMAT
Prevent SDL from using version 4 of the bitmap header when saving BMPs.
GLdouble GLdouble GLdouble r
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
GLboolean GLboolean GLboolean b
GLdouble GLdouble GLdouble GLdouble top
GLboolean GLboolean GLboolean GLboolean a
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const void * bits
GLfloat GLfloat GLfloat alpha
int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format)
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)
A collection of pixels used in software blitting.