zoukankan      html  css  js  c++  java
  • GDI+ 的绘画中的双缓冲。

    GDI+最大的特色就是Graphics,并提供了更多的画图功能。
    通过这几天的学习,对绘图基本有个掌握.
    首先我们来谈双缓冲的技术.
    如果我们是直接在窗体上绘图的话,我们可以使用如下的方法
      this.SetStyle(ControlStyles.DoubleBuffer |
          ControlStyles.UserPaint |
          ControlStyles.AllPaintingInWmPaint,
          true);
       this.UpdateStyles();
    通过Form的OnPaint()就可以绘无闪硕的图形了.
    还有一种方法:
      使用一个 Bitmap作为后端.
      private Bitmap renderSurface = null;
      初始化renderSuface()
      private void DoRenderSurface()
      {
       if (renderSurface != null)
       {
        renderSurface.Dispose();
       }
       renderSurface =new Bitmap(ClientRectangle.Width,ClientRectangle.Height);

       using (Graphics g = Graphics.FromImage(renderSurface))
       {
        g.Clear(this.BackColor);
       }

       

      }
       画图
       private void DoDraw(Graphics g)
      {
       if (renderSurface == null)
       {
        DoRenderSurface();
       }
       g.DrawImage(renderSurface,ClientRectangle,ClientRectangle,GraphicsUnit.Pixel);
      }

  • 相关阅读:
    FZU2150 Fire Game
    POJ3414 Pots
    POJ3087 Shuffle'm Up
    POJ3126 Prime Path
    POJ1426 Find The Multiple
    POJ3279 Fliptile
    甘特图实用技巧——项目进度一目了然!
    连设计图都不会画,你还想做“系统架构师”?
    java中list和map的底层实现原理
    redis四种部署方式
  • 原文地址:https://www.cnblogs.com/wanghualiang/p/174448.html
Copyright © 2011-2022 走看看