Jump to content

[SOLVED] GDI animation Help


Recommended Posts

I would like to create a GDI animation,  like this... NO GIF but Preferably png with transparency. Some examples or suggestions THX  :)

tumblr_mej6teJeU41qkc4kqo1_500.gif

I'm not sure the right way, 4 now I have tried with this

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <APIResConstants.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>
#include <FileConstants.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <GDIPlus.au3>

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $hGUI2
#Region ### START Koda GUI section ### Form=
$hGUI2 = GUICreate("nn", 800, 600, -1, -1)
$bt = GUICtrlCreateButton("go",10,10,100,20)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $bt
            For $x = 1 to 10
                Example($x)
            Next
    EndSwitch
WEnd



Func Example($direction)

_GDIPlus_Startup()

        $image2 = @ScriptDir&"\2.jpg"
        $hImage = _GDIPlus_ImageLoadFromFile($image2)
        $imgX = _GDIPlus_ImageGetWidth($hImage)
        $imgY = _GDIPlus_ImageGetHeight($hImage)
        $himage_Clone = _GDIPlus_BitmapCloneArea($hImage, 0, 0, $imgX, $imgY,$GDIP_PXF24RGB)
        _GDIPlus_ImageDispose($hImage)
        _GDIPlus_ImageRotateFlip($himage_Clone,$direction)
        ;load image window
        Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI2)
        $hImage_new2 = _GDIPlus_ImageResize($himage_Clone, 800,600)
        _GDIPlus_GraphicsDrawImage($hGraphics, $hImage_new2, 0, 0)

        ;Change image quality
        Local $hImage, $sCLSID, $tData, $tParams
        $clsid = _GDIPlus_EncodersGetCLSID("JPG");type
        $tParams = _GDIPlus_ParamInit(1)
        $tData = DllStructCreate("int Quality")
        DllStructSetData($tData, "Quality", 100) ;quality 0-100
        $pData = DllStructGetPtr($tData)
        _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData)
        $pParams = DllStructGetPtr($tParams)
        ;Save the new resized image.
        _GDIPlus_ImageSaveToFileEx($himage_Clone, $image2, $clsid, $pParams)
        ;clean
        _GDIPlus_ImageDispose($himage_Clone)
        _GDIPlus_BitmapDispose($hImage_new2)
        _WinAPI_DeleteObject($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

 

Edited by rootx
Link to comment
Share on other sites

#include <GDIPlus.au3>

_GDIPlus_Startup()

$hImage = _GDIPlus_ImageLoadFromFile("CD.png")
$aDim = _GDIPlus_ImageGetDimension($hImage)
$hBufImg = _GDIPlus_BitmapCreateFromScan0($aDim[0], $aDim[1])
$hBufGraph = _GDIPlus_ImageGetGraphicsContext($hBufImg)
_GDIPlus_GraphicsTranslateTransform($hBufGraph, $aDim[0] / 2, $aDim[1] / 2)

$iBackColor = 0xFFFFFFF0
$hGUI = GUICreate("CD Animation", $aDim[0], $aDim[1])
GUISetBkColor($iBackColor)
GUISetState()
$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)

$iAngle = 5 ; rotate speed
Do
  _GDIPlus_GraphicsRotateTransform($hBufGraph, $iAngle)
  _GDIPlus_GraphicsClear($hBufGraph, $iBackColor)
  _GDIPlus_GraphicsDrawImage($hBufGraph, $hImage, -$aDim[0] / 2, -$aDim[1] / 2)
  _GDIPlus_GraphicsDrawImage($hGraphics, $hBufImg, 0, 0)
Until GUIGetMsg() = -3

_GDIPlus_ImageDispose($hBufImg)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_GraphicsDispose($hBufGraph)
_GDIPlus_GraphicsDispose($hGraphics)

_GDIPlus_Shutdown()

 

CD.png

Edited by InnI
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...