2
Answers

Convert.ToByte = too slow

Ask a question
Devin

Devin

16y
5.4k
1

any1 know how I can speed up Convert.ToByte? this is from float to byte..

I'm developing a 2D realtime image processing engine, and is too slow on the conversion from a floating point array, back to a System.Drawing.Bitmap. I am using FastBitmap to modify the bitmap, but it only happens when an image is taken in to the class and then thrown out again, converting from bitmap is ok, cause it only happens once or twice, but after that it's output is rendered in realtime animation. I'd like at least 50 Frame Per Second, which it only achieves at 320 by 240. And I have profiled it using ANTS. and apart from the obvious SafeNativeMethods.BitBlt (which is used by the picturebox to show the image) it shows Convert.ToByte as using the most time.

I am using floating point so I can do multipycation, and division (blending and effects) on each pixel, without doing any unnescesary conversions.

hope some1 has an idea ;)

Thanks, heaps.


Answers (2)