Strip comments and inline ids onto h*
This commit is contained in:
parent
1997a7846d
commit
0f5f617adb
362 changed files with 2519 additions and 6694 deletions
30
55-01.html
30
55-01.html
|
|
@ -10,16 +10,9 @@
|
|||
<meta name="vspubdate" content="07/01/97" />
|
||||
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
|
||||
|
||||
<title>Michael Abrash's Graphics Programming Black Book Special Edition: Color Modeling in 256-Color Mode</title><!-- HEADER -->
|
||||
<!-- Empty Reference Subhead -->
|
||||
<!--ISBN=1576101746//-->
|
||||
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
|
||||
<!--AUTHOR=Michael Abrash//-->
|
||||
<!--PUBLISHER=The Coriolis Group, Inc.//-->
|
||||
<title>Michael Abrash's Graphics Programming Black Book Special Edition: Color Modeling in 256-Color Mode</title>
|
||||
<meta name="chapter" content="55" />
|
||||
<meta name="pages" content="1031-1035" />
|
||||
<!--UNASSIGNED1//-->
|
||||
<!--UNASSIGNED2//-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
|
@ -37,10 +30,10 @@
|
|||
|
||||
<p><br /></p>
|
||||
|
||||
<h2><a id="Heading1"></a>Chapter 55<br />
|
||||
<h2 id="Heading1">Chapter 55<br />
|
||||
Color Modeling in 256-Color Mode</h2>
|
||||
|
||||
<h3><a id="Heading2"></a>Pondering X-Sharp’s Color Model in an RGB State of Mind</h3>
|
||||
<h3 id="Heading2">Pondering X-Sharp’s Color Model in an RGB State of Mind</h3>
|
||||
|
||||
<p>Once she turned six, my daughter wanted some fairly sophisticated books read to her<i>. Wind in the Willows.</i> <i>Little House on the Prairie.</i> Pretty heady stuff for one so young, and sometimes I wondered how much of it she really understood. As an experiment, during one reading I stopped whenever I came to a word I thought she might not know, and asked her what it meant. One such word was “mulling.”</p>
|
||||
|
||||
|
|
@ -58,7 +51,7 @@
|
|||
|
||||
<p>What does this anecdote tell us about the universe in which we live? Well, it certainly indicates that this universe is inhabited by at least one comedian and one good straight man. Beyond that, though, it can be construed as a parable about the difficulty of defining things properly; for example, consider the complications inherent in the definition of color on a 256-color display adapter such as the VGA. Coincidentally, VGA color modeling just happens to be this chapter’s topic, and the place to start is with color modeling in general.</p>
|
||||
|
||||
<h4 align="left"><a id="Heading3"></a>A Color Model</h4>
|
||||
<h4 align="left" id="Heading3">A Color Model</h4>
|
||||
|
||||
<p>We’ve been developing X-Sharp for several chapters now. In the previous chapter, we added illumination sources and shading; that addition makes it necessary for us to have a general-purpose color model, so that we can display the gradations of color intensity necessary to render illuminated surfaces properly. In other words, when a bright light is shining straight at a green surface, we need to be able to display bright green, and as that light dims or tilts to strike the surface at a shallower angle, we need to be able to display progressively dimmer shades of green.</p>
|
||||
|
||||
|
|
@ -66,15 +59,14 @@
|
|||
|
||||
<p>In the RGB model, a given color is modeled as the mix of specific fractions of full intensities of each of the three color primaries. For example, the brightest possible pure blue is 0.0*R, 0.0*G, 1.0*B. Half-bright cyan is 0.0*R, 0.5*G, 0.5*B. Quarter-bright gray is 0.25*R, 0.25*G, 0.25*B. You can think of RGB color space as being a cube, as shown in Figure 55.1, with any particular color lying somewhere inside or on the cube.</p>
|
||||
|
||||
<p><a id="Fig1"><!-- </A><A HREF="javascript:displayWindow('images/55-01.jpg',406,192 )"> --><img src="images/55-01.jpg" /><br />
|
||||
<!-- </A>
|
||||
<BR><A HREF="javascript:displayWindow('images/55-01.jpg',406,192)"> --><b>Figure 55.1</b></a> <i>The RGB color cube.</i></p>
|
||||
<p><a id="Fig1"><img src="images/55-01.jpg" /><br />
|
||||
<b>Figure 55.1</b></a> <i>The RGB color cube.</i></p>
|
||||
|
||||
<p>RGB is good for modeling colors generated by light sources, because red, green, and blue are the additive primaries; that is, all other colors can be generated by mixing red, green, and blue light sources. They’re also the primaries for color computer displays, and the RGB model maps beautifully onto the display capabilities of 15- and 24-bpp display adapters, which tend to represent pixels as RGB combinations in display memory.</p>
|
||||
|
||||
<p>How, then, are RGB colors represented in X-Sharp? Each color is represented as an RGB triplet, with eight bits each of red, green, and blue resolution, using the structure shown in Listing 55.1.</p>
|
||||
|
||||
<p><b>LISTING 55.1 L55-1.C</b></p><!-- CODE SNIP //-->
|
||||
<p><b>LISTING 55.1 L55-1.C</b></p>
|
||||
<pre>
|
||||
typedef struct -ModelColor {
|
||||
unsigned char Red; /* 255 = max red, 0 = no red */
|
||||
|
|
@ -82,7 +74,7 @@
|
|||
unsigned char Blue; /* 255 = max blue, 0 = no blue */
|
||||
} ModelColor;
|
||||
|
||||
</pre><!-- END CODE SNIP //-->
|
||||
</pre>
|
||||
|
||||
<p>Here, each color is described by three color components—one each for red, green, and blue—and each primary color component is represented by eight bits. Zero intensity of a color component is represented by the value 0, and full intensity is represented by the value 255. This gives us 256 levels of each primary color component, and a total of 16,772,216 possible colors.</p>
|
||||
|
||||
|
|
@ -109,10 +101,6 @@
|
|||
|
||||
<div align="center">
|
||||
Graphics Programming Black Book © 2001 Michael Abrash
|
||||
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed -->
|
||||
<!-- reference_subfoot = footer -->
|
||||
<!-- reference_footer = subfoot -->
|
||||
<!-- BEGIN SUB FOOTER -->
|
||||
<!-- END FOOTER -->
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Reference in a new issue