Olá fórum.. estava precisando disso para um trabalho do colégio, o problema é que o projeto que estou usando só tem a função de carregar
os arquivos que já estavam lá e não tem um para criar os arquivos de imagem..
Code:
SDL_Surface* SDLClass::load_surface(int i)
{
SDL_Surface *tmp;
fstream file;
char loc[120];
memset(&loc, 0, sizeof(loc));
sprintf(loc, "images/0%d.sf", i);
file.open (loc, ios::in|ios::binary);
if (!file.is_open()) {
fprintf(stderr, "failed to open %s!", loc);
exit(1);
}
if (loaded != 0)
file.seekg(loaded, ios::beg);
long h, w, tmpi;
file.read((char *)&h, sizeof(h));
file.read((char *)&tmpi, sizeof(tmpi));
file.read((char *)&w, sizeof(w));
loaded += 12;
h = h >> 2;
w = w >> 2;
tmp = SDL_CreateRGBSurface(SDL_HWSURFACE, w, h, 24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
if (tmp == NULL) {
printf("failed to create RGB Surface");
return 0;
}
file.read((char *)tmp->pixels, h * (w *3));
loaded += h * (w *3);
file.close();
printf("Surface Loaded\n");
return SDL_DisplayFormat( tmp );
}