Sign in to follow this  
Followers 0
davidkim

image rotate question

5 posts in this topic

#1 ·  Posted (edited)

Posted Image

To see sample images

[Autoit] has written a sample code

this my code -> code

Preview

side gear

Posted Image

center gear

Posted Image

Small side gear

Posted Image

my code

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=C:AutoIt3Aut2ExeIconsSETUP09.ICO
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#Include <GDIPlus.au3>
#Include <WindowsConstants.au3>
FileInstall('.g_back.png',@ScriptDir & 'g_back.png',1)
FileInstall('.g_center.png',@ScriptDir & 'g_center.png',1)
FileInstall('.g_left.png',@ScriptDir & 'g_left.png',1)
FileInstall('.g_side.png',@ScriptDir & 'g_side.png',1)
Global Const $tagBITMAP = 'long bmType;long bmWidth;long bmHeight;long bmWidthBytes;ushort bmPlanes;ushort bmBitsPixel;ptr bmBits;'
_GDIPlus_Startup()
$hBackground = _GDIPlus_ImageLoadFromFile(@ScriptDir & 'g_back.png')
$center = _GDIPlus_ImageLoadFromFile(@ScriptDir & 'g_center.png')
$g_left = _GDIPlus_ImageLoadFromFile(@ScriptDir & 'g_left.png')
$g_side = _GDIPlus_ImageLoadFromFile(@ScriptDir & 'g_side.png')
$State = Default
; GUI Form
$hForm = GUICreate('', 600, 600, -1, -1, $WS_POPUPWINDOW, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
GUISetState()
; Moveable
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
; Exit key => ESC
HotKeySet("{ESC}",'_exit_')
HotKeySet("{END}",'_play_')

Global $ct = 0

Global Const $nPI      = 3.1415926535897932384626433832795
Global Const $PiDiv  = $nPI /180
Global $ii

For $angle = 1 to 360 ;step 20
       _Movement($angle)
Next
While 1
Sleep(30)
WEnd
Func _exit_()
_GDIPlus_Shutdown()
    Exit
EndFunc

Func _play_()
If $ct > 360 Then $ct = 0
$ct+=1
  _Movement($ct)
EndFunc


; form move
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $hForm) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc   ;==>WM_NCHITTEST

Func _Move_($graph, $png, $PngCenterX, $PngCenterY, $rAngle,$x,$y,$sw)
If $sw = 1 Then $rAngle = 0 - $rAngle
Local $status = DllCall($ghGDIPDll, "int", "GdipRotateWorldTransform", "hwnd", $graph, "float", $rAngle, "int", 1)
    $status = DllCall($ghGDIPDll, "int", "GdipTranslateWorldTransform", "hwnd", $graph, "float",$x, "float", $y, "int", 1)
  $mx = -$PngCenterX - ($rAngle = 180)
  $my = -$PngCenterY - ($rAngle = 180)
  $mw = _GDIPlus_ImageGetWidth($png)
  $mh = _GDIPlus_ImageGetHeight($png)
  _GDIPlus_GraphicsDrawImageRect($graph, $png, $mx, $my,$mw, $mh)
$status = DllCall($ghGDIPDll, "int", "GdipResetWorldTransform", "hwnd", $graph)
EndFunc   ;==>_DrawNeedle
Func _Movement($rAngle)
    Local $hGraphic, $hImage
    $hImage = _GDIPlus_ImageClone($hBackground)
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)
;~                          반지름,반지름  x+반지름,y+반지름
;gear ct center(22)
;gear ct left (14)
;gear ct side (50)
; Side 1' 회전할때..center 2.2727272727272727272727272727273x / left 3.5714285714285714285714285714286x rotate

_Move_($hGraphic, $g_side, 300,300, $rAngle,300,300,1) ; /// side gear
$center_angle= $rAngle * 2.2727272727272727272727272727273
_Move_($hGraphic, $center, 123,123, $center_angle,178+123,176+123,0) ; /// center gear

$left_angle = $rAngle * 3.5714285714285714285714285714286

_Move_($hGraphic, $g_left, 82,82, $left_angle,58+82,128+82,1) ; /// g_left gear
_Move_($hGraphic, $g_left, 82,82, $left_angle,377+82,127+82,1) ; /// g_left gear
_Move_($hGraphic, $g_left, 82,82, $left_angle,218+82,404+82,1) ; /// g_left gear
_WinAPI_UpdateLayeredWindowEx($hForm, _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage), 255, 1)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
Sleep(20)
EndFunc   ;==>_Movement
Func _GDIPlus_ImageClone($hImage)
    Local $aResult = DllCall($ghGDIPDll, 'uint', 'GdipCloneImage', 'ptr', $hImage, 'ptr*', 0)
    If @error Then
        Return SetError(1, 0, 0)
    Else
        If $aResult[0] Then
            Return SetError($aResult[0], 0, 0)
        EndIf
    EndIf
    Return $aResult[2]
