SDL_MapRGB

SDL_MapRGB konvertiert eine RGB Farbe in eine möglichst ähnliche Farbe in dem gegebene Pixel Format.

Signatur

#include <SDL.h>
 
Uint32 SDL_MapRGB(SDL_PixelFormat *fmt, Uint8 r, Uint8 g, Uint8 b);

Parameter

fmt

Das Zielformat (Beispielsweise aus SDL_Surface::format)

r, g, b

Die RGB Farbkomponenten.

Rückgabewert

  • Der Farbwert im Zielformat

Beispiel

Um eine Farbe im Bildschirmformat zu erhalten kann man wie folgt vorgehen:

// Fenster erstellen
SDL_Surface *screen = SDL_SetVideoMode(312, 61, 16, SDL_DOUBLEBUF);
 
// Rote Farbe im Bildschirmformat
Uint32 red_color = SDL_MapRGB(screen->format, 255, 0, 0);