21 #include "../SDL_internal.h"
40 #define SAVE_32BIT_BMP
47 #define BI_BITFIELDS 3
51 #ifndef LCS_WINDOWS_COLOR_SPACE
53 #define LCS_WINDOWS_COLOR_SPACE 0x57696E20
70 #define COPY_PIXEL(x) spot = &bits[ofs++]; if(spot >= start && spot < end) *spot = (x)
86 Uint8 pixel0 = pixel >> 4;
87 Uint8 pixel1 = pixel & 0x0F;
113 bits -= (ch * pitch);
124 needsPad = (((ch+1)>>1) & 1);
146 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
147 int alphaChannelOffset = 0;
149 int alphaChannelOffset = 3;
251 }
else if (biSize >= 40) {
304 if (biSize > headerSize) {
308 if (biWidth <= 0 || biHeight == 0) {
309 SDL_SetError(
"BMP file with bad dimensions (%dx%d)", biWidth, biHeight);
315 biHeight = -biHeight;
327 switch (biBitCount) {
330 ExpandBMP = biBitCount;
339 SDL_SetError(
"%d-bpp BMP images are not supported", biBitCount);
348 switch (biCompression) {
354 switch (biBitCount) {
362 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
402 palette = (
surface->format)->palette;
415 biClrUsed = 1 << biBitCount;
418 for (
i = 0;
i < (
int) biClrUsed; ++
i) {
425 for (
i = 0;
i < (
int) biClrUsed; ++
i) {
456 bmpPitch = (biWidth + 7) >> 3;
457 pad = (((bmpPitch) % 4) ? (4 - ((bmpPitch) % 4)) : 0);
460 bmpPitch = (biWidth + 1) >> 1;
461 pad = (((bmpPitch) % 4) ? (4 - ((bmpPitch) % 4)) : 0);
477 int shift = (8 - ExpandBMP);
479 if (
i % (8 / ExpandBMP) == 0) {
486 bits[
i] = (pixel >> shift);
487 if (
bits[
i] >= biClrUsed) {
488 SDL_SetError(
"A BMP image contains a pixel with a color out of the palette");
503 if (biBitCount == 8 && palette && biClrUsed < (1u << biBitCount)) {
505 if (
bits[
i] >= biClrUsed) {
506 SDL_SetError(
"A BMP image contains a pixel with a color out of the palette");
512 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
515 switch (biBitCount) {
537 for (
i = 0;
i < pad; ++
i) {
560 if (freesrc &&
src) {
577 char magic[2] = {
'B',
'M' };
602 Sint32 bV4Endpoints[3 * 3] = {0};
610 #ifdef SAVE_32BIT_BMP
686 biBitCount =
surface->format->BitsPerPixel;
691 if (
surface->format->palette) {
692 biClrUsed =
surface->format->palette->ncolors;
699 if (save32bit && !saveLegacyBMP) {
703 bV4RedMask = 0x00ff0000;
704 bV4GreenMask = 0x0000ff00;
705 bV4BlueMask = 0x000000ff;
706 bV4AlphaMask = 0xff000000;
727 if (save32bit && !saveLegacyBMP) {
733 for (
i = 0;
i < 3 * 3;
i++) {
742 if (
surface->format->palette) {
747 ncolors =
surface->format->palette->ncolors;
748 for (
i = 0;
i < ncolors; ++
i) {
768 pad = ((bw % 4) ? (4 - (bw % 4)) : 0);
776 const Uint8 padbyte = 0;
777 for (
i = 0;
i < pad; ++
i) {
800 if (freedst &&
dst) {
#define SDL_assert(condition)
#define SDL_COPY_COLORKEY
int SDL_SaveBMP_RW(SDL_Surface *saveme, SDL_RWops *dst, int freedst)
static void CorrectAlphaChannel(SDL_Surface *surface)
static int readRlePixels(SDL_Surface *surface, SDL_RWops *src, int isRle8)
#define LCS_WINDOWS_COLOR_SPACE
SDL_Surface * SDL_LoadBMP_RW(SDL_RWops *src, int freesrc)
#define SDL_UnlockSurface
#define SDL_GetHintBoolean
#define SDL_CreateRGBSurface
#define SDL_ConvertSurface
SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x)
SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x)
#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 height
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)
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld endif[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1 beq endif SRC MASK if dst_r_bpp DST_R else add endif PF add sub src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head pixblock_size cache_preload_simple process_pixblock_tail pixinterleave dst_w_basereg irp beq endif process_pixblock_tail_head tst beq irp if pixblock_size chunk_size tst beq pixld_src SRC pixld MASK if DST_R else pixld DST_R endif if
A collection of pixels used in software blitting.
typedef int(__stdcall *FARPROC)()