Newsgroup: it.comp.lang.visual-basic
Titolo: rotazione immagine in picture box

Salve avrei questo problema:
una picturebox mi gestisce uno stream video, io avrei bisogno di ruotare
questo stream di 90° quanlcuno saprebbe dirmi come fare? Grazie mille
anticipatamente
--------------------------------
Inviato via 
http://arianna.libero.it/usenet/

 anticipatamente
eccoti la funzione con relative api dichiarate....
metti tutto in un modulo
*******************************************************
Public Const PI As Double = 3.14159265358979
Public Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As
Long, ByVal y As Long, ByVal crColor As Long) As Long
Public Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As
Long, ByVal y As Long) As Long
Public Function RotateSurface(ByRef SourcePicture As PictureBox, ByRef
DestPicture As PictureBox, lngAngle As Long, Optional XDest As Long,
Optional Ydest As Long)
Dim iX As Long, iY As Long
Dim iXDest As Long, iYDest As Long
Dim sngA As Single, SinA As Single, CosA As Single
Dim dblRMax As Long
Dim lngXO As Long, lngYO As Long
Dim lngColor As Long
Dim lWidth As Long, lHeight As Long
sngA = (360 - lngAngle) * PI / 180
SinA = Sin(sngA)
CosA = Cos(sngA)
lWidth = SourcePicture.Width
lHeight = SourcePicture.Height
dblRMax = Sqr(lWidth ^ 2 + lHeight ^ 2)
XDest = XDest + lWidth / 2
Ydest = Ydest + lHeight / 2
For iX = -dblRMax To dblRMax
    For iY = -dblRMax To dblRMax
    DoEvents
        lngXO = lWidth / 2 - (iX * CosA + iY * SinA)
        lngYO = lHeight / 2 - (iX * SinA - iY * CosA)
        If lngXO >= 0 Then
            If lngYO >= 0 Then
                If lngXO < lWidth Then
                    If lngYO < lHeight Then
                        lngColor = GetPixel(SourcePicture.hdc, lngXO, lngYO)
                        If lngColor <> 0 Then
                        DestPicture.PSet ((lWidth + XDest) - iX, Ydest +
iY), lngColor
                        End If
                    End If
                End If
            End If
        End If
    Next iY
Next iX
End Function
******************************************************************
come si usa?
avrai picbox sorgente e quella di destinazione in cui avrai l'immagine
ruotata
se noti sfarfallamenti usa double o triple buffering (dipende poi dalle
dimensioni delle picbox)
Ora però mi devi dire come gestisci lo stream video (e che tipo di stream)
con una picturebox
ciao!!

Se quella di GioX non dovesse soddisfarti (e non ho motivi per pensarlo)
puoi provare con la seguente (originaria di Claudio Gucchierato) e da me
solo leggermente modificata.
Anche questa necessita di 2 picturebox e nella seconda (la ricevente)
agisce sulla proprietą image e non picture.
Ciao, Sauro
Public Sub RuotaFotoForm(PicOne As PictureBox, PicTwo As PictureBox, _
Gradi90_270 As Double)
Const PI = 3.14159265358979
PicTwo.Cls
Dim intX As Integer
Dim intY As Integer
Dim intX1 As Integer
Dim intY1 As Integer
Dim dblX2 As Double
Dim dblY2 As Double
Dim dblX3 As Double
Dim dblY3 As Double
Dim dblThetaRad As Double
Dim MemoScalePicOne
MemoScalePicOne = PicOne.ScaleMode
'Sauro
PicTwo.Width = PicOne.Height
PicTwo.Height = PicOne.Width
'PicTwo.Left = PicOne.Left
'PicTwo.Top = PicOne.Top
'Fine Sauro
'Compute angle in radians
dblThetaRad = Gradi90_270 * PI / 180
'Set scale modes to pixels
PicOne.ScaleMode = vbPixels
PicTwo.ScaleMode = vbPixels
For intX = 0 To PicTwo.ScaleWidth
    intX1 = intX - PicTwo.ScaleWidth \ 2
    For intY = 0 To PicTwo.ScaleHeight
        intY1 = intY - PicTwo.ScaleHeight \ 2
        'Rotate picture by dblThetaRad
        dblX2 = intX1 * Cos(-dblThetaRad) + _
            intY1 * Sin(-dblThetaRad)
        dblY2 = intY1 * Cos(-dblThetaRad) - _
            intX1 * Sin(-dblThetaRad)
        'Translate to center of picture box
        dblX3 = dblX2 + PicOne.ScaleWidth \ 2
        dblY3 = dblY2 + PicOne.ScaleHeight \ 2
        'If data point is in picOne, set its color in picTwo
        If dblX3 > 0 And dblX3 < PicOne.ScaleWidth - 1 _
            And dblY3 > 0 And dblY3 < PicOne.ScaleHeight - 1 Then
            PicTwo.PSet (intX, intY), PicOne.Point(dblX3, dblY3)
        End If
    Next intY
Next intX
PicOne.Width = PicTwo.Width
PicOne.Height = PicTwo.Height
Set PicOne.Picture = PicTwo.Image
'PicTwo.Image = Nothing
PicOne.ScaleMode = MemoScalePicOne
End Sub

Satiro ma non hai letto in fondo al mio post di risposta????!!
[cut]


scusami ma solo adesso ho letto le risposte al post.
Io gestisco stream video provenienti da telecamere o webcam utilizzando le
librerie VFW.
