Note that there are some explanatory texts on larger screens.

plurals
  1. POTransformation (rotation) of image using matrix - design-time vs. run-time rendering results
    text
    copied!<p>I have a 48x48 image which is rotated using a transformation matrix.</p> <p>For some reason, the rotated image in design-time differs from the rotated image in run-time as you can see from <a href="http://img210.yfrog.com/img210/8058/render.jpg" rel="nofollow noreferrer"><s>this screenshot (link dead)</s></a> (design-time on the left, run-time on the right):</p> <p>It might be a little bit difficult to spot, but if you look closely at the right edge of the blue circle, it is about a pixel wider in the image to the right. Note that the image is layered - the white glow in the foreground is the part that's being rotated, while the blue ball in the background is static.</p> <p>It seems like the image is offset 1 pixel in run-time, when rotating exactly 90 degrees (as in the screenshot), 180 degrees and probably also 270 degrees. The image looks the same with any other rotation angle, as far as I can see.</p> <p>Here's a snippet:</p> <pre><code>protected static Image RotateImage(Image pImage, Single pAngle) { Matrix lMatrix = new Matrix(); lMatrix.RotateAt(pAngle, new PointF(pImage.Width / 2, pImage.Height / 2)); Bitmap lNewBitmap = new Bitmap(pImage.Width, pImage.Height); lNewBitmap.SetResolution(pImage.HorizontalResolution, pImage.VerticalResolution); Graphics lGraphics = Graphics.FromImage(lNewBitmap); lGraphics.Transform = lMatrix; lGraphics.DrawImage(pImage, 0, 0); lGraphics.Dispose(); lMatrix.Dispose(); return lNewBitmap; } void SomeMethod() { // Same results in design-time and run-time: PictureBox1.Image = RotateImage(PictureBox2.Image, 18) // Different results in design-time and run-time. PictureBox1.Image = RotateImage(PictureBox2.Image, 90) } </code></pre> <p>Can anyone explain the reason for this behaviour? Or better yet, a solution to make run-time results look like design-time results?</p> <p>It's important for me because this image is part of an animation which is generated from code based on a single image which is then rotated in small steps. In design-time, the animation looks smooth and nice. In run-time it looks like it's jumping around :/</p> <p>I'm using Visual Studio 2005 on Windows Vista Business SP2.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload