Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problems with SDL_BlitSurface from PNG to transparent surface #51

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Closed

problems with SDL_BlitSurface from PNG to transparent surface #51

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Labels
invalid This doesn't seem right

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

Reported in version: 1.2.9
Reported for operating system, platform: Linux, x86

Comments on the original bug report:

On 2006-01-23 04:32:53 +0000, Davide Coppola wrote:

I have tried to blit a PNG with an alpha channel on a transparent surface created using format data from the image, the result of SDL_BlitSurface() is just nothing!

I have solved my problem using memcpy() if the image has the same dimension of the surface and using getpixel()/putpixel() if the image is smaller than the surface (or if I need a partial blit).

this source shows the problem:
http://mars.sourceforge.net/SDL/trans_bug/trans_test1.c
this are my solutions:
http://mars.sourceforge.net/SDL/trans_bug/trans_test2.c
and this is the package with all the sources and data:
http://mars.sourceforge.net/SDL/trans_bug.tar.gz

I hope this could help you.

On 2006-01-27 11:23:21 +0000, Ryan C. Gordon wrote:

Setting Sam as "QA Contact" on all bugs (even resolved ones) so he'll definitely be in the loop to any further discussion here about SDL.

--ryan.

On 2006-03-20 02:40:09 +0000, Sam Lantinga wrote:

This is not technically a bug.

According to the documentation:

  • RGBA->RGBA:
  • SDL_SRCALPHA set:
    
  •  alpha-blend (using the source alpha channel) the RGB values;
    
  •  leave destination alpha untouched. [Note: is this correct?]
    
  •  SDL_SRCCOLORKEY ignored.
    
  • SDL_SRCALPHA not set:
    
  •  copy all of RGBA to the destination.
    

SDL_DisplayFormatAlpha() turns on SDL_SRCALPHA by default (to enable blending)

What I did to fix this in your test program was just add SDL_SetAlpha(img, 0, 0) before the blit onto window. Of course a manual memcpy works just as well. :)

Thanks for the great test case!

On 2006-03-20 04:20:11 +0000, Davide Coppola wrote:

(In reply to comment # 2)

I confirm that your solution works well, and I'm glad of this ;)

Just a note for someone interested:
if you want to blit img on screen after you have set SDL_SetAlpha(img, 0, 0), you have to set SDL_SetAlpha(img, SDL_SRCALPHA, 0).

Best regards.

@SDLBugzilla SDLBugzilla added bug invalid This doesn't seem right labels Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant