Yeah, it’s perhaps not spelled out terribly explicitly, but that’s a matter
of style. What I’m saying is that there are two types of PNGs for your
issue. There are PNGs with no alpha channel (RGB), and those with an alpha
channel (RGBA). When you load an RGB PNG, it acts just like you loaded a
BMP. You can apply colorkey transparency because there’s no alpha channel
(the extra byte or so of transparency info in each pixel). If you load an
RGBA PNG, then there is an alpha channel. This alpha info automatically
overrides any other form of transparency (such as colorkeying). The
different forms of transparency cannot be used simultaneously. If you try
to use colorkeying on an RGBA surface, it won’t have any effect. My guess
was that this was your issue.
The extra alpha channel info is added to a PNG when it is created, say, by
the GIMP or Photoshop. Hence, if one of your PNGs is RGBA (like if you
didn’t notice that you used a little bit of transparency in the graphics
editor or you got the image from someone else who did this), then you get
two types of PNGs that you’re trying to treat the same way. One can use
colorkeying, one will not. Some possible (independent) solutions are:
- Use an alpha channel for all of your transparency and do not use
- Make sure that your graphics editor saves the files as RGB (with no alpha
channel). Use colorkey.
- Convert your SDL_Surfaces to RGB to strip out unintentional alpha
channels. Use colorkey.
Numbers 1 and 2 are done in the graphics editor. Number 3 is done with
Jonny DOn Sat, Oct 2, 2010 at 11:53 PM, bala_48225 <bala_48225 at yahoo.com> wrote:
So, what was the problem, exactly? It still sounds like you had an alpha
channel that you didn’t know about. Using SDL_DisplayFormat would remove
the alpha channel and make it work, of course.
I have no doubt that’s true about the alpha channel that I don’t know
about, or completely understand how to use it, despite reading your tutorial
a few times, since you yourself don’t just totally “give it” to the people
quite like your colleague Mr. Jones, with his "here’s a working program"
kind of thing. From what I can tell in your Blue Dino tutorial, a person
should set the alpha channel instead of setting the normal transparency, but
without everything being spelled out, or, “set the alpha channel to the same
colors as your transparency color would be”, then I could do it. Just, which
code would be replaced with which code, for example? I’ll figure it out
eventually if I don’t get that level of info right here from you. I was
actually thinking the other day about how alpha blending would be good to
darken the screen after the game is over. At any rate, I did feel like a
conquering hero when I fixed that transparency and runny screens issue, for
sure! Because of using 0 .BMPs, All my images total less than 1MB, which is
nice! Being classy is important, no need for excess space usage–but for CPU
usage, that’s another story. 800 FPS is a good speed, ja? -B
P.S. I didn’t know you responded till just now.
SDL mailing list
SDL at lists.libsdl.org