Matrix operations question

Started by
2 comments, last by Adam_42 12 years, 5 months ago
I have been reading about matrix operations and have a question.




Take a look at the following article http://www.switchonthecode.com/tutorials/csharp-tutorial-convert-a-color-image-to-grayscale




I understand why example 2 is quicker than example 1 due to the way the data is being accessed. However I do not understand why example 3 is quicker than example 2 as surely although it is using a built in gdi+ method to alter the pixels both examples are still having to effectively set the pixel values in the same way (ie adding values to each pixel)?




If anyone can explain the difference to me then I would be grateful.

Advertisement
While I can't say exactly what method 3 is doing underneath it all (i.e. all the implementation details), I would assume there is a lot of optimizations that the method makes. For example, it can potentially employ SSE, hardware acceleration (by using the graphics card), parallelism (there's no reason it can't compute it all using multiple threads), etc. There's a lot of potential options here, and to be honest I'm not sure exactly which options it's using without exposing the underlying code of the draw calls.
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]
Moving to General Programming; this isn't DirectX related.
If you read the comments on the linked article (especially the long comment by 'rc' near the bottom) you'll find out that method 2 is the quickest when it's been optimized a bit more.

This topic is closed to new replies.

Advertisement