Bitmap.SetPixel(X,Y,颜色)太慢 [英] Bitmap.SetPixel(x,y, Color) too slow

查看:1297
本文介绍了Bitmap.SetPixel(X,Y,颜色)太慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,目前我创建一个1000×1000的位图,它的支出约0.3秒简单地调用Bitmap.SetPixel()函数。

So currently I'm creating a 1000x1000 bitmap and it's spending about .3 seconds simply calling the Bitmap.SetPixel() function.

实际上,我只画大概50%的像素,因此它更像是500000呼叫setpixel。虽然这似乎想了很多电话,OTOH视频游戏做了很多更,推动许多许多像素(其中一些procedureally生成)。

I'm actually only drawing probably 50% of the pixels so it's more like 500,000 call to setpixel. While that does seem like a lot of calls, OTOH video games are do alot more and push many many more pixels (some of them procedureally generated).

显然Bitmap.SetPixel速度不是最优化的,但如果我需要更新的位图20-30次,第二次拿到像样的动画,这是方法要慢,所以我有哪些选择?

Obviously Bitmap.SetPixel isn't optimized for speed, but if I needed to update a bitmap 20-30 times a second to get decent animation, this is way to slow, so what are my options?

推荐答案

鲍勃·鲍威尔拥有一支优秀的教程有关访问像素直接映射到内存中。

Bob Powell has an excellent tutorial on accessing pixel maps directly in memory.

这篇关于Bitmap.SetPixel(X,Y,颜色)太慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