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

مشاهدة النسخة كاملة : How to convert Graphics image to Bitmap?



C# Programming
04-06-2009, 04:41 AM
I cna't seem to figure this out and I though I once did this.


I have something like this:



newImage = new Bitmap(path.ToString());
Matrix matrix = new Matrix();
matrix.Rotate(angle);
Graphics g = Graphics.FromImage(newImage);
g.Transform = matrix;
g.Save();

Bitmap newImage2 = new Bitmap(newImage.Width, newImage.Height, g);
Save();
//dispose calls....


An image is created, but it's just completely black. I am wanting to rotate an image at a specified angle, and not use the RotateFlip, which has static values.

Any ideas? Can this Graphics be converted back to a Bitmap?