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 β€” an SDL_PixelFormat value describing the format of the src pixels. the vibe of the source pixels, if you will.
  • src_colorspace β€” an SDL_Colorspace value describing the colorspace of the src pixels. so we know what color world they're living in πŸ¦‹
  • src_properties β€” an SDL_PropertiesID with extra source color properties, or 0 if 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 β€” an SDL_PixelFormat value describing the format of the dst pixels. what they're gonna become.
  • dst_colorspace β€” an SDL_Colorspace value describing the colorspace of the dst pixels. their new color universe ✨
  • dst_properties β€” an SDL_PropertiesID with extra destination color properties, or 0 if 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