⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 基于vc_net的gdi+编程入门之画刷 _4.htm

📁 GDI编程的参考资料
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0048)http://www.qqread.com/vcdotnet/f482126000_4.html -->
<HTML lang=zh xml:lang="zh" xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>基于VC.NET的GDI+编程入门之画刷 - QQread.com 电脑频道</TITLE>
<META http-equiv=Content-Language content=zh-CN>
<META 
content=[art_mtkw],电脑入门,上网指南,操作系统,常用软件,黑客与安全,网络游戏,程序开发,数据库开发,网页制作,图像处理,多媒体制作,网络编程,加密技术,网络技术 
name=keywords>
<META content=基于VC.NET的GDI+编程入门之画刷 name=description>
<META content=QQRead.com name=author>
<META content=all name=robots>
<META http-equiv=Content-Type content="text/html; charset=gb2312"><LINK 
href="基于VC_NET的GDI+编程入门之画刷 _4.files/qqread_html.css" type=text/css 
rel=stylesheet><LINK href="基于VC_NET的GDI+编程入门之画刷 _4.files/qqread_html_com.css" 
type=text/css rel=stylesheet>
<STYLE type=text/css>.STYLE2 {
	FONT-SIZE: 14px
}
</STYLE>

<META content="MSHTML 6.00.2900.2180" name=GENERATOR></HEAD>
<BODY><!-- 公共页头 -->
<DIV style="TEXT-ALIGN: center">
<DIV id=topad>
<TABLE>
  <TBODY>
  <TR>
    <TD width=10><SPAN 
id=ad_qqread_top></SPAN><!--End//--></TD></TR></TBODY></TABLE></DIV>
<DIV id=CHBig>
<DIV id=CHBigCSDNLogo><A href="http://www.qqread.com/"><IMG alt=巧巧读书网 
src="基于VC_NET的GDI+编程入门之画刷 _4.files/qqread.gif" border=0></A></DIV>
<DIV id=CHBigHeaderWrapper>
<DIV id=CHBigNavBar2>
<UL>
  <LI><A href="http://www.qqread.com/news/" target=_blank>新闻中心</A>| 
  <LI><A href="http://www.qqread.com/skill/" target=_blank>技巧集锦</A>| 
  <LI><A href="http://www.qqread.com/itlife/" target=_blank>IT人生雨露</A>| 
  <LI><A href="http://www.qqread.com/pcbase/" target=_blank>电脑入门</A>| 
  <LI><A href="http://www.qqread.com/netreference/" target=_blank>上网指南</A>| 
  <LI><A href="http://www.qqread.com/safe/" target=_blank>黑客与安全</A>| 
  <LI><A href="http://www.qqread.com/commentsoft/" target=_blank>常用软件</A>| 
  <LI><A href="http://www.qqread.com/os/" target=_blank>操作系统</A>| 
  <LI><A href="http://www.qqread.com/netgame/" target=_blank>网络游戏</A><BR>
  <LI><A title=图片欣赏 href="http://www.qqread.com/photo/index.html" 
  target=_blank>图片欣赏</A>| 
  <LI><A href="http://www.qqread.com/program/" target=_blank>程序开发</A>| 
  <LI><A href="http://www.qqread.com/database/" target=_blank>数据库开发</A>| 
  <LI><A href="http://www.qqread.com/webdesign/" target=_blank>网页制作</A>| 
  <LI><A href="http://www.qqread.com/photohandle/" target=_blank>图像处理</A>| 
  <LI><A href="http://www.qqread.com/mutimedia/" target=_blank>多媒体制作</A>| 
  <LI><A href="http://www.qqread.com/netprogram/" target=_blank>网络编程</A>| 
  <LI><A href="http://www.qqread.com/encrypt/" target=_blank>加密技术</A>| 
  <LI><A href="http://www.qqread.com/network/" target=_blank>网络技术</A> 
