spacer

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

home / experts / javascript / column17


Color Bit Depth

Developer News
MicrosoftÂ’s Automated Agent: Can We Talk?
Borland Finally Sells CodeGear
Red Hat Heads For The JON 2.0

The development of computer graphics technology is similar to the development of televisions. First it was black and white for everyone. Then color appeared, but at such a price that only the upper echelon could afford to work in it. Now, almost everyone has a color TV. The same process applies to computer systems. Almost every system is capable of displaying at least 65,000 colors simultaneously. Only two years ago I bought a Packard Bell computer, equipped with a rather dull Cirus Logic graphic card. Since the computer came with a 17-inch monitor, I had to compromise for only 256 colors. Adjusting it to a higher number of colors slowed down the computer, despite the screaming Pentium processor. My personal experience explains why some of your Web site visitors are surfing with 256 colors.

Most designers support the lowest common denominator to avoid image dithering. The advantage of this approach is that it keeps the colors looking as they were intended, and makes the images look smoother. Nevertheless, it sacrifices quality that site visitors equipped with better video systems could enjoy. The following table shows the correlation between color bit depth and the number of colors that can be simultaneously displayed:

Color Bit DepthNumber of Colors
416
8256
1665,536 (High Color)
2416,777,216 (True Color)

The colorDepth property of the screen object reveals the user's color bit depth. This property is very helpful if you're interested in providing the most suitable image for the user's color resolution. For example, you can create two versions of an image -- one with an 8-bit palette (8bit.gif), and the other one with a 16-bit palette (16bit.gif). A simple script offers a dynamic image based on a user's capability to display it:

<SCRIPT LANGUAGE="JavaScript">
<!--

var bName = navigator.appName;
var bVer = parseInt(navigator.appVersion);
var NS2 = (bName == "Netscape" && bVer == 2);
if (window.screen) {
  var url = (screen.colorDepth >= 16) ? "16bit.gif" : "8bit.gif";
  document.write("<IMG SRC='", url, "' HEIGHT='100' WIDTH='300'>");
} else if (!NS2) {
  document.write("<IMG SRC='8bit.gif' HEIGHT='100' WIDTH='300'>");
}

// -->
</SCRIPT>
<NOSCRIPT>
<IMG SRC="8bit.gif" HEIGHT="100" WIDTH="300">
</NOSCRIPT>

Notice the <NOSCRIPT>...</NOSCRIPT> definition which specifies a default image for browsers that cannot execute the script. The conditional statement in the script checks if the browser supports the screen object. If it doesn't, it prints the code for the default image. Navigator 2.0x doesn't support the <NOSCRIPT>...</NOSCRIPT> definition. In other words, it doesn't ignore its content. We set the LANGUAGE attribute of the <SCRIPT> tag to "JavaScript" so that all JavaScript-enabled browsers can execute the script. We then add an additional condition that prevents Navigator 2.0x from printing the image's code in the script. Thanks to this condition, Navigator 2.0x displays the image only once. Also note that this script cannot be used inside a table, because the document.write() method doesn't function properly within table cells.

click here

http://www.internet.com



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: April 7, 1998
Revised: April 7, 1998

URL: http://www.webreference.com/js/column17/colordepth.html