EndFunc   ;==>_GDIPlus_ImageClone
Func _WinAPI_UpdateLayeredWindowEx($hWnd, $hBitmap, $iOpacity = 255, $fDelete = 0)
    Local $Ret, $tSIZE, $tPOINT, $tBLENDFUNCTION, $hDC, $hDestDC, $hDestSv
    $Ret = DllCall('user32.dll', 'hwnd', 'GetDC', 'hwnd', $hWnd)
    $hDC = $Ret[0]
    $Ret = DllCall('gdi32.dll', 'hwnd', 'CreateCompatibleDC', 'hwnd', $hDC)
    $hDestDC = $Ret[0]
    $Ret = DllCall('gdi32.dll', 'hwnd', 'SelectObject', 'hwnd', $hDestDC, 'ptr', $hBitmap)
    $hDestSv = $Ret[0]
    $tSIZE = _WinAPI_GetBitmapDimension($hBitmap)
    $tPOINT = DllStructCreate($tagPOINT)
    $tBLENDFUNCTION = DllStructCreate($tagBLENDFUNCTION)
    DllStructSetData($tBLENDFUNCTION, 'Alpha', $iOpacity)
    DllStructSetData($tBLENDFUNCTION, 'Format', 1)
    $Ret = DllCall('user32.dll', 'int', 'UpdateLayeredWindow', 'hwnd', $hWnd, 'hwnd', $hDC, 'ptr', 0, 'ptr', DllStructGetPtr($tSIZE), 'hwnd', $hDestDC, 'ptr', DllStructGetPtr($tPOINT), 'dword', 0, 'ptr', DllStructGetPtr($tBLENDFUNCTION), 'dword', 0x02)
    DllCall('user32.dll', 'int', 'ReleaseDC', 'hwnd', $hWnd, 'hwnd', $hDC)
    DllCall('gdi32.dll', 'ptr', 'SelectObject', 'hwnd', $hDestDC, 'ptr', $hDestSv)
    DllCall('gdi32.dll', 'int', 'DeleteDC', 'hwnd', $hDestDC)
    If Not $Ret[0] Then
        Return SetError(1, 0, 0)
    EndIf
    If $fDelete Then
        _WinAPI_DeleteObject($hBitmap)
    EndIf
    Return 1
EndFunc   ;==>_WinAPI_UpdateLayeredWindowEx
Func _WinAPI_GetBitmapDimension($hBitmap)
    Local $tObj = DllStructCreate($tagBITMAP)
    Local $Ret = DllCall('gdi32.dll', 'int', 'GetObject', 'int', $hBitmap, 'int', DllStructGetSize($tObj), 'ptr', DllStructGetPtr($tObj))
    If (@error) Or (Not $Ret[0]) Then
        Return SetError(1, 0, 0)
    EndIf
    Local $tSIZE = DllStructCreate($tagSIZE)
    DllStructSetData($tSIZE, 1, DllStructGetData($tObj, 'bmWidth'))
    DllStructSetData($tSIZE, 2, DllStructGetData($tObj, 'bmHeight'))
    Return $tSIZE
EndFunc   ;==>_WinAPI_GetBitmapDimension

How small side while rotating the gear

Rotation in the desired direction at the same time possible?

Posted Image

Preview movie -> movie

Preview movie viewing install codec

http://www.2shared.com/file/EHpqiI3H/BDCAMSETUP_KOR.html

_Move_($hGraphic, $g_left, 82,82, $left_angle,58+82,128+82,1) ; /// g_left gear

_Move_($hGraphic, $g_left, 82,82, $left_angle,377+82,127+82,1) ; /// g_left gear

_Move_($hGraphic, $g_left, 82,82, $left_angle,218+82,404+82,1) ; /// g_left gear

--- edit code

_Move_($hGraphic, $g_left, 82+200,82+200, $left_angle,58+82,128+82,1) ; /// g_left gear

_Move_($hGraphic, $g_left, 82+200,82+200, $left_angle,377+82,127+82,1) ; /// g_left gear

_Move_($hGraphic, $g_left, 82+200,82+200, $left_angle,218+82,404+82,1) ; /// g_left gear

Increasing the number on the syntax.

Rotation while rotating in the direction you want, but ...

Are abnormally rotated.

Edited by davidkim

I interest am many quite in AutoitScript.From that is [http://cafe.naver.com/autoitscript[/color]] Korea of cafe(blog) to be operating, [size="2"][color="#ff00ff"]English cannot well[/size].Many help it requests.To read, it stands it thanks.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try this here:

Source Code too long: http://pastebin.com/FnxsCiLx

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Try this here:

Source Code too long: http://pastebin.com/FnxsCiLx

Br,

UEZ

Thank you. UEZ.

With the rotation of the object [_g_leftpng] is...

Thus, the inside of [_g_sidepng]

Should be rotated clockwise.

Modify your source Simplicity and good.

However, in the direction I want does not move.

Posted Image

green arrow Is my question.

and the form should be transparent.

Global Const $hGUI = GUICreate("GDI+ Gears Rotation Simulation by UEZ 2012", $iW_G1, $iH_G1)

Thank's UEZ.

Edited by davidkim

I interest am many quite in AutoitScript.From that is [http://cafe.naver.com/autoitscript[/color]] Korea of cafe(blog) to be operating, [size="2"][color="#ff00ff"]English cannot well[/size].Many help it requests.To read, it stands it thanks.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Here the new version: http://pastebin.com/Crd9mfR2

Is this what you want?

What is still missing is the mathematics behind the calculation for the rotation of the smallest gear. When I find the formula for line 77 I will post it.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Here the new version: http://pastebin.com/Crd9mfR2

Is this what you want?

What is still missing is the mathematics behind the calculation for the rotation of the smallest gear. When I find the formula for line 77 I will post it.

Br,

UEZ

Posted Image

g_left rotation want

Thanks UEZ


I interest am many quite in AutoitScript.From that is [http://cafe.naver.com/autoitscript[/color]] Korea of cafe(blog) to be operating, [size="2"][color="#ff00ff"]English cannot well[/size].Many help it requests.To read, it stands it thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0