| Summary: | SDL_UpperBlitScaled ignores alpha | ||
|---|---|---|---|
| Product: | SDL | Reporter: | ahelper2 |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | WAITING --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | philipp.wiesemann, scott.e.graves, sylvain.becker |
| Version: | HG 2.0 | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Attachments: |
test case
image updated testcase |
||
This bug doesn't seem to be isolated to Linux x86_64. I'm experiencing the same issue on WinXP/32, Win7/32 and Win7/64. For now, I've substituted SDL_SoftStretch() but there is a significant performance hit using this method. I've been unsuccessful to date resolving the issue in source but the issue still exists in the latest source snap 2.0.0-6894 as well as trunk. Glad to help out with examples. Yes, a simple example would be great. Thanks! Created attachment 3073 [details]
test case
Created attachment 3074 [details]
image
Here's a testcase and it's image, tested on latest and also SDL 2.0.0. On ubuntu converting to ARGB8888 and RGBA8888.
It seems to me it SDL_UpperBlit and SDL_UpperBlitScaled behave correctly.
But with SDL_SoftStretch, Alpha is copied instead of being blended.
But two things seems wrong :
- SDL_SoftStretch, Alpha is copied instead of being blended.
- Depending on the position of SDL_UpperBlit :
SDL_UpperBlit(surf, NULL, surf_target1, &clip); // Normal Blit
SDL_SoftStretch(surf, NULL, surf_target3, &clip); // Aie, no scaled !
SDL_UpperBlitScaled(surf, NULL, surf_target2, &clip); // Aie, no scaled !
or
SDL_SoftStretch(surf, NULL, surf_target3, &clip);
SDL_UpperBlitScaled(surf, NULL, surf_target2, &clip);
SDL_UpperBlit(surf, NULL, surf_target1, &clip); // Normal Blit
The following blit are scaled or not !
I'd say some "InvalidMap is missing somewhere ...
SDL_SoftStrech() behave as if SDL_BLENDMODE_NONE was enabled on source surface, instread of SDL_BLENDMOD_BLEND Created attachment 3075 [details]
updated testcase
I got mistaken because UpperBlit modified the destination rect parameter. hence the strange behavior.
About, SDL_SoftStrech(), I think this is the default behavior looking at the code as it does a plain copy, no blending.
|
SDL_UpperBlitScaled is able to scale a surface and blit it, but it ignores the alpha value of the source surface. Instead of alpha blending, it blits the source surface with a white background. Given: SDL_Surface *target; // target surface, RGBA SDL_Surface *src; // Contains RGBA surface float scale = 0.5; // Scaling factor SDL_Rect clip = {0,0,(int)(src->w * scale), (int)(src->h * scale)}; This blits it properly with alpha blending: SDL_Surface *copy = SDL_ConvertSurface(src, target->format, 0); // Ensure that format matches SDL_UpperBlit(copy, nullptr, target, &clip); SDL_FreeSurface(copy); This scales it, but alpha is ignored, giving a white background to blitted surfaces: SDL_Surface *copy = SDL_ConvertSurface(src, target->format, 0); // Ensure that format matches SDL_UpperBlitScaled(copy, nullptr, target, &clip); SDL_FreeSurface(copy); Additional Info: SDL revision: 6328:9a65b2bd4e01