N
news
Hi Guys,
Sorry if this is an obvious question but Im trying to rotate a bitmap and
then save it. So far Ive only found how to rotates a Graphic but I can't
find how to save it. I also want to crop the image and resize it, but I
assume thats straight foward and for the code below Ive set the resize to
0.5 the original size and left the crop out.
This is what Ive got so far :-
float imageRotationAngle = 30.0f;
System.Drawing.Graphics myGraphic;
myGraphic = Graphics.FromImage(bitmapOriginal);
Matrix myMatrix = new Matrix();
PointF point = new PointF(bitmapOriginal.Width * 0.5f, bitmapOriginal.Height
* 0.5f);
myMatrix.RotateAt(imageRotationAngle, point, MatrixOrder.Append);
myGraphic.Transform = myMatrix;
myGraphic.ScaleTransform(0.5f * size.Width, 0.5f * size.Height);
myGraphic.DrawImage(bitmapOriginal, destRect, cropRect, GraphicsUnit.Pixel);
So, how do I save this rotated image as a jpg or tiff ?
Thanks in advance,
Todd.
Sorry if this is an obvious question but Im trying to rotate a bitmap and
then save it. So far Ive only found how to rotates a Graphic but I can't
find how to save it. I also want to crop the image and resize it, but I
assume thats straight foward and for the code below Ive set the resize to
0.5 the original size and left the crop out.
This is what Ive got so far :-
float imageRotationAngle = 30.0f;
System.Drawing.Graphics myGraphic;
myGraphic = Graphics.FromImage(bitmapOriginal);
Matrix myMatrix = new Matrix();
PointF point = new PointF(bitmapOriginal.Width * 0.5f, bitmapOriginal.Height
* 0.5f);
myMatrix.RotateAt(imageRotationAngle, point, MatrixOrder.Append);
myGraphic.Transform = myMatrix;
myGraphic.ScaleTransform(0.5f * size.Width, 0.5f * size.Height);
myGraphic.DrawImage(bitmapOriginal, destRect, cropRect, GraphicsUnit.Pixel);
So, how do I save this rotated image as a jpg or tiff ?
Thanks in advance,
Todd.