How to turn an argb pixel array into an SDL surface?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


How to turn an argb pixel array into an SDL surface?



Using C and SDL2, I have a pixel array with an ARGB8888 format.


Uint32 *pixels = (Uint32 *) malloc (sizeof(Uint32)*(Uint32)windowWidth*(Uint32)windowHeight);



I want to put all that pixel information into a new SDL_Surface ready to save as a .bmp. How do I do this?


SDL_Surface


.bmp



I'm unsure because new surfaces have RGBA8888 format and sdl convert functions require an existing surface to convert to a new surface. And there is no function which simply passes all pixel array values to a surface, so I know it will involve some sort of loop which assigns the pixels one by one.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived