Gracias por el código.
Le hice algunas modificaciones porque lo giraba 90º pero espejado horizontalmente.
Yo esperaba que hubiera algo parecido al giro 180º, espejado horizontal y vertical que se logra con PaintPicture ya que la velocidad con que lo hace es excelente y las imágenes que necesito rotar son bastante pesadas.
Envío el código con los nuevos cálculos y las otras opciones esperando que puedan servirle a alguien más.
Saludos feg
Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal crColor As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Integer, ByVal X As Integer, ByVal Y As Integer) As Long
'======================================
'la propiedad autoredraw de picture1 y picture2 debe ser True
'Picture2.Visible=False
'Picture1.autoSize=True
'BorderStyle=0
'Con las propiedades establecidas de esta manera la imagen va rotando en picture1
Sub bmp_rotate90(pict1 As PictureBox, pict2 As PictureBox)
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim d As Integer
Dim X As Integer
Dim Y As Integer
Screen.MousePointer = vbHourglass
pict2.Width = pict1.Height
pict2.Height = pict1.Width
b = pict1.Height
a = pict1.ScaleWidth
d = pict1.ScaleHeight
For X = 0 To a
For Y = 0 To d
c = b - Y - 1
Call SetPixel(pict2.hdc, c, X, GetPixel(pict1.hdc, X, Y))
Next
'DoEvents
Next
DoEvents
Screen.MousePointer = vbDefault
End Sub
Private Sub Command1_Click()
'Flip Horizontal
Picture1.PaintPicture Picture1.Picture, Picture1.ScaleWidth - 1, 0, -Picture1.ScaleWidth, Picture1.ScaleHeight
Picture1.Picture = Picture1.Image
End Sub
Private Sub Command2_Click()
'Rotar 180º
Picture1.PaintPicture Picture1.Picture, Picture1.ScaleWidth - 1, Picture1.ScaleHeight - 1, -Picture1.ScaleWidth, -Picture1.ScaleHeight
Picture1.Picture = Picture1.Image
End Sub
Private Sub Command3_Click()
'Flip Vertical
Picture1.PaintPicture Picture1.Picture, 0, Picture1.ScaleHeight - 1, Picture1.ScaleWidth, -Picture1.ScaleHeight
Picture1.Picture = Picture1.Image
End Sub
Private Sub Command5_Click()
' Giro 90º
Picture2.Cls
Call bmp_rotate90(Picture1, Picture2)
Picture1.Picture = Picture2.Image
' el picture gira en el centro del form
Picture1.Left = (form1.ScaleWidth - Picture1.ScaleWidth) / 2
Picture1.Top = (form1.ScaleHeight - Picture1.ScaleHeight) / 2
End Sub
Sub Form_Load()
Picture1.ScaleMode = 3
Picture2.ScaleMode = 3
form1.ScaleMode = 3
Picture1.Left = (form1.ScaleWidth - Picture1.ScaleWidth) / 2
Picture1.Top = (form1.ScaleHeight - Picture1.ScaleHeight) / 2
End Sub