Is there bug in the Matrix.RotateAt method for certain angles? .Net Winforms

Posted by Jules on Stack Overflow See other posts from Stack Overflow or by Jules
Published on 2010-05-24T11:58:37Z Indexed on 2010/05/24 12:01 UTC
Read the original article Hit count: 219

Filed under:
|
|
|
|

Here's the code i'm using to rotate:

Dim m As New System.Drawing.Drawing2D.Matrix
Dim size = image.Size
m.RotateAt(degreeAngle, New PointF(CSng(size.Width / 2), CSng(size.Height / 2)))
Dim temp As New Bitmap(600, 600, Imaging.PixelFormat.Format32bppPArgb)
Dim g As Graphics = Graphics.FromImage(temp)
g.Transform = m
g.DrawImage(image, 0, 0)

(1) Disposals removed for brevity.
(2) I test the code with a 200 x 200 rectangle.
(3) Size 600,600 it just an arbitrary large value that I know will fit the right and bottom sides of the rotated image for testing purposes.
(4) I know, with this code, the top and left edges will be clipped because I'm not transforming the orgin after the rotate.

The problem only occurs at certain angles:

(1) At 90, the right hand edge disappears completely.
(2) At 180, the right and bottom edges are there, but very faded.
(3) At 270, the bottom edge disappears completely.

Is this a known bug?

If I manually rotate the corners an draw the image by specifying an output rectangle, I don't get the same problem - though it is slightly slower than using RotateAt.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET