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_CreateRGBSurface
  • SDL_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