WEB开发网
开发学院手机开发Windows Mobile 开发 GDI on Windows Mobile 托管代码和本地代码的性能... 阅读

GDI on Windows Mobile 托管代码和本地代码的性能比较

 2010-03-01 18:58:00 来源:WEB开发网   
核心提示:bop *= -1;boxBrush = CreateSolidBrush(RGB(r, g, b));FillRect(bufferDC, &rect, boxBrush);DeleteObject(boxBrush);Ellipse(bufferDC, width, height, BOX_WIDTH - widt

bop *= -1;

boxBrush = CreateSolidBrush(RGB(r, g, b));

FillRect(bufferDC, &rect, boxBrush);

DeleteObject(boxBrush);

Ellipse(bufferDC, width, height, BOX_WIDTH - width, BOX_HEIGHT - height);

Ellipse(bufferDC, height, width, BOX_WIDTH - height, BOX_HEIGHT - width);

BitBlt(screenDC, left, top, left + BOX_WIDTH, top + BOX_HEIGHT,

bufferDC, 0, 0, SRCCOPY);

}

...

运行效果如图:

测试结果是,在Windows Mobile 5.0的模拟器上,执行循环的速度为490次每秒(当然这跟你PC机的性能是有关的)。每一次操作包括了填充矩形和绘制两个椭圆的过程。在一台Windows Mobile 5.0 Dell Axim x51(PXA270处理器)的实际设备上,这个程序可以达到250次每秒的循环速度。

Compact Framework下的测试

厄,实际上这是一份和上面的代码很类似的C#代码:

...

Bitmap backBuffer = new Bitmap(BOX_WIDTH, BOX_HEIGHT);

Brush boxBrush;Brush ellipseBrush = new SolidBrush(Color.Green);

Graphics screenGraphics = f.CreateGraphics(); // Graphics.FromHdc(screenDC);

Graphics backGraphics = Graphics.FromImage(backBuffer);

for (i = 0; i < GDI_ITERATIONS_PER_REPORT; i++)

{

width += xop;

height += yop;

if ((width >= BOX_WIDTH) || (width <= 0))

xop *= -1;

if ((height >= BOX_HEIGHT) || (height <= 0))

yop *= -1;

r += rop;

g += gop;

b += bop;

if ((r > 254) || (r < 1))

rop *= -1;

if ((g > 254) || (g < 1))

gop *= -1;

if ((b > 254) || (b < 1))

bop *= -1;

boxBrush = new SolidBrush(Color.FromArgb(r, g, b));

backGraphics.FillRectangle(boxBrush, 0, 0, BOX_WIDTH, BOX_HEIGHT);

boxBrush.Dispose();

backGraphics.FillEllipse(ellipseBrush, width, height,

上一页  1 2 3 4  下一页

Tags:GDI on Windows

编辑录入:coldstar [复制链接] [打 印]
赞助商链接