sss
Продвинутый
- Сообщения
- 332
- Репутация
- 96
Всем доброго времени суток! Возникла проблема: необходимо повернуть полупрозрачную картинку (взятую из файла png) в GUI. Явно что-то связанное с GDIPlus, но я в нем не очень силен... Нашел на официальном форуме пример, но не получается адаптировать к моему случаю. Я так понял, самое интересное в функции Rotate(), но как вместо треугольника вставить картинку... И хотелось бы добавить туда параметр угла поворота и использовать без Adlib(это у меня получилось). Полупрозрачность обязательно должна остаться.
Помогите пожалуйста! Картинка во вложении. Код с форума ниже.
Помогите пожалуйста! Картинка во вложении. Код с форума ниже.
Код:
#include <GDIP.au3>
#include <winapi.au3>
#include <Misc.au3>
Opt("MouseCoordMode", 2)
_GDIPlus_Startup()
$hGui = GUICreate("GDI+ Evento by monoscout999", 300, 300)
$iPic = GUICtrlCreatePic("", 0, 0, 300, 300)
GUISetState()
Global $hDll = DllOpen("user32.dll")
global $RotAng = 1
Global $status
Global $aColors[4] = [3, 0xFFFF0000, 0xFF550000, 0xFF220000]
Global $aPoints[4][2] = [[3],[63, 200],[237, 200],[150, 50]]
Global $aPathPoints[4][2] = [[3],[-87, 50],[87, 50],[0, -100]] ; All elements - 150
$hGraphics = _GDIPlus_GraphicsCreateFromHWND(GUICtrlGetHandle($iPic))
_GDIPlus_GraphicsClear($hGraphics, 0xFF123456)
_GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2)
$hBrush = _GDIPlus_PathBrushCreate($aPoints)
_GDIPlus_PathBrushSetCenterColor($hBrush, 0xFF222200)
_GDIPlus_PathBrushSetSurroundColorsWithCount($hBrush, $aColors)
$hGBitmap = _GDIPlus_BitmapCreateFromGraphics(300, 300, $hGraphics)
$hGBackbuffer = _GDIPlus_ImageGetGraphicsContext($hGBitmap)
$hPath = _GDIPlus_PathCreate()
$hMatrix = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixTranslate($hMatrix, 150, 150)
AdlibRegister("Rotate", 20)
While True
$iMsg = GUIGetMsg()
Switch $iMsg
Case -3
Exit
EndSwitch
$status = _GDIPlus_PathIsVisiblePoint($hPath, MouseGetPos(0), MouseGetPos(1), $hGraphics)
If $status = True Then
GUISetCursor(14, 1, $hGui)
$MousePos = MouseGetPos(0)
While _IsPressed(0x01,$hDll)
$RotAng = (MouseGetPos(0) - $MousePos) / 50
Opt("MouseCoordMode", 1)
ToolTip($RotAng, MouseGetPos(0)+20, MouseGetPos(1)+20,"Rotation Speed")
Opt("MouseCoordMode", 2)
WEnd
ToolTip("")
Else
GUISetCursor(-1, 1, $hGui)
EndIf
WEnd
AdlibUnRegister("Rotate")
_GDIPlus_MatrixDispose($hMatrix)
_GDIPlus_PathDispose($hPath)
_GDIPlus_GraphicsDispose($hGBackbuffer)
_GDIPlus_BitmapDispose($hGBitmap)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_Shutdown()
DllClose($hDll)
Func Rotate()
_GDIPlus_GraphicsClear($hGBackbuffer, 0xFF123456)
_GDIPlus_MatrixRotate($hMatrix, $RotAng)
_GDIPlus_GraphicsSetTransform($hGraphics, $hMatrix)
$aPathPoints2 = _GDIPlus_MatrixTransformPoints($hMatrix, $aPathPoints)
_GDIPlus_PathReset($hPath)
_GDIPlus_PathAddPolygon($hPath, $aPathPoints2)
_GDIPlus_GraphicsFillPolygon($hGBackbuffer, $aPoints, $hBrush)
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hGBitmap, -150, -150, 300, 300)
EndFunc ;==>Rotate