Jump to content

Rotating transparent png


lokipoki
 Share

Recommended Posts

#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>

_GDIPlus_Startup()

$GUI_Width = @DesktopWidth  ;only with these macros other values will result in misplacement of the CD.
$GUI_Height = @DesktopHeight

;change the following variables and set the new pos and size of the resultant CD
Global $iX_Pos = 370, $iY_Pos = 150, $i_Radius = 200

$hGUI = GUICreate('MyGUI', $GUI_Width, $GUI_Height, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
GUICtrlCreatePic('ps2.jpg', 0, 0, $GUI_Width, $GUI_Height)
GUISetState()

$hBmp_CD = _GDIPlus_ScaleImage('jak 3.png', 2 * $i_Radius, 2 * $i_Radius)
$hBmp_Gfx_CD = _GDIPlus_ImageGetGraphicsContext($hBmp_CD)

$iWidth = _GDIPlus_ImageGetWidth($hBmp_CD)
$iHeight = _GDIPlus_ImageGetHeight($hBmp_CD)
$hGUI_Gfx = _GDIPlus_GraphicsCreateFromHWND($hGUI)

$hBmp = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hBmp_Gfx_CD)
$hBmp_Gfx = _GDIPlus_ImageGetGraphicsContext($hBmp)

$hMatrix = _GDIPlus_MatrixCreate()

_GDIPlus_MatrixTranslate($hMatrix, $iWidth / 2, $iHeight / 2)


Do

    _GDIPlus_MatrixRotate($hMatrix, 3)
    _GDIPlus_GraphicsSetTransform($hBmp_Gfx, $hMatrix)

    ;The CD is not at the Center perfectily, therefore some cliping would occur
    _GDIPlus_GraphicsDrawImage($hBmp_Gfx, $hBmp_CD, -$iWidth / 2, -$iHeight / 2)
    _GDIPlus_GraphicsDrawImage($hGUI_Gfx, $hBmp, $iX_Pos, $iY_Pos)


    _GDIPlus_GraphicsClear($hBmp_Gfx, 0x0000000) ;Make the Background equal to the background of the GUI
    Sleep(20)

Until GUIGetMsg() = $GUI_EVENT_CLOSE

;Link - http://www.autoitscript.com/forum/topic/145083-load-a-picture-resize-show-in-a-gui-and-store-in-sqlite/#entry1024693
Func _GDIPlus_ScaleImage($sFile, $iW, $iH, $iInterpolationMode = 7) ;coded by UEZ 2012
    If Not FileExists($sFile) Then Return SetError(1, 0, 0)
    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    If @error Then Return SetError(2, 0, 0)
    Local $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
    If @error Then Return SetError(3, 0, 0)
    $hBitmap = $hBitmap[6]
    Local $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hBmpCtxt, "int", $iInterpolationMode)
    _GDIPlus_GraphicsDrawImageRect($hBmpCtxt, $hImage, 0, 0, $iW, $iH)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hBmpCtxt)
    Return $hBitmap
EndFunc

;memory release
_GDIPlus_MatrixDispose($hMatrix)
_GDIPlus_GraphicsDispose($hBmp_Gfx)
_GDIPlus_GraphicsDispose($hGUI_Gfx)
_GDIPlus_GraphicsDispose($hBmp_Gfx_CD)
_GDIPlus_ImageDispose($hBmp)
_GDIPlus_ImageDispose($hBmp_CD)
_GDIPlus_Shutdown()

Does it help ? all credits goes to GDI+ hero UEZ

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

  • 3 weeks later...
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>

_GDIPlus_Startup()

$GUI_Width = @DesktopWidth  ;only with these macros other values will result in misplacement of the CD.
$GUI_Height = @DesktopHeight

;change the following variables and set the new pos and size of the resultant CD
Global $iX_Pos = 370, $iY_Pos = 150, $i_Radius = 200

$hGUI = GUICreate('MyGUI', $GUI_Width, $GUI_Height, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
GUICtrlCreatePic('ps2.jpg', 0, 0, $GUI_Width, $GUI_Height)
GUISetState()

$hBmp_CD = _GDIPlus_ScaleImage('jak 3.png', 2 * $i_Radius, 2 * $i_Radius)
$hBmp_Gfx_CD = _GDIPlus_ImageGetGraphicsContext($hBmp_CD)

$iWidth = _GDIPlus_ImageGetWidth($hBmp_CD)
$iHeight = _GDIPlus_ImageGetHeight($hBmp_CD)
$hGUI_Gfx = _GDIPlus_GraphicsCreateFromHWND($hGUI)

$hBmp = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hBmp_Gfx_CD)
$hBmp_Gfx = _GDIPlus_ImageGetGraphicsContext($hBmp)

$hMatrix = _GDIPlus_MatrixCreate()

_GDIPlus_MatrixTranslate($hMatrix, $iWidth / 2, $iHeight / 2)


Do

    _GDIPlus_MatrixRotate($hMatrix, 3)
    _GDIPlus_GraphicsSetTransform($hBmp_Gfx, $hMatrix)

    ;The CD is not at the Center perfectily, therefore some cliping would occur
    _GDIPlus_GraphicsDrawImage($hBmp_Gfx, $hBmp_CD, -$iWidth / 2, -$iHeight / 2)
    _GDIPlus_GraphicsDrawImage($hGUI_Gfx, $hBmp, $iX_Pos, $iY_Pos)


    _GDIPlus_GraphicsClear($hBmp_Gfx, 0x0000000) ;Make the Background equal to the background of the GUI
    Sleep(20)

Until GUIGetMsg() = $GUI_EVENT_CLOSE

;Link - http://www.autoitscript.com/forum/topic/145083-load-a-picture-resize-show-in-a-gui-and-store-in-sqlite/#entry1024693
Func _GDIPlus_ScaleImage($sFile, $iW, $iH, $iInterpolationMode = 7) ;coded by UEZ 2012
    If Not FileExists($sFile) Then Return SetError(1, 0, 0)
    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    If @error Then Return SetError(2, 0, 0)
    Local $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
    If @error Then Return SetError(3, 0, 0)
    $hBitmap = $hBitmap[6]
    Local $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hBmpCtxt, "int", $iInterpolationMode)
    _GDIPlus_GraphicsDrawImageRect($hBmpCtxt, $hImage, 0, 0, $iW, $iH)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hBmpCtxt)
    Return $hBitmap
EndFunc

;memory release
_GDIPlus_MatrixDispose($hMatrix)
_GDIPlus_GraphicsDispose($hBmp_Gfx)
_GDIPlus_GraphicsDispose($hGUI_Gfx)
_GDIPlus_GraphicsDispose($hBmp_Gfx_CD)
_GDIPlus_ImageDispose($hBmp)
_GDIPlus_ImageDispose($hBmp_CD)
_GDIPlus_Shutdown()

Does it help ? all credits goes to GDI+ hero UEZ

Thanks heaps. It works.

But when I call now, for example, pcsx2 the gui is still on top and I cant see pcsx2.

Should those lines kill the gui so that I can run pcsx2?!

;memory release
_GDIPlus_MatrixDispose($hMatrix)
_GDIPlus_GraphicsDispose($hBmp_Gfx)
_GDIPlus_GraphicsDispose($hGUI_Gfx)
_GDIPlus_GraphicsDispose($hBmp_Gfx_CD)
_GDIPlus_ImageDispose($hBmp)
_GDIPlus_ImageDispose($hBmp_CD)
_GDIPlus_Shutdown()

Thanks.

Edited by lokipoki
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...