david at olofson.net
Mon Nov 10 14:27:01 PST 2003
On Monday 10 November 2003 20.30, Stefan Viljoen wrote:
> >It might also happen that the jpeg compression loses "perfectly
> > black" pixels in favor of "almost black" pixels. Usually you
> > can't see the difference, but SDL will.
> Darn - what file format can I use to store graphics, except JPG,
> that will not "lose" certain colors? JPEG compresses nicely, but if
> it does this it obviously cannot be used for sprites.
I dunno about "nicely", but it *can* be used for sprites if you roll
your own colorkey "cleaner", with some fuzzyness factor. I added that
to Kobo Deluxe after getting tired of correcting the graphics after
some rounding error in GIMP changed the colorkey from 0xff0000 to
That said, I would not recommend jpeg for sprites.
Yes, and that also supports alpha channels. (That's why many 3D games
use it.) However, it doesn't support compression, so it's not a great
choice if you install plain files. You can get away with it if you're
running dirtly from compressed archives, though, like the .pk3 (zip)
files used by Q3 based games, for example.
Like TGA (no [widely supported] compression), but it doesn't support
> What would be best?
I would strongly recommend PNG. It's supported by most serious
applications, it's got efficient non-destructive compression, and it
supports alpha channels.
> I think you might have hit it on the nose here.
> Anybody else got any ideas?
> >>Any ideas anyone? Pointers to where I can get example code
> >> showing how to implement totally transparent pixels in a source
> >> surface?
> >It depends on what you want. Do you want both translucency and
> >colorkeying ? Looking at your message, it seems not. So you
> > shouldn't use both SDL_SetAlpha and SDL_SetColorKey at the same
> > time. Try removing the SDL_SetAlpha call.
> Hmm - did remove the setalpha call - still does not take the
> "black" pixels out.
As expected. Unless you set a non-opaque full surface alpha (the last
argument), it should have no effect, unless there actually is an
alpha channel - and a jpg can't have one.
//David Olofson - Programmer, Composer, Open Source Advocate
.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,... |
`-----------------------------------> http://audiality.org -'
--- http://olofson.net --- http://www.reologica.se ---
More information about the SDL