SDL_BlitSurface9Grid(3)
π
SDL_BlitSurface9Grid β the SDL3 FUNCTIONS girlies' fave π
okay bestie, sit DOWN, because this one is genuinely iconic. it's SDL_BlitSurface9Grid, and yes the name is a mouthful but the vibe is immaculate. we're doing a scaled blit using the 9-grid algorithm to a destination surface, which may be of a different format. different format!! we love a flexible queen π«Ά
β¨ NAME β¨
SDL_BlitSurface9Grid β perform a scaled blit using the 9-grid algorithm to a destination surface, which may be of a different format. periodt. π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_surface.h>
bool SDL_BlitSurface9Grid(SDL_Surface *src, const SDL_Rect *srcrect, int left_width, int right_width, int top_height, int bottom_height, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect);
like, look at that signature. eleven arguments. she's high maintenance and she KNOWS it. π
π¦ DESCRIPTION π¦
so here's the tea, and honestly it's kind of genius. the pixels in the source surface get split into a 3x3 grid β using the different corner sizes for each corner β and the sides and center make up the remaining pixels. so far so good? β¨
then the corners get scaled using scale and fit into the corners of the destination rectangle. corners stay cute and crisp. π
then the sides and center are stretched into place to cover the remaining destination rectangle. the way that only the corners get scaled and everything else just stretches? that's the whole trick. it's giving "border image" energy, iykyk. π§
π FUNCTION PARAMETERS π
srcβ theSDL_Surfacestructure to be copied from. your source material, your muse. πsrcrectβ theSDL_Rectstructure representing the rectangle to be used for the 9-grid, orNULLto use the entire surface. yes bestie,NULLis allowed, she'll just take the whole thing. πleft_widthβ the width, in pixels, of the left corners insrcrect. πright_widthβ the width, in pixels, of the right corners insrcrect. πtop_heightβ the height, in pixels, of the top corners insrcrect. β¬οΈbottom_heightβ the height, in pixels, of the bottom corners insrcrect. β¬οΈscaleβ the scale used to transform the corner ofsrcrectinto the corner ofdstrect, or0.0ffor an unscaled blit. (yes, literally0.0f. float, with the f. no cap.) π₯scaleModeβ scale algorithm to be used. she's picky about her scaling, let her choose. πdstβ theSDL_Surfacestructure that is the blit target. where it's all going, the final destination. πdstrectβ theSDL_Rectstructure representing the target rectangle in the destination surface, orNULLto fill the entire surface. again,NULL= whole surface, she's flexible like that. π
β RETURN VALUE β
returns true on success or false on failure β and if it's a false bestie, do NOT just sit there wondering what went wrong. call SDL_GetError() for more information. she will tell you. π
π THREAD SAFETY π
only one thread should be using thesrcanddstsurfaces at any given time. not two. not "well technically they're different surfaces". one. thread. don't make it weird, bestie. π
π AVAILABILITY π
this function is available since SDL 3.2.0. so if you're on something older, no she's not there, don't gaslight yourself. πΈ
π₯ SEE ALSO π₯
SDL_BlitSurface(3)β her simpler sister, also iconic, also worth your time. π
and that's the whole page, bestie!! π this lil' manual page came to you courtesy of Simple Directmedia Layer, rockin' SDL 3.4.18, and it was dated and stamped as SDL_BlitSurface9Grid(3) β go forth and blit those nine grids, you absolute main character. π
β¨π¦
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms