# Simple question from a beginner

**URL:** <https://discourse.libsdl.org/t/simple-question-from-a-beginner/1245>\
**Category:** SDL Development\
**Created:** [November 17, 1999, 4:32pm UTC](https://discourse.libsdl.org/t/simple-question-from-a-beginner/1245 "1999-11-17T16:32:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave\_Ashley](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/d/a9a28c/32.png) [@Dave\_Ashley](https://discourse.libsdl.org/u/Dave_Ashley)\
**Post date:** [November 17, 1999, 4:32pm UTC](https://discourse.libsdl.org/t/simple-question-from-a-beginner/1245/1 "1999-11-17T16:32:46Z")

</div>

Support for 8 bit might not be so important in the future as 16+ bit depths  
become the norm. I’m basically doing the minimum I can get by with on  
my projects. You might set up a 332 palette (3 bits red, 3 bits green, 2 bits  
blue) and force people to live with how awful that looks under 8 bits.

I can’t answer your question though. My guess would be SDL would be smart  
enough to do color mapping for you on the fly…

It is easy enough to do an experiment though.\>I’ve just started using SDL and I’ve a simple question to ask.

> I’m writing a little program using 8-bit video depth, and I tried to  
> visualize two different images with two different palettes : it seems to  
> work fine. So that’s my question : in a 8bpp mode can I use a different  
> palette from each image ??
> 
> Thanks for your help,  
> Andrea.

---

<div class="post-metadata">

**Author:** ![Andrea](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/c37758/32.png) [@Andrea](https://discourse.libsdl.org/u/Andrea)\
**Post date:** [November 17, 1999, 5:24pm UTC](https://discourse.libsdl.org/t/simple-question-from-a-beginner/1245/2 "1999-11-17T17:24:15Z")

</div>

Hi all!

I’ve just started using SDL and I’ve a simple question to ask.  
I’m writing a little program using 8-bit video depth, and I tried to  
visualize two different images with two different palettes : it seems to  
work fine. So that’s my question : in a 8bpp mode can I use a different  
palette from each image ??

Thanks for your help,  
Andrea.

---

<div class="post-metadata">

**Author:** ![Frank\_Ramsay](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/f/65b543/32.png) [@Frank\_Ramsay](https://discourse.libsdl.org/u/Frank_Ramsay)\
**Post date:** [November 17, 1999, 6:26pm UTC](https://discourse.libsdl.org/t/simple-question-from-a-beginner/1245/3 "1999-11-17T18:26:10Z")

</div>

Yes you can have multiple palettes, but you have to keep track of them  
yourself.

```
		-fjr

```

Andrea wrote:\>

> Hi all!
> 
> I’ve just started using SDL and I’ve a simple question to ask.  
> I’m writing a little program using 8-bit video depth, and I tried to  
> visualize two different images with two different palettes : it seems to  
> work fine. So that’s my question : in a 8bpp mode can I use a different  
> palette from each image ??
> 
> Thanks for your help,  
> Andrea.

---

<div class="post-metadata">

**Author:** ![Loren\_Osborn](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/l/7c8e57/32.png) [@Loren\_Osborn](https://discourse.libsdl.org/u/Loren_Osborn)\
**Post date:** [November 17, 1999, 7:44pm UTC](https://discourse.libsdl.org/t/simple-question-from-a-beginner/1245/4 "1999-11-17T19:44:14Z")

</div>

> Support for 8 bit might not be so important in the future as 16+ bit depths  
> become the norm. I’m basically doing the minimum I can get by with on  
> my projects. You might set up a 332 palette (3 bits red, 3 bits green, 2 bits  
> blue) and force people to live with how awful that looks under 8 bits.
> 
> I can’t answer your question though. My guess would be SDL would be smart  
> enough to do color mapping for you on the fly…
> 
> It is easy enough to do an experiment though.

3-3-2 can work okay, but it is rather clunky… I remember using 6_7_6 colors  
back when I did stuff in 8-bit color… That, coupled with dithering, produced  
passable results… even at 320x200… (bare in mind I’m talking 1992 and  
fairly dated hardware even then…) The math is a bit slower, because the  
color axises aren’t on bit boundries, but it depends on what you need…

-Loren

---

<div class="post-metadata">

**Author:** ![Lea\_Anthony](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/l/df788c/32.png) [@Lea\_Anthony](https://discourse.libsdl.org/u/Lea_Anthony)\
**Post date:** [November 18, 1999, 10:10am UTC](https://discourse.libsdl.org/t/simple-question-from-a-beginner/1245/5 "1999-11-18T10:10:35Z")

</div>

Hi Andrea,

I can’t answer your question, but I have a few pointers to determine if you  
are displaying more than 256 cols on an 8bit screen (how the heck could you  
do that?). Firstly, have you got a utility to display the umber of unique  
colours in a bitmap? That’d be a good start. Check if the number of unique  
cols in bitmap 1 + unique cols in bitmap 2 is greater than 256. If it is,  
I’m dumbfounded. If it isn’t, I’d guess SDL sets non used palette entries,  
or it quantises the colours to the display pixel format (non palettised  
mode). Does SDL support non palettised 8 bit modes?

Duh, I’ve got a cold and can’t think straight…

Cheers,

-Lea.

Andrea wrote:\> Hi all!

> I’ve just started using SDL and I’ve a simple question to ask.  
> I’m writing a little program using 8-bit video depth, and I tried to  
> visualize two different images with two different palettes : it seems to  
> work fine. So that’s my question : in a 8bpp mode can I use a different  
> palette from each image ??
> 
> Thanks for your help,  
> Andrea.

---

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [November 18, 1999, 4:17pm UTC](https://discourse.libsdl.org/t/simple-question-from-a-beginner/1245/6 "1999-11-18T16:17:02Z")

</div>

> Does SDL support non palettised 8 bit modes?

No. 🙂  
-Sam Lantinga (slouken at [devolution.com](http://devolution.com))

Lead Programmer, Loki Entertainment Software–  
“Any sufficiently advanced bug is indistinguishable from a feature”  
– Rich Kulawiec

---

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [November 18, 1999, 4:18pm UTC](https://discourse.libsdl.org/t/simple-question-from-a-beginner/1245/7 "1999-11-18T16:18:55Z")

</div>

> I’ve just started using SDL and I’ve a simple question to ask.  
> I’m writing a little program using 8-bit video depth, and I tried to  
> visualize two different images with two different palettes : it seems to  
> work fine. So that’s my question : in a 8bpp mode can I use a different  
> palette from each image ??

SDL will map your images to the display as best it can.  
If you are using an 8-bpp mode, the best thing to do is manage palettes  
yourself by setting the appropriate one in the display whenever you change  
image palettes. Many people create a single palette for most of their  
artwork, and display using that palette.

See SDL\_SetColors()

```
-Sam Lantinga (slouken at devolution.com)

```

Lead Programmer, Loki Entertainment Software–  
“Any sufficiently advanced bug is indistinguishable from a feature”  
– Rich Kulawiec

---

<div class="post-metadata">

**Author:** ![Andrea](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/c37758/32.png) [@Andrea](https://discourse.libsdl.org/u/Andrea)\
**Post date:** [November 19, 1999, 12:47pm UTC](https://discourse.libsdl.org/t/simple-question-from-a-beginner/1245/8 "1999-11-19T12:47:47Z")

</div>

> Newsgroups: loki.open-source.sdl
> 
> Hi Lea,  
> Tanks for your answer. I counted the number of unique colors in my bitmaps,  
> and it’s less than 256. I think you’re right saying that SDL sets the empty  
> palette entries to show both bitmaps correctly. Sorry for the dumb question,  
> but I’m still learning how to manage images.  
> Thanks a lot.
> 
> Andrea.
> 
> > Hi Andrea,
> > 
> > I can’t answer your question, but I have a few pointers to determine if  
> > you  
> > are displaying more than 256 cols on an 8bit screen (how the heck could  
> > you  
> > do that?). Firstly, have you got a utility to display the umber of unique  
> > colours in a bitmap? That’d be a good start. Check if the number of unique  
> > cols in bitmap 1 + unique cols in bitmap 2 is greater than 256. If it is,  
> > I’m dumbfounded. If it isn’t, I’d guess SDL sets non used palette entries,  
> > or it quantises the colours to the display pixel format (non palettised  
> > mode). Does SDL support non palettised 8 bit modes?
> > 
> > Duh, I’ve got a cold and can’t think straight…
> > 
> > Cheers,
> > 
> > -Lea.
> 
> > ----- Original Message -----  
> > From: [lea.anthony@prismtechnologies.com](mailto:lea.anthony@prismtechnologies.com) (Lea Anthony)  
> > To:   
> > Sent: Thursday, November 18, 1999 11:10 AM  
> > Subject: [SDL] Re: Simple question from a beginner

---

<div class="post-metadata">

**Author:** ![Marian\_Krivos](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/m/eb8c5e/32.png) [@Marian\_Krivos](https://discourse.libsdl.org/u/Marian_Krivos)\
**Post date:** [November 22, 1999, 4:25pm UTC](https://discourse.libsdl.org/t/simple-question-from-a-beginner/1245/9 "1999-11-22T16:25:51Z")

</div>

Hi lea & Andrea,

Try download my graphics library from [www.tutok.sk/fastgl](http://www.tutok.sk/fastgl) and see class  
Bitmap and CreateColor() in [fastgl.cc](http://fastgl.cc) source file. Its have very powerful  
colors management.

Marian K.
