Black edges when blending transparent Texture

  c++, sdl, sdl-2, textures

I am trying to render a Texture with Alpha-Channel to my Window but it shows up with dark/black edges on some parts of the Texture.

The Image is loaded via the SDL_image library IMG_Load(img_path) and later
converted to a Texture using SDL_CreateTextureFromSurface(img_surface).

The Texture has a Alpha-Channel and I would like to blend it onto the Screen.
I use SDL_SetTextureBlendMode(img_texture, SDL_BLENDMODE_BLEND) to set the Blend-Mode.

The Renderer is created with SDL_CreateRenderer(m_window, -1, SDL_RENDERER_ACCELERATED);.

My Problem does not occur when using SDL_BLENDMODE_ADD but this mode is not suitable for what I am trying to achieve.

I’ve also tried:

  • to write a custom Blend-Mode that emulates the behavior of the BLEND-Mode, same Problem.
  • to change the SDL_HINT_RENDER_SCALE_QUALITY to "0", "1" and "2" with always the same outcome.

This is an Image of my Problem:
Black edges on Texture

This is how it should look like:
Now without any black lines

Why could this happen? I am trying to fix this for hours now and every link on several google-pages is now purple.

The Codebase I am working with is relatively large so I can’t copy/paste anything useful,
because of lack of context.

EDIT:

Sorry, I forgot to mention that this behavior also only appears when
scaling the Image (un-)proportional.

Source: Windows Questions C++

LEAVE A COMMENT