wakillon

Gif2Avi

19 posts in this topic

#1 ·  Posted (edited)

An other tool for AutoIt Coders :

Gif2Avi permit to convert an animated Gif to an Avi file for use with the (rarely used) GUICtrlCreateAvi function.

Use an Avi file as loader or animation in a script (see StringFinder for example) is easier than use an animated gif.

With this little tool you can also :

_ Set the AVI file dimensions ( height will follow width changes for preserve ratio W/H )

_ Change FPS (frames per second) 

_ Try an other background color ( used in _GDIPlus_BitmapCreateHBITMAPFromBitmap function)

_ Crop width and height (From the original dimension)

image.jpg.c9838348cd3122e2abbe95ea8e9ac3

Thanks to monoceres, Prog@ndy and UEZ for AVI functions.

Source and compiled Version are available in the Download Section.

May be the "GUICtrlCreateAvi" function will be a bit more used ! :D

 

Some Links for find or create loaders/spinners

preloaders.net        loading.io      dribbble.com       chimply.com      tools.bit-hive.com

 

Edited by wakillon
2 people like this

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

This might be of interest: https://autoit.de/index.php/Thread/84289-AVI-Compose-Video-UDF/

 

Drag'n'drop doesn't work for me. Conversation works fine. Any chance to set the compression?


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
42 minutes ago, UEZ said:

This might be of interest: https://autoit.de/index.php/Thread/84289-AVI-Compose-Video-UDF/

 

Drag'n'drop doesn't work for me. Conversation works fine. Any chance to set the compression?

eukalyptus example is great, thanks !

May be you need to be admin for use Drag'n'drop ? :huh2:

Conversion or Conversation :D

For the compression unfortunatelly GuiCtrlCreateAvi (after many tries with other formats)

only support uncompressed "DIB " format (Microsoft Device Independent Bitmap)

The only interest is that no codec is required.

 

1 person likes this

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

The compiled exe is not working with drag'n'drop but running it from SciTE works.

 


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
1 minute ago, UEZ said:

The compiled exe is not working with drag'n'drop but running it from SciTE works.

 

Strange ! It works fine for me...

Compile it yourself and retry...


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

I wrote this example some time ago which uses a built-in codec for compression:

;captures whole desktop and saves it as an AVI file using Microsoft Video 1 codec
#include <ScreenCapture.au3>

#region structs and constans
Global Const $OF_CREATE = 0x00001000
Global Const $AVIIF_KEYFRAME = 0x00000010
Global Const $ICMF_CHOOSE_KEYFRAME = 1, $ICMF_CHOOSE_DATARATE = 2
Global Const $AVIERR_UNSUPPORTED = 0x80044065
Global Const $AVIERR_BADPARAM = 0x80044066
Global Const $AVIERR_MEMORY = 0x80044067
Global Const $AVIERR_NOCOMPRESSOR = 0x80044071
Global Const $AVIERR_CANTCOMPRESS = 0x80044075
Global Const $AVIERR_ERROR = 0x800440C7
Global Const $AVIERR_OK = 0
Global $Avi32_Dll

Global Const $ICINFO = _
    "DWORD dwSize;DWORD fccType;DWORD fccHandler;DWORD dwFlags;DWORD dwVersion;DWORD dwVersionICM;" & _
    "WCHAR szName[16];WCHAR szDescription[128];WCHAR szDriver[128];"

;http://msdn.microsoft.com/en-us/library/dd183374(v=vs.85).aspx
Global Const $BITMAPFILEHEADER = "WORD bfType;DWORD bfSize;WORD bfReserved1;WORD bfReserved2;DWORD bfOffBits;"
;~ Global Const $BITMAPFILEHEADER = "align 2;char magic[2];int size;short res1;short res2;ptr offset;"

;http://msdn.microsoft.com/en-us/library/dd183376(v=vs.85).aspx
Global Const $BITMAPINFOHEADER = _
        "dword biSize;long biWidth;long biHeight;short biPlanes;short biBitCount;dword biCompression;" & _
        "dword biSizeImage;long biXPelsPerMeter;long biYPelsPerMeter;dword biClrUsed;dword biClrImportant;"

;http://msdn.microsoft.com/en-us/library/ms899423.aspx
Global Const $AVISTREAMINFO = _
        "dword fccType;dword fccHandler;dword dwFlags;dword dwCaps;short wPriority;short wLanguage;dword dwScale;" & _
        "dword dwRate;dword dwStart;dword dwLength;dword dwInitialFrames;dword dwSuggestedBufferSize;dword dwQuality;" & _
        "dword dwSampleSize;int rleft;int rtop;int rright;int rbottom;dword dwEditCount;dword dwFormatChangeCount;wchar[64];"

;http://msdn.microsoft.com/en-us/library/dd756791(v=VS.85).aspx
Global Const $AVICOMPRESSOPTIONS = _
        "DWORD fccType;DWORD fccHandler;DWORD dwKeyFrameEvery;DWORD dwQuality;DWORD dwBytesPerSecond;" & _
        "DWORD dwFlags;PTR lpFormat;DWORD cbFormat;PTR lpParms;DWORD cbParms;DWORD dwInterleaveEvery;"
#endregion

Global $rec_duration = 15
Global $fps = 5
Global $iW = @DesktopWidth, $iH = @DesktopHeight

_StartAviLibrary()
FileDelete(@ScriptDir & "\Test.avi")
Global $aAVI = _CreateAvi(@ScriptDir & "\Test.avi", $fps, $iW - 1, $iH - 1)

Global $fSleep = 1000 / $fps, $t, $td
Global $total_FPS = $rec_duration * $fps, $fps_c = 1
Global $k32_dll = DllOpen("kernel32.dll")

Do
    $fTimer = TimerInit()

    $hBmp = _ScreenCapture_Capture("", 0, 0, $iW - 1, $iW - 1)
    _AddHBitmapToAvi($aAVI, $hBmp)
    _WinAPI_DeleteObject($hBmp)

    $fps_c += 1
    $td = $fSleep - TimerDiff($fTimer)
    If $td > 0 Then
        DllCall($k32_dll, "none", "Sleep", "dword", $td)
    EndIf

    If $fps_c > $total_FPS Then
        ExitLoop
    EndIf
Until False

_CloseAvi($aAVI)
_StopAviLibrary()
ConsoleWrite("Done!" & @LF)
DllClose($k32_dll)

Exit

#region AVIWriter UDF
;http://www.fourcc.org/codecs.php
Func _Create_mmioFOURCC($FOURCC) ;coded by UEZ
    If StringLen($FOURCC) <> 4 Then Return SetError(1, 0, 0)
    Local $aFOURCC = StringSplit($FOURCC, "", 2)
    Return BitOR(Asc($aFOURCC[0]), BitShift(Asc($aFOURCC[1]), -8), BitShift(Asc($aFOURCC[2]), -16), BitShift(Asc($aFOURCC[3]), -24))
EndFunc   ;==>_Create_mmioFOURCC

Func _DecodeFOURCC($iFOURCC);coded by UEZ
    If Not IsInt($iFOURCC) Then Return SetError(1, 0, 0)
    Return Chr(BitAND($iFOURCC, 0xFF)) & Chr(BitShift(BitAND(0x0000FF00, $iFOURCC), 8)) & Chr(BitShift(BitAND(0x00FF0000, $iFOURCC), 16)) & Chr(BitShift($iFOURCC, 24))
EndFunc   ;==>_DecodeFOURCC

;monoceres, Prog@ndy, UEZ
Func _CreateAvi($sFilename, $FrameRate, $Width, $Height, $BitCount = 24, $mmioFOURCC = "MSVC", $iQuality = 3333, $iKeyFrameEvery = 10) ;$iQuality from -1 to 10000
    Local $RetArr[6] ;avi file handle, compressed stream handle, bitmap count, BitmapInfoheader, Stride, stream handle

    Local $aRet, $pFile, $tASI, $tACO, $pStream, $psCompressed

    Local $stride = BitAND(($Width * ($BitCount / 8) + 3), BitNOT(3))

    Local $tBI = DllStructCreate($BITMAPINFOHEADER)
    DllStructSetData($tBI, "biSize", DllStructGetSize($tBI))
    DllStructSetData($tBI, "biWidth", $Width)
    DllStructSetData($tBI, "biHeight", $Height)
    DllStructSetData($tBI, "biPlanes", 1)
    DllStructSetData($tBI, "biBitCount", $BitCount)
    DllStructSetData($tBI, "biSizeImage", $stride * $Height)

    $tASI = DllStructCreate($AVISTREAMINFO) ;https://msdn.microsoft.com/en-us/library/aa919806.aspx
    DllStructSetData($tASI, "fccType", _Create_mmioFOURCC("vids"))
    DllStructSetData($tASI, "fccHandler", _Create_mmioFOURCC($mmioFOURCC))
    DllStructSetData($tASI, "dwScale", 1)
    DllStructSetData($tASI, "dwRate", $FrameRate)
    DllStructSetData($tASI, "dwQuality", $iQuality) ;Quality is represented as a number between 0 and 10,000. For compressed data, this typically represents the value of the quality parameter passed to the compression software. If set to -1, drivers use the default quality value.
    DllStructSetData($tASI, "dwSuggestedBufferSize", $stride * $Height)
    DllStructSetData($tASI, "rright", $Width)
    DllStructSetData($tASI, "rbottom", $Height)


    $tParms = DllStructCreate($ICINFO)
    DllCall("Msvfw32.dll", "BOOL", "ICInfo", "DWORD", _Create_mmioFOURCC("vids"), "DWORD", _Create_mmioFOURCC($mmioFOURCC), "ptr", DllStructGetPtr($tParms))

    $tACO = DllStructCreate($AVICOMPRESSOPTIONS) ;https://msdn.microsoft.com/en-us/library/windows/desktop/dd742972%28v=vs.85%29.aspx
    DllStructSetData($tACO, "fccType", _Create_mmioFOURCC("vids"))
    DllStructSetData($tACO, "fccHandler", _Create_mmioFOURCC($mmioFOURCC))
    DllStructSetData($tACO, "dwKeyFrameEvery", $iKeyFrameEvery)
    DllStructSetData($tACO, "dwQuality", $iQuality)
    DllStructSetData($tACO, "dwBytesPerSecond", 0)
    DllStructSetData($tACO, "dwFlags", 8)
    DllStructSetData($tACO, "lpFormat", 0)
    DllStructSetData($tACO, "cbFormat", 0)
    DllStructSetData($tACO, "lpParms", DllStructGetPtr($tParms))
    DllStructSetData($tACO, "cbParms", DllStructGetSize($tParms))
    DllStructSetData($tACO, "dwInterleaveEvery", 0)

