IMG_bmp.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. SDL_image: An example image loading library for use with SDL
  3. Copyright (C) 1999, 2000, 2001 Sam Lantinga
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with this library; if not, write to the Free
  14. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  15. Sam Lantinga
  16. slouken@libsdl.org
  17. */
  18. /* $Id: IMG_bmp.c,v 1.1 2004/07/21 16:24:11 paigoddess Exp $ */
  19. /* This is a BMP image file loading framework */
  20. #include <stdio.h>
  21. #include <string.h>
  22. #include "SDL_image.h"
  23. /* See if an image is contained in a data source */
  24. int IMG_isBMP(SDL_RWops *src)
  25. {
  26. int is_BMP;
  27. char magic[2];
  28. is_BMP = 0;
  29. if ( SDL_RWread(src, magic, 2, 1) ) {
  30. if ( strncmp(magic, "BM", 2) == 0 ) {
  31. is_BMP = 1;
  32. }
  33. }
  34. return(is_BMP);
  35. }
  36. /* Load a BMP type image from an SDL datasource */
  37. SDL_Surface *IMG_LoadBMP_RW(SDL_RWops *src)
  38. {
  39. return(SDL_LoadBMP_RW(src, 0));
  40. }