spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / web / dev / graphics / palette

Which Color Palette?

Biz Resources
Network Security Services
VoIP
CRM Software
Developer News
MicrosoftÂ’s Automated Agent: Can We Talk?
Borland Finally Sells CodeGear
Red Hat Heads For The JON 2.0

Optimizing Web Graphics

There is a 216-color palette that will not dither on Mac and Windows PCs.

There is much discussion and confusion on the Web about color palettes. There is, in fact, no one universal 8-bit palette that will not dither on all platforms. There is, however, a 216-color palette that will not dither on most.

The problem is that different platforms use different color palettes. Netscape and other applications use a 256-color palette on Macs and X-windows, a reduced palette on Windows, and UNIX varies the palette according to how many colors are available. Note: Netscape 4.0 Mac uses the 216-color "non-dithering" palette, not the Mac's system palette.


Figure 2 - The Netscape
216-color palette
216-Color GIF

The Windows Palette

Windows 3.x was designed around the ubiquitous 256-color VGA graphics board. Windows computers reserve 20 of these colors for system use; the first and last ten colors. Netscape reserves an additional 13 colors for its logo, which leaves 223 colors available to the user. Netscape's programmers reduced this figure to 216 colors (Figure 2), which is the closest cube root below 223 [Ve95, NC95].


The Netscape Color Cube (PC/Mac)

Figure 3 - The Netscape
6x6x6 Color Cube (PC/Mac)
PC/Macintosh color table

The 6x6x6 color matrix (or "cube") shown in Figure 3 is used by PC and Macintosh versions of Netscape Navigator 1.1 on 8-bit (256-color) displays. Graphics using this 216-color palette will not dither on either platform. Netscape 2.x adds one refinement: a GIF appearing as the only image on a page will be shown in its exact requested colors. If there's more than one image on a page, Netscape dithers to the 216-color cube.

The cube consists of 216 colors, 6 colors for the red component, 6 for the green, and 6 for the blue. Each basic hue in this RGB color space ranges from 0 to 255 in decimal or from 00 to ff in hexadecimal. The colors in the figure use RGB values of 00, 33, 66, 99, cc, and ff (hex) or 0, 51, 102, 153, 204, and 255 (decimal). The increment is no coincidence, 51 is 1/5 of 255 which gives 6 evenly spaced points along each axis.

Thanks to Rick Levine of Sun Microsystems [Le96] for the use of his color cubes.


The UNIX Palette

Netscape for UNIX, however, automatically adjusts the size of its color cube depending on how many colors are available at launch. It may use a 6x6x6, 5x5x5, or even a 4x4x4 color cube, depending on how many colors are free.

Figure 4 - The Netscape
5x5x5 Color Cube (UNIX)
Unix color table

The 5x5x5 color matrix (or "cube") shown in Figure 4 is most often used by UNIX versions of Netscape Navigator on 8-bit displays. Graphics using this 125-color palette will not dither on UNIX machines.

The cube consists of 125 colors, 5 colors for the red component, 5 for the green, and 5 for the blue. Each basic hue in this RGB color space ranges from 0 to 255 in decimal or from 00 to ff in hexadecimal. The colors in the figure use RGB values of 00, 40, 80, bf, and ff (hex) or 0, 64, 128, 191, and 255 (decimal).

On 8-bit PC and Macintosh platforms, all but eight colors in this table will be dithered (the cube's eight corners composed of 00s and ffs). So even when you use the 216-color cube, most Unix users will still see most of your colors dither [Le96].

The general approach on the Web has been to ignore UNIX users and design for the majority. Authors frequently cite the 216-color palette as a universal non-dithering palette when it is in fact non-dithering for only Macs and Windows.

The 216-color non-dithering palette

You can download the Mac or PC non-dithering CLUT right here. To use it, unbinhex and unstuff (Mac) it or unzip it (PC) and save to a convenient place. You'll see a file called 216clut. This file can double as both a CLUT (color lookup table) or a swatch in Photoshop. To avoid dithering on 8-bit machines you can either start out using only colors from this special palette (picking colors from this color swatch) or map your images to it (using the same file as a CLUT).

Load non-dithering palette as a Swatch

Figure 5 - 216-color swatch

To make it easy to pick non-dithering colors for your art you can make this non-dithering color table the default color swatch. First load the 216-color CLUT as a swatch (Windows/Swatches/Load swatch) and then select save. This swatch becomes the default and appears each time you start up Photoshop (Figure 5). Use this non-dithering swatch when creating graphics from scratch.

Mapping an image to the 216-color CLUT

To map the non-dithering CLUT to an existing image, first fill all of the flat-color areas with colors from the 216-color palette (see above). Any other colors in the non-flat areas of your image will dither on some systems, which is usually fine. Now convert the image from RGB to indexed colors and load the special 216-color CLUT (Mode/Indexed Colors/Custom Palette/Dither = None). Select load in the CLUT dialog box and select the special 216clut you just downloaded (Figure 6). Photoshop will reduce the image to 216 colors and map the image to this palette. Of course, during this color mapping some posterization may occur.

216-color CLUT

Figure 6 - Custom 216-color CLUT

You can also create your own 216 color table from figure 3 (Netscape 216-color cube). First save the image to a file on your computer. Open it in Photoshop, select Mode/Color Table, then select Save (Figure 6). These days, look for a modern image editing program (Imageready, Fireworks, etc) that includes a Web palette for you, to make this step unnecessary.

See also Webmonkey's tutorial on the Web-safe palette, they say there are really only 22 colors that are truly Web-safe.


Comments are welcome



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Win Server ‘08
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES
webref The latest from WebReference.com Browse >
Perl Pragma Primer · Implement Drag and Drop in Your Web Apps: Part 2 · How to Create an Ajax Autocomplete Text Field: Part 5
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
SQL Server 2005 Express Edition - Part 22 - Upgrading from Microsoft SQL Server Desktop Engine (MSDE) · Vyatta: Downgrades that Pay Off · NetMotion Brings Cross-Network Support to Wireless VoIP


Created: June 10, 1996
Revised: Dec. 13, 2000

URL: http://webreference.com/dev/graphics/palette.html