SDL_ConvertPixels(3)

πŸ’– SDL_ConvertPixels(3) πŸ’–

okay so bestie, welcome to the SDL3 FUNCTIONS corner of the manual, and today's main character is SDL_ConvertPixels πŸ’…


✨ NAME ✨

SDL_ConvertPixels β€” copy a block of pixels of one format to another format. literally just glow-up-ing your pixels into a different format, no cap πŸ¦‹


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_surface.h>

bool SDL_ConvertPixels(int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch);

πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • width β€” the width of the block you're copying, in pixels. yes queen, measured in pixels, not bytes, don't get it twisted πŸ™ˆ
  • height β€” the height of the block to copy, in pixels. also pixels. we stay consistent πŸ’…
  • src_format β€” an SDL_PixelFormat value describing what format the src pixels are in. iykyk 🧚
  • src β€” a pointer to the source pixels. the originals, the before pic πŸ’–
  • src_pitch β€” the pitch of the source pixels, in bytes. (pitch = how many bytes per row, bestie, it's giving row stride energy)
  • dst_format β€” an SDL_PixelFormat value describing what format the dst pixels should be. the after pic ✨
  • dst β€” a pointer to be filled in with new pixel data. this is where the glow-up lands 🫢
  • dst_pitch β€” the pitch of the destination pixels, in bytes. again: bytes, not pixels, ok? 😭

πŸ”₯ RETURN VALUE πŸ”₯

Returns true on success or false on failure β€” and if it's giving false, call SDL_GetError() for more information. she will tell you what went wrong, fr fr πŸ’€


πŸ‘‘ THREAD SAFETY πŸ‘‘

The same destination pixels should not be used from two threads at once.

but listen β€” it is safe to use the same source pixels from multiple threads. so many readers, exactly one writer. that's the vibe check 🌈


⭐ AVAILABILITY ⭐

This function is available since SDL 3.2.0. iconic behaviour, truly πŸ‘‘


πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page bestie, you ate πŸ’…βœ¨

this lil gem comes to you from the Simple Directmedia Layer, version SDL 3.4.18, and it's the SDL_ConvertPixels(3) page β€” mwah, take care of her πŸŽ€πŸ’–

πŸ“¦ where this page comes from