SDL_ConvertS...AndColorspace(3)

✨ NAME ✨

SDL_ConvertSurfaceAndColorspace β€” bestie, it copies an existing surface into a brand new surface with the format and colorspace you picked. glow-up for your pixels πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_surface.h>

SDL_Surface * SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelFormat format, SDL_Palette *palette, SDL_Colorspace colorspace, SDL_PropertiesID props);

πŸ’– DESCRIPTION πŸ’–

okay so here's the tea πŸ«– β€” this function takes an existing surface, converts it to a new format and a new colorspace, and hands you back the new surface. it does literally all the pixel format conversion and colorspace conversion that needs doing. no extra steps, no manual labor, it just handles it.

and the sweetest part? if your original surface has alternate images, the new surface keeps a reference to them too. it's giving "we come as a package deal" πŸŽ€


πŸ¦‹ FUNCTION PARAMETERS πŸ¦‹

  • surface β€” the existing SDL_Surface structure you wanna convert. your main character.
  • format β€” the new pixel format. yes, a whole new look.
  • palette β€” an optional palette to use for indexed formats. can be NULL, no pressure πŸ’œ
  • colorspace β€” the new colorspace. slay.
  • props β€” an SDL_PropertiesID with additional color properties, or 0. extra flair optional.

⭐ RETURN VALUE ⭐

returns the new SDL_Surface structure that gets created β€” iconic ✨ β€” or NULL on failure 😭. if it fails, call SDL_GetError() for more info, it'll tell you what went wrong.


🧚 THREAD SAFETY 🧚

you can call this on different threads with different surfaces. no cap. πŸ’…


🌈 AVAILABILITY 🌈

this function has been available since SDL 3.2.0. so it's not new new, but it's also not ancient. iykyk πŸ¦‹


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole vibe, bestie πŸ’– this lil page came from Simple Directmedia Layer β€” SDL 3.4.18, the SDL_ConvertS...AndColorspace(3) page. go convert something pretty, periodt. πŸŽ€βœ¨

πŸ“¦ where this page comes from