Is the .NET platform a good way to rotate an array of pixels? To be more clear, I'm not just looking for a way to rotate the image. Instead, I want to rotate the base pixel array on which the image will / will be used, so that I have access to the modified array. I would prefer not to use the rotation algorithm or wrap another library if the .NET platform already provides a good way to do this. I need to support any rotation, not just 90/180/270 / etc. which will be easy to implement.
I thought about using one of the image classes that support this type of rotation, and then accessing the modified array from it. I'm not sure if this is a good idea in the first place, nor am I sure which class of images would be the best choice for this. So far, I have not been able to find a class or a combination of classes that support the required rotations and allow access to an array of pixels.
Update:
I'm starting to think that I either asked the wrong question or asked the right question. If I understand that Cosmin means using the Matrix class correctly, I don't think this will work for what I'm actually trying to do. I will try to better explain my problem.
Basically, I have a 2D data array, and I want to rotate it. I mean, I want the values โโof the elements to be rotated to the corresponding elements based on rotation.
For instance:
----------- |A|A|A|A|A| ----------- |B|B|B|B|B| ----------- |C|C|C|C|C| -----------
If I had to rotate this array around the center element 90 degrees counterclockwise, I would have to do something like this:
----------- | |A|B|C| | ----------- | |A|B|C| | ----------- | |A|B|C| | -----------
Unfortunately, I have to support any rotation, not just 90-degree rotation, which means that a more complex rotation algorithm is needed, since indexes with rotating elements will not always be integers and may overlap. This seems like a problem that was probably resolved in the field of computer graphics, which led me to ask the question the way I did it.
foven
source share