[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] [OT] Sprite/pixel editor



On Friday, Mar 14, 2003, at 12:42 America/New_York, Gerrit Holl wrote:

Pete Shinners schreef op vrijdag 14 maart om 17:44:08 +0000:
Gerrit Holl wrote:
Ah! I didn't know this - I always thought The Gimp was for high-end
image processing, I didn't know one could also do simple drawing with
it :)
gimp is do-able for pixel graphics, but you will definitely find many
frustrations. especially when you go to 256 indexed color modes.
Is 256 indexed color modes necessary to use them as sprites, or only
under certain conditions or when I want to do certain things?
Is it satisfactory to use the web-pallete?
You can color-key without using 256 indexed color sprites. In many cases, using 8 bit paletted graphics these days is pretty worthless, because the CPU fetches 32bit chunks of data at a time. For each pixel you're potentially reading 64 bits of data (32bits to read the 8bit pixel, and 32bits to read the 32 or 24bit RGB code in the palette) from two entirely different memory locations.. this doesn't include possibly swizzling or scaling the palette information (i.e. RGB -> BGR or scaling palette values from 0..63 -> 0..255), not to mention the fact that approximately 3/4 of these reads are NOT 32bit aligned. Even hand-optimized assembly for 8bit palette graphics is likely to do FAR worse than simple C code for blitting 32bit -> 32bit.

In other words, 8 bit graphics are ONLY GOOD if your *video card and windowing system* are both in a native 8bit paletted mode. This is extremely rare these days, so use 32bits. If you only want to use 256 colors, that's fine, but save it as a 32bit PNG (and it's probably still a good idea to convert that surface because the screen may have a different byte order).

256 color paletted graphics files have no advantage over a 32bit PNG that uses only 256 colors.. the way zlib works is somewhat equivalent to what the palette is doing to reduce the size, except it's a lot more sophisticated and will always do better size-wise.

So to reiterate, 8bit graphics are dead, palette effects used to be cool but aren't practical anymore (you almost have to do them with OpenGL textures these days for the same kind of speed), and PNG defeats any reason to use 8bit paletted graphics files.

-bob