mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-16 09:48:26 +00:00
Simplified SDL_Surface
SDL_Surface has been simplified and internal details are no longer in the public structure. The `format` member of SDL_Surface is now an enumerated pixel format value. You can get the full details of the pixel format by calling `SDL_GetPixelFormatDetails(surface->format)`. You can get the palette associated with the surface by calling SDL_GetSurfacePalette(). You can get the clip rectangle by calling SDL_GetSurfaceClipRect(). SDL_PixelFormat has been renamed SDL_PixelFormatDetails and just describes the pixel format, it does not include a palette for indexed pixel types. SDL_PixelFormatEnum has been renamed SDL_PixelFormat and is used instead of Uint32 for API functions that refer to pixel format by enumerated value. SDL_MapRGB(), SDL_MapRGBA(), SDL_GetRGB(), and SDL_GetRGBA() take an optional palette parameter for indexed color lookups.
This commit is contained in:
parent
40ed098ce8
commit
2ba76dbe80
123 changed files with 1865 additions and 1838 deletions
|
@ -103,15 +103,15 @@ LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent,
|
|||
} else {
|
||||
/* Set transparent pixel as the pixel at (0,0) */
|
||||
if (transparent) {
|
||||
if (temp->format->palette) {
|
||||
const Uint8 bpp = temp->format->bits_per_pixel;
|
||||
if (SDL_GetSurfacePalette(temp)) {
|
||||
const Uint8 bpp = SDL_BITSPERPIXEL(temp->format);
|
||||
const Uint8 mask = (1 << bpp) - 1;
|
||||
if (SDL_PIXELORDER(temp->format->format) == SDL_BITMAPORDER_4321)
|
||||
if (SDL_PIXELORDER(temp->format) == SDL_BITMAPORDER_4321)
|
||||
SDL_SetSurfaceColorKey(temp, SDL_TRUE, (*(Uint8 *)temp->pixels) & mask);
|
||||
else
|
||||
SDL_SetSurfaceColorKey(temp, SDL_TRUE, ((*(Uint8 *)temp->pixels) >> (8 - bpp)) & mask);
|
||||
} else {
|
||||
switch (temp->format->bits_per_pixel) {
|
||||
switch (SDL_BITSPERPIXEL(temp->format)) {
|
||||
case 15:
|
||||
SDL_SetSurfaceColorKey(temp, SDL_TRUE,
|
||||
(*(Uint16 *)temp->pixels) & 0x00007FFF);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue