Die RotateFlip-Methode der Bitmap dreht immer die gesamten Bild-Daten, die die Bitmap enthält.
In einem Control angezeigte Ausschnitte werden dabei nicht berücksichtigt.
Den korrespondierenden Ausschnitt mußt Du danach neu berechnen.
Vielleicht helfen Dir dabei diese Routinen ...
Private Function ComputeRotatedPoint(ByVal p As Point, _
ByVal width As Integer, ByVal height As Integer, _
ByVal rf As RotateFlipType) As Point
'p Punkt in der unrotierten Bitmap
'Width, Height Abmessungen der unrotierten Bitmap
'Rückgabe: Position des Punktes p in der rotierten Bitmap
Dim ret As Point
Select Case rf
Case RotateFlipType.Rotate90FlipNone
ret = New Point(height - p.Y - 1, p.X)
Case RotateFlipType.Rotate180FlipNone
ret = New Point(width - p.X - 1, height - p.Y - 1)
Case RotateFlipType.Rotate270FlipNone
ret = New Point(p.Y, width - p.X - 1)
Case Else
ret = Nothing
End Select
Return ret
End Function
Private Function ComputeRotatedRectangle(ByVal rect As Rectangle, _
ByVal width As Integer, height As _
Integer, _
ByVal rf As RotateFlipType) As _
Rectangle
'Bestimmung eines Rectangle nach der Rotation
'rect Rechteck unrotiert
'width, height Abmessungen der unrotierten Bitmap
'Eckpunkte Original-Rechteck
Dim xleft As Integer = rect.X
Dim xright As Integer = rect.X + rect.Width - 1
Dim ytop As Integer = rect.Y
Dim ybottom As Integer = rect.Y + rect.Height - 1
'gegenüberliegende Eckpunkte des rotierten Rechtecks
Dim topleft As Point = _
ComputeRotatedPoint(New Point(xleft, ytop), width, height, rf)
Dim bottomright As Point = _
ComputeRotatedPoint(New Point(xright, ybottom), width, height, _
rf)
'Rectangle-Parameter ermitteln
Dim ret As New Rectangle
ret.Location = New Point(Math.Min(topleft.X, bottomright.X), _
Math.Min(topleft.Y, bottomright.Y))
ret.Size = New Size(Math.Abs(topleft.X - bottomright.X) + 1, _
Math.Abs(topleft.Y - bottomright.Y) + 1)
Return ret
End Function |