المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Sizing issue with rotate Graphic



C# Programming
04-06-2009, 10:41 AM
Okay, I thought this should be for a new thread....


I have an existing image.




originalImage = new Bitmap(path.ToString());

Bitmap newImage = new Bitmap(originalImage.Width, originalImage.Height);
g = Graphics.FromImage(newImage);

Matrix matrix = new Matrix();
matrix.Rotate(10f);

g.TranslateTransform( ((float)originalImage.Width) / 2, ((float)originalImage.Height) / 2);
g.RotateTransform(10f);
g.TranslateTransform(-((float)originalImage.Width) / 2, -((float)originalImage.Height) / 2);


g.DrawImage(originalImage, 0, 0);




This works just as I want it to in terms of rotating on an axis in the center of a picture instead of 0,0 (x,y)coords. However, say my original picture is (wXh) 473x640 and when resized 10f I know it's supposed to be 577x712 or so. The reason it's bigger is that when the picture is rotated, say, angle of 10, the top left corner is no longer within the original dimension of the image and therefore apear cut off. I do not want this. I want the image to resize as needed to fit the entire contents of a rotated image.

Any idears? Setting the g.DrawImage and setting the width height, even to the known values needed, just exands the image is the Graphics object, so it appears, already lopped off parts of my image to stay within the initial constraints. I don't know how to mkae the Graphic larger bigger without affecting the Bitmap it initially used....


If there are any good sources for .net graphics that'd be great. I can't find an examples in dr. google and my pro c# book doens't have any such examples.