My application needs to rotate a picture.
What works so far is to get a ref to the picture,
Create a PixmapShape with the picture as the image.
Rotate the PixmapShape,
Use .Graphics.DrawObject to return the rotated image.
This works but distorts the image. Although, if I rotate it back to it's original position, it looks perfect again.
So see if you think I am on the right track.
Assume that the picture coming into the method is a rectangle.
If I take the longer side,
And make the new picture area a square of the longest side,
Now If I rotate, I won't get any distortion as the area being used will not require distortion.
This may crop the PixmapShape if centered.
So I'll take the longer side and multiply it by sqroot(2). This would give me a square larger than the longest side by the hypotenuse. I am assuming this:
TO rotate a square in another square, the outer square need only be the hypotenuse in length.
That is, take a leg of the inner square, and multiply it by root(2), and you'll have a leg for the outer square large enough.
A leg large enough to rotate the inner square.
- Find the longer side of a OriginalPicture to be rotated.
- Mul that by root 2.
- Make a NewPicture, square, of the size of the new leg,
- Use PixmapShape to draw the OriginalPicture into the NewPicture - centered.
(to center use the width/2 and height/2 to center the PixmapShape)
Graphics.DrawObject(PMap, Pic.Width/2, Pic.Height/2) - here PMap is my PixMapShpe.
With that all done, ...
- Rotate the image with PixMapShape.
- Place the rotated PixMapShape into FinalPicture and return that from the routine.
I'm off to try this. ... let's see if it works ..