There are some looooong and hungry algorithms for doing so, but as of yet I haven't come up with or found anything particularly fast.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
This answer returns both the offset it should be drawn on and the image which has been rotated.It works by recreating the new image to the size it should be without clipping the angles. Originally written by Hisenburg from the #C# IRC chatroom and Bloodyaugust.
Here's what I ended up doing (after an extensive amount of continued research, and the helpful link provided by TheCodeKing):
Cheers!
This should rotate the image in C#. What is it doing instead?
I haven't experimented too much with GDI+. Remember to reverse the rotation after the image is drawn.
The fastest way is to this is to use unsafe calls to manipulate the image memory directly using
LockBits
. It sounds scary but it's pretty straight forward. If you search for LockBits you'll find plently of examples such as here.The interesting bit is:
Once you have the BitmapData you can pass the pixels and map them into a new image (again using LockBits). This is significantly quicker than using the
Graphics
API.