;~     $tACO = DllStructCreate($AVICOMPRESSOPTIONS)
;~     DllStructSetData($tACO, "fccType", _Create_mmioFOURCC("vids"))
;~     DllStructSetData($tACO, "fccHandler", _Create_mmioFOURCC($mmioFOURCC))
;~     DllStructSetData($tACO, "dwKeyFrameEvery", $iKeyFrameEvery)

    $aRet = DllCall($Avi32_Dll, "int", "AVIFileOpenW", "ptr*", 0, "wstr", $sFilename, "uint", $OF_CREATE, "ptr", 0)
    $pFile = $aRet[1]

    $aRet = DllCall($Avi32_Dll, "int", "AVIFileCreateStream", "ptr", $pFile, "ptr*", 0, "ptr", DllStructGetPtr($tASI))
    $pStream = $aRet[2]

;~     $aRet = DllCall($Avi32_Dll, "int_ptr", "AVISaveOptions", "hwnd", 0, "uint", BitOR($ICMF_CHOOSE_DATARATE, $ICMF_CHOOSE_KEYFRAME), "int", 1, "ptr*", $pStream, "ptr*", DllStructGetPtr($tACO))
;~     If $aRet[0] <> 1 Then
;~      $RetArr[0] = $pFile
;~      $RetArr[1] = $pStream
;~      $RetArr[2] = 0
;~      $RetArr[3] = $tBI
;~      $RetArr[4] = $Stride
;~      $RetArr[5] = $pStream
;~         Return SetError(1, 0, $RetArr)
;~     EndIf

;~     ConsoleWrite(_DecodeFOURCC(DllStructGetData($tACO, "fccHandler")) & @CRLF)

    ;http://msdn.microsoft.com/en-us/library/dd756811(v=VS.85).aspx
    $aRet = DllCall($Avi32_Dll, "int", "AVIMakeCompressedStream", "ptr*", 0, "ptr", $pStream, "ptr", DllStructGetPtr($tACO), "ptr", 0)
    If $aRet[0] <> $AVIERR_OK Then
            $RetArr[0] = $pFile
            $RetArr[1] = $pStream
            $RetArr[2] = 0
            $RetArr[3] = $tBI
            $RetArr[4] = $stride
            $RetArr[5] = $pStream
        Return SetError(2, 0, $RetArr)
    EndIf
    $psCompressed = $aRet[1]

    ;The format for the stream is the same as BITMAPINFOHEADER
    $aRet = DllCall($Avi32_Dll, "int", "AVIStreamSetFormat", "ptr", $psCompressed, "long", 0, "ptr", DllStructGetPtr($tBI), "long", DllStructGetSize($tBI))

    $RetArr[0] = $pFile
    $RetArr[1] = $psCompressed
    $RetArr[2] = 0
    $RetArr[3] = $tBI
    $RetArr[4] = $stride
    $RetArr[5] = $pStream
    Return $RetArr
EndFunc   ;==>_CreateAvi

;Adds a bitmap file to an already opened avi file.
;monoceres, Prog@ndy
Func _AddHBitmapToAvi(ByRef $Avi_Handle, $hBitmap)
    Local $DC = _WinAPI_GetDC(0)
    Local $hDC = _WinAPI_CreateCompatibleDC($DC)
    _WinAPI_ReleaseDC(0, $DC)

    Local $OldBMP = _WinAPI_SelectObject($hDC, $hBitmap)
    Local $bits = DllStructCreate("byte[" & DllStructGetData($Avi_Handle[3], "biSizeImage") & "]")
    _WinAPI_GetDIBits($hDC, $hBitmap, 0, Abs(DllStructGetData($Avi_Handle[3], "biHeight")), DllStructGetPtr($bits), DllStructGetPtr($Avi_Handle[3]), 0)
    _WinAPI_SelectObject($hDC, $OldBMP)
    _WinAPI_DeleteDC($hDC)

    DllCall($Avi32_Dll, "int", "AVIStreamWrite", "ptr", $Avi_Handle[1], "long", $Avi_Handle[2], "long", 1, "ptr", DllStructGetPtr($bits), _
                                        "long", DllStructGetSize($bits), "long", $AVIIF_KEYFRAME, "ptr*", 0, "ptr*", 0)
    $Avi_Handle[2] += 1
EndFunc   ;==>_AddHBitmapToAvi

;Adds a bitmap file to an already opened avi file.
Func _AddBitmapToAvi(ByRef $Avi_Handle, $sBitmap)
    Local $bm = LoadBitmap($sBitmap, True)
    DllCall($Avi32_Dll, "int", "AVIStreamWrite", "ptr", $Avi_Handle[1], "long", $Avi_Handle[2], "long", 1, "ptr", DllStructGetPtr($bm[2]), _
                                        "long", DllStructGetSize($bm[2]), "long", $AVIIF_KEYFRAME, "ptr*", 0, "ptr*", 0)
    $Avi_Handle[2] += 1
EndFunc   ;==>_AddBitmapToAvi

;Returns array with 3 elements
;[0]=BITMAPFILEHEADER
;[1]=BITMAPINFOHEADER
;[2]=Bitmap data buffer (if specified)
Func LoadBitmap($sFilename, $LoadData = False)
    Local $RetArr[3]
    Local $byref
    Local $tBIH, $tBFH, $buffer, $fhandle
    $tBFH = DllStructCreate($BITMAPFILEHEADER)
    $tBIH = DllStructCreate($BITMAPINFOHEADER)
    $fhandle = _WinAPI_CreateFile($sFilename, 2, 2, 0, 0)
    _WinAPI_ReadFile($fhandle, DllStructGetPtr($tBFH), DllStructGetSize($tBFH), $byref)
    _WinAPI_ReadFile($fhandle, DllStructGetPtr($tBIH), DllStructGetSize($tBIH), $byref)
    $RetArr[0] = $tBFH
    $RetArr[1] = $tBIH

    If Not $LoadData Then
        _WinAPI_CloseHandle($fhandle)
        Return $RetArr
    EndIf

    $buffer = DllStructCreate("byte[" & DllStructGetData($tBFH, "size") - 54 & "]")
    $RetArr[2] = $buffer
    _WinAPI_ReadFile($fhandle, DllStructGetPtr($buffer), DllStructGetSize($buffer), $byref)
    _WinAPI_CloseHandle($fhandle)

    Return $RetArr
EndFunc   ;==>LoadBitmap

;Init the avi library
Func _StartAviLibrary()
    $Avi32_Dll = DllOpen("Avifil32.dll")
    DllCall($Avi32_Dll, "none", "AVIFileInit")
EndFunc   ;==>_StartAviLibrary

;Release the library
Func _StopAviLibrary()
    DllCall($Avi32_Dll, "none", "AVIFileExit")
    DllClose($Avi32_Dll)
EndFunc   ;==>_StopAviLibrary

Func _CloseAvi($Avi_Handle)
    DllCall($Avi32_Dll, "int", "AVIStreamRelease", "ptr", $Avi_Handle[1])
    DllCall($Avi32_Dll, "int", "AVIStreamRelease", "ptr", $Avi_Handle[5])
    DllCall($Avi32_Dll, "int", "AVIFileRelease", "ptr", $Avi_Handle[0])
EndFunc   ;==>_CloseAvi
#endregion AVIWriter UDF

 

Drag'n'drop works only when I comment out "#AutoIt3Wrapper_res_requestedExecutionLevel=highestAvailable". Tested on Win10 x64.


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

"MSVC" is not supported by GuiCtrlCreateAvi function

I have uploaded files following your suggestion. ;)

Added some links to the first Post.


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

One more thing - I would always use ($GDIP_PXF32ARGB)

$ahClone[$i] = _GDIPlus_BitmapCloneArea ( $hImage, 0, 0, $iWidth, $iHeight, $GDIP_PXF32ARGB )

for a better quality in line 414 and remove the sleep.


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

 

Sure as I use it line 101 ;)

But line 414, $aPixelFormat[0] is always equal to $GDIP_PXF32ARGB for all Gifs used.

Sleep ( 20 ) is used for limit cpu usage when there is lot of frames.


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

@UEZ

Something who could be interesting, would be to get ( i have try unsuccessfully with GdipGetPropertyItem )

the transparency color or the transparency index from the colors palette and be able to change it.

Any idea ? :)


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
13 hours ago, wakillon said:

@UEZ

Something who could be interesting, would be to get ( i have try unsuccessfully with GdipGetPropertyItem )

the transparency color or the transparency index from the colors palette and be able to change it.

Any idea ? :)

What is the purpose for this? I would say it is much easier to change the background color thus you change also the transparent color at least for transparent GIFs.


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

The purpose would be to convert not transparent GIF to transparent GIF for a better display on a GUI.


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

How you want to get the proper color value to make it transparent? To make a color value transparent is easy.

 

#include <GDIPlus.au3>


Global $sFile_GIF = FileOpenDialog("Select a GIF image (non animated!)", @ScriptDir, "GIF (*.gif)")
If @error Then Exit

_GDIPlus_Startup()
Global Const $hImage = _GDIPlus_ImageLoadFromFile($sFile_GIF)

Global $iSize = _GDIPlus_ImageGetColorPaletteSize($hImage)
Global $tColorPalette = DllStructCreate("struct;uint Flags;uint Count;dword Entries[256];endstruct")

_GDIPlus_ImageGetColorPalette($hImage, $tColorPalette, $iSize)

ConsoleWrite($iSize & @CRLF)
ConsoleWrite($tColorPalette.Flags & @CRLF)
ConsoleWrite($tColorPalette.Count & @CRLF & @CRLF)

;print color table
For $i = 1 To $tColorPalette.Count
    ConsoleWrite(Hex($tColorPalette.Entries(($i)), 8) & @CRLF)
Next

_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()



Func _GDIPlus_ImageGetColorPalette($hImage, $tColorPalette, $iSize)
    Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetImagePalette", "handle", $hImage, "struct*", $tColorPalette, "uint", $iSize)
    If @error Then Return SetError(@error, @extended, 0)
    If $aResult[0] Then Return SetError(10, $aResult[0], 0)
    Return True
EndFunc   ;==>_GDIPlus_ImageGetColorPalette

