I want to create a button for a game's UI. The background uses a gradient and then I blit a surface on top of the gradient and use SDL_SetColorKey to delete the unwanted pixels. The surfaces are not the same size: the clipping mask is 200 x 50 and the gradient 1 x 50, so I need to stretch the gradient to the same width of the cliping mask, I can't use a wider image because the purpose of doing this is to save memory and storage and using the same gradient image on multiple clipping_masks of different widths.
I found I can use SDL_BlitScaled but I need to blit the surface to itself and it appears to be useless because the surface remains the same size, am I doing something wrong? Is there a way to do it without blitting the surface to itself?
SDL_Rect final_size;
final_size.w = 200;
final_size.h = 50;
final_size.x = 0;
final_size.y = 0;
SDL_BlitScaled(gradient_surface, NULL, gradient_surface, &final_size);
//do some stuff with those textures
SDL_CreateTextureFromSurface(renderer, final_button_surface);