Sub save_and_rotate(dir,fn)
Dim Out As OutputStream
Dim Canvas1 As Canvas
Dim Bitmap1 As Bitmap
Dim bitmap2 As Bitmap
Dim DestRect As Rect
Bitmap1.Initializesample(dir,fn,1500,1150)
bitmap2.InitializeMutable(1500,1150)
Canvas1.Initialize2(bitmap2)
DestRect.Initialize(0dip, 0dip, bitmap1.width, bitmap1.Width)
Canvas1.DrawBitmapRotated(Bitmap1, Null, destrect, 90)
Out = File.OpenOutput(dir, fn, False)
Canvas1.Bitmap.WriteToStream(Out, 100, "JPEG")
Out.Close
ToastMessageShow("Image saved: " & File.Combine(dir, fn), True)
End Sub