http://forums.codeguru.com/showthread.php?414694-PictureBox-Rotation
Option Explicit
'2 ways to rotate a picture
' -------------------------------------------------
Private Type POINTAPI
x As Long
y As Long
End Type
Dim Pt(0 To 2) As POINTAPI
Private Declare Function PlgBlt Lib "gdi32" ( _
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 Sub Command1_Click()
Call Rotate90(Picture1)
End Sub
Private Sub Form_Load()
With Picture1
.AutoRedraw = True
.AutoSize = True
.BorderStyle = 0
.Appearance = 0
.ScaleMode = vbPixels
'your favorite picture here
.Picture = LoadPicture("d:\temp\alexa.bmp")
End With
Me.ScaleMode = vbPixels
End Sub
Private Sub Rotate90(picsrc As PictureBox)
Dim picWidth As Long
Dim picHeight As Long
picWidth = picsrc.Width
picHeight = picsrc.Height
Pt(2).x = 0
Pt(2).y = 0
Pt(0).x = picHeight
Pt(0).y = 0
Pt(1).x = picHeight
Pt(1).y = picWidth
If picWidth > picHeight Then
picsrc.Height = picWidth
Else
picsrc.Width = picHeight
End If
Call PlgBlt(picsrc.hDC, Pt(0), picsrc.hDC, 0, 0, picWidth, picHeight, ByVal 0&, ByVal 0&, ByVal 0&)
picsrc.Width = picHeight
picsrc.Height = picWidth
picsrc.Refresh
End Sub
' -------------------------------------------------
Sub flip()
Dim H As Long
Dim W As Long
H = Picture1.Height
W = Picture1.Width
'flip vertical
Picture1.PaintPicture Picture1.Picture, 0, H, W, -H
'flip horizontally
Picture1.PaintPicture Picture1.Picture, W, 0, -W
'flip both
Picture1.PaintPicture Picture1.Picture, W, H, -W, -H
End Sub
첫댓글 좋은 정보 고맙습니다. 잘보고 잘 활용 하겠습니다. 즐거운 하루 되세요 ^^