📄 chap01.htm
字号:
<html>
<!-- Mirrored from www.lgui.net/column/book1/chap01.htm by HTTrack Website Copier/3.x [XR&CO'2005], Mon, 21 Mar 2005 13:19:34 GMT -->
<head>
<meta http-equiv=Content-Type content="text/html; charset=GB2312">
<link rel=Edit-Time-Data href="http://www-scf.usc.edu/~flv/ipbookchap01.files/editdata.mso" >
<title>第1章 Windows位图和调色板</title>
<style><!--
.Normal
{text-align:justify;
text-justify:inter-ideograph;
text-indent:0pt;
line-height:normal;
font-size:10.5pt;
font-family:"Times New Roman";}
.a
{text-align:center;
text-indent:0pt;
line-height:20.0pt;
font-size:12.0pt;
font-family:"Times New Roman";}
-->
</style>
</head>
<body lang=ZH-CN link=blue vlink=purple class="Normal" bgcolor="#FFFFFF">
<div style='layout-grid:15.6pt'>
<h1><a name="_Toc486331863"></a><a name="_Toc486332863"></a><a
name="_Toc486338972"></a><a name="_Toc454810837"></a><a name="_Toc454856611"><span><span>第<span
lang=EN-US>1</span></span></span></a><span><span><span style='font-family:黑体;"Times New Roman"'>章</span><span
lang=EN-US> Windows</span></span></span><span><span><span style='font-family:黑体;"Times New Roman"'>位图和调色板</span></span></span></h1>
<h2> <span
lang=EN-US>1.1</span> <span lang=EN-US> </span><a name="_Toc486331864"></a><a
name="_Toc486332864"></a><a name="_Toc486338973"></a><a name="_Toc454810838"></a><a
name="_Toc454856612"><span><span>位图和调色板的概念</span></span></a></h2>
<p style='line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>如今</span><span lang=EN-US>Windows(3.x</span><span
style='font-family:宋体;"Times New Roman"'>以及</span><span lang=EN-US>95</span><span style='font-family:
宋体;"Times New Roman"'>,</span><span
lang=EN-US>98</span><span style='font-family:宋体;
"Times New Roman"'>,</span><span lang=EN-US>NT)</span><span
style='font-family:宋体;"Times New Roman"'>系列已经成为绝大多数用户使用的操作系统,它比</span><span lang=EN-US>DOS</span><span
style='font-family:宋体;"Times New Roman"'>成功的一个重要因素是它可视化的漂亮界面。那么</span><span lang=EN-US>Windows</span><span
style='font-family:宋体;"Times New Roman"'>是如何显示图象的呢?这就要谈到位图</span><span lang=EN-US>(bitmap)</span><span
style='font-family:宋体;"Times New Roman"'>。</span></p>
<p style='line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>我们知道,普通的显示器屏幕是由许许多多点构成的,我们称之为象素。显示时采用扫描的方法:电子枪每次从左到右扫描一行,为每个象素着色,然后从上到下这样扫描若干行,就扫过了一屏。为了防止闪烁,每秒要重复上述过程几十次。例如我们常说的屏幕分辨率为</span><span
lang=EN-US>640×480</span><span style='font-family:宋体;"Times New Roman";"Times New Roman"'>,刷新频率为</span><span
lang=EN-US>70Hz</span><span style='font-family:宋体;
"Times New Roman"'>,意思是说每行要扫描</span><span lang=EN-US>640</span><span
style='font-family:宋体;"Times New Roman"'>个象素,一共有</span><span lang=EN-US>480</span><span
style='font-family:宋体;"Times New Roman"'>行,每秒重复扫描屏幕</span><span lang=EN-US>70</span><span
style='font-family:宋体;"Times New Roman"'>次。</span></p>
<p style='line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>我们称这种显示器为位映象设备。所谓位映象,就是指一个二维的象素矩阵,而位图就是采用位映象方法显示和存储的图象。举个例子,图</span><span
lang=EN-US>1.1</span><span style='font-family:宋体;
"Times New Roman"'>是一幅普通的黑白位图,图</span><span lang=EN-US>1.2</span><span
style='font-family:宋体;"Times New Roman"'>是被放大后的图,图中每个方格代表了一个象素。我们可以看到:整个骷髅就是由这样一些黑点和白点组成的。</span></p>
<table border=0 cellspacing=0 cellpadding=0>
<tr>
<td width=276 valign=bottom class="Normal">
<p class=a style='line-height:18.0pt'><span lang=EN-US> <img width=48 height=48
src="chap01.files/image001.gif" v:shapes="_x0000_i1026"> </span></p>
<p class=a style='line-height:18.0pt'><b><span style='font-family:宋体;
"Times New Roman"'>图</span>1.1 </b><b><span
style='font-family:宋体;"Times New Roman"'>骷髅</span></b></p>
</td>
<td width=276 valign=bottom class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><b><span
lang=EN-US> <img width=157 height=177
src="chap01.files/image003.jpg" v:shapes="_x0000_i1025"> </span></b></p>
<p align=center style='text-align:center;line-height:18.0pt'><b><span
style='font-family:宋体;"Times New Roman"'>图</span>1.2
</b><b><span style='font-family:
宋体;"Times New Roman"'>放大后的骷髅位图</span></b></p>
</td>
</tr>
</table>
<p style='line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>那么,彩色图是怎么回事呢?</span></p>
<p style='line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>我们先来说说三元色</span><span lang=EN-US>RGB</span><span
style='font-family:宋体;"Times New Roman"'>概念。</span></p>
<p style='line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>我们知道,自然界中的所有颜色都可以由红、绿、蓝</span><span lang=EN-US>(R</span><span
style='font-family:宋体;"Times New Roman"'>,</span><span lang=EN-US>G</span><span style='font-family:
宋体;"Times New Roman"'>,</span><span
lang=EN-US>B)</span><span style='font-family:宋体;
"Times New Roman"'>组合而成。有的颜色含有红色成分多一些,如深红;有的含有红色成分少一些,如浅红。针对含有红色成分的多少,可以分成</span><span
lang=EN-US>0</span><span style='font-family:宋体;
"Times New Roman"'>到</span><span lang=EN-US>255</span><span
style='font-family:宋体;"Times New Roman"'>共</span><span lang=EN-US>256</span><span style='font-family:
宋体;"Times New Roman"'>个等级,</span><span
lang=EN-US>0</span><span style='font-family:宋体;
"Times New Roman"'>级表示不含红色成分;</span><span lang=EN-US>255</span><span
style='font-family:宋体;"Times New Roman"'>级表示含有</span><span lang=EN-US>100%</span><span
style='font-family:宋体;"Times New Roman"'>的红色成分。同样,绿色和蓝色也被分成</span><span lang=EN-US>256</span><span
style='font-family:宋体;"Times New Roman"'>级。这种分级概念称为量化。</span></p>
<p style='line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>这样,根据红、绿、蓝各种不同的组合我们就能表示出</span><span lang=EN-US>256×256×256</span><span
style='font-family:宋体;"Times New Roman"'>,约</span><span lang=EN-US>1600</span><span style='font-family:
宋体;"Times New Roman"'>万种颜色。这么多颜色对于我们人眼来说已经足够丰富了。</span></p>
<p align=center style='text-align:center;line-height:18.0pt'><b><span
style='font-family:宋体;"Times New Roman"'>表</span>1.1 </b><b><span
style='font-family:宋体;"Times New Roman"'>常见颜色的</span><span lang=EN-US>RGB</span></b><b><span
style='font-family:宋体;"Times New Roman"'>组合值</span><span lang=EN-US></span></b></p>
<div align=center>
<table border=1 cellspacing=0 cellpadding=0 width="75%">
<tr>
<td width="25%" class="Normal">
<p class=a style='line-height:18.0pt'><span style='font-family:宋体;"Times New Roman";"Times New Roman"'>颜色</span></p>
</td>
<td width="25%" class="Normal">
<p class=a style='line-height:18.0pt'><span lang=EN-US>R</span></p>
</td>
<td width="25%" class="Normal">
<p class=a style='line-height:18.0pt'><span lang=EN-US>G</span></p>
</td>
<td width="25%" class="Normal">
<p class=a style='line-height:18.0pt'><span lang=EN-US>B</span></p>
</td>
</tr>
<tr>
<td width="25%" class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>红</span></p>
</td>
<td width="25%" class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US>255</span></p>
</td>
<td width="25%" class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US>0</span></p>
</td>
<td width="25%" class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US>0</span></p>
</td>
</tr>
<tr>
<td width="25%" class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>蓝</span></p>
</td>
<td width="25%" class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US>0</span></p>
</td>
<td width="25%" class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US>255</span></p>
</td>
<td width="25%" class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US>0</span></p>
</td>
</tr>
<tr>
<td width="25%" class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>绿</span></p>
</td>
<td width="25%" class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US>0</span></p>
</td>
<td width="25%" class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US>0</span></p>
</td>
<td width="25%" class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US>255</span></p>
</td>
</tr>
<tr>
<td width="25%" class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>黄</span></p>
</td>
<td width="25%" class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US>255</span></p>
</td>
<td width="25%" class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US>255</span></p>
</td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -