Picture auf tastendruck drehen ?

Hallo,
gibt es die möglichkeit ein Picture auf tastendruck zu drehen ?

mfg jonny

habe da was gefunden … aber sehr langsam …
http://support.microsoft.com/kb/80406/de

Hallo,
gibt es die möglichkeit ein Picture auf tastendruck zu drehen
?

mfg jonny

Hallo,
gibt es die möglichkeit ein Picture auf tastendruck zu drehen
?

mfg jonny

Hallo Jonny,

jawoll die gibt es :wink:
Anbei poste ich dir mal 2 Routinen, die das erledigen :smile:
Bei de zweiten hast du sogar die Möglichkeit das Bild zu zoomen :smile:

'Variante 1 mit Point-PSet 
'Klappt bei jedem OS, ist aber langsamer

Option Explicit

Private Const pi = 3.14159265359

Public Sub BildDrehen(ByVal picSource As PictureBox, \_
 ByVal picDest As PictureBox, \_
 Optional ByVal DrehWinkel As Long = 0)
 Dim cp0 As Long, cp1 As Long
 Dim cp2 As Long, cp3 As Long
 Dim w1 As Long, h1 As Long
 Dim w2 As Long, h2 As Long
 Dim p1x As Double, p1y As Double
 Dim p2x As Double, p2y As Double
 Dim n As Double, r As Double, a As Double
 picSource.AutoSize = True
 picSource.Visible = False
 picSource.AutoRedraw = True
 picDest.AutoRedraw = True
 picSource.ScaleMode = vbPixels
 picDest.ScaleMode = vbPixels
 Set picDest.Picture = Nothing
 picDest.Cls
 w1 = picSource.ScaleWidth \ 2
 h1 = picSource.ScaleHeight \ 2
 w2 = picDest.ScaleWidth \ 2
 h2 = picDest.ScaleHeight \ 2
 If w2 -1 Then picDest.PSet (w2 + p2x, h2 + p2y), cp0
 If cp1 -1 Then picDest.PSet (w2 - p2x, h2 - p2y), cp1
 If cp2 -1 Then picDest.PSet (w2 + p2y, h2 - p2x), cp2
 If cp3 -1 Then picDest.PSet (w2 - p2y, h2 + p2x), cp3
 Next p2y
 Next p2x
 Set picDest.Picture = picDest.Image
End Sub

'2 Variante mit API 
'Ist schneller geht glaube aber erst ab win2k

Option Explicit

' Benötigte API-Funktionen
Private Declare Function PlgBlt Lib "gdi32.dll" ( \_
 ByVal hdcDest As Long, \_
 lpPoint As POINTAPI, \_
 ByVal hdcSrc As Long, \_
 ByVal nXSrc As Long, ByVal nYSrc As Long, \_
 ByVal nWidth As Long, ByVal nHeight As Long, \_
 ByVal hbmMask As Long, \_
 ByVal xMask As Long, ByVal yMask As Long) As Long

Private Type POINTAPI
 x As Long
 y As Long
End Type

Private Const pi180 = 3.14159265358979 / 180
Private PtList(2) As POINTAPI

Public Sub BildDrehen(ByVal picSource As PictureBox, ByVal picDest As PictureBox, \_
 Optional ByVal DrehWinkel As Long = 0, \_
 Optional ByVal intZoom As Integer = 46, \_
 Optional ByVal horzDrehWinkel As Long = 0, \_
 Optional ByVal vertDrehWinkel As Long = 0)
 Dim i As Integer
 Dim NewX As Double, NewY As Double
 Dim SinAng1 As Double, CosAng1 As Double
 Dim SinAng2 As Double, SinAng3 As Double
 Dim dblZoom As Double
 With picSource
 .Visible = False
 .ScaleMode = vbPixels
 .AutoRedraw = True
 .AutoSize = True
 picDest.ScaleMode = vbPixels
 picDest.AutoRedraw = True
 PtList(0).x = -(.ScaleWidth / 2)
 PtList(0).y = -(.ScaleHeight / 2)
 PtList(1).x = (.ScaleWidth / 2)
 PtList(1).y = -(.ScaleHeight / 2)
 PtList(2).x = -(.ScaleWidth / 2)
 PtList(2).y = (.ScaleHeight / 2)
 dblZoom = Tan(intZoom \* pi180)
 SinAng1 = Sin((DrehWinkel + 90) \* pi180)
 CosAng1 = Cos((DrehWinkel + 90) \* pi180)
 SinAng2 = Sin((horzDrehWinkel + 90) \* pi180) \* dblZoom
 SinAng3 = Sin((vertDrehWinkel + 90) \* pi180) \* dblZoom
 For i = 0 To 2
 NewX = (PtList(i).x \* SinAng1 + PtList(i).y \* CosAng1) \* SinAng2
 NewY = (PtList(i).y \* SinAng1 - PtList(i).x \* CosAng1) \* SinAng3
 PtList(i).x = NewX + (picDest.ScaleWidth / 2)
 PtList(i).y = NewY + (picDest.ScaleHeight / 2)
 Next i
 picDest.Cls
 picDest.Picture = Nothing
 Call PlgBlt(picDest.hDC, PtList(0), .hDC, 0, 0, \_
 .ScaleWidth, .ScaleHeight, 0, 0, 0)
 picDest.Picture = picDest.Image
 End With
End Sub

MfG Alex

Besten Dank.