is it possible to rotate an image that is inside a picturebox???? please help
Printable View
is it possible to rotate an image that is inside a picturebox???? please help
Her you go:-
thnx but er.. my visual basic couldn't upgrade the file to visual basic.net2003 is there by anychance u could just type cut/paste the code realy quick?
VB Code:
Option Explicit Private Type POINTAPI x As Long y As Long End Type Dim Pt(0 To 2) As POINTAPI Dim Angle As Double Private Const PI As Double = 3.14159265358979 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 Slider1_Click() Angle = Slider1 / 100 Rotate Picture2, Picture1, Angle End Sub Private Sub Slider1_Scroll() Angle = Slider1 / 100 Rotate Picture2, Picture1, Angle End Sub Private Sub Rotate(picDest As PictureBox, picsrc As PictureBox, Angle As Double) Dim a As Integer Pt(0).x = 0 Pt(0).y = 0 Pt(1).x = picsrc.Width Pt(1).y = 0 Pt(2).x = 0 Pt(2).y = picsrc.Height For a = 0 To 2 Pt(a) = RotateP(picsrc.Width / 2, picsrc.Height / 2, Pt(a), Angle) Next PlgBlt picDest.hDC, Pt(0), picsrc.hDC, 0, 0, picsrc.Width, picsrc.Height, ByVal 0&, ByVal 0&, ByVal 0& picDest.Refresh End Sub Private Function RotateP(ByRef x As Long, ByRef y As Long, ByRef Point As POINTAPI, Angle As Double) As POINTAPI Dim Tmp1 As Double Dim Tmp2 As Double Tmp1 = Point.x - x Tmp2 = Point.y - y Point.x = Tmp1 * Cos(Angle) - Tmp2 * Sin(Angle) Point.y = Tmp1 * Sin(Angle) + Tmp2 * Cos(Angle) Point.x = Point.x + x Point.y = Point.y + y RotateP = Point End Function
err....i'm in high shool doing my second semeseter of visual basic.....i don't understand half the code. is there a simple property value u can change to rotate the image?
Needs quie a lot of code depending what you wan to do.
Try this thread for help many examples for tou to look through
http://www.vbforums.com/search.php?s...ost&sortorder=
Cheers
question 2 how do u flip images like how do u get picMove1 to flip
VB Code:
Option Explicit Private Type POINTAPI x As Long y As Long End Type Dim Pt(0 To 2) As POINTAPI Dim Angle As Double Private Const PI As Double = 3.14159265358979 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 Slider1_Click() Angle = Slider1 / 100 Rotate Picture1, Picture2, Angle 'Change this line End Sub Private Sub Slider1_Scroll() Angle = Slider1 / 100 Rotate Picture1, Picture2, Angle 'Change this line End Sub Private Sub Rotate(picDest As PictureBox, picsrc As PictureBox, Angle As Double) Dim a As Integer Pt(0).x = 0 Pt(0).y = 0 Pt(1).x = picsrc.Width Pt(1).y = 0 Pt(2).x = 0 Pt(2).y = picsrc.Height For a = 0 To 2 Pt(a) = RotateP(picsrc.Width / 2, picsrc.Height / 2, Pt(a), Angle) Next PlgBlt picDest.hDC, Pt(0), picsrc.hDC, 0, 0, picsrc.Width, picsrc.Height, ByVal 0&, ByVal 0&, ByVal 0& picDest.Refresh End Sub Private Function RotateP(ByRef x As Long, ByRef y As Long, ByRef Point As POINTAPI, Angle As Double) As POINTAPI Dim Tmp1 As Double Dim Tmp2 As Double Tmp1 = Point.x - x Tmp2 = Point.y - y Point.x = Tmp1 * Cos(Angle) - Tmp2 * Sin(Angle) Point.y = Tmp1 * Sin(Angle) + Tmp2 * Cos(Angle) Point.x = Point.x + x Point.y = Point.y + y RotateP = Point End Function
Assuming from your "visual basic.net 2003" thing I think you should be posting in the VB.net section, not here. seriously it's right below this one. You can't miss it. You shouldn't have missed it.
i have this project, and works... but when i try put in my project, like copy your functions and the variables, the code is ignored... but why the code is ignored?Quote:
Originally Posted by laserman
thank you
Heres a simple way to flip an image inside a picture box.Quote:
Originally Posted by doggychow14
Code:Option Explicit
Private Declare Function StretchBlt Lib "gdi32" _
(ByVal hdc As Long, ByVal x As Long, ByVal y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal hSrcDC As Long, ByVal xSrc As Long, _
ByVal ySrc As Long, ByVal nSrcWidth As Long, _
ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Private Const SRCCOPY = &HCC0020
Code:' set pic box to pixel mode
Picture1.ScaleMode = 3
'To flip horizontally ...
Call StretchBlt(Picture1.hdc, Picture1.ScaleWidth, 0, Picture1.ScaleWidth * -1, Picture1.ScaleHeight, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, SRCCOPY)
'To flip vertically...
Call StretchBlt(Picture1.hdc, 0, Picture1.ScaleHeight, Picture1.ScaleWidth, Picture1.ScaleHeight * -1, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, SRCCOPY)
thank you... thank you... but what i need is more complex... in Games and Graphics section one person is help me the rotation math...Quote:
Originally Posted by Edgemeal
thank you my friend...