</LI></UL></DIV>
<DIV id=CHBigNavBar1></DIV></DIV>
<DIV style="CLEAR: both"></DIV></DIV></DIV><!-- /公共页头 -->
<DIV id=OutBox>
<DIV id=listMainArea>
<DIV id=disclaimer><A href="http://www.qqread.com/">巧巧读书首页</A> &gt; <A 
title=程序开发 href="http://www.qqread.com/program/index.html">程序开发</A> &gt; <A 
title=.Net技术 href="http://www.qqread.com/dotnet/index.html">.Net技术</A> &gt; <A 
title=VC.NET href="http://www.qqread.com/vcdotnet/index.html">VC.NET</A> &gt; 
正文</DIV>
<DL class=ReadArticle>
  <DT>基于VC.NET的GDI+编程入门之画刷 
  <DD class=ArticleInfo3>
  <SCRIPT src="基于VC_NET的GDI+编程入门之画刷 _4.files/adtitle.js" 
  type=text/javascript></SCRIPT>

  <HR SIZE=2>

  <DD class=ArticleInfo3>
  <DIV align=center><A href="http://www.qqread.com/">http://www.qqread.com/</A> 
  作者:刘涛 2005-12-03 来源:天极网 浏览:<SPAN id=count></SPAN> </DIV>
  <DD class=ArticleInfo_3>
  <DD class=ArticleInfo_3><A 
  href="http://www.qqread.com/vcdotnet/f482126000_3.html">上一页</A>&nbsp;<A 
  href="http://www.qqread.com/vcdotnet/f482126000.html">1</A>&nbsp;<A 
  href="http://www.qqread.com/vcdotnet/f482126000_2.html">2</A>&nbsp;<A 
  href="http://www.qqread.com/vcdotnet/f482126000_3.html">3</A>&nbsp;<FONT 
  color=#ff0000>4</FONT>&nbsp; 
  <DD 
  class=ArticleContent>  (四)渐变画刷<BR><BR>  渐变画刷类似与实心画刷,因为它也是基于颜色的,与实心画刷不同的是,渐变画刷使用两种颜色,它的主要特点是,在使用过程中,一种颜色在一端,而另外一种颜色在另一端。在中间,两种颜色融合产生过渡或衰减的效果。 
  <BR><BR>  渐变画刷有两种:线性画刷和路径画刷<BR><BR>  1、线性渐变画刷<BR>  
  <BR>  线性渐变画刷在封闭的区域内的两端使用两种颜色,如左端和右端。<BR><BR>  为了支持线性渐变画刷,.NET框架在名字空间System::Drawing::Drawing2D 
  中对LinearGradientBrush类进行了定义,为了规定填充图形的起点和终点,可以使用下面的构造函数:<BR><BR>
  <TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#dadacf 
    border=1><TBODY>
    <TR>
      <TD>public: LinearGradientBrush(Point point1, Point point2, Color 
        color1, Color color2);<BR>public: LinearGradientBrush(PointF point1, 
        PointF point2, Color color1, Color 
  color2);</TD></TR></TBODY></TABLE><BR>  第一个参数point1是绘制的起点,第三个参数color1是对应该点的颜色,第二个参数point2对应着绘制的终点,color2是该点的颜色。例子代码如下:<BR><BR>
  <TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#dadacf 
    border=1><TBODY>
    <TR>
      <TD>private: System::Void Form1_Paint(System::Object * sender, 
        <BR>System::Windows::Forms::PaintEventArgs * e)<BR>{<BR>using namespace 
        System::Drawing::Drawing2D;<BR>LinearGradientBrush *lgb = new 
        LinearGradientBrush(Point(20, 20), <BR>Point(450,20), Color::DarkGreen, 
        Color::LightBlue);<BR>e-&gt;Graphics-&gt;FillRectangle(lgb, 20, 20, 430, 
        180);<BR>}</TD></TR></TBODY></TABLE><BR>
  <TABLE width="90%" align=center border=0>
    <TBODY>
    <TR>
      <TD>
        <DIV align=center><IMG hspace=3 
        src="基于VC_NET的GDI+编程入门之画刷 _4.files/20051203ig390_11.gif" align=center 
        vspace=1 border=1 
  ;?><BR>图十一、线性渐变画刷效果</DIV></TD></TR></TBODY></TABLE><BR>  默认情况下,渐变画刷按照水平渐变的方式填充图形,如果想让颜色按照不同的方向渐变,如垂直或对角线方向,可以使用下面的构造函数:<BR><BR>
  <TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#dadacf 
    border=1><TBODY>
    <TR>
      <TD>public: LinearGradientBrush(Rectangle rect, Color color1, Color 
        color2, <BR>LinearGradientMode factor);<BR>public: 
        LinearGradientBrush(RectangleF rect, Color color1, Color color2, 
        <BR>LinearGradientMode 
  factor);</TD></TR></TBODY></TABLE><BR>  第一个参数rect是所要填充颜色的矩形,第二个参数是起点的颜色,第三个参数是终点的颜色,第四个参数factor用来决定颜色融合的方向。它可以取以下值: 
  <BR><BR>  Vertical:垂直方向渐变:<BR><BR>
  <TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#dadacf 
    border=1><TBODY>
    <TR>
      <TD>private: System::Void Form1_Paint(System::Object * sender, 
        <BR>System::Windows::Forms::PaintEventArgs * e)<BR>{<BR>using namespace 
        System::Drawing::Drawing2D;<BR>Rectangle rect(10, 10, 470, 
        300);<BR>LinearGradientBrush *lgb = new 
        LinearGradientBrush(rect,<BR>Color::DarkRed,Color::White, 
        LinearGradientMode::Vertical);<BR>e-&gt;Graphics-&gt;FillRectangle(lgb, 
        10, 10, 450, 280);<BR>}</TD></TR></TBODY></TABLE><BR>
  <TABLE width="90%" align=center border=0>
    <TBODY>
    <TR>
      <TD>
        <DIV align=center><IMG hspace=3 
        src="基于VC_NET的GDI+编程入门之画刷 _4.files/20051203ig390_12.gif" align=center 
        vspace=1 border=1 
  ;?><BR>图十二、代码运行效果图</DIV></TD></TR></TBODY></TABLE><BR>  Horizontal:水平渐变; 
  BackwardDiagonal:反向对角线渐变; 
  ForwardDiagonal:正向对角线渐变。<BR><BR>  用来指定渐变方向的构造函数有局限性,它只有四个选项,如果需要,可以使用下面的构造函数来指定任意角度的渐变。<BR><BR>
  <TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#dadacf 
    border=1><TBODY>
    <TR>
      <TD>public: LinearGradientBrush(Rectangle rect, Color color1, Color 
        color2, float angle);<BR>public: LinearGradientBrush(RectangleF rect, 
        Color color1, Color color2, float 
  angle);</TD></TR></TBODY></TABLE><BR>  第一个参数rect指的是所要画颜色的区域,最后一个参数angle(按顺时针方向计算),定义了颜色融合的方向。参数color1是开始点的颜色,参数color2是终点的颜色。这里有个例子:<BR><BR>
  <TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#dadacf 
    border=1><TBODY>
    <TR>
      <TD>private: System::Void Form1_Paint(System::Object * sender, 
        <BR>System::Windows::Forms::PaintEventArgs * e)<BR>{<BR>using namespace 
        System::Drawing::Drawing2D;<BR>Rectangle rect(10, 10, 470, 
        300);<BR>LinearGradientBrush *lgb = new 
        LinearGradientBrush(rect,<BR>Color::DarkRed, Color::White, 
        -65.24F);<BR>e-&gt;Graphics-&gt;FillRectangle(lgb, 10, 10, 450, 
        280);<BR>}</TD></TR></TBODY></TABLE><BR>
  <TABLE width="90%" align=center border=0>
    <TBODY>
    <TR>
      <TD>
        <DIV align=center><IMG hspace=3 
        src="基于VC_NET的GDI+编程入门之画刷 _4.files/20051203ig390_13.gif" align=center 
        vspace=1 border=1 
  ;?><BR>图十三、代码运行效果图</DIV></TD></TR></TBODY></TABLE><BR>  2、路径渐变画刷<BR><BR>  第二种可用的渐变画刷就是路径渐变画刷,这种画刷用在路径上,来产生渐变效果。.NET 
  框架在System.Drawing.Drawing2D名字空间中提供了 PathGradientBrush,这个类比有两个构造函数:<BR><BR>
  <TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#dadacf 
    border=1><TBODY>
    <TR>
      <TD>public: PathGradientBrush(Point points[]);<BR>public: 
        PathGradientBrush(PointF 
  points[]);</TD></TR></TBODY></TABLE><BR>  传递给这个构造函数的参数是Point类型的数组,这里有一个例子:<BR><BR>
  <TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#dadacf 
    border=1><TBODY>
    <TR>
      <TD>private: System::Void Form1_Paint(System::Object * sender, 
        <BR>System::Windows::Forms::PaintEventArgs * e)<BR>{<BR>using namespace 
        System::Drawing::Drawing2D;<BR>Point ptGraph[] = { Point(10, 
        10),<BR>Point(450, 10),<BR>Point(450, 250),<BR>Point(10, 250) 
        };<BR>PathGradientBrush *pgb = new 
        PathGradientBrush(ptGraph);<BR>e-&gt;Graphics-&gt;FillRectangle(pgb, 10, 
        10, 450, 280);<BR>}</TD></TR></TBODY></TABLE><BR>
  <TABLE width="90%" align=center border=0>
    <TBODY>
    <TR>
      <TD>
        <DIV align=center><IMG hspace=3 
        src="基于VC_NET的GDI+编程入门之画刷 _4.files/20051203ig390_14.gif" align=center 
        vspace=1 border=1 ;?><BR>图十四、代码运行效果图</DIV></TD></TR></TBODY></TABLE>
  <TABLE style="MARGIN: 10px 8px 3px 7px" cellSpacing=0 cellPadding=0 align=left 
  border=0>
    <TBODY>
    <TR>
      <TD><SPAN id=ad_qqread_mid_big></SPAN></TD></TR></TBODY></TABLE>
  <DD class=ArticleContent>关键字: <A 
  href="http://www.qqread.com/keywords/file-format.html">文件格式</A>&nbsp;&nbsp;<A 
  href="http://www.baidu.com/baidu?tn=jkday2000&amp;word=设计">设计</A>&nbsp;&nbsp;<A 
  href="http://www.qqread.com/keywords/windows.html">windows</A>&nbsp;&nbsp;<A 
  href="http://www.qqread.com/keywords/vcdotnet.html">vc.net</A>&nbsp;&nbsp;<A 
  href="http://www.qqread.com/keywords/os.html">os</A>&nbsp;&nbsp;<A 
  href="http://www.qqread.com/keywords/ie.html">ie</A>&nbsp;&nbsp; 
  <DD class=ArticleInfo_3><A 
  href="http://www.qqread.com/vcdotnet/f482126000_3.html">上一页</A>&nbsp;<A 
  href="http://www.qqread.com/vcdotnet/f482126000.html">1</A>&nbsp;<A 
  href="http://www.qqread.com/vcdotnet/f482126000_2.html">2</A>&nbsp;<A 
  href="http://www.qqread.com/vcdotnet/f482126000_3.html">3</A>&nbsp;<FONT 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -