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 existingSDL_Surfacestructure 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 beNULL, no pressure πcolorspaceβ the new colorspace. slay.propsβ anSDL_PropertiesIDwith additional color properties, or0. 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
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms