SDL_CONVERTPIXELSANDCOLORSPACE(3)
β¨ SDL_ConvertPixelsAndColorspace π
okay bestie, gather round, because this one is a baddie from the SDL3 functions crew π«Ά
πΈ NAME πΈ
SDL_ConvertPixelsAndColorspace β copy a block of pixels of one format and colorspace to another format and colorspace. yes. format AND colorspace. both. it's giving glow-up for your pixel data β¨
π SYNOPSIS π
#include <SDL3/SDL_surface.h>
bool SDL_ConvertPixelsAndColorspace(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
look at that signature. it's long. it's dramatic. it's the main character π
π FUNCTION PARAMETERS π
widthβ how wide the block you're copying is, in pixels. width rights, literally πheightβ how tall that block is, in pixels. yes queen, we're doing 2D πsrc_formatβ anSDL_PixelFormatvalue describing the format of thesrcpixels. the vibe of the source pixels, if you will.src_colorspaceβ anSDL_Colorspacevalue describing the colorspace of thesrcpixels. so we know what color world they're living in π¦src_propertiesβ anSDL_PropertiesIDwith extra source color properties, or0if you got nothing to add (valid, we respect it).srcβ a pointer to the source pixels. the originals. the blueprint πsrc_pitchβ the pitch of the source pixels, in bytes. slay, pitch, slay.dst_formatβ anSDL_PixelFormatvalue describing the format of thedstpixels. what they're gonna become.dst_colorspaceβ anSDL_Colorspacevalue describing the colorspace of thedstpixels. their new color universe β¨dst_propertiesβ anSDL_PropertiesIDwith extra destination color properties, or0if it's giving minimal.dstβ a pointer that gets filled in with the new pixel data. this is where the glow-up lands πdst_pitchβ the pitch of the destination pixels, in bytes. consistent queen.
π¦ RETURN VALUE π¦
Returns true on success or false on failure β and if it flops, call SDL_GetError() for more info, because it will tell you what went wrong. no secrets here, bestie π
π₯ THREAD SAFETY π₯
The same destination pixels should not be used from two threads at once. do not do it. that's a fight you will lose π
It is safe to use the same source pixels from multiple threads though, so go off, share the source, it's fine πΈ
β AVAILABILITY β
This function is available since SDL 3.2.0. periodt. don't come at it with an older version, it simply will not be there π
π SEE ALSO π
ok that's the whole page, no notes. go convert some pixels and be iconic about it β¨
mwah π β this page came to you from Simple Directmedia Layer, rockin' SDL 3.4.18, and the header on top was SDL_ConvertPi...AndColorspace(3). stay gorgeous, stay pitch-aligned π«Ά
π¦ 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