Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bitmap.SetPixel(x,y, Color) too slow

Tags:

.net

bitmap

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

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).

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?

like image 561
Joel Barsotti Avatar asked Dec 22 '22 08:12

Joel Barsotti


1 Answers

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

like image 50
Dour High Arch Avatar answered Jan 05 '23 12:01

Dour High Arch