SDL_surface.h
Función SDL_LoadBMP
Sintaxis
SDL_Surface* SDL_LoadBMP(const char* file)
Descripción
Cargar una imagen BMP desde una ruta de archivo.
Parámetros
- file
- El archivo que contiene una imagen BMP.
Valor de retorno
Devuelve un puntero a una nueva estructura SDL_Surface o NULL si hubo un error. Ver SDL_GetError.
Observaciones
La nueva superficie debe ser liberada con SDL_FreeSurface(). Si no se hace así, se producirá una fuga de memoria.
SDL_LoadBMP es una macro de preprocesador definida para llamar a SDL_LoadBMP_RW() con un archivo cerrado automáticamente cargado por SDL_RWFromFile().
Ejemplo
const char *image_path = "myimage.bmp"; SDL_Surface *image = SDL_LoadBMP(image_path); /* Let the user know if the file failed to load */ if (!image) { printf("Failed to load image at %s: %s\n", image_path, SDL_GetError()); return; } /* Do something with image here. */ /* Make sure to eventually release the surface resource */ SDL_FreeSurface(image);