现象:各种图的速度绘制的差异。
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
更奇怪的是: