| doublechar |
| | Ci ho speso una serata, per questa cavolata... Photoshop e Gimp, vi odio <3 Bene, ho googlato tutto il mondo per trovare / capire come ruotare solamente un'immagine e non tutto il grafico in GDI+... ho trovato il modo e l'ho implementato in AutoIt! Ed ho creato questo stupido programmino, ma "divertente" [citazione necessaria]Date un'occhiata al source, e provatelo Grazie a #dd per _ATAN2 e a #dd e Master per aver beta-testato, se così si può dire CODICE #include <GDIPlus.au3>
Global Const $nPI = 3.1415926535897932384626433832795
_GDIPlus_Startup()
Global $GUIWidth = 800 Global $GUIHeight = 600
Opt("GuiOnEventMode", 1)
If Not FileExists(@TempDir&"Sprite.bmp") Then InetGet("http://rikkardo.altervista.org/_altervista_ht/img/01_13/Sprite400979.bmp", @TempDir&"Sprite.bmp")
$GUI = GUICreate("dafuq gdi", $GUIWidth, $GUIHeight) GUISetBkColor(0xFFFFFF, $GUI) GUISetOnEvent(-3, "GUIExit")
$Graphics = _GDIPlus_GraphicsCreateFromHWND($GUI) $BufferBMP = _GDIPlus_BitmapCreateFromGraphics($GUIWidth, $GUIHeight, $Graphics) $Buffer = _GDIPlus_ImageGetGraphicsContext($BufferBMP)
$spriteBitmap = _GDIPlus_ImageLoadFromFile(@TempDir&"Sprite.bmp")
$width = _GDIPlus_ImageGetWidth($spriteBitmap) $height = _GDIPlus_ImageGetHeight($spriteBitmap)
GUISetState(@SW_SHOW, $GUI)
$FPSTimer = TimerInit()
AdlibRegister("Draw", 35)
While 1 Sleep(20) WEnd
Func Draw() $MousePos = GUIGetCursorInfo($GUI) If IsArray($MousePos) Then $MousePos[0] -= $GUIWidth / 2 $MousePos[1] -= $GUIHeight / 2 $Angle = _ATAN2($MousePos[1], $MousePos[0]) $i = $Angle * 57.29577 + 90 Else $i = 0 EndIf
_GDIPlus_GraphicsClear($Buffer, 0xFFFFFF) RotateImageDraw($Buffer, $spriteBitmap, $GUIWidth / 2 - $width / 2, $GUIHeight / 2 - $height / 2, $i) _GDIPlus_GraphicsDrawImageRect($Graphics, $BufferBMP, 0, 0, $GUIWidth, $GUIHeight) EndFunc ;==>Draw
Func GUIExit() _GDIPlus_GraphicsDispose($Graphics) _GDIPlus_GraphicsDispose($Buffer) _GDIPlus_BitmapDispose($BufferBMP) _GDIPlus_ImageDispose($spriteBitmap) _GDIPlus_Shutdown() Exit EndFunc ;==>GUIExit
Func RotateImageDraw($graph, $hpic, $x, $y, $degrees, $size = 1) ; la dedico a quel nabbo di master, by th1sk <3
$w = _GDIPlus_ImageGetWidth($hpic) $h = _GDIPlus_ImageGetHeight($hpic) $nw = $w * $size $nh = $h * $size $newhbitmap = _WinAPI_CreateBitmap($nw, $nh, 1, 32) $newbitmap = _GDIPlus_BitmapCreateFromHBITMAP($newhbitmap) $m = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($m, $nw / 2, $nh / 2) _GDIPlus_MatrixRotate($m, $degrees) $g = _GDIPlus_ImageGetGraphicsContext($newbitmap) _GDIPlus_GraphicsClear($g, 0xFFFFFFFF) _GDIPlus_GraphicsSetTransform($g, $m) _GDIPlus_GraphicsDrawImage($g, $hpic, -($w / 2), -($h / 2)) _GDIPlus_MatrixDispose($m) _GDIPlus_GraphicsDispose($g) _WinAPI_DeleteObject($newhbitmap) _GDIPlus_GraphicsDrawImage($graph, $newbitmap, $x, $y) _GDIPlus_BitmapDispose($newbitmap) EndFunc ;==>RotateImageDraw
Func _ATAN2(Const $NY, Const $NX) Local $NRESULT If IsNumber($NY) = 0 Then SetError(1) Return 0 ElseIf IsNumber($NX) = 0 Then SetError(1) Return 0 EndIf If $NX = 0 Then If $NY > 0 Then $NRESULT = $NPI / 2 ElseIf $NY < 0 Then $NRESULT = 3 * $NPI / 2 Else SetError(2) Return 0 EndIf ElseIf $NX < 0 Then $NRESULT = ATan($NY / $NX) + $NPI Else $NRESULT = ATan($NY / $NX) EndIf While $NRESULT < 0 $NRESULT += 2 * $NPI WEnd Return $NRESULT EndFunc
| | |
| |
|