﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-厚积薄发，滴水穿石-随笔分类-Tools</title><link>http://www.cppblog.com/cokecoffe/category/17381.html</link><description /><language>zh-cn</language><lastBuildDate>Sat, 02 Jun 2012 23:20:33 GMT</lastBuildDate><pubDate>Sat, 02 Jun 2012 23:20:33 GMT</pubDate><ttl>60</ttl><item><title>Subversion基础：概念、安装、配置和基本操作(转）</title><link>http://www.cppblog.com/cokecoffe/archive/2012/06/01/177030.html</link><dc:creator>Wangkeke</dc:creator><author>Wangkeke</author><pubDate>Fri, 01 Jun 2012 02:25:00 GMT</pubDate><guid>http://www.cppblog.com/cokecoffe/archive/2012/06/01/177030.html</guid><wfw:comment>http://www.cppblog.com/cokecoffe/comments/177030.html</wfw:comment><comments>http://www.cppblog.com/cokecoffe/archive/2012/06/01/177030.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/cokecoffe/comments/commentRss/177030.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/cokecoffe/services/trackbacks/177030.html</trackback:ping><description><![CDATA[<p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; "></p><div>转自:http://www.uml.org.cn/pzgl/200902137.asp<br /></div>摘要：介绍了 Subversion 的基本概念。详细讲解了在Windows下如何安装 Subversion，如何配置一个基本的Subversion&nbsp;<a title="服务器" target="_blank" href="http://server.it168.com/" style="text-decoration: none; color: #000000; cursor: pointer; ">服务器</a>。<p>&nbsp;</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">目录</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">一、基本概念</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">1、什么是版本控制</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">2、什么是 Subversion</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">3、版本库(repository)</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">二、安装</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">1、准备工作</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">2、安装<a title="服务器" target="_blank" href="http://product.it168.com/files/0402search.shtml" style="text-decoration: none; color: #000000; cursor: pointer; ">服务器</a>端和客户端</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">3、建立版本库(Repository)</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">4、运行独立服务器</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">三、基本配置</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">1、配置用户和权限</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">2、初始化导入</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">四、基本操作流程</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">1、取出(check out)</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">2、存入(check in)/提交(commit)</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">------------------------------------------------------------------分 割 线---------------------------------------------------------------</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; "><strong>一、基本概念</strong></p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">1、什么是版本控制</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">简单点来说，版本控制就是数据仓库，它可以记录你对文件的每次更改。这样，就算你在昏天黑地的改了几个月后老板说不要了，还是按照过去那样，你也不会抓狂，简单的恢复版本操作就搞定一切。</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">2、什么是 Subversion</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">Subversion是一个自由/开源版本控制系统，它管理文件和目录可以超越时间。一组文件存放在中心版本库，这个版本库很像一个普通的文件服务器，只是它可以记录每一次文件和目录的修改，这便使你可以取得数据以前的版本，从而可以检查所作的更改。从这个方面看，许多人把版本控制系统当作一种&#8220;时间机器&#8221;。</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">Subversion可以通过<a title="网络" target="_blank" href="http://net.it168.com/" style="text-decoration: none; color: #000000; cursor: pointer; ">网络</a>访问它的版本库，从而使用户可以在不同的电脑上使用。一定程度上可以说，允许用户在各自的地方修改同一份数据是促进协作。进展可能非常的迅速，并没有一个所有的改变都会取得效果的通道，由于所有的工作都有历史版本，你不必担心由于失去某个通道而影响质量，如果存在不正确的改变，只要取消改变。</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">一些版本控制系统也是<a title="软件" target="_blank" href="http://software.it168.com/" style="text-decoration: none; color: #000000; cursor: pointer; ">软件</a>配置管理(SCM)系统，这种系统经过特定的精巧设计来管理源代码，有许多关于软件开发的特性&#8212;本身理解编程语言、或者提供构建程序的工具。然而，Subversion不是这样一个系统，它是一个通用系统，可以管理任何类型的文件集，对你这可能是源代码，对别人，可能是一个货物报价单或者是书稿，或者是电影剪辑等。</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">3、版本库(repository)</p><p style="text-indent: 12pt; font-family: 宋体; font-size: 12px; line-height: 20px; ">Subversion 的核心就是 repository ，中文翻译成&#8220;版本库&#8221;。就是位于服务器端，统一管理和储存数据的地方。</p><div style="font-family: 宋体; font-size: 12px; line-height: 20px; "><div><div><p style="text-indent: 12pt; "><strong>二、安装</strong></p><div><p style="text-indent: 12pt; ">Subversion的设计包括一个抽象的<a title="网络" target="_blank" href="http://net.it168.com/" style="text-decoration: none; color: #000000; cursor: pointer; ">网络</a>层，这意味着版本库可以通过各种<a title="服务器" target="_blank" href="http://server.it168.com/" style="text-decoration: none; color: #000000; cursor: pointer; ">服务器</a>进程访问。理论上讲，Subversion可以使用无限数量的网络协议实现，目前实践中存在着两种<a title="服务器" target="_blank" href="http://product.it168.com/files/0402search.shtml" style="text-decoration: none; color: #000000; cursor: pointer; ">服务器</a>。</p><p style="text-indent: 12pt; ">&#8226; SVNServer：svnserve 是一个小的(也叫轻型的)、独立服务器，使用自己定义的协议和客户端。(作者注：以下称这种服务器为&#8220;svnserver服务器&#8221;。)</p><p style="text-indent: 12pt; ">&#8226; ApacheSVN：Apache是最流行的web服务器，通过使用 mod_dav_svn 模块，Apache可以访问版本库，并且可以使客户端使用HTTP的扩展协议WebDAV/DeltaV进行访问。(作者注：以下称这种服务器为&#8220;ApacheSVN服务器&#8221;。)</p><p style="text-indent: 12pt; ">下面介绍 SVNServer 服务器的安装，ApacheSVN 服务器的安装使用请看我写的《Subversion高级应用：SVN的多种认证方式》。</p><p style="text-indent: 12pt; ">环境</p><p style="text-indent: 12pt; ">OS：Windows XP SP2</p><p style="text-indent: 12pt; ">Web：Apache 2.2.6</p><p style="text-indent: 12pt; ">SVN：svn-win32-1.4.6</p><p style="text-indent: 12pt; ">1、准备工作。</p><p style="text-indent: 12pt; ">(1)获取 Subversion 服务器程序。</p><p style="text-indent: 12pt; ">到官方网站(http://subversion.tigris.org/)下载最新的服务器安装程序。目前最新的是1.4.6版本，具体下载地址在：http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=8100&amp;expandFolder=8100&amp;folderID=91 ，注意找 for apache 2.2.x 版本的。</p><p style="text-indent: 12pt; ">(2)获取 TortoiseSVN 客户端程序。</p><p style="text-indent: 12pt; ">从官方网站 http://tortoisesvn.net/downloads 获取最新的 TortoiseSVN 。TortoiseSVN 是一个客户端程序，用来与 subvers 服务器端通讯。Subversion 自带一个客户端程序 svn.exe ,但 TortoiseSVN 更好操作，提高效率。</p><p style="text-indent: 12pt; ">2、安装服务器端和客户端</p><p style="text-indent: 12pt; ">首先安装 Apache 2.2.6 ，具体安装方法大家参考相关资料，或者参看我写的《Windows下安装Apache 2.2.x》。</p><p style="text-indent: 12pt; ">其次安装 Subversion(以下简称SVN)的服务器端和客户端。下载下来的服务器端是个 zip 压缩包，直接解压缩即可，比如我解压到 E:\subversion 。客户端安装文件是个 exe 可执行文件，直接运行按提示安装即可，客户端安装完成后提示重启。</p><p style="text-indent: 12pt; ">3、建立版本库(Repository)</p><p style="text-indent: 12pt; ">运行Subversion服务器需要首先要建立一个版本库(Repository)。版本库可以看作是服务器上集中存放和管理数据的地方。</p><p style="text-indent: 12pt; ">开始建立版本库。首先建立 e:\svn 空文件夹作为所有版本库的根目录。然后，进入命令行并切换到subversion的bin目录。输入如下命令：</p><div style="width: 825px; word-break: break-all; border: 0.5pt solid windowtext; padding: 4px 5.4pt; background-color: #e6e6e6; background-position: initial initial; background-repeat: initial initial; ">　　svnadmin create E:\svn\repos1</div><p style="text-indent: 12pt; ">此命令在 E:\svn 下建立一个版本库 repos1 。repos1 下面会自动生成一些文件夹和文件。</p><p style="text-indent: 12pt; ">我们也可以使用 TortoiseSVN 图形化的完成这一步：</p><p style="text-indent: 12pt; ">先建立空目录 E:\svn\repos1 ，注意一定是要空的。然后在 repos1 文件夹上&#8220;右键-&gt;TortoiseSVN-&gt;Create Repository here...&#8221;，然后可以选择版本库模式，这里使用默认的FSFS即可，然后就创建了一系列文件夹和文件，同命令行建立的一样。</p><p style="text-indent: 12pt; ">4、运行独立服务器</p><p style="text-indent: 12pt; ">此时 subversion 服务还没有开始，只是通过它的命令建立了版本库。继续在刚才的命令窗口输入：&nbsp;</p><div style="width: 825px; word-break: break-all; border: 0.5pt solid windowtext; padding: 4px 5.4pt; background-color: #e6e6e6; background-position: initial initial; background-repeat: initial initial; ">　　svnserve.exe &#8211;daemon</div><p style="text-indent: 12pt; ">svnserve 将会在端口 3690 等待请求，--daemon(两个短横线)选项告诉 svnserve 以守护进程方式运行，这样在手动终止之前不会退出。注意不要关闭命令行窗口，关闭窗口会把 svnserve 停止。</p><p style="text-indent: 12pt; ">为了验证svnserve正常工作，使用TortoiseSVN -&gt; Repo-browser 来查看版本库。在弹出的 URL 对话框中输入：&nbsp;</p><div style="width: 825px; word-break: break-all; border: 0.5pt solid windowtext; padding: 4px 5.4pt; background-color: #e6e6e6; background-position: initial initial; background-repeat: initial initial; ">　　svn://localhost/svn/repos1</div><p style="text-indent: 12pt; ">点 OK 按钮后就可以看见 repos1 版本库的目录树结构了，只不过这时 repos1 是个空库。</p><p style="text-indent: 12pt; ">你也可以使用--root选项设置根位置来限制服务器的访问目录，从而增加<a title="安全" target="_blank" href="http://safe.it168.com/" style="text-decoration: none; color: #000000; cursor: pointer; ">安全</a>性和节约输入svnserve URL的时间：&nbsp;</p><div style="width: 825px; word-break: break-all; border: 0.5pt solid windowtext; padding: 4px 5.4pt; background-color: #e6e6e6; background-position: initial initial; background-repeat: initial initial; ">　　svnserve.exe --daemon --root drive:\path\to\repository</div><p style="text-indent: 12pt; ">以前面的测试作为例，svnserve 将会运行为：&nbsp;</p><div style="width: 825px; word-break: break-all; border: 0.5pt solid windowtext; padding: 4px 5.4pt; background-color: #e6e6e6; background-position: initial initial; background-repeat: initial initial; ">　　svnserve.exe --daemon --root e:\svn</div><p style="text-indent: 12pt; ">然后TortoiseSVN中的版本库浏览器URL缩减为：&nbsp;</p><div style="width: 825px; word-break: break-all; border: 0.5pt solid windowtext; padding: 4px 5.4pt; background-color: #e6e6e6; background-position: initial initial; background-repeat: initial initial; ">　　svn://localhost/repos1</div></div></div></div></div><div style="font-family: 宋体; font-size: 12px; line-height: 20px; "><div><div><div><p style="text-indent: 12pt; "><strong>三、基本配置</strong></p><p style="text-indent: 12pt; ">SVNServer<a title="服务器" target="_blank" href="http://server.it168.com/" style="text-decoration: none; color: #000000; cursor: pointer; ">服务器</a>安装完成后，必须经过基本配置才能使用。</p><p style="text-indent: 12pt; ">1、配置用户和权限</p><p style="text-indent: 12pt; ">用文本编辑器打开E:\svn\repos1\conf目录，修改svnserve.conf：</p><p style="text-indent: 12pt; ">将：&nbsp;</p><div style="width: 825px; word-break: break-all; border: 0.5pt solid windowtext; padding: 4px 5.4pt; background-color: #e6e6e6; background-position: initial initial; background-repeat: initial initial; ">　　# password-db = passwd</div><p style="text-indent: 12pt; ">改为：&nbsp;</p><div style="width: 825px; word-break: break-all; border: 0.5pt solid windowtext; padding: 4px 5.4pt; background-color: #e6e6e6; background-position: initial initial; background-repeat: initial initial; ">　　password-db = passwd</div><p style="text-indent: 12pt; ">即去掉前面的 # 注释符，注意前面不能有空格。</p><p style="text-indent: 12pt; ">然后修改同目录的passwd文件，增加一个帐号：</p><p style="text-indent: 12pt; ">将：</p><div style="width: 825px; word-break: break-all; border: 0.5pt solid windowtext; padding: 4px 5.4pt; background-color: #e6e6e6; background-position: initial initial; background-repeat: initial initial; ">[users]<br /># harry = harryssecret<br /># sally = sallyssecret</div><p style="text-indent: 12pt; ">增加帐号：</p><div style="width: 825px; word-break: break-all; border: 0.5pt solid windowtext; padding: 4px 5.4pt; background-color: #e6e6e6; background-position: initial initial; background-repeat: initial initial; ">　　[users]<br />　　#harry = harryssecret<br />　　#sally = sallyssecret<br />　　test = test</div><p style="text-indent: 12pt; ">2、初始化导入</p><p style="text-indent: 12pt; ">下面就是将我们的数据(项目)导入到这个版本库，以后就由版本库管理我们的数据。我们的任何改动都会被版本库记录下来，甚至我们自己丢失、改错数据时版本库也能帮我们找回数据。</p><p style="text-indent: 12pt; ">比如，我在 d:\wwwroot 下有个 guestbook 文件夹，里面存放的是我编写的留言簿程序。在此文件夹上&#8220;右键 -&gt; TortoiseSVN -&gt; Import...&#8221; ，在弹出对话框的&#8220;URL of repository&#8221;输入&#8220;svn://localhost/repos1/guestbook&#8221;。在&#8220;Import message&#8221;输入&#8220;导入整个留言簿&#8221;作为注释。</p><p style="text-indent: 12pt; ">点 OK 后要求输入帐号。我们在用户名和密码处都输入 test 。完成后 guestbook 中的内容全部导入到了 svn://localhost/svn/repos1/guestbook 。</p><p style="text-indent: 12pt; ">我们看到在 e:\svn\repos1 没有任何变化，连个 guestbook 文件夹都没有建立，唯一的变化就是e:\svn\repos1容量变大了。实际上我们源guestbook中的内容已经导入 repos1 版本库了，源 guestbook 文件夹可以删除了。</p><p style="text-indent: 12pt; ">需要注意的是，这一步操作可以完全在另一台安装了 TortoiseSVN 的客户机上进行。例如运行svnserve的主机的IP是133.96.121.22，则URL部分输入的内容就是&#8220;svn://133.96.121.22&#8221; 。</p><p style="text-indent: 12pt; "><strong>四、基本操作流程</strong></p><p style="text-indent: 12pt; ">1、取出(check out)</p><p style="text-indent: 12pt; ">取出版本库到一个工作拷贝：</p><p style="text-indent: 12pt; ">来到任意空目录下，比如在f分区建立一个空文件夹 f:\work 。&#8220;右键 -&gt; SVN Checkout&#8221;。在&#8220;URL of repository&#8221;中输入&#8220;svn://localhost/svn/repos1/guestbook&#8221;，这样我们就得到了一份 guestbook 中内容的工作拷贝。</p><p style="text-indent: 12pt; ">2、存入(check in)/提交(commit)</p><p style="text-indent: 12pt; ">在工作拷贝中作出修改并提交：</p><p style="text-indent: 12pt; ">在 guestbook 工作拷贝中随便打开一个文件，作出修改，然后&#8220;右键 -&gt; SVN Commit... &#8221;。这样我们就把修改提交到了版本库，版本库根据情况<a title="存储" target="_blank" href="http://storage.it168.com/" style="text-decoration: none; color: #000000; cursor: pointer; ">存储</a>我们提交的数据。</p><p style="text-indent: 12pt; ">在修改过的文件上&#8220;右键 -&gt; TortoiseSVN -&gt; Show Log&#8221; ，可以看到对这个文件所有的提交。在不同的 revision 条目上&#8220;右键 -&gt; Compare with working copy&#8221;，我们可以比较工作拷贝的文件和所选 revision 版本的区别。</p></div></div></div></div><img src ="http://www.cppblog.com/cokecoffe/aggbug/177030.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/cokecoffe/" target="_blank">Wangkeke</a> 2012-06-01 10:25 <a href="http://www.cppblog.com/cokecoffe/archive/2012/06/01/177030.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Xcode 中使用Github</title><link>http://www.cppblog.com/cokecoffe/archive/2012/04/22/172373.html</link><dc:creator>Wangkeke</dc:creator><author>Wangkeke</author><pubDate>Sun, 22 Apr 2012 13:37:00 GMT</pubDate><guid>http://www.cppblog.com/cokecoffe/archive/2012/04/22/172373.html</guid><wfw:comment>http://www.cppblog.com/cokecoffe/comments/172373.html</wfw:comment><comments>http://www.cppblog.com/cokecoffe/archive/2012/04/22/172373.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/cokecoffe/comments/commentRss/172373.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/cokecoffe/services/trackbacks/172373.html</trackback:ping><description><![CDATA[<p>第一步：为你的mac添加认证，使得它能够连接到github。</p>
<div style="line-height: 25px;"><span style="line-height: 25px; white-space: pre;"> </span>参考http://help.github.com/mac-set-up-git/  一步一步操作即可</div>
<div style="line-height: 25px;">====================================================================</div>
<div style="line-height: 25px;">第二步：新建项目</div>
<div style="line-height: 25px;"><span style="line-height: 25px; white-space: pre;"> </span>先在github里面添加一个Repository，通过http://github.com/首页的new Repository连接进入，填写相关的项目信息，创建即可。创建后会跳转到初始项目界面，先暂停，在第三步再使用这个界面。</div>
<div style="line-height: 25px;"><span style="line-height: 25px; white-space: pre;"> </span>在mac上使用xcode新建一个项目，为项目使用git，创建过程中使用 create local git repository for this project，指定要存储的目录即可。</div>
<div style="line-height: 25px;">====================================================================</div>
<div style="line-height: 25px;">第三步：初始化提交项目</div>
<div style="line-height: 25px;"><span style="line-height: 25px; white-space: pre;"> </span>回到第二步github创建项目后的界面。初始化有几种方式，这里我们选择从已有仓库提交代码。执行下面的代码即可。</div>
<div style="line-height: 25px;"><span style="line-height: 23px; font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px; background-color: #eaf2f5;">
<h2 style="line-height: 18px; padding: 0px; margin: 0px;"><span style="line-height: 36px; white-space: pre;"> </span>Existing Git Repo?</h2>
<pre style="line-height: 18px; font: normal normal normal 12px/normal 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 13px; padding: 0px; margin: 0px;">  <span style="line-height: 23px; white-space: pre;"> </span>cd existing_git_repo   <span style="line-height: 23px; white-space: pre;"> </span></pre>
<pre style="line-height: 18px; font: normal normal normal 12px/normal 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 13px; padding: 0px; margin: 0px;">   git remote add origin git@github.com:your_account/your_project.git   </pre>
<pre style="line-height: normal; font: normal normal normal 12px/normal 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 13px; padding: 0px; margin: 0px;">   <span style="line-height: 18px;">git push -u origin master</span></pre>
<pre style="line-height: normal; font: normal normal normal 12px/normal 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 13px; padding: 0px; margin: 0px;"><span style="line-height: 18px;">上面的代码将本地的仓库连接到远程仓库，并且将代码提交到master分支上。</span></pre>
<pre style="line-height: normal; font: normal normal normal 12px/normal 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 13px; padding: 0px; margin: 0px;"><span style="line-height: 18px;">====================================================================<br style="line-height: 23px;" /></span></pre>
<pre style="line-height: normal; font: normal normal normal 12px/normal 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 13px; padding: 0px; margin: 0px;"><span style="line-height: 18px;">第四步：提交代码</span></pre>
<pre style="line-height: normal; font: normal normal normal 12px/normal 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 13px; padding: 0px; margin: 0px;"><span style="line-height: 18px;">   新建的文件，XCode会提示一个A标签，表示是added的。</span></pre>
<pre style="line-height: normal; font: normal normal normal 12px/normal 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 13px; padding: 0px; margin: 0px;"><span style="line-height: 18px;">   编辑的文件，XCode会提示一个M标签，表示是Modified的。</span></pre>
<pre style="line-height: normal; font: normal normal normal 12px/normal 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 13px; padding: 0px; margin: 0px;"><span style="line-height: 18px;">   选中要更新的文件，右键--&gt;Source Control--&gt;Commit Selected Files 通过此操作将变更提交到本地的仓库中。</span></pre>
<pre style="line-height: normal; font: normal normal normal 12px/normal 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 13px; padding: 0px; margin: 0px;"><span style="line-height: 18px;">   选中要更新的文件，File菜单--&gt;Source Control--&gt;Push 将本地变化存储到远程服务器中。</span></pre>
<pre style="line-height: normal; font: normal normal normal 12px/normal 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 13px; padding: 0px; margin: 0px;"><span style="line-height: 18px;"><br /></span></pre>
<pre style="line-height: normal; font: normal normal normal 12px/normal 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 13px; padding: 0px; margin: 0px;"><span style="line-height: 18px;">from：<span style="text-decoration: underline;">http://qiufangzhou.blog.163.com/blog/static/506421802011924102515390/</span><br /></span></pre>
</span></div><img src ="http://www.cppblog.com/cokecoffe/aggbug/172373.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/cokecoffe/" target="_blank">Wangkeke</a> 2012-04-22 21:37 <a href="http://www.cppblog.com/cokecoffe/archive/2012/04/22/172373.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>公钥 私钥</title><link>http://www.cppblog.com/cokecoffe/archive/2011/10/19/158703.html</link><dc:creator>Wangkeke</dc:creator><author>Wangkeke</author><pubDate>Wed, 19 Oct 2011 13:32:00 GMT</pubDate><guid>http://www.cppblog.com/cokecoffe/archive/2011/10/19/158703.html</guid><wfw:comment>http://www.cppblog.com/cokecoffe/comments/158703.html</wfw:comment><comments>http://www.cppblog.com/cokecoffe/archive/2011/10/19/158703.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/cokecoffe/comments/commentRss/158703.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/cokecoffe/services/trackbacks/158703.html</trackback:ping><description><![CDATA[<span style="font-family: simsun; font-size: 14px; line-height: 21px; background-color: #ffffff; color: #000000; ">&nbsp;</span><span style="font-family: simsun; font-size: 14px; line-height: 21px; background-color: #ffffff; ">&nbsp;&nbsp;<wbr><br />&nbsp;<wbr></span><span style="font-family: simsun; font-size: 14px; line-height: 21px; background-color: #ffffff; color: #000000; ">&nbsp;</span><span style="font-family: simsun; font-size: 14px; line-height: 21px; ">一，公钥私钥&nbsp;<wbr><br />&nbsp;<wbr></span><span style="font-family: simsun; font-size: 14px; line-height: 21px; ">&nbsp;1，公钥和私钥成对出现&nbsp;<wbr><br />&nbsp;<wbr></span><span style="font-family: simsun; font-size: 14px; line-height: 21px; ">&nbsp;2，公开的密钥叫公钥，只有自己知道的叫私钥&nbsp;<wbr><br />&nbsp;<wbr></span><span style="font-family: simsun; font-size: 14px; line-height: 21px; ">&nbsp;3，用公钥加密的数据只有对应的私钥可以解密&nbsp;<wbr><br />&nbsp;<wbr></span><span style="font-family: simsun; font-size: 14px; line-height: 21px; ">&nbsp;4，用私钥加密的数据只有对应的公钥可以解密&nbsp;<wbr><br />&nbsp;<wbr></span><span style="font-family: simsun; font-size: 14px; line-height: 21px; ">&nbsp;5，如果可以用公钥解密，则必然是对应的私钥加的密&nbsp;<wbr><br />&nbsp;<wbr></span><span style="font-family: simsun; font-size: 14px; line-height: 21px; ">&nbsp;6，如果可以用私钥解密，则必然是对应的公钥加的密&nbsp;<wbr><br />&nbsp;<wbr></span><span style="font-family: simsun; font-size: 14px; line-height: 21px; ">&nbsp;明白了？&nbsp;<wbr><br />&nbsp;<wbr>&nbsp;<wbr><br />&nbsp;<wbr></span><span style="font-family: simsun; font-size: 14px; line-height: 21px; ">&nbsp;假设一下，我找了两个数字，一个是1，一个是2。我喜欢2这个数字，就保留起来，不告诉你们，然后我告诉大家，1是我的公钥。&nbsp;<wbr><br />&nbsp;<wbr>&nbsp;<wbr><br />&nbsp;<wbr></span><span style="font-family: simsun; font-size: 14px; line-height: 21px; ">&nbsp;我有一个文件，不能让别人看，我就用1加密了。别人找到了这个文件，但是他不知道2就是解密的私钥啊，所以他解不开，只有我可以用数字2，就是我的私钥，来解密。这样我就可以保护数据了。&nbsp;<wbr><br />&nbsp;<wbr>&nbsp;<wbr><br />&nbsp;<wbr></span><span style="font-family: simsun; font-size: 14px; line-height: 21px; ">&nbsp;我的好朋友x用我的公钥1加密了字符a，加密后成了b，放在网上。别人偷到了这个文件，但是别人解不开，因为别人不知道2就是我的私钥，只有我才能解密，解密后就得到a。这样，我们就可以传送加密的数据了。&nbsp;<wbr><br />&nbsp;<wbr>&nbsp;<wbr><br />&nbsp;<wbr></span><span style="font-family: simsun; font-size: 14px; line-height: 21px; ">&nbsp;现在我们知道用公钥加密，然后用私钥来解密，就可以解决安全传输的问题了。如果我用私钥加密一段数据（当然只有我可以用私钥加密，因为只有我知道2是我的私钥），结果所有的人都看到我的内容了，因为他们都知道我的公钥是1，那么这种加密有什么用处呢？&nbsp;<wbr><br />&nbsp;<wbr>&nbsp;<wbr><br />&nbsp;<wbr></span><span style="font-family: simsun; font-size: 14px; line-height: 21px; ">但是我的好朋友x说有人冒充我给他发信。怎么办呢？我把我要发的信，内容是c，用我的私钥2，加密，加密后的内容是d，发给x，再告诉他解密看是不是c。他用我的公钥1解密，发现果然是c。这个时候，他会想到，能够用我的公钥解密的数据，必然是用我的私钥加的密。只有我知道我得私钥，因此他就可以确认确实是我发的东西。这样我们就能确认发送方身份了。这个过程叫做数字签名。当然具体的过程要稍微复杂一些。用私钥来加密数据，用途就是数字签名。&nbsp;<wbr><br />&nbsp;<wbr>&nbsp;<wbr><br />&nbsp;<wbr></span><span style="font-family: simsun; font-size: 14px; line-height: 21px; ">&nbsp;好，我们复习一下：&nbsp;<wbr><br />&nbsp;<wbr></span><span style="font-family: simsun; font-size: 14px; line-height: 21px; ">&nbsp;1，公钥私钥成对出现&nbsp;<wbr><br />&nbsp;<wbr></span><span style="font-family: simsun; font-size: 14px; line-height: 21px; ">&nbsp;2，私钥只有我知道&nbsp;<wbr><br />&nbsp;<wbr></span><span style="font-family: simsun; font-size: 14px; line-height: 21px; ">&nbsp;3，大家可以用我的公钥给我发加密的信了&nbsp;<wbr><br />&nbsp;<wbr></span><span style="font-family: simsun; font-size: 14px; line-height: 21px; ">&nbsp;4，大家用我的公钥解密信的内容，看看能不能解开，能解开，说明是经过我的私钥加密了，就可以确认确实是我发的了。&nbsp;<wbr><br />&nbsp;<wbr>&nbsp;<wbr><br />&nbsp;<wbr></span><span style="font-family: simsun; font-size: 14px; line-height: 21px; ">&nbsp;总结一下结论：&nbsp;<wbr><br />&nbsp;<wbr></span><span style="font-family: simsun; font-size: 14px; line-height: 21px; ">&nbsp;1，用公钥加密数据，用私钥来解密数据&nbsp;<wbr><br />&nbsp;<wbr></span><span style="font-family: simsun; font-size: 14px; line-height: 21px; ">&nbsp;2，用私钥加密数据（数字签名），用公钥来验证数字签名。&nbsp;<wbr><br />&nbsp;<wbr>&nbsp;<wbr><br />&nbsp;<wbr></span><span style="font-family: simsun; font-size: 14px; line-height: 21px; ">&nbsp;在实际的使用中，公钥不会单独出现，总是以数字证书的方式出现，这样是为了公钥的安全性和有效性。</span><img src ="http://www.cppblog.com/cokecoffe/aggbug/158703.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/cokecoffe/" target="_blank">Wangkeke</a> 2011-10-19 21:32 <a href="http://www.cppblog.com/cokecoffe/archive/2011/10/19/158703.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>复习Linux中的一些零碎知识点</title><link>http://www.cppblog.com/cokecoffe/archive/2011/09/25/156771.html</link><dc:creator>Wangkeke</dc:creator><author>Wangkeke</author><pubDate>Sun, 25 Sep 2011 10:47:00 GMT</pubDate><guid>http://www.cppblog.com/cokecoffe/archive/2011/09/25/156771.html</guid><wfw:comment>http://www.cppblog.com/cokecoffe/comments/156771.html</wfw:comment><comments>http://www.cppblog.com/cokecoffe/archive/2011/09/25/156771.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/cokecoffe/comments/commentRss/156771.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/cokecoffe/services/trackbacks/156771.html</trackback:ping><description><![CDATA[<span style="color: #800000; "><strong>1.查找grep、find</strong></span><br /><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">在Linux下，常用 grep列出（文件内容）含有某个字符串的文件。<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;find命令查找匹配给定（文件名）的文件。<br />grep用法：&nbsp;<span class="Apple-style-span" style="font-size: 13px; background-color: #eeeeee; ">grep&nbsp;[options]&nbsp;PATTERN&nbsp;[FILE<img src="http://www.cppblog.com/Images/dot.gif" alt="" />]<br /></span>例子：<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-style-span" style="font-size: 13px; background-color: #eeeeee; "><span style="color: #000000; ">grep&nbsp;</span><span style="color: #800000; ">"</span><span style="color: #800000; ">main</span><span style="color: #800000; ">"</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">*</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">-</span><span style="color: #000000; ">R//查找当前目录下的所有文件、目录中包含&#8220;main&#8221;字样的文件<br /></span></span>find用法：&nbsp;<span class="Apple-style-span" style="font-size: 13px; background-color: #eeeeee; "><span style="color: #000000; ">find&nbsp;[</span><span style="color: #000000; ">-</span><span style="color: #000000; ">H]&nbsp;[</span><span style="color: #000000; ">-</span><span style="color: #000000; ">L]&nbsp;[</span><span style="color: #000000; ">-</span><span style="color: #000000; ">P]&nbsp;[path<img src="http://www.cppblog.com/Images/dot.gif" alt="" />]&nbsp;[expression]<br /></span></span>例子：<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-style-span" style="font-size: 13px; background-color: #eeeeee; "><span style="color: #000000; ">find&nbsp;</span><span style="color: #000000; ">/</span><span style="color: #000000; ">work</span><span style="color: #000000; ">/</span><span style="color: #000000; ">driver</span><span style="color: #000000; ">/</span><span style="color: #000000; ">net&nbsp;</span><span style="color: #000000; ">-</span><span style="color: #000000; ">name&nbsp;</span><span style="color: #800000; ">"</span><span style="color: #800000; ">*fb*</span><span style="color: #800000; ">"</span><span style="color: #000000; ">//</span><span style="color: #000000; ">查找</span><span style="color: #000000; ">/</span><span style="color: #000000; ">work</span><span style="color: #000000; ">/</span><span style="color: #000000; ">drivers</span><span style="color: #000000; ">/</span><span style="color: #000000; ">net目录下名字中包含fb的文件</span></span></blockquote><br /><span style="color: #800000; "><strong>2.压缩、解压缩、打包、解包 tar</strong></span><br /><blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">压缩解压缩常用的两种方式：gzip、bzip2<br />一般而言，&#8220;.gz&#8221;、&#8220;z&#8221;结尾的文件是gzip方式压缩的；<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8220;.bz2&#8221;结尾的文件是以bzip2方式进行压缩的；<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 后缀中有tar字样时表示这是一个文件包；<br />tar的5个常用选项:1.c &nbsp; &nbsp;创建，用来生成文件包<blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">2.x &nbsp; 提取，从文件包中提取文件</blockquote></blockquote></blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">3.z &nbsp; 使用gzip方式进行处理（压缩、解压缩）</blockquote></blockquote></blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">4.j &nbsp; &nbsp;使用bzip2方式进行处理（压缩、解压缩）</blockquote></blockquote></blockquote><blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">5.f &nbsp; &nbsp;表示文件，后面接着一个文件名<br /></blockquote></blockquote></blockquote></blockquote><img src ="http://www.cppblog.com/cokecoffe/aggbug/156771.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/cokecoffe/" target="_blank">Wangkeke</a> 2011-09-25 18:47 <a href="http://www.cppblog.com/cokecoffe/archive/2011/09/25/156771.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>FreeType的使用</title><link>http://www.cppblog.com/cokecoffe/archive/2011/09/07/155264.html</link><dc:creator>Wangkeke</dc:creator><author>Wangkeke</author><pubDate>Wed, 07 Sep 2011 02:47:00 GMT</pubDate><guid>http://www.cppblog.com/cokecoffe/archive/2011/09/07/155264.html</guid><wfw:comment>http://www.cppblog.com/cokecoffe/comments/155264.html</wfw:comment><comments>http://www.cppblog.com/cokecoffe/archive/2011/09/07/155264.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/cokecoffe/comments/commentRss/155264.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/cokecoffe/services/trackbacks/155264.html</trackback:ping><description><![CDATA[<span style="font-family: simsun; font-size: 14px; line-height: 23px; ">在嵌入式环境中显示字体，如果采用点阵的方式，要先取得汉字的点阵表示形式，然后根据点阵中每一位是否为1来决定是否对屏幕上相应的像素赋值；如果采用矢量字体的话，例如使用freetype库来显示TrueType类型的字体时，其大致的过程如下：<br />1.初始化库<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080; ">1</span>&nbsp;<span style="color: #000000; ">FT_Library&nbsp;library;<br /></span><span style="color: #008080; ">2</span>&nbsp;FT_Face&nbsp;face;<font class="Apple-style-span" color="#008080"><br />3</font>&nbsp;<span style="color: #000000; ">FT_Error&nbsp;error&nbsp;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&nbsp;FT_Init_FreeType(&nbsp;</span><span style="color: #000000; ">&amp;</span><span style="color: #000000; ">library&nbsp;);</span>&nbsp;<span style="color: #000000; "></span></div><br />2. 加载相应的字体文件<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><span style="color: #000000; ">error&nbsp;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&nbsp;FT_New_Face(&nbsp;library,&nbsp;</span><span style="color: #000000; ">"</span><span style="color: #000000; ">/usr/share/fonts/truetype/arial.ttf</span><span style="color: #000000; ">"</span><span style="color: #000000; ">,&nbsp;</span><span style="color: #000000; ">0</span><span style="color: #000000; ">,&nbsp;</span><span style="color: #000000; ">&amp;</span><span style="color: #000000; ">face&nbsp;);<br /></span></div><br />3. 设置字体的大小&nbsp;&nbsp;<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080; ">1</span>&nbsp;<span style="color: #000000; ">error&nbsp;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&nbsp;FT_Set_Char_Size(face,&nbsp;</span><span style="color: #008000; ">/*</span><span style="color: #008000; ">&nbsp;handle&nbsp;to&nbsp;face&nbsp;object&nbsp;</span><span style="color: #008000; ">*/</span><span style="color: #000000; ">&nbsp;&nbsp;<br /></span><span style="color: #008080; ">2</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;</span><span style="color: #000000; ">0</span><span style="color: #000000; ">,&nbsp;</span><span style="color: #008000; ">/*</span><span style="color: #008000; ">&nbsp;char_width&nbsp;in&nbsp;1/64th&nbsp;of&nbsp;points&nbsp;</span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">3</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;</span><span style="color: #000000; ">16</span><span style="color: #000000; ">*</span><span style="color: #000000; ">64</span><span style="color: #000000; ">,&nbsp;</span><span style="color: #008000; ">/*</span><span style="color: #008000; ">&nbsp;char_height&nbsp;in&nbsp;1/64th&nbsp;of&nbsp;points&nbsp;</span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">4</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;</span><span style="color: #000000; ">300</span><span style="color: #000000; ">,&nbsp;</span><span style="color: #008000; ">/*</span><span style="color: #008000; ">&nbsp;horizontal&nbsp;device&nbsp;resolution&nbsp;</span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">5</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;</span><span style="color: #000000; ">300</span><span style="color: #000000; ">&nbsp;);&nbsp;</span><span style="color: #008000; ">/*</span><span style="color: #008000; ">&nbsp;vertical&nbsp;device&nbsp;resolution&nbsp;</span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">6</span>&nbsp;<span style="color: #000000; "><br /></span><span style="color: #008080; ">7</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;error&nbsp;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&nbsp;FT_Set_Pixel_Sizes(face,&nbsp;</span><span style="color: #008000; ">/*</span><span style="color: #008000; ">&nbsp;handle&nbsp;to&nbsp;face&nbsp;object&nbsp;</span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">8</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;</span><span style="color: #000000; ">0</span><span style="color: #000000; ">,&nbsp;</span><span style="color: #008000; ">/*</span><span style="color: #008000; ">&nbsp;pixel_width&nbsp;</span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">9</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;</span><span style="color: #000000; ">16</span><span style="color: #000000; ">&nbsp;);&nbsp;</span><span style="color: #008000; ">/*</span><span style="color: #008000; ">&nbsp;pixel_height&nbsp;</span><span style="color: #008000; ">*/</span></div><br />4. 加载字符的glyph<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080; ">1</span>&nbsp;<span style="color: #000000; ">glyph_index&nbsp;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&nbsp;FT_Get_Char_Index(&nbsp;face,&nbsp;charcode&nbsp;);<br /></span><span style="color: #008080; ">2</span>&nbsp;<span style="color: #000000; "><br /></span><span style="color: #008080; ">3</span>&nbsp;<span style="color: #000000; ">error&nbsp;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&nbsp;FT_Load_Glyph(face,&nbsp;</span><span style="color: #008000; ">/*</span><span style="color: #008000; ">&nbsp;handle&nbsp;to&nbsp;face&nbsp;object&nbsp;</span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">4</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;glyph_index,&nbsp;</span><span style="color: #008000; ">/*</span><span style="color: #008000; ">&nbsp;glyph&nbsp;index&nbsp;</span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">5</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;load_flags&nbsp;);&nbsp;</span><span style="color: #008000; ">/*</span><span style="color: #008000; ">&nbsp;load&nbsp;flags,&nbsp;see&nbsp;below&nbsp;</span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">6</span>&nbsp;<span style="color: #000000; "><br /></span><span style="color: #008080; ">7</span>&nbsp;<span style="color: #000000; ">error&nbsp;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&nbsp;FT_Render_Glyph(&nbsp;face</span><span style="color: #000000; ">-&gt;</span><span style="color: #000000; ">glyph,&nbsp;</span><span style="color: #008000; ">/*</span><span style="color: #008000; ">&nbsp;glyph&nbsp;slot&nbsp;</span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">8</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;render_mode&nbsp;);&nbsp;</span><span style="color: #008000; ">/*</span><span style="color: #008000; ">&nbsp;render&nbsp;mode&nbsp;</span><span style="color: #008000; ">*/</span><font class="Apple-style-span" color="#008080"><br /></font><span style="color: #000000; "></span></div><br />5. 字体变换(旋转和缩放)<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080; ">1</span>&nbsp;<span style="color: #000000; ">error&nbsp;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&nbsp;FT_Set_Transform(&nbsp;face,&nbsp;</span><span style="color: #008000; ">/*</span><span style="color: #008000; ">&nbsp;target&nbsp;face&nbsp;object&nbsp;</span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">2</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;</span><span style="color: #000000; ">&amp;</span><span style="color: #000000; ">matrix,&nbsp;</span><span style="color: #008000; ">/*</span><span style="color: #008000; ">&nbsp;pointer&nbsp;to&nbsp;2x2&nbsp;matrix&nbsp;</span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">3</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;</span><span style="color: #000000; ">&amp;</span><span style="color: #000000; ">delta&nbsp;);&nbsp;</span><span style="color: #008000; ">/*</span><span style="color: #008000; ">&nbsp;pointer&nbsp;to&nbsp;2d&nbsp;vector&nbsp;</span><span style="color: #008000; ">*/</span></div><br />6. 把字符显示出来<br /><div style="font-size: 13px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-right: 5px; padding-bottom: 4px; padding-left: 4px; padding-top: 4px; width: 98%; word-break: break-all; background-color: #eeeeee; "><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080; ">1</span>&nbsp;<span style="color: #000000; ">draw_bitmap(&nbsp;</span><span style="color: #000000; ">&amp;</span><span style="color: #000000; ">slot</span><span style="color: #000000; ">-&gt;</span><span style="color: #000000; ">bitmap,&nbsp;pen_x&nbsp;</span><span style="color: #000000; ">+</span><span style="color: #000000; ">&nbsp;slot</span><span style="color: #000000; ">-&gt;</span><span style="color: #000000; ">bitmap_left,&nbsp;pen_y&nbsp;</span><span style="color: #000000; ">-</span><span style="color: #000000; ">&nbsp;slot</span><span style="color: #000000; ">-&gt;</span><span style="color: #000000; ">bitmap_top&nbsp;);</span></div></span><img src ="http://www.cppblog.com/cokecoffe/aggbug/155264.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/cokecoffe/" target="_blank">Wangkeke</a> 2011-09-07 10:47 <a href="http://www.cppblog.com/cokecoffe/archive/2011/09/07/155264.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>BMP数据结构分析</title><link>http://www.cppblog.com/cokecoffe/archive/2011/08/03/152326.html</link><dc:creator>Wangkeke</dc:creator><author>Wangkeke</author><pubDate>Wed, 03 Aug 2011 02:08:00 GMT</pubDate><guid>http://www.cppblog.com/cokecoffe/archive/2011/08/03/152326.html</guid><wfw:comment>http://www.cppblog.com/cokecoffe/comments/152326.html</wfw:comment><comments>http://www.cppblog.com/cokecoffe/archive/2011/08/03/152326.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/cokecoffe/comments/commentRss/152326.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/cokecoffe/services/trackbacks/152326.html</trackback:ping><description><![CDATA[<span style="font-family: Verdana, Arial, Geneva, Helvetica, sans-serif; "><div style="background-image: url(http://www.cppblog.com/Skins/BlackSun/images/Topic.gif); padding-left: 15px; font-size: 1em; margin-top: 6px; margin-bottom: 0px; background-repeat: no-repeat no-repeat; "><span style="text-decoration: none; color: #000000; "><a id="viewpost1_TitleUrl" href="http://www.cppblog.com/tdweng/articles/140512.html" style="color: #000000; text-decoration: none; "><br /></a><strong>BMP</strong>文件结构</span></div><div style="padding-right: 10px; padding-left: 15px; padding-bottom: 2px; padding-top: 2px; font: normal normal normal 13px/normal verdana, sans-serif; color: #333333; line-height: 1.5; margin-top: 0px; "><div id="articleBody" style="background-color: #ffffff; "><u><span style="color: #000000; ">1：</span><span style="color: #000000; ">BMP</span><span style="color: #000000; ">文件组成</span></u><br style="color: #000000; " /><span style="color: #000000; ">BMP</span><span style="color: #000000; ">文件由文件头、位图信息头、颜色信息和图形数据四部分组成。</span><br style="color: #000000; " /><u><span style="color: #000000; ">2：</span><span style="color: #000000; ">BMP</span><span style="color: #000000; ">文件头(14字节)</span></u><br style="color: #000000; " /><span style="color: #000000; ">BMP</span><span style="color: #000000; ">文件头数据</span><span style="color: #000000; ">结构</span><span style="color: #000000; ">含有</span><span style="color: #000000; ">BMP</span><span style="color: #000000; ">文件的类型、文件大小和位图起始位置等信息。</span><br style="color: #000000; " /><span style="color: #000000; ">其</span><strong style="color: #000000; ">结构</strong><span style="color: #000000; ">定义如下:</span><br style="color: #000000; " /><span style="color: #000000; ">typedef struct tagBITMAPFILEHEADER</span><br style="color: #000000; " /><span style="color: #000000; ">{</span><br style="color: #000000; " /><span style="color: #000000; ">WORDbf Type; // 位图文件的类型，必须为</span><span style="color: #000000; ">BMP</span><span style="color: #000000; ">(0-1字节)</span><br style="color: #000000; " /><span style="color: #000000; ">DWORD bfSize; // 位图文件的大小，以字节为单位(2-5字节)</span><br style="color: #000000; " /><span style="color: #000000; ">WORD bfReserved1; // 位图文件保留字，必须为0(6-7字节)</span><br style="color: #000000; " /><span style="color: #000000; ">WORD bfReserved2; // 位图文件保留字，必须为0(8-9字节)</span><br style="color: #000000; " /><span style="color: #000000; ">DWORD bfOffBits; // 位图数据的起始位置，以相对于位图(10-13字节)</span><br style="color: #000000; " /><span style="color: #000000; ">// 文件头的偏移量表示，以字节为单位</span><br style="color: #000000; " /><span style="color: #000000; ">} BITMAPFILEHEADER;</span><br style="color: #000000; " /><span style="color: #000000; "><u>3：位图信息头(40字节)</u></span><br style="color: #000000; " /><span style="color: #000000; ">BMP</span><span style="color: #000000; ">位图信息头数据用于说明位图的尺寸等信息。</span><br style="color: #000000; " /><span style="color: #000000; ">typedef struct tagBITMAPINFOHEADER{</span><br style="color: #000000; " /><span style="color: #000000; ">DWORD biSize; // 本</span><strong style="color: #000000; ">结构</strong><span style="color: #000000; ">所占用字节数(14-17字节)</span><br style="color: #000000; " /><span style="color: #000000; ">LONG biWidth; // 位图的宽度，以像素为单位(18-21字节)</span><br style="color: #000000; " /><span style="color: #000000; ">LONG biHeight; // 位图的高度，以像素为单位(22-25字节)</span><br style="color: #000000; " /><span style="color: #000000; ">WORD biPlanes; // 目标设备的级别，必须为1(26-27字节)</span><br style="color: #000000; " /><span style="color: #000000; ">WORD biBitCount;// 每个像素所需的位数，必须是1(双色),(28-29字节)</span><br style="color: #000000; " /><span style="color: #000000; ">// 4(16色)，8(256色)或24(真彩色)之一</span><br style="color: #000000; " /><span style="color: #000000; ">DWORD biCompression; // 位图压缩类型，必须是 0(不压缩),(30-33字节)</span><br style="color: #000000; " /><span style="color: #000000; ">// 1(BI_RLE8压缩类型)或2(BI_RLE4压缩类型)之一</span><br style="color: #000000; " /><span style="color: #000000; ">DWORD biSizeImage; // 位图的大小，以字节为单位(34-37字节)</span><br style="color: #000000; " /><span style="color: #000000; ">LONG biXPelsPerMeter; // 位图水平分辨率，每米像素数(38-41字节)</span><br style="color: #000000; " /><span style="color: #000000; ">LONG biYPelsPerMeter; // 位图垂直分辨率，每米像素数(42-45字节)</span><br style="color: #000000; " /><span style="color: #000000; ">DWORD biClrUsed;// 位图实际使用的颜色表中的颜色数(46-49字节)</span><br style="color: #000000; " /><span style="color: #000000; ">DWORD biClrImportant;// 位图显示过程中重要的颜色数(50-53字节)</span><br style="color: #000000; " /><span style="color: #000000; ">} BITMAPINFOHEADER;</span><br style="color: #000000; " /><span style="color: #000000; "><u>4：颜色表</u></span><br style="color: #000000; " /><span style="color: #000000; ">颜色表用于说明位图中的颜色，它有若干个表项，每一个表项是一个RGBQUAD类型的</span><strong style="color: #000000; ">结构</strong><span style="color: #000000; ">，定义一种颜色。RGBQUAD</span><strong style="color: #000000; ">结构</strong><span style="color: #000000; ">的定义如下:</span><br style="color: #000000; " /><span style="color: #000000; ">typedef struct tagRGBQUAD {</span><br style="color: #000000; " /><span style="color: #000000; ">BYTE rgbBlue;// 蓝色的亮度(值范围为0-255)</span><br style="color: #000000; " /><span style="color: #000000; ">BYTE rgbGreen; // 绿色的亮度(值范围为0-255)</span><br style="color: #000000; " /><span style="color: #000000; ">BYTE rgbRed; // 红色的亮度(值范围为0-255)</span><br style="color: #000000; " /><span style="color: #000000; ">BYTE rgbReserved;// 保留，必须为0</span><br style="color: #000000; " /><span style="color: #000000; ">} RGBQUAD;</span><br style="color: #000000; " /><span style="color: #000000; ">颜色表中RGBQUAD</span><strong style="color: #000000; ">结构</strong><span style="color: #000000; ">数据的个数有biBitCount来确定:</span><br style="color: #000000; " /><span style="color: #000000; ">当biBitCount=1,4,8时，分别有2,16,256个表项;</span><br style="color: #000000; " /><span style="color: #000000; ">当biBitCount=24时，没有颜色表项。</span><br style="color: #000000; " /><span style="color: #000000; ">位图信息头和颜色表组成位图信息，BITMAPINFO</span><strong style="color: #000000; ">结构</strong><span style="color: #000000; ">定义如下:</span><br style="color: #000000; " /><span style="color: #000000; ">typedef struct tagBITMAPINFO {</span><br style="color: #000000; " /><span style="color: #000000; ">BITMAPINFOHEADER bmiHeader; // 位图信息头</span><br style="color: #000000; " /><span style="color: #000000; ">RGBQUAD bmiColors[1]; // 颜色表</span><br style="color: #000000; " /><span style="color: #000000; ">} BITMAPINFO;</span><br style="color: #000000; " /><span style="color: #000000; "><u>5：位图数据</u></span><br style="color: #000000; " /><span style="color: #000000; ">位图数据记录了位图的每一个像素值，记录顺序是在扫描行内是从左到右,扫描行之间是从下到上。位图的一个像素值所占的字节数:</span><br style="color: #000000; " /><span style="color: #000000; ">当biBitCount=1时，8个像素占1个字节;</span><br style="color: #000000; " /><span style="color: #000000; ">当biBitCount=4时，2个像素占1个字节;</span><br style="color: #000000; " /><span style="color: #000000; ">当biBitCount=8时，1个像素占1个字节;</span><br style="color: #000000; " /><span style="color: #000000; ">当biBitCount=24时,1个像素占3个字节;</span><br style="color: #000000; " /><span style="color: #000000; ">Windows规定一个扫描行所占的字节数必须是</span><br style="color: #000000; " /><span style="color: #000000; ">4的倍数(即以long为单位),不足的以0填充，</span><br style="color: #000000; " /><span style="color: #000000; ">biSizeImage = ((((bi.biWidth * bi.biBitCount) + 31) &amp; ~31) / 8) * bi.biHeight;</span><br style="color: #000000; " /><span style="color: #000000; ">具体数据举例：</span><br style="color: #000000; " /><span style="color: #000000; ">如某</span><span style="color: #000000; ">BMP</span><span style="color: #000000; ">文件开头：</span><br style="color: #000000; " /><span style="color: #000000; ">4D42 4690 0000 0000 0000 4600 0000 2800 0000 8000 0000 9000 0000 0100*1000 0300 0000 0090 0000 A00F 0000 A00F 0000 0000 0000 0000 0000*00F8 0000 E007 0000 1F00 0000 0000 0000*02F1 84F1 04F1 84F1 84F1 06F2 84F1 06F2 04F2 86F2 06F2 86F2 86F2 .... ....</span><br style="color: #000000; " /><span style="color: #000000; ">BMP</span><span style="color: #000000; ">文件可分为四个部分：位图文件头、位图信息头、彩色板、图像数据阵列，在上图中已用*分隔。</span><br style="color: #000000; " /><span style="color: #000000; ">一、图像文件头</span><br style="color: #000000; " /><span style="color: #000000; ">1）1：(这里的数字代表的是"字",即两个字节,下同)图像文件头。0x4D42=&#8217;BM&#8217;，表示是Windows支持的</span><span style="color: #000000; ">BMP</span><span style="color: #000000; ">格式。</span><br style="color: #000000; " /><span style="color: #000000; ">2）2-3：整个文件大小。4690 0000，为00009046h=36934。</span><br style="color: #000000; " /><span style="color: #000000; ">3）4-5：保留，必须设置为0。</span><br style="color: #000000; " /><span style="color: #000000; ">4）6-7：从文件开始到位图数据之间的偏移量。4600 0000，为00000046h=70，上面的文件头就是35字=70字节。</span><br style="color: #000000; " /><span style="color: #000000; ">二、位图信息头</span><br style="color: #000000; " /><span style="color: #000000; ">5）8-9：位图图信息头长度。</span><br style="color: #000000; " /><span style="color: #000000; ">6）10-11：位图宽度，以像素为单位。8000 0000，为00000080h=128。</span><br style="color: #000000; " /><span style="color: #000000; ">7）12-13：位图高度，以像素为单位。9000 0000，为00000090h=144。</span><br style="color: #000000; " /><span style="color: #000000; ">8）14：位图的位面数，该值总是1。0100，为0001h=1。</span><br style="color: #000000; " /><span style="color: #000000; ">9）15：每个像素的位数。有1（单色），4（16色），8（256色），16（64K色，高彩色），24（16M色，真彩色），32（4096M色，增强型真彩色）。1000为0010h=16。</span><br style="color: #000000; " /><span style="color: #000000; ">10）16-17：压缩说明：有0（不压缩），1（RLE 8，8位RLE压缩），2（RLE 4，4位RLE压缩，3（Bitfields，位域存放）。RLE简单地说是采用像素数+像素值的方式进行压缩。T408采用的是位域存放方式，用两个字节表示一个像素，位域分配为r5b6g5。图中0300 0000为00000003h=3。</span><br style="color: #000000; " /><span style="color: #000000; ">11）18-19：用字节数表示的位图数据的大小，该数必须是4的倍数，数值上等于（&#8805;位图宽度的最小的4的倍数）&#215;位图高度&#215;每个像素位数。0090 0000为00009000h=80&#215;90&#215;2h=36864。</span><br style="color: #000000; " /><span style="color: #000000; ">12）20-21：用象素/米表示的水平分辨率。A00F 0000为0000 0FA0h=4000。</span><br style="color: #000000; " /><span style="color: #000000; ">13）22-23：用象素/米表示的垂直分辨率。A00F 0000为0000 0FA0h=4000。</span><br style="color: #000000; " /><span style="color: #000000; ">14）24-25：位图使用的颜色索引数。设为0的话，则说明使用所有调色板项。</span><br style="color: #000000; " /><span style="color: #000000; ">15）26-27：对图象显示有重要影响的颜色索引的数目。如果是0，表示都重要。</span><br style="color: #000000; " /><span style="color: #000000; ">三、彩色板</span><br style="color: #000000; " /><span style="color: #000000; ">16）28-....(不确定)：彩色板规范。对于调色板中的每个表项，用下述方法来描述RGB的值：</span><br style="color: #000000; " /><span style="color: #000000; ">1字节用于蓝色分量</span><br style="color: #000000; " /><span style="color: #000000; ">1字节用于绿色分量</span><br style="color: #000000; " /><span style="color: #000000; ">1字节用于红色分量</span><br style="color: #000000; " /><span style="color: #000000; ">1字节用于填充符(设置为0)</span><br style="color: #000000; " /><span style="color: #000000; ">对于24-位真彩色图像就不使用彩色板，因为位图中的RGB值就代表了每个象素的颜色。</span><br style="color: #000000; " /><span style="color: #000000; ">如，彩色板为00F8 0000 E007 0000 1F00 0000 0000 0000，其中：</span><br style="color: #000000; " /><span style="color: #000000; ">00FB 0000为FB00h=1111100000000000（二进制），是蓝色分量的掩码。</span><br style="color: #000000; " /><span style="color: #000000; ">E007 0000为 07E0h=0000011111100000（二进制），是绿色分量的掩码。</span><br style="color: #000000; " /><span style="color: #000000; ">1F00 0000为001Fh=0000000000011111（二进制），是红色分量的掩码。</span><br style="color: #000000; " /><span style="color: #000000; ">0000 0000总设置为0。</span><br style="color: #000000; " /><span style="color: #000000; ">将掩码跟像素值进行&#8220;与&#8221;运算再进行移位操作就可以得到各色分量值。看看掩码，就可以明白事实上在每个像素值的两个字节16位中，按从高到低取5、6、5位分别就是r、g、b分量值。取出分量值后把r、g、b值分别乘以8、4、8就可以补齐第个分量为一个字节，再把这三个字节按rgb组合，放入存储器（同样要反序），就可以转换为24位标准</span><span style="color: #000000; ">BMP</span><span style="color: #000000; ">格式了。</span><br style="color: #000000; " /><span style="color: #000000; ">四、图像数据阵列</span><br style="color: #000000; " /><span style="color: #000000; ">17)27(无调色板)-．．．：每两个字节表示一个像素。阵列中的第一个字节表示位图左下角的象素，而最后一个字节表示位图右上角的象素。</span><br style="color: #000000; " /><span style="color: #000000; ">五、存储算法</span><br style="color: #000000; " /><span style="color: #000000; ">BMP</span><span style="color: #000000; ">文件通常是不压缩的，所以它们通常比同一幅图像的压缩图像文件格式要大很多。例如，一个800&#215;600的24位几乎占据1.4MB空间。因此它们通常不适合在因特网或者其它低速或者有容量限制的媒介上进行传输。根据颜色深度的不同，图像上的一个像素可以用一个或者多个字节表示，它由n/8所确定（n是位深度，1字节包含8个数据位）。图片浏览器等基于字节的ASCII值计算像素的颜色，然后从调色板中读出相应的值。更为详细的信息请参阅下面关于位图文件的部分。 n位2n种颜色的位图近似字节数可以用下面的公式计算：&nbsp;</span><span style="color: #000000; ">BMP</span><span style="color: #000000; ">文件大小约等于 54+4*2的n次方+（w*h*n)/8</span><br style="color: #000000; " /><span style="color: #000000; ">，其中高度和宽度都是像素数。需要注意的是上面公式中的54是位图文件的文件头，是彩色调色板的大小。另外需要注意的是这是一个近似值，对于n位的位图图像来说，尽管可能有最多2n中颜色，一个特定的图像可能并不会使用这些所有的颜色。由于彩色调色板仅仅定义了图像所用的颜色，所以实际的彩色调色板将小于。如果想知道这些值是如何得到的，请参考下面文件格式的部分。由于存储算法本身决定的因素，根据几个图像参数的不同计算出的大小与实际的文件大小将会有一些细小的差别。</span></div></div></span><img src ="http://www.cppblog.com/cokecoffe/aggbug/152326.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/cokecoffe/" target="_blank">Wangkeke</a> 2011-08-03 10:08 <a href="http://www.cppblog.com/cokecoffe/archive/2011/08/03/152326.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>