ich arbeite mich derzeit in ResourceFiles ein. Dabei lade ich X Byte aus einer Datei und will das entsprechende Bild daraus erstellen. Ungetestet würde ich das damit machen:
Code: Alles auswählen
SDL_Surface* getImage(const char* data, std::size_t size) {
// Read RAW Data from Buffered Data
SDL_RWops* raw = SDL_RWFromMem(data, size);
// Create Image
SDL_Surface* image = SDL_LoadBMP_RW(raw, 1);
if (image == NULL) {
throw std::runtime_error(SDL_GetError());
}
// Free RAW Data
SDL_FreeRW(raw);
// Convert Image Format
image = SDL_DisplayFormat(image);
if (image == NULL) {
throw std::runtime_error(SDL_GetError());
}
// Set Color Key for Alpha Transparency
Uint32 colorkey = SDL_MapRGB(image->format, 0, 0xFF, 0xFF);
SDL_SetColorKey(image, SDL_SRCCOLORKEY, colorkey);
// Return Image
return image;
}
Danke im Vorraus
