游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1381|回复: 0

为什么用managed directX绘2D图的速度比GDI+还慢?

[复制链接]

1

主题

1

帖子

3

积分

新手上路

Rank: 1

积分
3
发表于 2010-2-26 22:58:00 | 显示全部楼层 |阅读模式
这是一段移动图片的代码
图片是64*64的。
  string file = @"D:\d.JPG";
            te = TextureLoader.FromFile(de, file);
            
            int a = 0;
            if (a == 0)
            {

                for (int i = 0; i < 500; i++)
                {
                    de.Clear(ClearFlags.Target, Color.Blue, 1.0f, 0);
                    de.BeginScene();
                    sp.Begin(SpriteFlags.AlphaBlend);
                    sp.Draw2D(te, Rectangle.Empty, new Rectangle(0, 0, 64, 64), new Point(i, 0), Color.White);            
                    
                    sp.End();
                    de.EndScene();
                    de.Present();
                    Application.DoEvents();
                }
            }
            if (a == 1)
            {
                Bitmap bm = new Bitmap(panel1.Width, panel1.Height);
                Graphics g = Graphics.FromImage(bm);
                for (int i = 0; i < 500; i++)
                {
                    g.DrawImage(Image.FromFile(file), i, 0);
                  
                    e.Graphics.DrawImage(bm, 0, 0);
                    Application.DoEvents();
                }
            }
                    }
前者是DX绘图。后者是GDI+。
但是在移动速度上后者比前者快好几倍~~
是不是我的代码有什么地方不对?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-6-12 17:43

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表