#include <stdio.h>
#include <stdlib.h>
#include <SDL.h>
void createBMP(void* image, int width, int height, const char* filename) {
SDL_Surface* surface = SDL_CreateRGBSurfaceFrom(image, width, height, 32, width * 4, 0xFF0000, 0x00FF00, 0x0000FF, 0);
if (surface == NULL) {
printf("Error al crear la superficie SDL: %s\n", SDL_GetError());
return;
}
if (SDL_SaveBMP(surface, filename) != 0) {
printf("Error al guardar el archivo BMP: %s\n", SDL_GetError());
}
SDL_FreeSurface(surface);
}
int main() {
// Ejemplo de imagen en memoria
int width = 640;
int height = 480;
void* image = malloc(width * height * 4); // Supongamos que la imagen tiene un formato RGBA
// Llenar la imagen con datos
// Crear el archivo BMP
createBMP(image, width, height, "imagen.bmp");
free(image);
return 0;
}