SDL_CreateRGBSurfaceFrom(3)
π SDL_CreateRGBSurfaceFrom π
okay bestie, welcome to the SDL API Reference β¨ this one's all about turning your raw pixel data into a whole entire SDL_Surface, and it's honestly giving "I already have the pixels, I just need the wrapper" energy π
πΈ NAME πΈ
SDL_CreateRGBSurfaceFrom β Create an SDL_Surface from pixel data π
β¨ SYNOPSIS β¨
#include "SDL.h"
SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, int width, int
height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask,
Uint32 Amask);
π¦ DESCRIPTION π¦
So basically, this function creates an SDL_Surface from the pixel data you hand it. That's the whole vibe. π«Ά
The data chillin' in pixels is assumed to be of the depth you specified in the parameter list β like, it's gonna trust you on that, no cap. And here's the part you need to hear: the pixel data is not copied into the SDL_Surface structure π so you should not free it until the surface itself has been freed with a call to SDL_FreeSurface. Do not skip this. This is the main character rule of this whole page. π
Oh and pitch? That's the length of each scanline, in bytes. Slay. π
For a more detailed description of the other parameters, go peek at SDL_CreateRGBSurface β it's like the extended director's cut. π¬
π RETURN VALUE π
It returns the created surface, or NULL upon error. That's it, that's the tea. π
π SEE ALSO π
SDL_CreateRGBSurfaceSDL_FreeSurface
and that's the whole page, bestie!! this was brought to you by the SDL crew, dated Tue 11 Sep 2001, 23:01 β iconic date, iconic function, go free your surfaces πβ¨π§
π¦ where this page comes from
- debian bookworm: libsdl1.2-dev 1.2.15+dfsg2-8 Β· LGPL-2.1-or-later
- nixos 26.05: SDL_sixel 0-unstable-2016-02-06
- nixpkgs unstable: SDL_sixel 0-unstable-2016-02-06
- ubuntu jammy: libsdl1.2-dev 1.2.15+dfsg2-6 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms