comparison src/video/SDL_bmp.c @ 1330:450721ad5436

It's now possible to build SDL without any C runtime at all on Windows, using Visual C++ 2005
author Sam Lantinga <slouken@libsdl.org>
date Mon, 06 Feb 2006 08:28:51 +0000
parents bc67bbf87818
children 3692456e7b0f
comparison
equal deleted inserted replaced
1329:bc67bbf87818 1330:450721ad5436
32 BMP is a good alternative. 32 BMP is a good alternative.
33 33
34 This code currently supports Win32 DIBs in uncompressed 8 and 24 bpp. 34 This code currently supports Win32 DIBs in uncompressed 8 and 24 bpp.
35 */ 35 */
36 36
37 #include <string.h>
38
39 #include "SDL_error.h" 37 #include "SDL_error.h"
40 #include "SDL_video.h" 38 #include "SDL_video.h"
41 #include "SDL_endian.h" 39 #include "SDL_endian.h"
40 #include "SDL_string.h"
42 41
43 /* Compression encodings for BMP files */ 42 /* Compression encodings for BMP files */
44 #ifndef BI_RGB 43 #ifndef BI_RGB
45 #define BI_RGB 0 44 #define BI_RGB 0
46 #define BI_RLE8 1 45 #define BI_RLE8 1
236 } 235 }
237 palette->ncolors = biClrUsed; 236 palette->ncolors = biClrUsed;
238 } 237 }
239 238
240 /* Read the surface pixels. Note that the bmp image is upside down */ 239 /* Read the surface pixels. Note that the bmp image is upside down */
241 if ( SDL_RWseek(src, fp_offset+bfOffBits, SEEK_SET) < 0 ) { 240 if ( SDL_RWseek(src, fp_offset+bfOffBits, RW_SEEK_SET) < 0 ) {
242 SDL_Error(SDL_EFSEEK); 241 SDL_Error(SDL_EFSEEK);
243 was_error = 1; 242 was_error = 1;
244 goto done; 243 goto done;
245 } 244 }
246 bits = (Uint8 *)surface->pixels+(surface->h*surface->pitch); 245 bits = (Uint8 *)surface->pixels+(surface->h*surface->pitch);
317 } 316 }
318 } 317 }
319 done: 318 done:
320 if ( was_error ) { 319 if ( was_error ) {
321 if ( src ) { 320 if ( src ) {
322 SDL_RWseek(src, fp_offset, SEEK_SET); 321 SDL_RWseek(src, fp_offset, RW_SEEK_SET);
323 } 322 }
324 if ( surface ) { 323 if ( surface ) {
325 SDL_FreeSurface(surface); 324 SDL_FreeSurface(surface);
326 } 325 }
327 surface = NULL; 326 surface = NULL;
473 } 472 }
474 } 473 }
475 474
476 /* Write the bitmap offset */ 475 /* Write the bitmap offset */
477 bfOffBits = SDL_RWtell(dst)-fp_offset; 476 bfOffBits = SDL_RWtell(dst)-fp_offset;
478 if ( SDL_RWseek(dst, fp_offset+10, SEEK_SET) < 0 ) { 477 if ( SDL_RWseek(dst, fp_offset+10, RW_SEEK_SET) < 0 ) {
479 SDL_Error(SDL_EFSEEK); 478 SDL_Error(SDL_EFSEEK);
480 } 479 }
481 SDL_WriteLE32(dst, bfOffBits); 480 SDL_WriteLE32(dst, bfOffBits);
482 if ( SDL_RWseek(dst, fp_offset+bfOffBits, SEEK_SET) < 0 ) { 481 if ( SDL_RWseek(dst, fp_offset+bfOffBits, RW_SEEK_SET) < 0 ) {
483 SDL_Error(SDL_EFSEEK); 482 SDL_Error(SDL_EFSEEK);
484 } 483 }
485 484
486 /* Write the bitmap image upside down */ 485 /* Write the bitmap image upside down */
487 bits = (Uint8 *)surface->pixels+(surface->h*surface->pitch); 486 bits = (Uint8 *)surface->pixels+(surface->h*surface->pitch);
500 } 499 }
501 } 500 }
502 501
503 /* Write the BMP file size */ 502 /* Write the BMP file size */
504 bfSize = SDL_RWtell(dst)-fp_offset; 503 bfSize = SDL_RWtell(dst)-fp_offset;
505 if ( SDL_RWseek(dst, fp_offset+2, SEEK_SET) < 0 ) { 504 if ( SDL_RWseek(dst, fp_offset+2, RW_SEEK_SET) < 0 ) {
506 SDL_Error(SDL_EFSEEK); 505 SDL_Error(SDL_EFSEEK);
507 } 506 }
508 SDL_WriteLE32(dst, bfSize); 507 SDL_WriteLE32(dst, bfSize);
509 if ( SDL_RWseek(dst, fp_offset+bfSize, SEEK_SET) < 0 ) { 508 if ( SDL_RWseek(dst, fp_offset+bfSize, RW_SEEK_SET) < 0 ) {
510 SDL_Error(SDL_EFSEEK); 509 SDL_Error(SDL_EFSEEK);
511 } 510 }
512 511
513 /* Close it up.. */ 512 /* Close it up.. */
514 SDL_UnlockSurface(surface); 513 SDL_UnlockSurface(surface);