Ive actually just sussed it out but Im not sure if its a valid way to do
it...
I doing this :-
Graphics first = Graphics.FromImage (sourceImage);
myMatrix = new Matrix ();
PointF point = new PointF(sourceImage.Width * 0.5f, sourceImage.Height *
0.5f);
myMatrix.RotateAt(myAngle, point, MatrixOrder.Append);
Bitmap target = new Bitmap (sourceImage.Width, sourceImage.Height);
Graphics second = Graphics.FromImage (target);
second.Transform = myMatrix;
second.DrawImage(sourceImage, destRect, cropRect, GraphicsUnit.Pixel);
target.Save(filename, myImageCodecInfo, myEncoderParameters);
dispose.first, ();
dispose.second ();
dispose.myMatrix ();
dispose.target ();
It this the best way ?
Thanks
Todd
"(E-Mail Removed)" <(E-Mail Removed)> wrote in message
news:dgjs9l$1d0$(E-Mail Removed)...
> Hi Mark
>
> Thanks for the reply. Yes, I know about the bitmap rotation save and am
> using it, but the image is not saved with the transformation applied (or
> does not appear to be). In the code snippet I supplied if I just put :-
>
> bitMapOrigina.save (filename....);
>
> the image saved will be identical to the original and not rotated by 30
> degrees.
>
> Perhaps I am approaching the problem the wrong way ? All Im trying to do
> is allow the user to view an image on the screen and specify a rotation
> and a crop region. Then I want to save the rotated&cropped image. So far I
> have only found the Graphics.RotateAt method and am using that... but I
> can't seem to save the rotated image.
>
> Any further ideas now I've explained myself a bit more ?
>
> Thanks,
>
> Todd.
>
> "Mark R. Dawson" <(E-Mail Removed)> wrote in message
> news:F302680B-2AFA-421C-81C2-(E-Mail Removed)...
>> Hi,
>> the Bitmap class has a save method which allows you to specify various
>> file formats while saving.
>>
>> Mark R Dawson
>> http://www.markdawson.org
>>
>>
>>
>> "(E-Mail Removed)" wrote:
>>
>>> 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.
>>>
>>>
>>>
>
>