[SDL] RE: pleae help! making a transparant background using SDL_image??/ (Graveyard
David Olofson
david at olofson.net
Sat Feb 28 03:36:41 PST 2004
On Saturday 28 February 2004 01.04, Graveyard Filla wrote:
> thanks a lot david. i didnt know that .jpg was destructive or
> whatever. hell, i didnt even know what a destructive format is.
Well, if you lower the quality when saving a JPG, you'll get the
idea. ;-) What's happening is very similar to what's happening when
encoding an mp3 file: Information that's less important (by some
"smart" definition, which is a major part of the trick) is removed to
make the file smaller.
BTW, both mp3 and JPG are based on the idea of converting the data
from the time/space domain (samples/pixels) to the frequency domain,
sorting the resulting spectra somehow, removing the least significant
ones and then storing the remaining data, possibly after compressing
it using some non-destructive method.
Non-destructive formats OTOH, just rely on patterns and stuff in the
data, to store it more efficiently. Every single bit is restored when
you uncompress the data. Examples of formats that use this type of
compression would be ZIP, bzip2 and RAR. These very algorithms, or
very similar algorithms, are also used "inside" various image
formats, such as GIF - and our friend, PNG.
> thanks for your help. so .png is the preffered file type for this
> kind of stuff?
It's definitely the most suitable format I know about, that is also
widely available.
Formats like PSD (PhotoShop's native format) and XCF (GIMP's native
format) can be really rather nice if you want advanced stuff
(multilayer graphics, animations, easilly configurable blending and
stuff), but those formats are normally uncompressed and perhaps more
seriously, not really standardized. They tend to change between
versions of their respective applications, breaking some or all of
the third-party loaders.
> is it much smaller then .bmp?
Yes, especially compared to the usual uncompressed BMP format. (The
RLE format isn't widely supported, AFAIK.)
> well, i guess ill find
> out for myself.
Yeah, just try it. File sizes depend on the image data, but generally,
I don't think you can get better non-destructive compression than
with PNG, except possibly if you put your data in bzip2 or RAR
archives or something. (Those compress some 10-25% better than most
other popular algorithms on most kinds of data.)
If you go destructive, all bets are off, though. There's basically no
limit to how small files you can have, but it depends entirely on
what kind of graphics you have, and what kind of quality is required.
Note that for simple images with large flat colored areas (as opposed
to gradients and "noise"), nondestructive formats often beat JPG at
both size and quality! That kind of images compress well with typical
nondestructive algorithms, so there's no point in messing up the data
with algorithms tuned for photo-like images.
> thanks man!!!
No problem... :-)
//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
mailing list