Copy alpha channel

Hello, I am making a game where I’m trying to smoothly blend textures. I used SDL_Image to load a png with an alpha channel, and I would like to copy the alpha channel from another PNG to this one. Is there a way to do this?

I think you can.
First render the png that you loaded with SDL_BLENDMODE_NONE to a new target texture to exactly copy the loaded png, this is important because you can’t render to a texture created by SDL_Image.

SDL_BlendMode mode = SDL_ComposeCustomBlendMode(
                           SDL_BLENDFACTOR_ZERO,
                           SDL_BLENDFACTOR_ONE,  // keep color of the target texture
                           SDL_BLENDOPERATION_ADD,
                           SDL_BLENDFACTOR_ONE, // keep src alpha channel 
                           SDL_BLENDFACTOR_ZERO, // set alpha channel of target texture to zero
                           SDL_BLENDOPERATION_ADD);

Use the blend mode above as the blend mode of the png that you want to copy the alpha channel from and render again to the target texture, this code is not tested though.

Hey, the blendmode just copied the destination texture, can you try to figure out what went wrong?