c#GDI+绘图速度的一些差异不理解

现象:各种图的速度绘制的差异。

 

1:绘制内存位图,例如

Bitmap _SourceBitmap=new Bitmap(800,480);

Bitmap _DesBitmap=new Bitmap(800,480);

 

           Rectangle ScreenRect = new Rectangle(0, 0, 800, 480);
            Rectangle rect_1 = new Rectangle(0, 0, 800, 480);

            Graphics gScreen = this.CreateGraphics();

            Bitmap _membitmap = new Bitmap(800, 480);
            Graphics g_membitmap = Graphics.FromImage(_membitmap);

            uint time1 = GetTickCount();
            int nCount = 0;
            for (int width = m_CartoonLen; width <= 800; width += m_CartoonLen)
            {
                nCount++;

                int _width = width;
                int _heihg = width * 3 / 5;
                int x = (800 - width) / 2;
                int y = (480 - _heihg) / 2;

                rect_1.X = x;
                rect_1.Y = y;
                rect_1.Width = _width;
                rect_1.Height = _heihg;

                //恢复矩形区域
                g_membitmap.DrawImage(_SourceBitmap, 0, 0);
                g_membitmap.DrawImage(_DesBitmap, rect_1, ScreenRect, GraphicsUnit.Pixel);
                gScreen.DrawImage(_membitmap, 0, 0);
            }

            uint time2 = GetTickCount();
            uint len = time2 - time1;

.........(省略)

 

 

得到的结果是.303

 

按照5/0.303=15帧的速度

 

如果是:

 _SourceBitmap = TestWinceSpeed.Properties.Resources.WallPaper__0_;
            _DesBitmap = TestWinceSpeed.Properties.Resources.WallPaper__1_;

 

得到的结果是:

257

 

按照5/0.25=20帧的速度。

 

说明差异在30%,是否非常明显的。但是不知道为什么。

 

 

再做一下试验:

 Graphics gScreen = this.CreateGraphics();
            uint time1 = GetTickCount();
            int nCount = 0;
            for (int i = 0; i < 100; i++)
            {
                nCount++;
                gScreen.DrawImage(_SourceBitmap, m_Rect_1, m_Rect_1, GraphicsUnit.Pixel);
            }
            uint time2 = GetTickCount();
            uint len = time2 - time1;

            Console.WriteLine(nCount.ToString() + "Fun Cost Time ms:" + len.ToString());

            gScreen.Dispose();
            gScreen = null;

 

 

如果来自SourceBitmap=new Bitmap();

打印值

鼠标点击=515

手指触摸=391

 

 

如果值来自于资源文件,打印值=409

如果我是用鼠标点击=409,

如果是手指触摸屏=283

 

 

 

更奇怪的是:

 

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值