8bit greyscale surfaces

What would the most optimum way of changing the SDL api to allow 8bit greyscale
surfaces be? I was thinking the surface’s pallete pointer == NULL, but might
screw up pre-existing programs… what do you guys think?–
Patrick “Diablo-D3” McFarland || unknown at panax.com
"Computer games don’t affect kids; I mean if Pac-Man affected us as kids, we’d
all be running around in darkened rooms, munching magic pills and listening to
repetitive electronic music." – Kristian Wilson, Nintendo, Inc, 1989
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040107/834f875b/attachment.pgp

Hey patrick, what about changing the pallette to 256 shades of grey? (;> ----- Original Message -----

From: unknown@panax.com (Patrick McFarland)
To:
Sent: Wednesday, January 07, 2004 4:58 PM
Subject: [SDL] 8bit greyscale surfaces

Unacceptable. That means I have a 8bit paletted image, instead of an actual
greyscale image. Theres a bunch of reasons why this is bad, including needing
to load four bytes instead of one (pixel value (as pallete entry) and r, g, b, instead of just the pixel value (as intensity)); and the fact that I no longer
have any easy way of knowing its greyscale (I already hashed this out with LIM
on irc, and there just isnt any easy way of doing this that squashes most/all
corner cases.)

What I want to do is extend the SDL api to allow 8bit greyscale, instead of
screwing around with paletted surfaces.

I’m hoping for a responce from Sam, actually.On 07-Jan-2004, Alan Wolfe wrote:

Hey patrick, what about changing the pallette to 256 shades of grey? (;


Patrick “Diablo-D3” McFarland || unknown at panax.com
"Computer games don’t affect kids; I mean if Pac-Man affected us as kids, we’d
all be running around in darkened rooms, munching magic pills and listening to
repetitive electronic music." – Kristian Wilson, Nintendo, Inc, 1989
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040107/486bea7e/attachment.pgp

Hey patrick, what about changing the pallette to 256 shades of grey? (;

Unacceptable. That means I have a 8bit paletted image, instead of an actual
greyscale image. Theres a bunch of reasons why this is bad, including needing
to load four bytes instead of one (pixel value (as pallete entry) and r, g, b, instead of just the pixel value (as intensity)); and the fact that I no longer
have any easy way of knowing its greyscale (I already hashed this out with LIM
on irc, and there just isnt any easy way of doing this that squashes most/all
corner cases.)

What I want to do is extend the SDL api to allow 8bit greyscale, instead of
screwing around with paletted surfaces.

You have me very confused. I am guessing, since you have never said
this, that you want to add an 8 bit gray scale surface type to SDL. Is
that correct? If so, how deep does it need to go into SDL? Is that data
going directly to the screen? Or, is it just for internal use?

Originally I thought you were asking how to implement an 8 bit gray
scale image. Which made no sense at all coming from you.

	Bob PendletonOn Wed, 2004-01-07 at 21:09, Patrick McFarland wrote:

On 07-Jan-2004, Alan Wolfe wrote:

I’m hoping for a responce from Sam, actually.

±--------------------------------------+

[…]

You have me very confused. I am guessing, since you have never said
this, that you want to add an 8 bit gray scale surface type to
SDL. Is that correct? If so, how deep does it need to go into SDL?
Is that data going directly to the screen? Or, is it just for
internal use?

My guess is the point is to have a “native” SDL gray scale format, to
allow some optimizations in the blitters. (Less data and fewer
channels.)

How about something like this:
* 8 bpp no longer implies palettized.
* Using only the red channel gives you a grayscale image.
* Using red + alpha gives you a grayscale + alpha image.

Anyway, I think some more blitting features (like ways to colorize a
grayscale image when blitting it to an RGB surface) would be needed
to make this really useful.

Sounds like SDL 2.x stuff to me. Would fit in perfectly with OpenGL
(glSDL) and Direct3D, BTW.

//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.nethttp://www.reologica.se —On Thursday 08 January 2004 18.56, Bob Pendleton wrote:

im kind of curious, why do you want 8 bit greyscale support?> ----- Original Message -----

From: david@olofson.net (David Olofson)
To:
Sent: Thursday, January 08, 2004 10:49 AM
Subject: Re: [SDL] 8bit greyscale surfaces

On Thursday 08 January 2004 18.56, Bob Pendleton wrote:
[…]

You have me very confused. I am guessing, since you have never said
this, that you want to add an 8 bit gray scale surface type to
SDL. Is that correct? If so, how deep does it need to go into SDL?
Is that data going directly to the screen? Or, is it just for
internal use?

My guess is the point is to have a “native” SDL gray scale format, to
allow some optimizations in the blitters. (Less data and fewer
channels.)

How about something like this:

  • 8 bpp no longer implies palettized.
  • Using only the red channel gives you a grayscale image.
  • Using red + alpha gives you a grayscale + alpha image.

Anyway, I think some more blitting features (like ways to colorize a
grayscale image when blitting it to an RGB surface) would be needed
to make this really useful.

Sounds like SDL 2.x stuff to me. Would fit in perfectly with OpenGL
(glSDL) and Direct3D, BTW.

//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.nethttp://www.reologica.se


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Perhaps SDL is being targetted to a BW PDA or some other system?
SDL has cropped up in some interesting places in the past.
Not everyone is using it for games on their Pentium desktops :wink:

-bill!On Thu, Jan 08, 2004 at 01:46:07PM -0800, Alan Wolfe wrote:

im kind of curious, why do you want 8 bit greyscale support?

Use SDL stuff to generate and manipulate heightmaps! :wink:

-bill!
bill at newbreedsoftware.com Got kids? Get Tux Paint!
http://newbreedsoftware.com/bill/ http://newbreedsoftware.com/tuxpaint/On Thu, Jan 08, 2004 at 07:49:05PM +0100, David Olofson wrote:

How about something like this:

  • 8 bpp no longer implies palettized.
  • Using only the red channel gives you a grayscale image.
  • Using red + alpha gives you a grayscale + alpha image.

Anyway, I think some more blitting features (like ways to colorize a
grayscale image when blitting it to an RGB surface) would be needed
to make this really useful.

Well, that technically can be done now. Its easy to hack 8bit surface ->
greyscale texture, just by passing whats supposed to be the palette index
pixel data (ie, whats stored in surface->pixels) directly to glTexImage2D, and
telling it is greyscale data.

But, of course, this is a hack, and you lose the ability to tell the
difference between 8bit paletted images and greyscale without some outside
human readable setting, due to the fact that a bpp of 8 now always ==
greyscale. There is no easy and consistant way of checking the difference
when you only know that the surface is 8 bpp.On 08-Jan-2004, Bill Kendrick wrote:

Use SDL stuff to generate and manipulate heightmaps! :wink:


Patrick “Diablo-D3” McFarland || unknown at panax.com
"Computer games don’t affect kids; I mean if Pac-Man affected us as kids, we’d
all be running around in darkened rooms, munching magic pills and listening to
repetitive electronic music." – Kristian Wilson, Nintendo, Inc, 1989
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040108/62e0d2c3/attachment.pgp

Well, as I said in the post before this one, surface -> gl texture stuff is
a very major use for this, in addition to optimizing greyscale blitting
operations; why use four bytes for every pixel (which paletted images need,
one for the palette index, and three for the color in the palette), when you
can just use one?On 08-Jan-2004, Alan Wolfe wrote:

im kind of curious, why do you want 8 bit greyscale support?


Patrick “Diablo-D3” McFarland || unknown at panax.com
"Computer games don’t affect kids; I mean if Pac-Man affected us as kids, we’d
all be running around in darkened rooms, munching magic pills and listening to
repetitive electronic music." – Kristian Wilson, Nintendo, Inc, 1989
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040108/f7da1069/attachment.pgp

Um, paletted images need three (four, actually) bytes for every color, not every
pixel; a constant 1024 byte overhead per surface (which is negligible in
many applications).

I use 8-bit paletted images in OpenGL for grayscale (G8), as well as for
faking useful things like 8-bit G4A4 (4 bits of gray, 4 bits of alpha)
and G7A1 (7 bits of gray, one bit of alpha), and it works very well.
G4A4 is particularly useful for bitmap fonts; we put dark borders
on edges (for readability), keep alpha channel antialiasing and still fit
it in 8bpp.On Thu, Jan 08, 2004 at 07:08:52PM -0500, Patrick McFarland wrote:

Well, as I said in the post before this one, surface -> gl texture stuff is
a very major use for this, in addition to optimizing greyscale blitting
operations; why use four bytes for every pixel (which paletted images need,
one for the palette index, and three for the color in the palette), when you
can just use one?


Glenn Maynard