Hi...
Um ein Multimedia Programm zu programmieren, brauch ich auch ein wenig Grafik...
Dazu benutz ich ein Bild von einer Schallplatte, die sich dreht... Diese wird in der Picture Box picTT1 dargestellt...
Jetzt habe ich ein Problem.. Ich habe das Drehprinzip mit dem Tipp
http://www.vbarchiv.net/archiv/tipp_details.php?pid=928
nachgebaut...
Mit anderen Worten: Ich habe ein Form und ein Modul...
Das Modul:
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
' Aufruf-Beispiele:
'
'Private Sub Form_Load()
' ' Bild laden
' picQuelle.Picture = LoadPicture(App.Path & "\Test.jpg")
' ' Bild ohne Drehung darstellen
' Call BildDrehen(picQuelle, picZiel)
'End Sub
' ' Bild im Uhrzeigersinn um 90° drehen
' Call BildDrehen(picQuelle, picZiel, 90)
' ' Bild horizontal spiegeln
' Call BildDrehen(picQuelle, picZiel, , , 180)
' ' Bild vertikal spiegeln
' Call BildDrehen(picQuelle, picZiel, , , , 180)
' -------------------------------------------------------------------
' Mögliche Werte:
' DrehWinkel -360 bis 360
' horzDrehWinkel -180 bis 180 (180 = Spiegelung)
' vertDrehWinkel -180 bis 180 (180 = Spiegelung)
' -------------------------------------------------------------------
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
' Punktliste zurücksetzen:
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)
' Variablen vorberechnen:
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
' Punkte transformieren:
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
' alte Darstellung löschen
picDest.Cls
picDest.Picture = Nothing
' neue Darstellung zeichnen:
Call PlgBlt(picDest.hDC, PtList(0), .hDC, 0, 0, _
.ScaleWidth, .ScaleHeight, 0, 0, 0)
' und in die Anzeige PicBox übernehmen:
picDest.Picture = picDest.Image
End With
End Sub Und das Form:
Private Sub Form_Load()
tmrTT1Drehen.Enabled = False
tmrTT1Drehen.Intervall = 10
End Sub
Private Sub tmrTT1Drehen_Timer()
BildDrehen picTT1, picTT1, 1
End Sub
Private Sub cmdPlay1_Click()
tmrTT1Drehen.Enabled = True
End Sub
Private Sub cmdStop1_Click()
tmrTT1Drehen.Enabled = False
End Sub Jetz habe ich das Problem, dass wenn ich auf den Button zum Abspielen klicke, die Picture Box einfach so verschwindet!
Wie kann ich die Platte drehen lassen?
_______________________________________
VD DeV Compile Statics.........
Loaded!
sXNet Engine Statics...............
Loaded!
Intelligence................................
Error! |