SDL_PremultiplySurfaceAlpha(3)

πŸ’– SDL_PremultiplySurfaceAlpha(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual πŸŽ€ β€” today's main character is SDL_PremultiplySurfaceAlpha, and she is so useful, no cap.


✨ NAME ✨

SDL_PremultiplySurfaceAlpha β€” premultiply the alpha in a surface. that's it, that's the whole vibe πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_surface.h>

bool SDL_PremultiplySurfaceAlpha(SDL_Surface *surface, bool linear);

πŸ¦‹ DESCRIPTION πŸ¦‹

This is safe to use with src == dst, but not for other overlapping areas.

so like, if your source and destination are literally the same thing, you're golden ✨. but overlapping-but-not-identical areas? nope, that's giving chaos, don't do it πŸ’€


πŸ‘‘ FUNCTION PARAMETERS πŸ‘‘

  • surface β€” the surface to modify. this is the glow-up recipient, the one getting the alpha premultiplied 🫢
  • linear β€” pass true to convert from sRGB to linear space for the alpha multiplication, or false to do the multiplication in sRGB space. pick your fighter, both are valid 🌈

⭐ RETURN VALUE ⭐

Returns true on success or false on failure β€” and if it fails, call SDL_GetError() for more information, because she will tell you what went wrong, bestie 😭


🧚 THREAD SAFETY 🧚

This function can be called on different threads with different surfaces. so like, multitasking queen energy, as long as everybody's got their own surface πŸ‘‘

not me gently reminding you: different surfaces on different threads. sharing one surface across threads is not the move πŸ™ˆ

πŸ’œ AVAILABILITY πŸ’œ

This function is available since SDL 3.2.0. so if you're on anything older, it's giving dust, upgrade fr fr πŸ“¦βœ¨


and that's the whole page, periodt. πŸ’…

simple directmedia layer, SDL 3.4.18, SDL_PremultiplySurfaceAlpha(3) β€” mwah, love u, go premultiply responsibly πŸ’–πŸŒ·πŸ“

πŸ“¦ where this page comes from