ورود

View Full Version : چرخوندن عکس.



Ner'zhul Arthas
دوشنبه 29 اسفند 1384, 15:44 عصر
چطور میشه یه عکسو چرخوند؟
مثلا 180 درجه؟ یا 270 درجه؟

behzad_gh
دوشنبه 29 اسفند 1384, 16:43 عصر
با سلام
با کد زیر می‌تونی عکس داخل یک PictureBox رو 90 درجه بچرخونی

Option Explicit

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 Form_Load()

With Picture1
.AutoRedraw = True
.AutoSize = True
.BorderStyle = 0
.Appearance = 0
.ScaleMode = vbPixels
'your favorite picture here
.Picture = LoadPicture("C:\Sunset.jpg")
End With

Me.ScaleMode = vbPixels

End Sub

Private Sub Command1_Click()
Dim picWidth As Long
Dim picHeight As Long

picWidth = Picture1.Width
picHeight = Picture1.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
Picture1.Height = picWidth
Else
Picture1.Width = picHeight
End If
Call PlgBlt(Picture1.hDC, Pt(0), Picture1.hDC, 0, 0, picWidth, picHeight, ByVal 0&, ByVal 0&, ByVal 0&)

Picture1.Width = picHeight
Picture1.Height = picWidth
Picture1.Refresh

End Sub

Ner'zhul Arthas
دوشنبه 29 اسفند 1384, 22:27 عصر
ممنون.
دستور کوتاه تر نداریم؟

behzad_gh
دوشنبه 29 اسفند 1384, 22:43 عصر
به این فایل هم یک نگاهی بینداز