SDL_GetMasksForPixelFormat(3)

πŸ’… SDL_GetMasksForPixelFormat πŸ’…

okay bestie, welcome to the SDL_GetMasksForPixelFormat(3) page β€” yes it lives in the SDL3 FUNCTIONS crew, and yes it's about pixels, which means it's automatically iconic. πŸ’–

✨ NAME ✨

SDL_GetMasksForPixelFormat β€” converts one of the enumerated pixel formats into a bpp value plus RGBA masks. that's the whole job. she's a translator. a pixel-format-to-masks translator. slay. 🌈


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_pixels.h>

bool SDL_GetMasksForPixelFormat(SDL_PixelFormat format, int *bpp, Uint32 *Rmask, Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask);

look at her. six whole parameters. main character energy fr fr. πŸ‘‘


🫢 FUNCTION PARAMETERS 🫢

  • format β€” one of the SDL_PixelFormat values. just hand her the format you're curious about and she'll spill everything.
  • bpp β€” a bits-per-pixel value; usually 15, 16, or 32. lowkey those three are the usual suspects.
  • Rmask β€” a pointer that gets filled in with the red mask for the format. πŸ”΄
  • Gmask β€” a pointer that gets filled in with the green mask for the format. 🟒
  • Bmask β€” a pointer that gets filled in with the blue mask for the format. πŸ”΅
  • Amask β€” a pointer that gets filled in with the alpha mask for the format. the transparency one. the vibe one. πŸ«₯
bestie these are pointers, so she's writing into them. don't pass her something uninitialized and then act surprised, i'm begging. 😭

πŸ’€ RETURN VALUE πŸ’€

Returns true on success or false on failure. and if it fails?? call SDL_GetError() for more information, because she will NOT be explaining herself unprompted. πŸ™ˆ


🧚 THREAD SAFETY 🧚

It is safe to call this function from any thread. yes, any thread. she does not gatekeep, she does not play favourites, she is safe everywhere. periodt. πŸ’œ


⭐ AVAILABILITY ⭐

This function is available since SDL 3.2.0. so if you're on something older, no masks for you, sorry babe. πŸŽ€


🌸 SEE ALSO 🌸

  • SDL_GetPixelFormatForMasks(3) β€” the reverse direction, the uno reverse card, the "okay but what format do these masks make" question. iykyk. πŸ¦‹

and that's the page!! this lil writeup came to you from Simple Directmedia Layer, version SDL 3.4.18, and it's literally the SDL_GetMasksForPixelFormat(3) manpage but make it cute. go forth and mask responsibly, bestie πŸ’–βœ¨πŸ“

πŸ“¦ where this page comes from