开发者

Simple brightness but slow

I have a 开发者_如何学Gopicture, and I get every pixels and multiply the RGB for a number. I also need to take care when R * number > 255. When this happen, r = 255. It's taking about 10s+ to complete a 1024x768 image. The common softwares that do brightness, takes less than 1s to do it. Any ideias to improve my strategy? Thanks.


I had a similar problem:

How to use ColorMatrix in .NET to change Brightness, Color, Saturation, Hue

For brightness alone, colormatrix will work fine. If you want to start using contrast, etc, you will need to use some other solution. It seems to be SetPixel is the slowest part. See this solution for doing this quickly:

http://www.codeproject.com/KB/GDI-plus/csharpgraphicfilters11.aspx


Using a ColorMatrix would probably be the best way to go. Here's an article to get you on your way: http://www.c-sharpcorner.com/UploadFile/mahesh/Transformations0512192005050129AM/Transformations05.aspx


when I did some simple image manipulation on multi megabyte images I significantly improved performance using unsafe code and pointer manipulation to get at the to the raw bytes.

This might get you in the right direction http://wcode.net/2009/08/unsafe-in-c-and-image-processing/


well this site helped me a lot: http://blogs.msdn.com/b/llobo/archive/2007/03/08/bitmapsource-bitmap-interop.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