M
hallo leute,
ich versuche gerade ein sdl-surface in eine datei zu speichern und das surface dann wieder auszulesen, nur leider sehen ich nach dem flippen nichts auf dem bildschirm. vielleicht hat ja einer ne idee.
das bild besitzt die werte wie sie bei SDL_CreateRGBSurfaceFrom eingetragen sind, habe ich kontrolliert.
danke
msp
void save_image_to_file(SDL_Surface* img)
{
FILE* datei = fopen("test.img","w");
fprintf(datei,"%s",img->pixels);
fclose(datei);
printf("%d,%d,%d,%d,%u",img->w,img->h,img->format->BitsPerPixel,img->pitch,img->format->Amask);
}
SDL_Surface* load_image_from_file()
{
Uint32 rmask, gmask, bmask, amask;
/* SDL interprets each pixel as a 32-bit number, so our masks must depend
on the endianness (byte order) of the machine */
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0xff000000;
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
#else
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
#endif
FILE* datei = fopen("test.img","r");
char* surf = new char[21000000];
fscanf(datei,"%s",surf);
printf("surf: %s",surf);
fclose(datei);
return SDL_CreateRGBSurfaceFrom(surf, 200, 132, 16, 400, rmask, gmask, bmask, amask);
}