support in the SDL_image library is incorrect. For bit depths < 8 it
should use the palette in the PCX header. The following patch seems
correct to me:
(My newsreader has probably stuffed up the tabbing, but fortunately the
patch is small enough that you can apply it by hand anyway.)
— IMG_pcx.c.orig Wed Feb 21 22:52:40 2001
+++ IMG_pcx.c Wed Feb 21 22:54:32 2001
@@ -152,15 +152,15 @@
/* Look for the palette, if necessary */
switch (surface->format->BitsPerPixel) {
case 1: {
case 1:
case 2:
case 4: {
SDL_Color *colors = surface->format->palette->colors;>From my reading of the PCX spec the palette color handling of the PCX
colors[0].r = 0x00;
colors[0].g = 0x00;
colors[0].b = 0x00;
colors[1].r = 0xFF;
colors[1].g = 0xFF;
colors[1].b = 0xFF;
for (i=0; i<surface->format->palette->ncolors; ++i) {
support in the SDL_image library is incorrect. For bit depths < 8 it
should use the palette in the PCX header.
i’m not sure if this suffices for <8 bit surfaces — we have to decide
whether to expand them to 8bpp or keep them at their original depth and
in the latter case there’s bit/nybble order to think about
in general the support for <8bpp surfaces in SDL is spotty at best and
not really well-defined. it’s something we should think hard about for
1.3>>From my reading of the PCX spec the palette color handling of the PCX
support in the SDL_image library is incorrect. For bit depths < 8 it
should use the palette in the PCX header.
i’m not sure if this suffices for <8 bit surfaces — we have to decide
whether to expand them to 8bpp or keep them at their original depth and
in the latter case there’s bit/nybble order to think about
in general the support for <8bpp surfaces in SDL is spotty at best and
not really well-defined. it’s something we should think hard about for
1.3
What has been done in the past is expand the surfaces to 8 bpp with
a 256 entry palette that only has colors in the first 2^N entries.
This works very well with SDL.
See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software> >>From my reading of the PCX spec the palette color handling of the PCX
More than one pixel/byte… Great fun! Reminds me of the bitplane
based Amiga graphics chipset. hehe
However, it’s not all that different from doing 24 bits/3 bytes/pixel
efficiently with 32 or 64 bit operations. I’m just wondering if it’s
worth the effort… When do you have too low bandwidth or too hard
memory constraints to deal with 8 bit surfaces?
Not arguing against <8 bit/pixel support, though - it’s just not very
likely that I’ll be the one to hack the code.
//David
.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia | ----------------------> http://www.linuxaudiodev.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |--------------------------------------> david at linuxdj.com -'On Thursday 22 February 2001 12:18, Mattias Engdeg?rd wrote:
From my reading of the PCX spec the palette color handling of the
PCX
support in the SDL_image library is incorrect. For bit depths < 8
it should use the palette in the PCX header.
i’m not sure if this suffices for <8 bit surfaces — we have to
decide whether to expand them to 8bpp or keep them at their
original depth and in the latter case there’s bit/nybble order to
think about
in general the support for <8bpp surfaces in SDL is spotty at best
and not really well-defined. it’s something we should think hard
about for 1.3
What has been done in the past is expand the surfaces to 8 bpp with
a 256 entry palette that only has colors in the first 2^N entries.
This works very well with SDL.
indeed and it reduces surprises for the user. On the other hand we probably
want better support for <8bpp surfaces in 1.3 (mainly for low-depth devices
such as handhelds)
indeed and it reduces surprises for the user. On the other hand we probably
want better support for <8bpp surfaces in 1.3 (mainly for low-depth devices
such as handhelds)
Yup.
-Sam Lantinga, Lead Programmer, Loki Entertainment Software
indeed and it reduces surprises for the user. On the other hand we probably
want better support for <8bpp surfaces in 1.3 (mainly for low-depth devices
such as handhelds)
While I appreciate all the design discussions, I have an immediate
problem in that a 1 bit PCX file I’m loading with SDL_image doesn’t get
the palette loaded.
Is the patch I sent sufficient to go in to SDL_image? If not can someone
please tell me what’s wrong with it so I can write one that is.
MikeOn 22 Feb 2001 09:47:28 -0800, Sam Lantinga wrote:
i’m not sure if this suffices for <8 bit surfaces — we have to decide
whether to expand them to 8bpp or keep them at their original depth and
in the latter case there’s bit/nybble order to think about
What has been done in the past is expand the surfaces to 8 bpp with
a 256 entry palette that only has colors in the first 2^N entries.
This works very well with SDL.
While I appreciate all the design discussions, I have an immediate
problem in that a 1 bit PCX file I’m loading with SDL_image doesn’t get
the palette loaded.
would you prefer a <8bpp file to be loaded as a 1 or 8bpp surface? should
we settle on a bit/nybble order for all surfaces or augment the SDL_format
struct to contain a flag for this? what about the bitmap unit, should it
be a fixed 8 or 32 bits or perhaps another parameter (like XImage has it)?
i’d be happy to hard-code a format (and it would really help the
implementation) if someone can convince me that all low-depth framebuffers
that we would like to support have the same format. for the record,
atari st planar format is out, and so are the speccy’s three venetian blinds
Is the patch I sent sufficient to go in to SDL_image? If not can someone
please tell me what’s wrong with it so I can write one that is.
no worry, i’ll whip up a solution as soon as i’ve decided what it should be
should be; i’ll probably convert it to a less controversial 8bpp for the
time being
i’m trying to do this properly, so can someone please tell me what
depth/plane combinations of PCX files are actually used?
it seems that the set includes
The first two cases are obvious and already supported in SDL_image. It seems
that Gimp also supports 1 and 4 planes, 1 bit/plane, and netpbm can
read/write the 1 plane, 1,2,4 bits/plane format. The pcx docs I have
(from www.wotsit.org) also mentions planar representation with a fourth
"intensity" plane, but i’m not sure how to interpret that
While I appreciate all the design discussions, I have an immediate
problem in that a 1 bit PCX file I’m loading with SDL_image doesn’t get
the palette loaded.
would you prefer a <8bpp file to be loaded as a 1 or 8bpp surface? should
we settle on a bit/nybble order for all surfaces or augment the SDL_format
struct to contain a flag for this? what about the bitmap unit, should it
be a fixed 8 or 32 bits or perhaps another parameter (like XImage has it)?
For my purposes, as long as I can color-key blit it into an RGBA surface
then I don’t care (it’s for texture building for OpenGL). Practically
speaking I think it’s reasonable given the current SDL implementation
to convert <8bpp images into 8bpp surfaces, but I’ll leave the details
to the SDL gurus as there may be issues with (e.g.) handheld devices that
need considering.
no worry, i’ll whip up a solution as soon as i’ve decided what it should be
should be; i’ll probably convert it to a less controversial 8bpp for the
time being
i’m trying to do this properly, so can someone please tell me what
depth/plane combinations of PCX files are actually used?
I’m working off the netpbm format sets, as it’s the most comprehensive
PCX handler I’ve been able to get hold of in terms of handling all of
the in-the-wild PCX images I’ve found. I’ll mail you a couple of sample
images but they’re probably nothing you can’t create yourself with netpbm.
(from www.wotsit.org) also mentions planar representation with a fourth
"intensity" plane, but i’m not sure how to interpret that
No idea.
MikeOn 26 Feb 2001 07:31:39 -0800, Mattias Engdeg?rd wrote:
here’s the patch, sorry for the delay. there’s also a small update to
showimage to use a hwpalette when needed (I’ll see if I can find a way
around this later)
I didn’t bother to add support for packed-pixel types that gimp won’t
read, assuming them to be rare (none of the test images I received
were of that kind). thanks everyone for the help