Func _GDIPlus_ImageGetColorPaletteSize($hImage)
    Local $aResult = DllCall($__g_hGDIPDll, "uint", "GdipGetImagePaletteSize", "handle", $hImage, "uint*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    If $aResult[0] Then Return SetError(10, $aResult[0], 0)
    Return $aResult[2]
EndFunc   ;==>_GDIPlus_ImageGetColorPaletteSize

 


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

Thanks for sharing. :thumbsup:


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites
35 minutes ago, TheSaint said:

Thanks for sharing. :thumbsup:

You're wellcome ;)

 

@UEZ

Have you seen in eukalyptus AVI-Compose-Video-UDF that you can extract frames as you want some time ago ?

#include <AVIComp.au3>

Global $tAVI = _AVIComp_Open( 'D:\Bureau\Test_CVID.avi' )
ConsoleWrite("> Dimension: " & $tAVI.Width & "x" & $tAVI.Height & @CRLF)
ConsoleWrite("> FrameRate: " & $tAVI.FrameRate & @CRLF)
DirCreate ( @ScriptDir & '\Frames' )
For $i = 1 To $tAVI.Frames
    _AVIComp_GetFrame($tAVI, $i)
    _GDIPlus_ImageSaveToFile($tAVI.Bmp, @ScriptDir & "\Frames\Frame_" & StringFormat("%03s", $i) & ".gif")
Next
_AVIComp_Close($tAVI)
ShellExecute(@ScriptDir & "\Frames\Frame_001.gif")

 


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
2 minutes ago, wakillon said:

Have you seen in eukalyptus AVI-Compose-Video-UDF that you can extract frames as you want some time ago ?

Yes of course. :D 

 

My idea was to convert an AVI to a GIF animation. Now it can be made...


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
16 minutes ago, UEZ said:

My idea was to convert an AVI to a GIF animation. Now it can be made...

Great !

But it will be only for AVI files.

Have you find a solution for mp4 or mkv ?


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

This was only something within mind. That means I never tried anything in that direction yet.

Currently I'm trying other things to speed up GDI+ stuff using ext. DLL which I create with FreeBasic.

 

FreeBasic is very powerful and faaaaaaaaassssssssssttttttttt. ;)

 

Little example: Random Pixel Generator

Edited by UEZ
1 person likes this

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

Wow you are right !

I will take a look

Thanks.


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

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

  • Similar Content

    • Bilgus
      By Bilgus
      Draw Path Points allows you to make line paths for drawing with gdi
      You can even load an image and trace the outline
      Save and load functionality undo and redo zoom and scale; Don't Forget Rotate!
      ;Draw Path Points BILGUS 2018 ;Includes #include <File.au3> #include <GDIPlus.au3> #include <GUIConstants.au3> #include <GuiEdit.au3> #include <GuiListView.au3> #include <GuiTab.au3> #include <Misc.au3> If OnAutoItExitRegister("_Exit") <> 0 Then _GDIPlus_Startup() ;initialize GDI+ ConsoleWrite("GDI+ Started" & @CRLF) EndIf Opt("MouseCoordMode", 2) ;Relative coords to the client area of the active window Opt("PixelCoordMode", 2) ;Relative coords to the client area of the active window Global $iXScale = 8 Global $iYScale = $iXScale Global $sFileSave = @ScriptDir & "\DrawPath.txt" ;Default Global $b_ClosePath = False Global $b_ShowImage = False Global $sImagefile = "" Global $iUndo_Max = 50 Global $a_sUndo_Files[1] = [""] Global $a_sRedo_Files[1] = [""] Global $aPath_Points[1][2] = [[0, 0]] Global $aPath_Rot_Points Global $Form1 = GUICreate("Draw Path Points", 615, 437, 192, 124) Global $SelSquare = GUICtrlCreateLabel("", 0, 0, 0, 0, $SS_BLACKFRAME, $WS_EX_TOPMOST) GUICtrlSetState(-1, $GUI_HIDE) ;------------------------------------------------------------------------------- Global Enum $eC1_delete, $eC1_del_all, $eC1_update, $eC1_shift_dn, $eC1_shift_up, _ $eC1_closepath, $eC1_showimg, $eC1_lock, $eC1_undo, $eC1_redo, $aCtl1_LAST Global $aCtl1[$aCtl1_LAST] Control_Create_Group1() ;------------------------------------------------------------------------------- Global Enum $eC2_zin, $eC2_zout, $eC2_dgroup, $eC2_decx, $eC2_incx, $eC2_decy, _ $eC2_incy, $eC2_edit_rot, $eC2_rot, $eC2_ud_rot, $eC2_rev, $eC2_toall, $aCtl2_LAST Global $aCtl2[$aCtl2_LAST] Control_Create_Group2() ;------------------------------------------------------------------------------- Global $Btn_load = GUICtrlCreateButton("Load", 5, 1, 35, 20) Global $Btn_save = GUICtrlCreateButton("Save", 40, 1, 35, 20) Global $Btn_arr_disp = GUICtrlCreateButton("Array", 75, 1, 35, 20) Global $Edit_encoded = GUICtrlCreateEdit("", 115, 2, 50, 18, $ES_READONLY + $ES_AUTOHSCROLL, $WS_EX_STATICEDGE + $WS_EX_TRANSPARENT) Global $List1 = GUICtrlCreateListView("#|x|y", 5, 24, 161, 201, $LVS_SHOWSELALWAYS Or $LVS_SINGLESEL) Global $List1_LVN = GUICtrlCreateDummy() ;listview notifications Global $Image1 = GUICtrlCreatePic("", 200, 16, 400, 400, -1, $WS_EX_LAYERED) Global $Tab1 = GUICtrlCreateTab(1, 225, 20, 500, $TCS_VERTICAL) GUICtrlCreateTabItem(" ") GUICtrlSetState(-1, $GUI_SHOW) ; will be display first GUICtrlCreateTabItem(" ") GUICtrlCreateTabItem("") ; end tabitem definition For $i = 0 To UBound($aCtl2) - 1 GUICtrlSetState($aCtl2[$i], $GUI_HIDE) Next GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") List_Update() List_Index() GUISetState(@SW_SHOW) State_Save($aPath_Points) Points_Update($aPath_Points) While 1 $nMsg = GUIGetMsg() If $nMsg > 0 And $nMsg <> $aCtl2[$eC2_ud_rot] And $nMsg <> $aCtl2[$eC2_edit_rot] And GUICtrlRead($aCtl2[$eC2_edit_rot]) <> 0 Then ;ConsoleWrite("Cancel_Rotate? " & $nMsg & @CRLF) If MsgBox($MB_ICONQUESTION + $MB_OKCANCEL + $MB_DEFBUTTON2, "Save?", "Save Rotated Points?", 10) == $IDOK Then _GUICtrlEdit_SetText($aCtl2[$eC2_edit_rot], "0") $aPath_Points = $aPath_Rot_Points State_Save($aPath_Points) List_Update(List_Index()) Else _GUICtrlEdit_SetText($aCtl2[$eC2_edit_rot], "0") Points_Update($aPath_Points, $b_ClosePath, $b_ShowImage, List_Index()) ;, True) EndIf EndIf Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Tab1 Tab1_Select() Case $SelSquare ;ConsoleWrite("SelSquare" & @CRLF) SelSquare_Drag() Case $List1 ;ConsoleWrite("List1 " & $nMsg & @CRLF) Local $iIndex = List_Index() If $iIndex <> -1 Then Points_Update($aPath_Points, $b_ClosePath, $b_ShowImage, $iIndex) _GUICtrlListView_SetItemSelected($List1, $iIndex, True, True) EndIf Case $List1_LVN Point_Selected($aPath_Points, $Image1, List_Index()) Case $List1_LVN Case $Image1 Image1_Clicked() Case $Btn_save Btn_save_Clicked() Case $Btn_load Btn_load_Clicked() Case $Btn_arr_disp _ArrayDisplay($aPath_Points) ;------------------------------------------------------------------- Case $aCtl1[$eC1_shift_up] Local $iIndex = List_Index() Point_Swap($iIndex, -1) Points_Update($aPath_Points, $b_ClosePath, $b_ShowImage) Case $aCtl1[$eC1_shift_dn] Local $iIndex = List_Index() Point_Swap($iIndex, 1) Points_Update($aPath_Points, $b_ClosePath, $b_ShowImage) Case $aCtl1[$eC1_del_all] $aPath_Points = 0 Dim $aPath_Points[1][2] = [[0, 0]] List_Update() Points_Update($aPath_Points, $b_ClosePath, $b_ShowImage) Case $aCtl1[$eC1_delete] Local $iIndex = List_Index() Point_Delete($iIndex) _GUICtrlListView_ClickItem($List1, $iIndex) Points_Update($aPath_Points, $b_ClosePath, $b_ShowImage) Case $aCtl1[$eC1_redo] $aPath_Points = State_Restore($aPath_Points, False) List_Update() Points_Update($aPath_Points, $b_ClosePath, $b_ShowImage) Case $aCtl1[$eC1_undo] $aPath_Points = State_Restore($aPath_Points, True) List_Update() Points_Update($aPath_Points, $b_ClosePath, $b_ShowImage) Case $aCtl1[$eC1_update] List_Update(List_Index()) Points_Update($aPath_Points, $b_ClosePath, $b_ShowImage) Ascii_Points($aPath_Points) _GUICtrlEdit_SetSel($Edit_encoded, 0, -1) Case $aCtl1[$eC1_closepath] $b_ClosePath = Control_IsChecked($aCtl1[$eC1_closepath]) List_Update(List_Index()) Points_Update($aPath_Points, $b_ClosePath, $b_ShowImage) If $b_ClosePath Then GUICtrlSetState($aCtl2[$eC2_rev], $GUI_DISABLE) Else GUICtrlSetState($aCtl2[$eC2_rev], $GUI_ENABLE) EndIf Case $aCtl1[$eC1_showimg] If Not $b_ShowImage Then $sImagefile = FileOpenDialog("Select an image", SplitDir($sImagefile), "All Files(*.*)", 0, SplitFileName($sImagefile), $Form1) EndIf $b_ShowImage = Control_IsChecked($aCtl1[$eC1_showimg]) List_Update(List_Index()) Points_Update($aPath_Points, $b_ClosePath, $b_ShowImage) ;------------------------------------------------------------------- Case $aCtl2[$eC2_zin] If Control_IsChecked($aCtl2[$eC2_toall]) Then Points_Scale(1, 1) Else $iXScale += 1 $iYScale += 1 Points_Update($aPath_Points, $b_ClosePath, $b_ShowImage) EndIf _GUICtrlListView_ClickItem($List1, List_Index()) Case $aCtl2[$eC2_zout] If Control_IsChecked($aCtl2[$eC2_toall]) Then Points_Scale(-1, -1) Else $iXScale -= 1 $iYScale -= 1 Points_Update($aPath_Points, $b_ClosePath, $b_ShowImage) EndIf _GUICtrlListView_ClickItem($List1, List_Index()) Case $aCtl2[$eC2_rev] Local $iIndex = List_Index() $aPath_Points = Points_Reverse($aPath_Points) Points_Update($aPath_Points, $b_ClosePath, $b_ShowImage, $iIndex) ;, True) List_Update($iIndex) Case $aCtl2[$eC2_edit_rot] ;ConsoleWrite("Rotate" & @CRLF) Local $iIndex = List_Index() Local $iDegrees = GUICtrlRead($aCtl2[$eC2_edit_rot]) $aPath_Rot_Points = Points_Rotate($aPath_Points, $iDegrees) Points_Update($aPath_Rot_Points, $b_ClosePath, $b_ShowImage, $iIndex) ;, True) Case $aCtl2[$eC2_incx] Point_Adjust(1, 0, Control_IsChecked($aCtl2[$eC2_toall])) Case $aCtl2[$eC2_decx] Point_Adjust(-1, 0, Control_IsChecked($aCtl2[$eC2_toall])) Case $aCtl2[$eC2_incy] Point_Adjust(0, 1, Control_IsChecked($aCtl2[$eC2_toall])) Case $aCtl2[$eC2_decy] Point_Adjust(0, -1, Control_IsChecked($aCtl2[$eC2_toall])) EndSwitch WEnd ;---------------------------------------------------------------------------------------------------- Func _Exit() _GDIPlus_Shutdown() ConsoleWrite("GDI+ Stopped" & @CRLF) State_Destroy() EndFunc ;==>_Exit Func Ascii_Points($aPts) ;encodes points into an ascii string Local Const $iChrOffset = 33 Local Const $iMaxOffset = 126 - $iChrOffset If Not IsArray($aPts) Then Return Local $sAscEnc = StringFormat("%03i%05i", $iChrOffset, UBound($aPts) * 2 + 8) If _ArrayMin($aPts) >= 0 And (_ArrayMax($aPts) - _ArrayMin($aPts)) <= $iMaxOffset Then For $i = 0 To UBound($aPts) - 1 $sAscEnc = $sAscEnc & Chr($aPts[$i][0] + $iChrOffset) & Chr($aPts[$i][1] + $iChrOffset) Next EndIf _GUICtrlEdit_SetText($Edit_encoded, $sAscEnc) EndFunc ;==>Ascii_Points Func Btn_load_Clicked() ConsoleWrite("Load: " & SplitDir($sFileSave) & @CRLF) $sFileSave = FileOpenDialog("Select a save file", SplitDir($sFileSave), "All Files(*.*)", 0, SplitFileName($sFileSave), $Form1) _FileReadToArray($sFileSave, $aPath_Points, 0, ",") If @error Then Dim $aPath_Points[1][2] = [[0, 0]] Else State_Destroy() State_Save($aPath_Points) EndIf List_Update() Points_Update($aPath_Points, $b_ClosePath, $b_ShowImage) EndFunc ;==>Btn_load_Clicked Func Btn_save_Clicked() List_Update(List_Index()) $sFileSave = FileOpenDialog("Select a save file", SplitDir($sFileSave), "All Files(*.*)", 0, SplitFileName($sFileSave), $Form1) _FileWriteFromArray($sFileSave, $aPath_Points, 0, Default, ",") EndFunc ;==>Btn_save_Clicked Func Control_Create_Group1() Local $iX = 30 Local $iY = 225 $aCtl1[$eC1_delete] = GUICtrlCreateButton("Delete", $iX + 0, $iY + 0, 50, 20) $aCtl1[$eC1_shift_dn] = GUICtrlCreateButton("+", $iX + 70, $iY + 0, 20, 20) $aCtl1[$eC1_shift_up] = GUICtrlCreateButton("-", $iX + 95, $iY + 0, 20, 20) $aCtl1[$eC1_del_all] = GUICtrlCreateButton("Delete All", $iX + 0, $iY + 25, 50, 20) $aCtl1[$eC1_update] = GUICtrlCreateButton("Update", $iX + 70, $iY + 25, 50, 20) $aCtl1[$eC1_undo] = GUICtrlCreateButton("Undo", $iX + 0, $iY + 50, 50, 20) $aCtl1[$eC1_redo] = GUICtrlCreateButton("Redo", $iX + 70, $iY + 50, 50, 20) GUICtrlSetState($aCtl1[$eC1_undo], $GUI_DISABLE) GUICtrlSetState($aCtl1[$eC1_redo], $GUI_DISABLE) $aCtl1[$eC1_closepath] = GUICtrlCreateCheckbox("Complete", $iX + 0, $iY + 70, 65, 25) $aCtl1[$eC1_showimg] = GUICtrlCreateCheckbox("Image", $iX + 0, $iY + 90, 65, 25) $aCtl1[$eC1_lock] = GUICtrlCreateCheckbox("Locked", $iX + 0, $iY + 110, 65, 25) EndFunc ;==>Control_Create_Group1 Func Control_Create_Group2() Local $iX = 30 Local $iY = 225 $aCtl2[$eC2_rev] = GUICtrlCreateButton("Reverse", $iX + 0, $iY + 0, 50, 20) $aCtl2[$eC2_edit_rot] = GUICtrlCreateInput("0", $iX + 0, $iY + 25, 40, 20) $aCtl2[$eC2_ud_rot] = GUICtrlCreateUpdown(-1) GUICtrlSetLimit($eC2_ud_rot, 360, -360) $aCtl2[$eC2_rot] = GUICtrlCreateButton("", $iX + 40, $iY + 25, 10, 20) $aCtl2[$eC2_dgroup] = GUICtrlCreateGroup("Coords", 5 + $iX + 70, $iY + 0, 55, 70) $aCtl2[$eC2_decy] = GUICtrlCreateButton("-", 24 + $iX + 70, 16 + $iY + 0, 17, 17) $aCtl2[$eC2_incy] = GUICtrlCreateButton("+", 24 + $iX + 70, 48 + $iY + 0, 17, 17) $aCtl2[$eC2_decx] = GUICtrlCreateButton("-", 8 + $iX + 70, 32 + $iY + 0, 17, 17) $aCtl2[$eC2_incx] = GUICtrlCreateButton("+", 40 + $iX + 70, 32 + $iY + 0, 17, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $aCtl2[$eC2_zout] = GUICtrlCreateButton("Zoom -", $iX + 0, $iY + 75, 50, 20) $aCtl2[$eC2_zin] = GUICtrlCreateButton("Zoom +", $iX + 75, $iY + 75, 50, 20) $aCtl2[$eC2_toall] = GUICtrlCreateCheckbox("Apply to all", $iX + 0, $iY + 100, 80, 25) EndFunc ;==>Control_Create_Group2 Func Control_IsChecked($IdCtrl) Return (BitAND(GUICtrlRead($IdCtrl), $GUI_CHECKED) = $GUI_CHECKED) EndFunc ;==>Control_IsChecked Func GDI_Draw_ArrayPoints(ByRef $aPts, $hImage, $b_ClosePath, $iX, $iY, $sFileName, $iSelected = -1) Local $hWnd = GUICtrlGetHandle($hImage) If UBound($aPts) > 1 Then Local $aPoints = GDI_Points($aPts, $iX, $iY) Else Local $aPoints[1][2] = [[0, 0]] EndIf Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd) ;create a graphics object from a window handle _GDIPlus_GraphicsClear($hGraphics, 0xFFFFFFFF) If FileExists($sFileName) Then Local $hBitmap = _GDIPlus_BitmapCreateFromFile($sFileName) Local Const $iWidth = ScaleX(_GDIPlus_ImageGetWidth($hBitmap)) Local Const $iHeight = ScaleY(_GDIPlus_ImageGetHeight($hBitmap)) Local $hBitmap_Scaled = _GDIPlus_ImageResize($hBitmap, $iWidth, $iHeight) ;resize image _GDIPlus_BitmapDispose($hBitmap) ;Done with initial bitmap _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Scaled, 0, 0) _GDIPlus_BitmapDispose($hBitmap_Scaled) EndIf Local $hPen = _GDIPlus_PenCreate(0xFFFF0000, ScaleX(1)) $hEndCap = _GDIPlus_ArrowCapCreate(1, 1) _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap) If $b_ClosePath Then _GDIPlus_GraphicsDrawPolygon($hGraphics, $aPoints, $hPen) Local $iX0, $iY0, $iX1, $iY1 For $i = 1 To $aPoints[0][0] If Not $b_ClosePath And $i < $aPoints[0][0] Then $iX0 = $aPoints[$i][0] $iY0 = $aPoints[$i][1] $iX1 = $aPoints[$i + 1][0] $iY1 = $aPoints[$i + 1][1] _GDIPlus_GraphicsDrawLine($hGraphics, $iX0, $iY0, $iX1, $iY1, $hPen) EndIf Next _GDIPlus_ArrowCapDispose($hEndCap) _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphics) Point_Selected($aPts, $hImage, $iSelected) EndFunc ;==>GDI_Draw_ArrayPoints Func GDI_Line_hPath_From_Points($aPts, $iXorig, $iYorig) ;Returns hpath object be sure to delete it when finished Local $hPath = _GDIPlus_PathCreate() ;Create new path object Local $aPoints = GDI_Points($aPts, $iXorig, $iYorig) Local $iX0, $iY0, $iX1, $iY1 If IsArray($aPoints) Then For $i = 1 To $aPoints[0][0] - 1 $iX0 = $aPoints[$i][0] $iY0 = $aPoints[$i][1] $iX1 = $aPoints[$i + 1][0] $iY1 = $aPoints[$i + 1][1] _GDIPlus_PathAddLine($hPath, $iX0, $iY0, $iX1, $iY1) Next EndIf Return $hPath ;_GDIPlus_PathDispose($hPath) EndFunc ;==>GDI_Line_hPath_From_Points Func GDI_Points($aPts, $iXo, $iYO) Local $aGDIPts If IsArray($aPts) And UBound($aPts) > 1 Then Local $aGDIPts[UBound($aPts) + 1][2] $aGDIPts[0][0] = UBound($aPts) For $i = 1 To $aGDIPts[0][0] ;Build points list $aGDIPts[$i][0] = ScaleX($aPts[$i - 1][0]) + $iXo $aGDIPts[$i][1] = ScaleY($aPts[$i - 1][1]) + $iYO Next Else Local $aGDIPts[1][2] = [[0, 0]] EndIf Return $aGDIPts EndFunc ;==>GDI_Points Func Image1_Clicked() If Not Control_IsChecked($aCtl1[$eC1_lock]) Then Local $aCPos = ControlGetPos(GUICtrlGetHandle($Image1), "", 0) Local $aPos = MouseGetPos() If IsArray($aPos) And IsArray($aCPos) Then Local $iXn = Int(($aPos[0] - $aCPos[0] + ScaleX(1) / 2) / ScaleX(1)) Local $iYn = Int(($aPos[1] - $aCPos[1] + ScaleY(1) / 2) / ScaleY(1)) Point_Add(List_Index(), $iXn, $iYn) EndIf Points_Update($aPath_Points, $b_ClosePath, $b_ShowImage) Else ToolTip("Locked") Sleep(500) ToolTip("") EndIf EndFunc ;==>Image1_Clicked Func List_Index() Static Local $hWndList1 = GUICtrlGetHandle($List1) Local $iIndex = _GUICtrlListView_GetSelectionMark($hWndList1) If _GUICtrlListView_GetItemSelected($List1, $iIndex) Then Return $iIndex Return -1 EndFunc ;==>List_Index Func List_Update($iIndex = -1) Static $hWnd_List1 = GUICtrlGetHandle($List1) _GUICtrlListView_BeginUpdate($List1) _GUICtrlListView_DeleteAllItems($hWnd_List1) For $i = 0 To UBound($aPath_Points) - 1 GUICtrlCreateListViewItem($i & "|" & $aPath_Points[$i][0] & "|" & $aPath_Points[$i][1], $List1) Next If $iIndex > -1 Then _GUICtrlListView_ClickItem($List1, $iIndex) _GUICtrlListView_EnsureVisible($List1, $iIndex) EndIf _GUICtrlListView_EndUpdate($List1) EndFunc ;==>List_Update Func Point_Add($iIndex, $iX, $iY) If $iIndex <> -1 Then _ArrayInsert($aPath_Points, $iIndex, $iX & "|" & $iY, 0) _GUICtrlListView_InsertItem($List1, $iIndex, $iIndex) _GUICtrlListView_SetItemText($List1, $iIndex, $iX, 1) _GUICtrlListView_SetItemText($List1, $iIndex, $iY, 2) _GUICtrlListView_EnsureVisible($List1, $iIndex) Else _ArrayAdd($aPath_Points, $iX & "|" & $iY, 0) GUICtrlCreateListViewItem(UBound($aPath_Points) - 1 & "|" & $iX & "|" & $iY, $List1) _GUICtrlListView_EnsureVisible($List1, UBound($aPath_Points) - 1) EndIf State_Save($aPath_Points) EndFunc ;==>Point_Add Func Point_Adjust($iX, $iY, $bToAll) If Not $bToAll Then Local $iIndex = List_Index() If $iIndex == -1 And IsArray($aPath_Points) Then $iIndex = UBound($aPath_Points) - 1 If $iIndex == -1 Then Return $aPath_Points[$iIndex][0] += $iX $aPath_Points[$iIndex][1] += $iY _GUICtrlListView_SetItemText($List1, $iIndex, $aPath_Points[$iIndex][0], 1) _GUICtrlListView_SetItemText($List1, $iIndex, $aPath_Points[$iIndex][1], 2) If $iIndex <> UBound($aPath_Points) - 1 Then _GUICtrlListView_ClickItem($List1, $iIndex) Else For $i = 0 To UBound($aPath_Points) - 1 $aPath_Points[$i][0] += $iX $aPath_Points[$i][1] += $iY Next List_Update(List_Index()) EndIf State_Save($aPath_Points) Points_Update($aPath_Points, $b_ClosePath, $b_ShowImage) EndFunc ;==>Point_Adjust Func Point_Delete($iIndex) If $iIndex <> -1 Then _ArrayDelete($aPath_Points, $iIndex) _GUICtrlListView_DeleteItem($List1, $iIndex) State_Save($aPath_Points) ;List_Update($iIndex) EndIf EndFunc ;==>Point_Delete Func Point_Modify($iIndex, $iX, $iY) If $iIndex <> -1 Then $aPath_Points[$iIndex][0] = $iX $aPath_Points[$iIndex][1] = $iY _GUICtrlListView_SetItemText($List1, $iIndex, $iX, 1) _GUICtrlListView_SetItemText($List1, $iIndex, $iY, 2) _GUICtrlListView_EnsureVisible($List1, $iIndex) State_Save($aPath_Points) EndIf EndFunc ;==>Point_Modify Func Point_Selected($aPts, $hImage, $iIndex) If $iIndex > -1 Then GUICtrlSetState($SelSquare, $GUI_HIDE) Local $hWnd = GUICtrlGetHandle($hImage) Local $aPos = ControlGetPos($hWnd, "", 0) If IsArray($aPos) And IsArray($aPts) Then _WinAPI_RedrawWindow($hWnd, Default, Default, $RDW_ERASENOW) Local $iXs = ScaleX($aPts[$iIndex][0]) + $aPos[0] - ScaleX(1) / 2 Local $iYs = ScaleY($aPts[$iIndex][1]) + $aPos[1] - ScaleY(1) / 2 WinMove(GUICtrlGetHandle($SelSquare), "", $iXs, $iYs, ScaleX(1), ScaleY(1)) GUICtrlSetState($SelSquare, $GUI_SHOW) ;ConsoleWrite("Point_Selected" & @CRLF) Else ConsoleWriteError("Error: Point_Selected" & @CRLF) EndIf EndIf EndFunc ;==>Point_Selected Func Point_Swap($iIndex1, $iNext) _GUICtrlListView_BeginUpdate($List1) Local $iIndex2 If $iIndex1 <> -1 Then $iIndex2 = $iIndex1 + $iNext If $iIndex2 > UBound($aPath_Points) - 1 Then $iIndex2 = 0 ElseIf $iIndex2 < 0 Then $iIndex2 = UBound($aPath_Points) - 1 EndIf _ArraySwap($aPath_Points, $iIndex1, $iIndex2) Local $iX1 = _GUICtrlListView_GetItemText($List1, $iIndex1, 2) Local $iY1 = _GUICtrlListView_GetItemText($List1, $iIndex1, 2) Local $iX2 = _GUICtrlListView_GetItemText($List1, $iIndex2, 2) Local $iY2 = _GUICtrlListView_GetItemText($List1, $iIndex2, 2) _GUICtrlListView_SetItemText($List1, $iIndex1, $iX2, 1) _GUICtrlListView_SetItemText($List1, $iIndex1, $iY2, 2) _GUICtrlListView_SetItemText($List1, $iIndex2, $iX1, 1) _GUICtrlListView_SetItemText($List1, $iIndex2, $iY1, 2) _GUICtrlListView_ClickItem($List1, $iIndex2) _GUICtrlListView_EnsureVisible($List1, $iIndex2) Else ;ConsoleWrite("Array Shift" & @CRLF) If $iNext > 0 Then ;ARRAY SHIFT -- Melba23 Local $iUBound = UBound($aPath_Points) ; Get size of array Local $aTmp = _ArrayExtract($aPath_Points, 0, $iUBound - 2) ; Extract all but last _ArrayInsert($aTmp, 0, _ArrayExtract($aPath_Points, $iUBound - 1, Default)) ; Insert last at top $aPath_Points = $aTmp Else Local $aTmp = _ArrayExtract($aPath_Points, 1, Default) ; Extract all but top row _ArrayAdd($aTmp, _ArrayExtract($aPath_Points, 0, 0)) ; Add top row at bottom $aPath_Points = $aTmp EndIf List_Update(List_Index()) Points_Update($aPath_Points, $b_ClosePath, $b_ShowImage) EndIf State_Save($aPath_Points) _GUICtrlListView_EndUpdate($List1) EndFunc ;==>Point_Swap Func Points_Reverse($aPts) Local $hPath = GDI_Line_hPath_From_Points($aPts, 0, 0) ;_GDIPlus_PathFlatten($hPath) _GDIPlus_PathReverse($hPath) $aPoints = _GDIPlus_PathGetPoints($hPath) _GDIPlus_PathDispose($hPath) If IsArray($aPoints) Then ;ConsoleWrite("Flipped_Points" & @CRLF) Dim $aPts_Rev[$aPoints[0][0]][2] For $i = 1 To $aPoints[0][0] $aPts_Rev[$i - 1][0] = Int($aPoints[$i][0] / ScaleX(1)) $aPts_Rev[$i - 1][1] = Int($aPoints[$i][1] / ScaleY(1)) Next Return $aPts_Rev Else Return $aPts EndIf EndFunc ;==>Points_Reverse Func Points_Rotate($aPts, $iDegrees) Local $hPath = GDI_Line_hPath_From_Points($aPts, 0, 0) ;_GDIPlus_PathFlatten($hPath) Local $hPen = _GDIPlus_PenCreate(0x0, ScaleX(1)) Local $aBounds = _GDIPlus_PathGetWorldBounds($hPath, 0, $hPen) _GDIPlus_PenDispose($hPen) If IsArray($aBounds) Then $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($hMatrix, $aBounds[0] + $aBounds[2] / 2, $aBounds[1] + $aBounds[3] / 2) _GDIPlus_MatrixRotate($hMatrix, $iDegrees) _GDIPlus_MatrixTranslate($hMatrix, -($aBounds[0] + $aBounds[2] / 2), -($aBounds[1] + $aBounds[3] / 2)) _GDIPlus_PathTransform($hPath, $hMatrix) _GDIPlus_MatrixDispose($hMatrix) EndIf Local $aPoints = _GDIPlus_PathGetPoints($hPath) _GDIPlus_PathDispose($hPath) If IsArray($aPoints) Then ;ConsoleWrite("Rotate_Points" & @CRLF) Dim $aPts_Rev[$aPoints[0][0]][2] For $i = 1 To $aPoints[0][0] $aPts_Rev[$i - 1][0] = Int($aPoints[$i][0] / ScaleX(1)) $aPts_Rev[$i - 1][1] = Int($aPoints[$i][1] / ScaleY(1)) Next Return $aPts_Rev Else Return $aPts EndIf EndFunc ;==>Points_Rotate Func Points_Scale($iScaleX, $iScaleY) For $i = 0 To UBound($aPath_Points) - 1 If $iScaleX > 0 Then $aPath_Points[$i][0] *= 2 Else $aPath_Points[$i][0] /= 2 EndIf If $iScaleY > 0 Then $aPath_Points[$i][1] *= 2 Else $aPath_Points[$i][1] /= 2 EndIf Next State_Save($aPath_Points) List_Update(List_Index()) Points_Update($aPath_Points, $b_ClosePath, $b_ShowImage) EndFunc ;==>Points_Scale Func Points_Update($aPts, $b_ClosePath = False, $b_Show_Image = True, $iSelected = -1) Local $_Image_File = $sImagefile If Not $b_Show_Image Then $_Image_File = "" GDI_Draw_ArrayPoints($aPts, $Image1, $b_ClosePath, 0, 0, $_Image_File, $iSelected) EndFunc ;==>Points_Update Func ScaleX($iX) Local $iXs = $iXScale If $iXs == 0 Then $iXs = -1 If $iXs > 0 Then $iX = $iX * $iXs Else $iX = $iX / Abs($iXs) EndIf Return $iX EndFunc ;==>ScaleX Func ScaleY($iY) Local $iYs = $iYScale If $iYs == 0 Then $iYs = -1 If $iYs > 0 Then $iY = $iY * $iYs Else $iY = $iY / Abs($iYs) EndIf Return $iY EndFunc ;==>ScaleY Func SelSquare_Drag() Local $iIndex = List_Index() If $iIndex <> -1 Then Local $cInfo = GUIGetCursorInfo($Form1) Local $aPosSelOrig = ControlGetPos($Form1, "", $SelSquare) If IsArray($aPosSelOrig) Then Local $iSubtractX = $cInfo[0] - $aPosSelOrig[0] Local $iSubtractY = $cInfo[1] - $aPosSelOrig[1] EndIf If IsArray($cInfo) Then Do $cInfo = GUIGetCursorInfo($Form1) ControlMove($Form1, "", $SelSquare, $cInfo[0] - $iSubtractX, $cInfo[1] - $iSubtractY) Until Not $cInfo[2] EndIf Local $aPosSelNew = ControlGetPos($Form1, "", $SelSquare) If IsArray($aPosSelNew) And IsArray($aPosSelOrig) Then Local $iXm = $aPath_Points[$iIndex][0] + Int(($aPosSelNew[0] - $aPosSelOrig[0]) / ScaleX(1)) Local $iYm = $aPath_Points[$iIndex][1] + Int(($aPosSelNew[1] - $aPosSelOrig[1]) / ScaleY(1)) Point_Modify($iIndex, $iXm, $iYm) Points_Update($aPath_Points, $b_ClosePath, $b_ShowImage, $iIndex) EndIf EndIf EndFunc ;==>SelSquare_Drag Func SplitDir($FullPath) Local $sDrive, $sDir, $sDummy _PathSplit($FullPath, $sDrive, $sDir, $sDummy, $sDummy) Return $sDrive & $sDir EndFunc ;==>SplitDir Func SplitFileName($FullPath) Local $sDummy, $sFileName, $sExt _PathSplit($FullPath, $sDummy, $sDummy, $sFileName, $sExt) Return $sFileName & "" & $sExt EndFunc ;==>SplitFileName Func State_Cleanup(ByRef $a1) If (UBound($a1) > $iUndo_Max + 2) Then Local $a1Rem = _ArrayExtract($a1, 1, Default) $a1Rem[0] = $a1[0] Local $sTmp = $a1[1] If $sTmp <> "" And FileExists($sTmp) Then FileDelete($sTmp) ;ConsoleWrite("Cleanup Delete (UnD) " & $sTmp & @CRLF) EndIf $a1 = $a1Rem EndIf EndFunc ;==>State_Cleanup Func State_Destroy($bRedo_Only = False) Local $sTmp While (UBound($a_sRedo_Files) > 1) $sTmp = _ArrayPop($a_sRedo_Files) If $sTmp <> "" And FileExists($sTmp) Then FileDelete($sTmp) ;ConsoleWrite(", Delete (ReD) " & $sTmp) If @error Then ConsoleWriteError("Failed to Delete " & $sTmp) EndIf WEnd GUICtrlSetState($aCtl1[$eC1_redo], $GUI_DISABLE) If $bRedo_Only Then Return While (UBound($a_sUndo_Files) > 1) $sTmp = _ArrayPop($a_sUndo_Files) If $sTmp <> "" And FileExists($sTmp) Then FileDelete($sTmp) ;ConsoleWrite(", Delete (UnD)" & $sTmp) If @error Then ConsoleWriteError("Failed to Delete " & $sTmp) EndIf WEnd GUICtrlSetState($aCtl1[$eC1_undo], $GUI_DISABLE) EndFunc ;==>State_Destroy Func State_Is_Diff(ByRef $a1, ByRef $a2) Local $bIsDiff = True If UBound($a1) = UBound($a2) Then $bIsDiff = False For $i = UBound($a1) - 1 To 0 Step -1 If $a1[$i][0] == $a2[$i][0] And $a1[$i][1] == $a2[$i][1] Then ContinueLoop Else ;ConsoleWrite("Diff " & $i & @CRLF) $bIsDiff = True ExitLoop EndIf Next Else ;ConsoleWrite("Diff " & @CRLF) EndIf Return $bIsDiff EndFunc ;==>State_Is_Diff Func State_Restore(ByRef $aPts, $bUndo) Local $sTmp = "" Local $aRes If $bUndo Then $sTmp = _ArrayPop($a_sUndo_Files) ;ConsoleWrite(", Restore (UnD)" & $sTmp) If $sTmp <> "" And FileExists($sTmp) Then _ArrayAdd($a_sRedo_Files, $sTmp) _FileReadToArray($sTmp, $aRes, 0, ",") If UBound($a_sUndo_Files) < 2 Then GUICtrlSetState($aCtl1[$eC1_undo], $GUI_DISABLE) If UBound($a_sRedo_Files) > 2 Then GUICtrlSetState($aCtl1[$eC1_redo], $GUI_ENABLE) If UBound($a_sUndo_Files) > 1 And Not State_Is_Diff($aPts, $aRes) Then Return State_Restore($aPts, $bUndo) If Not @error Then Return $aRes Else ConsoleWriteError("Failed to Restore " & $sTmp) EndIf Else $sTmp = _ArrayPop($a_sRedo_Files) ;ConsoleWrite(", Restore (ReD) " & $sTmp) If $sTmp <> "" And FileExists($sTmp) Then _ArrayAdd($a_sUndo_Files, $sTmp) _FileReadToArray($sTmp, $aRes, 0, ",") If UBound($a_sRedo_Files) < 2 Then GUICtrlSetState($aCtl1[$eC1_redo], $GUI_DISABLE) If UBound($a_sUndo_Files) > 2 Then GUICtrlSetState($aCtl1[$eC1_undo], $GUI_ENABLE) If UBound($a_sRedo_Files) > 1 And Not State_Is_Diff($aPts, $aRes) Then Return State_Restore($aPts, $bUndo) If Not @error Then Return $aRes Else ConsoleWriteError("Failed to Restore " & $sTmp) EndIf EndIf Return $aPts EndFunc ;==>State_Restore Func State_Save($aPts, $bClean = True) If $iUndo_Max < 1 Then Return Local $bFileDiff = True Local $sTmp = _TempFile(@TempDir, "DPP_") If UBound($a_sRedo_Files) > 2 Then _ArrayAdd($a_sUndo_Files, _ArrayPop($a_sRedo_Files)) _ArrayAdd($a_sUndo_Files, $sTmp) _FileWriteFromArray($sTmp, $aPath_Points, 0, Default, ",") If UBound($a_sRedo_Files) > 2 Then State_Destroy(True) State_Cleanup($a_sUndo_Files) ;ConsoleWrite("Save State " & UBound($a_sUndo_Files) & " " & $sTmp & @CRLF) If UBound($a_sUndo_Files) > 2 Then GUICtrlSetState($aCtl1[$eC1_undo], $GUI_ENABLE) If @error Then MsgBox(0, @ScriptName & " Error", "Unable to create undo file " & $sTmp) GUICtrlSetState($aCtl1[$eC1_undo], $GUI_DISABLE) GUICtrlSetState($aCtl1[$eC1_redo], $GUI_DISABLE) $iUndo_Max = 0 EndIf EndFunc ;==>State_Save Func Tab1_Select() Local $iStateCtl1, $iStateCtl2 Local $tabindex = GUICtrlRead($Tab1) ;ConsoleWrite("tab" & $tabindex + 1 & "_selected" & @CRLF) Select Case $tabindex = 0 $iStateCtl1 = $GUI_SHOW $iStateCtl2 = $GUI_HIDE Case $tabindex = 1 $iStateCtl1 = $GUI_HIDE $iStateCtl2 = $GUI_SHOW Case Else _GUICtrlTab_ActivateTab($Tab1, 0) Return EndSelect For $i = 0 To UBound($aCtl1) - 1 GUICtrlSetState($aCtl1[$i], $iStateCtl1) Next For $i = 0 To UBound($aCtl2) - 1 GUICtrlSetState($aCtl2[$i], $iStateCtl2) Next EndFunc ;==>Tab1_Select Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Static Local $hWndList1 = GUICtrlGetHandle($List1) If Not IsHWnd($hWndList1) Then $hWndList1 = GUICtrlGetHandle($List1) If @error Then Return $GUI_RUNDEFMSG If $wParam = $List1 Then Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $iCode = DllStructGetData($tNMHDR, "Code") Switch DllStructGetData($tNMHDR, "Code") Case $LVN_KEYDOWN, $NM_CLICK GUICtrlSendToDummy($List1_LVN, $lParam) EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY  


    • fenhanxue
      By fenhanxue
      i want to copy a picture file to clipboard, so that i can paste the picture through ctrl+V
      this is my code ,but it dosen't work :
      #AutoIt3Wrapper_UseX64 = n #Include <Clipboard.au3> #include <GDIPlus.au3> _GDIPlus_Startup() $hClipboard_Bitmap = _GDIPlus_BitmapCreateFromFile('C:\1.jpg') _ClipBoard_Open(0) _ClipBoard_SetDataEx($hClipboard_Bitmap,$CF_BITMAP) _ClipBoard_Close() _GDIPlus_Shutdown() can you help me
    • UEZ
      By UEZ
      I saw this code here: http://zoomquilt.org/ and here: http://arkadia.xyz and thought how this can be implemented in AutoIt. Here the results.
       
      The Zoomquilt:
      ;coded by UEZ build 2018-01-10, idea and images taken from http://zoomquilt.org/ ;thanks to spudw2k for the MouseZoom function #pragma compile(Icon, "c:\Program Files (x86)\AutoIt3\Icons\au3.ico") #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so /pe /rm #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_stripped.au3" #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global $hGUI, $iFPS = 0, $iShowFPS = 0, $bExit, $iW, $iH Global Const $sTitle = "GDI Image Zoom v2.1.2 coded by UEZ" AutoItSetOption("GUIOnEventMode", 1) Downloader() GDIPlus_ZoomImage() AutoItSetOption("GUIOnEventMode", 0) _GDIPlus_Shutdown() Func GDIPlus_ZoomImage($bMultimonitor = False) $bExit = False Local $i, $aImages[46], $hImage, $hObj ConsoleWrite("Loading images from local disk..." & @CRLF) Local $fTimer = TimerInit() For $i = 0 To UBound($aImages) - 1 $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Images\TheZoomquilt" & StringFormat("%02i.jpg", $i)) $aImages[$i] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _GDIPlus_ImageDispose($hImage) Next ConsoleWrite(UBound($aImages) & " images loaded in " & TimerDiff($fTimer) & " ms" & @CRLF) Local $tDim = DllStructCreate($tagBITMAP) DllCall("GDI32.dll", 'int', 'GetObject', 'int', $aImages[0], 'int', DllStructGetSize($tDim), 'ptr', DllStructGetPtr($tDim)) $iW = $tDim.bmWidth $iH = $tDim.bmHeight Local $hFullScreen = WinGetHandle("[TITLE:Program Manager;CLASS:Progman]"), $aFullScreen[4], $iW_Dt, $iH_Dt $aFullScreen = WinGetPos($hFullScreen) If $bMultimonitor Then $iW_Dt = $aFullScreen[2] $iH_Dt = $aFullScreen[3] Else $iW_Dt = @DesktopWidth $iH_Dt = @DesktopHeight $aFullScreen[0] = "" $aFullScreen[1] = "" EndIf $hGUI = GUICreate($sTitle, $iW_Dt, $iH_Dt, $aFullScreen[0], $aFullScreen[1], $WS_POPUP, $WS_EX_TOPMOST) GUISetState(@SW_SHOW, $hGUI) GUISetCursor(16, 1) ;create canvas elements Local Const $hDC = _WinAPI_GetDC($hGUI) Local Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iW_Dt, $iH_Dt) Local Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC) Local Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap) Local Const $hMemDC = _WinAPI_CreateCompatibleDC($hDC) _WinAPI_SetStretchBltMode($hDC_backbuffer, $STRETCH_DELETESCANS) Local Const $hCanvas = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer) _GDIPlus_GraphicsSetSmoothingMode($hCanvas, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetPixelOffsetMode($hCanvas, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) Local Const $hBrush_Clr = _GDIPlus_BrushCreateSolid(0xFF000000), _ $hBrush_FPS = _GDIPlus_BrushCreateSolid(0xFFFFFFFF), _ $hFormat_FPS = _GDIPlus_StringFormatCreate(), _ $hFamily_FPS = _GDIPlus_FontFamilyCreate("Arial"), _ $hFont_FPS = _GDIPlus_FontCreate($hFamily_FPS, 8), _ $tLayout_FPS = _GDIPlus_RectFCreate(0, 0, 130, 16) $iFPS = 0 GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit_About") AdlibRegister("CalcFPS", 1000) Local $a[3], $b = 1, $c, $x, $e, $y, $w, $h, $w2 = $iW_Dt / 2, $h2 = $iH_Dt / 2, $q, $r If $iW_Dt > 1.5 * $iH_Dt Then $q = $iW_Dt $r = 0.75 * $iW_Dt Else $q = 1.5 * $iH_Dt $r = 0.75 * $iH_Dt EndIf Do For $e = 0 To 2 $a[$e] = $aImages[Mod(Floor($b) + $e, UBound($aImages))] Next $c = 2^(Mod($b, 1)) For $e = 0 To 2 $x = $w2 - $q / 2 * $c $y = $h2 - $r / 2 * $c $w = $q * $c $h = $r * $c $hObj = _WinAPI_SelectObject($hMemDC, $a[$e]) _WinAPI_StretchBlt($hDC_backbuffer, $x, $y, $w, $h, $hMemDC, 0, 0, $iW, $iH, $SRCCOPY) $c *= 0.5 Next $b += MouseZoom() IF $b < 0 Then $b = UBound($aImages) - $b _GDIPlus_GraphicsDrawStringEx($hCanvas, "FPS: " & $iShowFPS & " @ " & $iW_Dt & "x" & $iH_Dt & " px", $hFont_FPS, $tLayout_FPS, $hFormat_FPS, $hBrush_FPS) _WinAPI_BitBlt($hDC, 0, 0, $iW_Dt, $iH_Dt, $hDC_backbuffer, 0, 0, $SRCCOPY) $iFPS += 1 If $bExit Then ExitLoop Until Not Sleep(0) AdlibUnRegister("CalcFPS") ;release resources _GDIPlus_FontDispose($hFont_FPS) _GDIPlus_FontFamilyDispose($hFamily_FPS) _GDIPlus_StringFormatDispose($hFormat_FPS) _GDIPlus_BrushDispose($hBrush_Clr) _GDIPlus_BrushDispose($hBrush_FPS) _GDIPlus_GraphicsDispose($hCanvas) _WinAPI_SelectObject($hMemDC, $hObj) _WinAPI_DeleteDC($hMemDC) _WinAPI_SelectObject($hDC_backbuffer, $DC_obj) _WinAPI_DeleteDC($hDC_backbuffer) _WinAPI_DeleteObject($hHBitmap) _WinAPI_ReleaseDC($hGUI, $hDC) For $i = 0 To UBound($aImages) - 1 _WinAPI_DeleteObject($aImages[$i]) Next GUIDelete($hGUI) EndFunc ;==>GDIPlus_ZoomImage Func MouseZoom() ;https://www.arduino.cc/reference/en/language/functions/math/map/ Local $iInput = MouseGetPos(1), $iInMin = 0, $iInMax = @DesktopHeight, $iOutMin = 1, $iOutMax = -1, $iStep = 0.025 Return (($iInput - $iInMin) * ($iOutMax - $iOutMin) / ($iInMax - $iInMin) + $iOutMin) * $iStep EndFunc ;MouseZoom() Func _Exit_About() $bExit = True EndFunc ;==>_Exit_About Func CalcFPS() ;display FPS $iShowFPS = $iFPS $iFPS = 0 EndFunc ;==>CalcFPS Func Downloader() Local $i, $A = StringSplit("FUjD9hf gbHhxTR 8YyzJdR xP3aNkR 2Qi4fQr E6pW5Ky zmtWIBF Af7LtYp TuXy30d 3nKGLr2 hNoWscB mSBvv3K f4wJ70e mIt9XmM M4TkAyh P4L4qhd hNM6bTv VoT8JXM jqcGH0B DYVoN8n bOPQkOI NeaTfJ1 18ppMNr FZ3d8Jv HsoX2RP mjv4kzI 6rpJbef pySKauq WjNQYRV Ffooo8y Xei5XfD T5A415r LiV0VNB nGcwiO4 b1Gdjjy GE828iy eSQ7SLe 1mPyGgL GNtwJIr KxBlU7E aKXhms5 9Quu2wu Y07quDf r0yC5Qa 273fCkD 2wMyCUw FUjD9hf", " ", 2) Local $sURL For $i = 0 To UBound($A) - 1 If Not FileExists(@ScriptDir & "\Images\TheZoomquilt" & StringFormat("%02i.jpg", $i)) Then If Not FileExists(@ScriptDir & "\Images") Then DirCreate(@ScriptDir & "\Images") $sURL = "http://imgur.com/" & $A[Mod(20 + $i, 46)] & ".jpg" ConsoleWrite("Downloading " & $sURL & ": " & InetGet($sURL, @ScriptDir & "\Images\TheZoomquilt" & StringFormat("%02i.jpg", $i), 8) & " bytes" & @CRLF) ToolTip("Downloading images...Please wait! -> " & $i + 1 & " / " & UBound($A), MouseGetPos(0), MouseGetPos(1)) EndIf Next ToolTip("") EndFunc ;==>Downloader  
       
      Arkadia:
      ;coded by UEZ build 2018-01-10, idea and images taken from http://arkadia.xyz ;thanks to spudw2k for the MouseZoom function #pragma compile(Icon, "c:\Program Files (x86)\AutoIt3\Icons\au3.ico") #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so /pe /rm #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_stripped.au3" #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global $hGUI, $iFPS = 0, $iShowFPS = 0, $bExit, $iW, $iH Global Const $sTitle = "GDI Image Zoom v2.2.1 coded by UEZ" AutoItSetOption("GUIOnEventMode", 1) Downloader() GDIPlus_ZoomImage() AutoItSetOption("GUIOnEventMode", 0) _GDIPlus_Shutdown() Func GDIPlus_ZoomImage($bMultimonitor = False) $bExit = False Local $i, $aImages[49], $hImage, $hObj ConsoleWrite("Loading images from local disk..." & @CRLF) Local $fTimer = TimerInit() For $i = 0 To UBound($aImages) - 1 $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Images\Arkadia" & $i & ".jpg") $aImages[$i] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _GDIPlus_ImageDispose($hImage) Next ConsoleWrite(UBound($aImages) & " images loaded in " & TimerDiff($fTimer) & " ms" & @CRLF) Local $tDim = DllStructCreate($tagBITMAP) DllCall("GDI32.dll", "int", "GetObject", "int", $aImages[0], "int", DllStructGetSize($tDim), "ptr", DllStructGetPtr($tDim)) $iW = $tDim.bmWidth $iH = $tDim.bmHeight Local $hFullScreen = WinGetHandle("[TITLE:Program Manager;CLASS:Progman]"), $aFullScreen[4], $iW_Dt, $iH_Dt $aFullScreen = WinGetPos($hFullScreen) If $bMultimonitor Then $iW_Dt = $aFullScreen[2] $iH_Dt = $aFullScreen[3] Else $iW_Dt = @DesktopWidth $iH_Dt = @DesktopHeight $aFullScreen[0] = "" $aFullScreen[1] = "" EndIf $hGUI = GUICreate($sTitle, $iW_Dt, $iH_Dt, $aFullScreen[0], $aFullScreen[1], $WS_POPUP, $WS_EX_TOPMOST) GUISetState(@SW_SHOW, $hGUI) GUISetCursor(16, 1) ;create canvas elements Local Const $hDC = _WinAPI_GetDC($hGUI) Local Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iW_Dt, $iH_Dt) Local Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC) Local Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap) Local Const $hMemDC = _WinAPI_CreateCompatibleDC($hDC) _WinAPI_SetStretchBltMode($hDC_backbuffer, $STRETCH_DELETESCANS) Local Const $hCanvas = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer) _GDIPlus_GraphicsSetSmoothingMode($hCanvas, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetPixelOffsetMode($hCanvas, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) Local Const $hBrush_Clr = _GDIPlus_BrushCreateSolid(0xFF000000), _ $hBrush_FPS = _GDIPlus_BrushCreateSolid(0xFFFFFFFF), _ $hFormat_FPS = _GDIPlus_StringFormatCreate(), _ $hFamily_FPS = _GDIPlus_FontFamilyCreate("Arial"), _ $hFont_FPS = _GDIPlus_FontCreate($hFamily_FPS, 8), _ $tLayout_FPS = _GDIPlus_RectFCreate(0, 0, 130, 16) $iFPS = 0 GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit_About") AdlibRegister("CalcFPS", 1000) Local $a[3], $b = 1, $c, $x, $e, $y, $w, $h, $w2 = $iW_Dt / 2, $h2 = $iH_Dt / 2, $q, $r If $iW_Dt > 1.5 * $iH_Dt Then $q = $iW_Dt $r = 0.75 * $iW_Dt Else $q = 1.5 * $iH_Dt $r = 0.75 * $iH_Dt EndIf Do For $e = 0 To 2 $a[$e] = $aImages[Mod(Floor($b) + $e, UBound($aImages))] Next $c = 2^(Mod($b, 1)) For $e = 0 To 2 $x = $w2 - $q / 2 * $c $y = $h2 - $r / 2 * $c $w = $q * $c $h = $r * $c $hObj = _WinAPI_SelectObject($hMemDC, $a[$e]) _WinAPI_StretchBlt($hDC_backbuffer, $x, $y, $w, $h, $hMemDC, 0, 0, $iW, $iH, $SRCCOPY) $c *= 0.5 Next $b += MouseZoom() IF $b < 0 Then $b = UBound($aImages) - $b _GDIPlus_GraphicsDrawStringEx($hCanvas, "FPS: " & $iShowFPS & " @ " & $iW_Dt & "x" & $iH_Dt & " px", $hFont_FPS, $tLayout_FPS, $hFormat_FPS, $hBrush_FPS) _WinAPI_BitBlt($hDC, 0, 0, $iW_Dt, $iH_Dt, $hDC_backbuffer, 0, 0, $SRCCOPY) $iFPS += 1 If $bExit Then ExitLoop Until Not Sleep(0) AdlibUnRegister("CalcFPS") ;release resources _GDIPlus_FontDispose($hFont_FPS) _GDIPlus_FontFamilyDispose($hFamily_FPS) _GDIPlus_StringFormatDispose($hFormat_FPS) _GDIPlus_BrushDispose($hBrush_Clr) _GDIPlus_BrushDispose($hBrush_FPS) _GDIPlus_GraphicsDispose($hCanvas) _WinAPI_SelectObject($hMemDC, $hObj) _WinAPI_DeleteDC($hMemDC) _WinAPI_SelectObject($hDC_backbuffer, $DC_obj) _WinAPI_DeleteDC($hDC_backbuffer) _WinAPI_DeleteObject($hHBitmap) _WinAPI_ReleaseDC($hGUI, $hDC) For $i = 0 To UBound($aImages) - 1 _WinAPI_DeleteObject($aImages[$i]) Next GUIDelete($hGUI) EndFunc ;==>GDIPlus_ZoomImage Func MouseZoom() ;https://www.arduino.cc/reference/en/language/functions/math/map/ Local $iInput = MouseGetPos(1), $iInMin = 0, $iInMax = @DesktopHeight, $iOutMin = 1, $iOutMax = -1, $iStep = 0.025 Return (($iInput - $iInMin) * ($iOutMax - $iOutMin) / ($iInMax - $iInMin) + $iOutMin) * $iStep EndFunc ;MouseZoom() Func _Exit_About() $bExit = True EndFunc ;==>_Exit_About Func CalcFPS() ;display FPS $iShowFPS = $iFPS $iFPS = 0 EndFunc ;==>CalcFPS Func Downloader() Local $sURL, $i For $i = 0 To 48 If Not FileExists(@ScriptDir & "\Images\Arkadia" & $i & ".jpg") Then If Not FileExists(@ScriptDir & "\Images") Then DirCreate(@ScriptDir & "\Images") $sURL = "http://arkadia.xyz/images/arkadia" & $i & ".jpg" ConsoleWrite("Downloading " & $sURL & ": " & InetGet($sURL, @ScriptDir & "\Images\Arkadia" & $i & ".jpg", 8) & " bytes" & @CRLF) ToolTip("Downloading images...Please wait! -> " & $i + 1 & " / " & $i, MouseGetPos(0), MouseGetPos(1)) EndIf Next ToolTip("") EndFunc ;==>Downloader  
      The missing images will be download and saved to script dir in folder images. Due to internal integer format of the GDI functions the screen is little bit wobbling.
       
      Happy watching. 
    • Miliardsto
      By Miliardsto
      Hello I have problem with my object drawn in gdi
      Func drawTriangle($tabName,$gui_active = 0) _GDIPlus_Startup() ;initialize GDI+ Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($sGUI[$gui_active]) ;create a graphics object from a window handle _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing) Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFEFEFEF) ;color format AARRGGBB (hex) Local $aPoints[5][3] $aPoints[0][0] = 4 $aPoints[1][0] = 0.0 ; left $aPoints[1][1] = 0.0 ; top $aPoints[2][0] = 0.0 ; left $aPoints[2][1] = 30.0 ; top $aPoints[3][0] = 80.0 ; left $aPoints[3][1] = 30.0 ; top $aPoints[4][0] = 110.0 ; left $aPoints[4][1] = 0.0 ; top _GDIPlus_GraphicsFillPolygon($hGraphics, $aPoints, $hBrush) ;draw the triangle Local $fBrush = _GDIPlus_BrushCreateSolid(0xFFAAAAAA) ;color format AARRGGBB (hex) Local $sString = $tabName, $aInfo ; from the func param Local $hFormat, $hFamily, $hFont, $tLayout $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate("Segoe UI") $hFont = _GDIPlus_FontCreate($hFamily, 12, 2) $tLayout = _GDIPlus_RectFCreate(6, 2) $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat) _GDIPlus_GraphicsDrawStringEx($hGraphics, $sString, $hFont, $aInfo[0], $hFormat, $fBrush) ;_GDIPlus_GraphicsDrawString($hGraphics, $tabName, 6, 3, "Segoe UI", 12) ; write text ;cleanup GDI+ resources _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() EndFunc After this code execution I got new object rectangle
      Global $ma_border = GUICtrlCreateGraphic(100, 180, 40, 40) GUICtrlSetGraphic($ma_border, $GUI_GR_COLOR, 0x00000, $COLOR_BLUE) GUICtrlSetGraphic($ma_border, $GUI_GR_RECT, 0, 0, 40, 40) GUICtrlSetState(-1,$GUI_DISABLE) And what happens is first func = draw rectangle is pushed to parameters from GUICtrlCreateGraphic func. Left: 100, Top: 180.
      I can simplu reverse order of these func execution but There is too much things to change in my code.
      Can something be done to prevent this slipping?
    • Larnil
      By Larnil
      This script generates Barnsleys Fractal Fern using script only.
      ; version 2017-10-03 ; Barnsley Fractal Fern ; by larnil #include <GUIConstants.au3> Dim $x, $y, $xn, $yn, $n, $r, $dc $WinSize = 800 ; window size ;Create graphics windows AutoItSetOption("GUIOnEventMode", 1) $GUI = GUICreate("Barnsley Fractal Fern", $WinSize, $WinSize, -1, -1) $Graphic = GuiCtrlCreateGraphic(0, 0, $WinSize, $WinSize) GUICtrlSetBkColor(-1, 0x000000) GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x00ff00) GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_CLOSE,"Bye") ;Main $start = TimerInit() _Fern(800) ; hight of fern - can be larger than window MsgBox(0,"Time taken:",Round(TimerDiff($start)/1000,3) &" seconds") While 1 Sleep(100) WEnd Func Bye() Exit EndFunc Func _Fern($height) $f = $height/10.6 ; scale factor. Complete fern is within 0 <= y <= 9.9983 (with no scale) $offset_x = $height/2 - $height/40 ; Side adjustment. Fern is within −2.1820 < x < 2.6558 (with no scale) For $n = 1 To $height*200 ; Number of iterations $r = Random(0, 99, 1) Select Case $r < 85 ; 0-84 = 85% of the time $xn = 0.85 * $x + 0.04 * $y $yn = -0.04 * $x + 0.85 * $y + 1.6 Case $r > 84 AND $r < 92 ; 85-91 = 7% of the time $xn = 0.2 * $x - 0.26 * $y $yn = 0.23 * $x + 0.22 * $y + 1.6 Case $r > 91 AND $r < 99 ; 92-98 = 7% of the time $xn = -0.15 * $x + 0.28 * $y $yn = 0.26 * $x + 0.24 * $y + 0.44 Case Else ; 99-99 = 1% of the time $xn = 0 $yn = 0.16 * $y EndSelect $x = $xn $y = $yn GUICtrlSetGraphic($Graphic, $GUI_GR_PIXEL, $offset_x + $x * $f, $height - $y * $f) Next GUICtrlSetGraphic($Graphic, $GUI_GR_REFRESH) EndFunc ;==> Fern  
      Here is another example where I have used GDI (my very first attempt at using GDI by the way). This script can generate much larger Ferns and save them to file (png). I have used this script to generate a 20000 x 20000 pixel @ 600 dpi image. Looks really good printed out in full size.
      #include <GDIPlus.au3> #include <GUIConstantsEx.au3> ; Param Local Const $iPxColor = 0xFF00FF00 ; Pixel color for fractal Alpha/R/G/B Local Const $iBgColor = 0xFFFFFFFF ; Background color for image Alpha/R/G/B Local Const $iSize = 1000 ; Hight of fern in pixels - image will have this hight and width too Local Const $iIter = $iSize*400 ; Number of iterations - $iSize * 200 is a good starting point ; Call function ;$start = TimerInit() _Fern($iSize,$iIter) ;MsgBox(0,"Time taken:",Round(TimerDiff($start)/1000,3) &" seconds") ; Function for generating Barnsley Fractal Fern Func _Fern($Size,$Iter) _GDIPlus_Startup() ; initialize GDI+ Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($Size, $Size) ; create an empty bitmap Local $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) ; get the graphics context of the image _GDIPlus_GraphicsClear($hBmpCtxt, $iBgColor) ; Set the background color for empty bitmap ; Here the magic happens $x=0 ; init $y=0 ; init $f = $Size/10.6 ; scale factor. Complete fern is within 0 <= y <= 9.9983 (with no scale) $offset_x = $Size/2 - $Size/40 ; Side adjustment. Fern is within −2.1820 < x < 2.6558 (with no scale) For $n = 1 To $Iter ; Number of iterations $r = Random(0, 99, 1) Select Case $r < 85 ; 0-84 = 85% of the time $xn = 0.85 * $x + 0.04 * $y $yn = -0.04 * $x + 0.85 * $y + 1.6 Case $r > 84 AND $r < 92 ; 85-91 = 7% of the time $xn = 0.2 * $x - 0.26 * $y $yn = 0.23 * $x + 0.22 * $y + 1.6 Case $r > 91 AND $r < 99 ; 92-98 = 7% of the time $xn = -0.15 * $x + 0.28 * $y $yn = 0.26 * $x + 0.24 * $y + 0.44 Case Else ; 99-99 = 1% of the time $xn = 0 $yn = 0.16 * $y EndSelect $x = $xn $y = $yn _GDIPlus_BitmapSetPixel($hBitmap, $offset_x + $x * $f, $Size - $y * $f, $iPxColor) ; Change pixel color for calculated X,Y Next ; ==> End of magic $File = "\Fractal_Fern_"&StringRight(Hex($iPxColor),6)&"-"&StringRight(Hex($iBgColor),6)&"-"&$iSize&".png" _GDIPlus_ImageSaveToFile($hBitmap, @MyDocumentsDir & $File) ;save bitmap to disk ShellExecute(@MyDocumentsDir & $File); Show it to the world in your default image viewer ; Cleanup GDI+ resources _GDIPlus_GraphicsDispose($hBmpCtxt) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() EndFunc ;==> _Fern