#NoTrayIcon #Region #AutoIt3Wrapper_Icon=Icone_349.1.ico #AutoIt3Wrapper_Outfile=AnimatedGifAnalyzer.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_UPX_Parameters=--best --lzma #AutoIt3Wrapper_Res_Description=Get Internal Infos From Animated Gif #AutoIt3Wrapper_Res_Fileversion=1.0.7 #AutoIt3Wrapper_Res_LegalCopyright=wakillon 2017 #AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer% #AutoIt3Wrapper_Res_Field=Compile date|%longdate% %time #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so /pe /rm #AutoIt3Wrapper_Run_After=del "%scriptfile%_stripped.au3" #EndRegion #CS ------ Gif Docs ------------------------------ https://www.w3.org/Graphics/GIF/spec-gif89a.txt https://en.wikipedia.org/wiki/GIF https://tronche.com/computer-graphics/gif/ http://www.matthewflickinger.com/lab/whatsinagif/bits_and_bytes.asp http://wiki.gis.com/wiki/index.php/Graphics_Interchange_Format http://gifsearcher.com/htmlviewer.php?FileIdx=1&LangCode=2 http://www.onicos.com/staff/iz/formats/gif.html#ib http://www.fileformat.info/format/gif/egff.htm http://www.gsp.com/cgi-bin/man.cgi?section=4&topic=m-gif http://www.rexswain.com/gifparse.rex http://www.rexswain.com/gifbuild.rex http://commandlinefanatic.com/cgi-bin/showarticle.cgi?article=art011 #CE ------ Gif Docs ------------------------------ #Region ;************ Includes ************ #Include #Include #Include #EndRegion ;************ Includes ************ Opt( 'GUIOnEventMode', 1 ) Opt( 'MustDeclareVars', 1 ) #Region ------ Global Variables ------------------------------ Global $hGui, $aidEdit, $aColors, $iFrameCount, $aIdLabelColorTable, $idComboFrameIndex, $idLabelGifPath, $idButtonOpen, $idLabelColorTableTitle Global $aGlobalInfos, $aLocalInfos, $Bin, $sFile, $bSelect, $iFrameIndex, $bFlash = True, $iLabelBkColorIndex, $Count, $CountOld Global $iLabelTransparentColorIndex = -1, $bFrameSelectionChange, $bFileOpenDialog #EndRegion --- Global Variables ------------------------------ _Gui() #Region ------ Main Loop ------------------------------ While 1 If $bSelect Then $bSelect = False AdlibUnRegister( '_GuiGlobalBkColorFlash' ) ControlSetText( $hGui, '', $idLabelGifPath, 'Analyzing File...' ) ; Delete previous values For $i = 0 To UBound( $aidEdit ) -1 GUICtrlSetData( $aidEdit[ $i ], '' ) Next _GuiLabelColorTableDelete() $Bin = _GifOpen( $sFile ) If Not @error Then $aGlobalInfos = _GifGlobalInfosGet( $Bin ) If Not @error Then $aLocalInfos = _GifFrameInfosGet( $Bin ) If Not @error Then ControlSetText( $hGui, '', $idLabelGifPath, $sFile ) _GuiGlobalInfosDisplay() $iLabelBkColorIndex = _GuiColorTableFill() _GuiFramelInfosDisplay() AdlibRegister( '_GuiGlobalBkColorFlash', 1200 ) Else ConsoleWrite( '! @error _GifFrameInfosGet : ' & @error & @Crlf ) MsgBox ( 262144+16, 'Error', 'Can not get Frame Infos from this File !', 4, $hGui ) EndIf Else ConsoleWrite( '! @error _GifGlobalInfosGet : ' & @error & @Crlf ) MsgBox ( 262144+16, 'Error', 'Can not get Global Infos from this File !', 4, $hGui ) EndIf Else ConsoleWrite( '! @error _GifOpen : ' & @error & @Crlf ) ControlSetText( $hGui, '', $idLabelGifPath, '' ) $aGlobalInfos = 0 $aLocalInfos = 0 GUICtrlSetData( $idComboFrameIndex, '|1', '1' ) MsgBox ( 262144+16, 'Error', 'This File is Not an Animated Gif !', 4, $hGui ) EndIf $Bin = 0 Else If $bFrameSelectionChange Then $bFrameSelectionChange = False If $aGlobalInfos[2] = 0 Then AdlibUnRegister( '_GuiGlobalBkColorFlash' ) $iLabelBkColorIndex = _GuiColorTableFill() _GuiFramelInfosDisplay() If $aGlobalInfos[2] = 0 Then AdlibRegister( '_GuiGlobalBkColorFlash', 1200 ) EndIf If $bFileOpenDialog Then $bFileOpenDialog = False $sFile = FileOpenDialog( 'Select an Animated Gif', '', 'Images (*.gif)' ) If @error Then MsgBox( 262144+16, '', 'Selection Aborted', 4, $hGui ) $bSelect = False Else $bSelect = True EndIf EndIf EndIf Sleep( 50 ) WEnd #EndRegion --- Main Loop ------------------------------ Func _Base64Decode ( $input_string ) ; by trancexx Local $struct = DllStructCreate ( 'int' ) Local $a_Call = DllCall ( 'Crypt32.dll', 'int', 'CryptStringToBinary', 'str', $input_string, 'int', 0, 'int', 1, 'ptr', 0, 'ptr', DllStructGetPtr ( $struct, 1 ), 'ptr', 0, 'ptr', 0 ) If @error Or Not $a_Call[0] Then Return SetError ( 1, 0, '' ) Local $a = DllStructCreate ( 'byte[' & DllStructGetData ( $struct, 1 ) & ']' ) $a_Call = DllCall ( 'Crypt32.dll', 'int', 'CryptStringToBinary', 'str', $input_string, 'int', 0, 'int', 1, 'ptr', DllStructGetPtr ( $a ), 'ptr', DllStructGetPtr ( $struct, 1 ), 'ptr', 0, 'ptr', 0 ) If @error Or Not $a_Call[0] Then Return SetError ( 2, 0, '' ) Return DllStructGetData ( $a, 1 ) EndFunc ;==> _Base64Decode() Func _Exit() AdlibUnRegister( '_GuiGlobalBkColorFlash' ) GUIDelete( $hGui ) Exit EndFunc ;==> _Exit() Func _FileDrag() $sFile = @GUI_DragFile $bSelect = True EndFunc Func _FileRead( $sGifPath ) If Not FileExists( $sGifPath ) Then Return SetError( 1, 0, 0 ) ; src file do not exists Local $hFile, $Binary $hFile = FileOpen( $sGifPath, 16 ) ; Read Binary mode If $hFile = -1 Then Return SetError( 2, 0, 0 ) ; file can not be read $Binary = FileRead( $hFile ) FileClose( $hFile ) Return $Binary EndFunc ;==> _FileRead() Func _FileSelect() $bFileOpenDialog = True EndFunc ;==> _FileSelect() Func _GifCheck( $Binary ) ; Check Header If StringLeft( $Binary, 14 ) <> '0x474946383961' And StringLeft( $Binary, 14 ) <> '0x474946383761' Then Return SetError( 1, 0, 0 ) ; not a GIF89a or GIF87a Header ; Check Frames Count Local $Extended StringReplace ( $Binary, '0021F904', '0021F904' ) $Extended = @extended If $Extended > 1 Then Return $Extended StringReplace ( $Binary, '21F904', '21F904' ) If $Extended And @extended > 1 Then Return @extended Return SetError( 2, 0, 0 ) EndFunc ;==> _GifCheck() Func _GifFrameInfosGet( $Binary ) Local $aSplit = StringSplit( $Binary, '0021F904', 1+2 ) ; 0 based If UBound( $aSplit ) -1 < $aGlobalInfos[10] Then $aSplit = StringSplit( $Binary, '21F904', 1+2 ) ; 0 based Dim $aLocalInfos[UBound( $aSplit )][15] ; based 1 ; Part 1 from Graphic Control Extension ; [$i][0] = Disposal Method ; [$i][1] = User Input Flag ; [$i][2] = Transparent Color Flag ; [$i][3] = Delay Time ; [$i][4] = Transparent Color Index ; Part 2 from Image Descriptor ; [$i][5] = Image Left ; [$i][6] = Image Top ; [$i][7] = Image Width ; [$i][8] = Image Height ; [$i][9] = Local Color Table Flag ; [$i][10] = InterlaceFlag ; [$i][11] = Sort Flag ; [$i][12] = Local Color Table Size ; [$i][13] = Transparent Color ; Part 3 from Local Color Table ; [$i][14] = Local Color Table (string to split for display) Local $sPackedField, $BinaryBase2, $DM, $Dec, $Uif, $Tcf, $DT, $ImageDescriptorField, $TCI, $Ok, $StringInstr, $iImageLeft, $iImageTop, $iImageWidth, $iImageHeight, $aColor For $i = 1 To UBound( $aSplit ) -1 $sPackedField = StringMid( $aSplit[$i], 1, 2 ) $BinaryBase2 = HexToBinBase2( $sPackedField ) $DM = StringMid( $BinaryBase2, 4, 3 ) $Dec = Dec( BinBase2ToHex( '0' & $DM ) ) $aLocalInfos[$i][0] = $Dec +1 ; first method for value 0 $Uif = StringMid( $BinaryBase2, 7, 1 ) $aLocalInfos[$i][1] = $Uif $Tcf = StringMid( $BinaryBase2, 8, 1 ) $aLocalInfos[$i][2] = $Tcf $DT = StringMid( $aSplit[$i], 5, 2 ) & StringMid( $aSplit[$i], 3, 2 ) $DT = Dec( $DT ) $aLocalInfos[$i][3] = $DT $TCI = StringMid( $aSplit[$i], 7, 2 ) $TCI = Dec( $TCI ) $aLocalInfos[$i][4] = $TCI ; Image Descriptor $Ok = 0 ; Find Image Separator StringReplace( $aSplit[$i], '2C', '2C' ) For $j = 1 To @extended $StringInstr = StringInStr( $aSplit[$i], '2C', 0, $j ) $ImageDescriptorField = StringMid( $aSplit[$i], $StringInstr, 20 ) $iImageWidth = Dec( StringMid( StringMid( $ImageDescriptorField, 11, 4 ), 3, 2 ) & StringMid( StringMid( $ImageDescriptorField, 11, 4 ), 1, 2 ) ) $iImageHeight = Dec( StringMid( StringMid( $ImageDescriptorField, 15, 4 ), 3, 2 ) & StringMid( StringMid( $ImageDescriptorField, 15, 4 ), 1, 2 ) ) $iImageLeft = Dec( StringMid( StringMid( $ImageDescriptorField, 3, 4 ), 3, 2 ) & StringMid( StringMid( $ImageDescriptorField, 3, 4 ), 1, 2 ) ) $iImageTop = Dec( StringMid( StringMid( $ImageDescriptorField, 7, 4 ), 3, 2 ) & StringMid( StringMid( $ImageDescriptorField, 7, 4 ), 1, 2 ) ) ; bypass comments If $iImageWidth <= $aGlobalInfos[0] And _ $iImageHeight <= $aGlobalInfos[1] And _ $iImageLeft <= $aGlobalInfos[0] And _ $iImageTop <= $aGlobalInfos[1] Then $Ok = 1 ExitLoop EndIf Next If $Ok <> 1 Then $StringInstr = 11 ; if not found use default pos $ImageDescriptorField = StringMid( $aSplit[$i], $StringInstr, 20 ) ; 10 bytes long ; Image Left $iImageLeft = StringMid( $ImageDescriptorField, 3, 4 ) $iImageLeft = StringMid( $iImageLeft, 3, 2 ) & StringMid( $iImageLeft, 1, 2 ) $iImageLeft = Dec( $iImageLeft ) $aLocalInfos[$i][5] = $iImageLeft ; Image Top $iImageTop = StringMid( $ImageDescriptorField, 7, 4 ) $iImageTop = StringMid( $iImageTop, 3, 2 ) & StringMid( $iImageTop, 1, 2 ) $iImageTop = Dec( $iImageTop ) $aLocalInfos[$i][6] = $iImageTop ; Image Width $iImageWidth = StringMid( $ImageDescriptorField, 11, 4 ) $iImageWidth = StringMid( $iImageWidth, 3, 2 ) & StringMid( $iImageWidth, 1, 2 ) $iImageWidth = Dec( $iImageWidth ) $aLocalInfos[$i][7] = $iImageWidth ; Image Height $iImageHeight = StringMid( $ImageDescriptorField, 15, 4 ) $iImageHeight = StringMid( $iImageHeight, 3, 2 ) & StringMid( $iImageHeight, 1, 2 ) $iImageHeight = Dec( $iImageHeight ) $aLocalInfos[$i][8] = $iImageHeight ; Packed Field $sPackedField = StringMid( $ImageDescriptorField, 19, 2 ) $BinaryBase2 = HexToBinBase2( $sPackedField ) ; Local Color Table Flag $aLocalInfos[$i][9] = StringMid( $BinaryBase2, 1, 1 ) ; InterlaceFlag $aLocalInfos[$i][10] = StringMid( $BinaryBase2, 2, 1 ) ; Sort Flag $aLocalInfos[$i][11] = StringMid( $BinaryBase2, 3, 1 ) ; Local Color Table Size If $aLocalInfos[$i][9] <> 0 Then $aLocalInfos[$i][12] = 2^( BinBase2ToHex( '0' & StringMid( $BinaryBase2, 6, 3 ) ) +1 ) ; number of bits in the global color table, minus 1 Else $aLocalInfos[$i][12] = 0 EndIf ; Local Color Table If $aGlobalInfos[2] = 0 And $aLocalInfos[$i][9] <> 0 And $aLocalInfos[$i][12] > 0 Then $aLocalInfos[$i][14] = StringMid( $aSplit[$i], $StringInstr + 20, $aLocalInfos[$i][12]*6 ) EndIf ; Transparent Color If $aLocalInfos[$i][2] <> 0 Then ; if Transparent Color Flag If $aGlobalInfos[2] = 0 Then ; if local Table $aColor = StringRegExp( $aLocalInfos[$i][14], '.{6}', 3 ) If Not @error And $aLocalInfos[$i][4] < UBound( $aColor ) Then $aLocalInfos[$i][13] = '0x' & $aColor[$aLocalInfos[$i][4]] Else ; if global Table If $aLocalInfos[$i][4] < UBound( $aColors ) Then $aLocalInfos[$i][13] = '0x' & $aColors[$aLocalInfos[$i][4]] EndIf EndIf Next If $aGlobalInfos[2] = 0 Then For $i = UBound( $aLocalInfos ) -1 To 1 Step -1 ; correction for frames without global and local color table If $aLocalInfos[$i][9] <> 1 Then _ArrayDelete( $aLocalInfos, $i ) Next $aGlobalInfos[10] = UBound( $aLocalInfos ) -1 Else For $i = UBound( $aLocalInfos ) -1 To 1 Step -1 ; correction for frames with false position If $aLocalInfos[$i][5] > $aGlobalInfos[0] And $aLocalInfos[$i][6] > $aGlobalInfos[1] Then _ArrayDelete( $aLocalInfos, $i ) Next $aGlobalInfos[10] = UBound( $aLocalInfos ) -1 EndIf $aSplit = 0 Return $aLocalInfos EndFunc ;==> _GifFrameInfosGet() Func _GifGlobalInfosGet( $Binary ) Local $sPackedField, $aInfo[12] GUICtrlSetColor( $aidEdit[3], 0x000000 ) GUICtrlSetColor( $aidEdit[6], 0x000000 ) ; Logical Screen Descriptor ; [0] = Canvas Width ; [1] = Canvas Height ; [2] = Global Color Table Flag ; [3] = Color Resolution ; [4] = Sort Flag ; [5] = Global Color Table Size ; [6] = BackGround Color Index ; [7] = Pixel Aspect Ratio ; [8] = BackGround Color ; [9] = Loop Count ; [10] = Frames Count ; [11] = Gif Version Local $ScreenDesc = StringMid( $Binary, 15, 14 ) Local $CanvasWidth = StringMid( $ScreenDesc, 1, 4 ) ; This field is an unsigned 2-byte integer in little-endian $aInfo[0] = Dec( StringMid( $CanvasWidth, 3, 2 ) & StringMid( $CanvasWidth, 1, 2 ) ) Local $CanvasHeight = StringMid( $ScreenDesc, 5, 4 ) ; This field is an unsigned 2-byte integer in little-endian $aInfo[1] = Dec( StringMid( $CanvasHeight, 3, 2 ) & StringMid( $CanvasHeight, 1, 2 ) ) $sPackedField = StringMid( $ScreenDesc, 9, 2 ) Local $BinaryBase2 = HexToBinBase2( $sPackedField ) $aInfo[2] = StringMid( $BinaryBase2, 1, 1 ) $aInfo[3] = BinBase2ToHex( '0' & StringMid( $BinaryBase2, 2, 3 ) ) +1 ; number of color resolution bits, minus 1 $aInfo[4] = StringMid( $BinaryBase2, 5, 1 ) If $aInfo[2] <> 0 Then $aInfo[5] = 2^( BinBase2ToHex( '0' & StringMid( $BinaryBase2, 6, 3 ) ) +1 ) ; number of bits in the global color table, minus 1 If $aInfo[5] <> 2^$aInfo[3] Then GUICtrlSetColor( $aidEdit[3], 0xFF0000 ) Switch $aInfo[5] Case 256 ConsoleWrite( '! Color Resolution Should be : 8 bit/px' & @Crlf ) Case 128 ConsoleWrite( '! Color Resolution Should be : 7 bit/px' & @Crlf ) Case 64 ConsoleWrite( '! Color Resolution Should be : 6 bit/px' & @Crlf ) Case 32 ConsoleWrite( '! Color Resolution Should be : 5 bit/px' & @Crlf ) Case 16 ConsoleWrite( '! Color Resolution Should be : 4 bit/px' & @Crlf ) Case 8 ConsoleWrite( '! Color Resolution Should be : 3 bit/px' & @Crlf ) Case 4 ConsoleWrite( '! Color Resolution Should be : 2 bit/px' & @Crlf ) Case 2 ConsoleWrite( '! Color Resolution Should be : 1 bit/px' & @Crlf ) EndSwitch EndIf $aInfo[6] = Dec( StringMid( $ScreenDesc, 11, 2 ) ) If $aInfo[2] <> 0 And $aInfo[6] > $aInfo[5] Then GUICtrlSetColor( $aidEdit[6], 0xFF0000 ) ; Global Color Table Local $GCT = StringMid( $Binary, 15+14, $aInfo[5]*6 ) $aColors = StringRegExp( $GCT, '.{6}', 3 ) Local $q = $aInfo[6] If $aInfo[6] > $aInfo[5] Then $aInfo[8] = '' ; background color Else $aInfo[8] = '0x' & $aColors[$q] ; background color EndIf Else $aInfo[5] = 0 $aInfo[6] = '' $aInfo[8] = '' EndIf $aInfo[7] = Dec( StringMid( $ScreenDesc, 13, 2 ) ) ; ratio of the pixel's widths to their heights in the original image. Local $Netscape = StringInStr( $Binary, '4E45545343415045322E300301' ) ; NETSCAPE2.0 part of Application Extension If $Netscape <> 0 Then Local $LoopCount = StringMid( $Binary, $Netscape +26, 4 ) ; This field is an unsigned 2-byte integer in little-endian $aInfo[9] = Dec( StringMid( $LoopCount, 3, 2 ) & StringMid( $LoopCount, 1, 2 ) ) Else $aInfo[9] = 1 EndIf $aInfo[10] = $iFrameCount Switch StringLeft( $Binary, 14 ) Case '0x474946383961' $aInfo[11] = 'GIF89a' Case '0x474946383761' $aInfo[11] = 'GIF87a' EndSwitch $Binary = 0 Return $aInfo EndFunc ;==> _GifGlobalInfosGet() Func _GifOpen( $sGifPath ) Local $Binary = _FileRead( $sGifPath ) If @error Then Return SetError( - @error, 0, 0 ) $iFrameCount = _GifCheck( $Binary ) If @error Then Return SetError( 1, 0, 0 ) ; not an animated gif Return $Binary EndFunc ;==> _GifOpen() Func _Gui() Icone_3491Ico ( 'Icone_349.1.ico', @TempDir ) $hGui = GUICreate( 'Animated Gif Analyzer by wakillon', 880, 440, -1, -1, -1, $WS_EX_ACCEPTFILES ) GUISetIcon( @TempDir & '\Icone_349.1.ico' ) GUISetFont( 9, 700 ) GUISetOnEvent( $GUI_EVENT_CLOSE, '_Exit' ) GUISetOnEvent( $GUI_EVENT_DROPPED, '_FileDrag' ) GUICtrlCreateLabel( '', 10, 10, 910, 400 ) GUICtrlSetState( -1, $GUI_DROPACCEPTED ) GUICtrlSetState( -1, $GUI_DISABLE ) Dim $aidEdit[26] GUICtrlCreateLabel( 'Global Gif Infos', 20, 20, 150, 20 ) GUICtrlCreateLabel( 'Gif Version', 20, 50, 150, 20 ) $aidEdit[11] = GUICtrlCreateEdit( '', 175, 50, 80, 20, BitOR( 2048, 2 ) ) GUICtrlCreateLabel( 'Canvas Width', 20, 75, 150, 20 ) $aidEdit[0] = GUICtrlCreateEdit( '', 175, 75, 80, 20, BitOR( 2048, 2 ) ) GUICtrlCreateLabel( 'Canvas Height', 20, 100, 150, 20 ) $aidEdit[1] = GUICtrlCreateEdit( '', 175, 100, 80, 20, BitOR( 2048, 2 ) ) GUICtrlCreateLabel( 'Global Color Table Flag', 20, 125, 150, 20 ) $aidEdit[2] = GUICtrlCreateEdit( '', 175, 125, 80, 20, BitOR( 2048, 2 ) ) GUICtrlCreateLabel( 'Color Resolution', 20, 150, 150, 20 ) $aidEdit[3] = GUICtrlCreateEdit( '', 175, 150, 80, 20, BitOR( 2048, 2 ) ) GUICtrlCreateLabel( 'Sort Flag', 20, 175, 150, 20 ) $aidEdit[4] = GUICtrlCreateEdit( '', 175, 175, 80, 20, BitOR( 2048, 2 ) ) GUICtrlCreateLabel( 'Global Color Table Size', 20, 200, 150, 20 ) $aidEdit[5] = GUICtrlCreateEdit( '', 175, 200, 80, 20, BitOR( 2048, 2 ) ) GUICtrlCreateLabel( 'BackGround Color Index', 20, 225, 150, 20 ) $aidEdit[6] = GUICtrlCreateEdit( '', 175, 225, 80, 20, BitOR( 2048, 2 ) ) GUICtrlCreateLabel( 'PixelAspectRatio', 20, 250, 150, 20 ) $aidEdit[7] = GUICtrlCreateEdit( '', 175, 250, 80, 20, BitOR( 2048, 2 ) ) GUICtrlCreateLabel( 'BackGround Color', 20, 275, 150, 20 ) $aidEdit[8] = GUICtrlCreateEdit( '', 175, 275, 80, 20, BitOR( 2048, 2 ) ) GUICtrlCreateLabel( 'Loop Count', 20, 300, 150, 20 ) $aidEdit[9] = GUICtrlCreateEdit( '', 175, 300, 80, 20, BitOR( 2048, 2 ) ) GUICtrlCreateLabel( 'Frames Count', 20, 325, 150, 20 ) $aidEdit[10] = GUICtrlCreateEdit( '', 175, 325, 80, 20, BitOR( 2048, 2 ) ) $idLabelColorTableTitle = GUICtrlCreateLabel( 'Global Color Table (Palette)', 280, 20, 160, 20 ) GUICtrlCreateLabel( 'Local Frames Infos', 620, 20, 110, 20 ) $idComboFrameIndex = GUICtrlCreateCombo( '1', 775, 17, 80, 20 ) GUICtrlSetData( -1, '1', '1' ) GUICtrlSetOnEvent( -1, '_GuiComboFrameIndexSelect' ) ; Graphic Control Extension GUICtrlCreateLabel( 'Disposal Method', 620, 50, 150, 20 ) $aidEdit[12] = GUICtrlCreateEdit( '', 770+5, 50, 80, 20, BitOR( 2048, 2 ) ) GUICtrlCreateLabel( 'User Input Flag', 620, 75, 150, 20 ) $aidEdit[13] = GUICtrlCreateEdit( '', 770+5, 75, 80, 20, BitOR( 2048, 2 ) ) GUICtrlCreateLabel( 'Transparent Color Flag', 620, 100, 150, 20 ) $aidEdit[14] = GUICtrlCreateEdit( '', 770+5, 100, 80, 20, BitOR( 2048, 2 ) ) GUICtrlCreateLabel( 'Delay Time', 620, 125, 150, 20 ) $aidEdit[15] = GUICtrlCreateEdit( '', 770+5, 125, 80, 20, BitOR( 2048, 2 ) ) GUICtrlCreateLabel( 'Transparent Color Index', 620, 150, 150, 20 ) $aidEdit[16] = GUICtrlCreateEdit( '', 770+5, 150, 80, 20, BitOR( 2048, 2 ) ) ; image descriptor GUICtrlCreateLabel( 'Image Left', 620, 175, 150, 20 ) $aidEdit[17] = GUICtrlCreateEdit( '', 770+5, 175, 80, 20, BitOR( 2048, 2 ) ) GUICtrlCreateLabel( 'Image Top', 620, 200, 150, 20 ) $aidEdit[18] = GUICtrlCreateEdit( '', 770+5, 200, 80, 20, BitOR( 2048, 2 ) ) GUICtrlCreateLabel( 'Image Width', 620, 225, 150, 20 ) $aidEdit[19] = GUICtrlCreateEdit( '', 770+5, 225, 80, 20, BitOR( 2048, 2 ) ) GUICtrlCreateLabel( 'Image Height', 620, 250, 150, 20 ) $aidEdit[20] = GUICtrlCreateEdit( '', 770+5, 250, 80, 20, BitOR( 2048, 2 ) ) GUICtrlCreateLabel( 'Local Color Table Flag', 620, 275, 150, 20 ) $aidEdit[21] = GUICtrlCreateEdit( '', 770+5, 275, 80, 20, BitOR( 2048, 2 ) ) GUICtrlCreateLabel( 'Interlace Flag', 620, 300, 150, 20 ) $aidEdit[22] = GUICtrlCreateEdit( '', 770+5, 300, 80, 20, BitOR( 2048, 2 ) ) GUICtrlCreateLabel( 'Sort Flag', 620, 325, 150, 20 ) $aidEdit[23] = GUICtrlCreateEdit( '', 770+5, 325, 80, 20, BitOR( 2048, 2 ) ) GUICtrlCreateLabel( 'Local Color Table Size', 620, 350, 150, 20 ) $aidEdit[24] = GUICtrlCreateEdit( '', 770+5, 350, 80, 20, BitOR( 2048, 2 ) ) ; Palette Labels Local $x, $y, $iX = 270, $iY = 50, $iMargin = 1 Dim $aIdLabelColorTable[256] For $i = 0 To 255 For $j = 16 To 1 Step -1 If $i >= 16*$j Then If $y <> ( 20 + $iMargin )*$j Then $x = 0 $y = ( 20 + $iMargin )*$j EndIf ExitLoop EndIf Next $aIdLabelColorTable[$i] = GUICtrlCreateLabel( '', $iX + $x, $iY + $y, 20, 20, 0x01 ) GUICtrlSetFont( -1, 11, 900 ) $x += ( 20 + $iMargin ) Next $idButtonOpen = GUICtrlCreateButton( 'Select an Animated Gif', 20, 362, 235, 25 ) GUICtrlSetOnEvent( -1, '_FileSelect' ) GUICtrlCreateLabel( 'Transparent Color', 620, 375, 150, 20 ) $aidEdit[25] = GUICtrlCreateEdit( '', 770+5, 375, 80, 20, BitOR( 2048, 2 ) ) $idLabelGifPath = GUICtrlCreateLabel( 'Select or Drag an Animated Gif File...', 20, 416, 880, 20, 0x01 ) GUISetState() EndFunc ;==> _Gui() Func _GuiColorTableFill() $iFrameIndex = GUICtrlRead( $idComboFrameIndex ) -1 ; FrameIndex is based 0 ConsoleWrite( '$iFrameIndex : ' & $iFrameIndex & @Crlf ) $iLabelTransparentColorIndex = -1 If $aGlobalInfos[2] = 0 Then $aColors = StringRegExp( $aLocalInfos[$iFrameIndex +1][14], '.{6}', 3 ) ControlSetText( $hGui, '', $idLabelColorTableTitle, 'Local Color Table (Palette)' ) $Count = UBound( $aColors ) If $Count <> $CountOld Then _GuiLabelColorTableDelete() $CountOld = $Count EndIf Else ControlSetText( $hGui, '', $idLabelColorTableTitle, 'Global Color Table (Palette)' ) EndIf Local $u = UBound( $aColors ), $Ret, $j = -1 For $i = 0 To 255 ; 256 Color Labels GUICtrlSetData( $aIdLabelColorTable[$i], '' ) If $i <= $u -1 Then Switch $u Case 128 Switch $j Case 11, 27, 43, 59, 75, 91, 107, 123, 139, 155 $j += 4 EndSwitch Case 64 Switch $j Case 7, 23, 39, 55, 71, 87, 103 $j += 8 EndSwitch Case 32 Switch $j Case 5, 21, 37, 53, 69 $j += 10 EndSwitch Case 16 Switch $j Case 3, 19, 35, 51 $j += 12 EndSwitch Case 8 Switch $j Case 2, 18, 34 $j += 13 EndSwitch Case 4 If $j = 1 Or $j = 17 Then $j += 14 EndSwitch $j += 1 GUICtrlSetBkColor( $aIdLabelColorTable[$j], '0x' & $aColors[$i] ) If $i = $aGlobalInfos[6] Then $Ret = $j If $aLocalInfos[$iFrameIndex +1][2] = 1 And $i = $aLocalInfos[$iFrameIndex +1][4] Then $iLabelTransparentColorIndex = $j EndIf EndIf Next Return $Ret EndFunc ;==> _GuiColorTableFill() Func _GuiComboFrameIndexSelect() $bFrameSelectionChange = True EndFunc ;==> _GuiComboFrameIndexSelect() Func _GuiFramelInfosDisplay() If Not IsArray( $aLocalInfos ) Then Return $iFrameIndex = GUICtrlRead( $idComboFrameIndex ) -1 For $i = 12 To 25 ; $aidEdit[12] To $aidEdit[25] ; [$i][0] = Disposal Method ; [$i][1] = User Input Flag ; [$i][2] = Transparent Color Flag ; [$i][3] = Delay Time ; [$i][4] = Transparent Color Index ; [$i][5] = Image Left ; [$i][6] = Image Top ; [$i][7] = Image Width ; [$i][8] = Image Height ; [$i][9] = Local Color Table Flag ; [$i][10] = InterlaceFlag ; [$i][11] = Sort Flag ; [$i][12] = Local Color Table Size ; [$i][13] = Transparent Color ; [$i][14] = Local Color Table (string to split for display) Switch $i -12 Case 4 If $aLocalInfos[$iFrameIndex +1][$i -12] <> 0 And $aLocalInfos[$iFrameIndex +1][2] = 0 Then ; if Transparent Color Index = 1 and Transparent Color Flag = 0 GUICtrlSetColor( $aidEdit[$i], 0xFF0000 ) Else If $aGlobalInfos[2] = 1 Then ; if Global Color Table Flag and Transparent Color Index >= Global Color Table Size If $aLocalInfos[$iFrameIndex +1][$i -12] >= $aGlobalInfos[5] Then GUICtrlSetColor( $aidEdit[$i], 0xFF0000 ) Else GUICtrlSetColor( $aidEdit[$i], 0x000000 ) EndIf Else; if Transparent Color Index >= Local Color Table Size If $aLocalInfos[$iFrameIndex +1][$i -12] >= $aLocalInfos[$iFrameIndex +1][12] Then GUICtrlSetColor( $aidEdit[$i], 0xFF0000 ) Else GUICtrlSetColor( $aidEdit[$i], 0x000000 ) EndIf EndIf EndIf Case 9, 11, 12 ; if Global Color Table Flag = 1 and Local Color Table Flag = 1 If $aLocalInfos[$iFrameIndex +1][$i -12] <> 0 And $aGlobalInfos[2] = 1 Then GUICtrlSetColor( $aidEdit[$i], 0xFF0000 ) Else GUICtrlSetColor( $aidEdit[$i], 0x000000 ) EndIf Case 5, 7 If $aLocalInfos[$iFrameIndex +1][$i -12] > $aGlobalInfos[0] Then GUICtrlSetColor( $aidEdit[$i], 0xFF0000 ) Else GUICtrlSetColor( $aidEdit[$i], 0x000000 ) EndIf Case 6, 8 If $aLocalInfos[$iFrameIndex +1][$i -12] > $aGlobalInfos[1] Then GUICtrlSetColor( $aidEdit[$i], 0xFF0000 ) Else GUICtrlSetColor( $aidEdit[$i], 0x000000 ) EndIf EndSwitch GUICtrlSetData( $aidEdit[$i], $aLocalInfos[$iFrameIndex +1][$i -12] ) Next EndFunc ;==> _GuiFramelInfosDisplay() Func _GuiGlobalBkColorFlash() If $bSelect Then Return $iFrameIndex = GUICtrlRead( $idComboFrameIndex ) -1 If $aGlobalInfos[2] = 0 And $aLocalInfos[$iFrameIndex+1][2] = 0 Then Return If IsArray( $aGlobalInfos ) And IsArray( $aColors ) Then If $aGlobalInfos[6] > $aGlobalInfos[5] Then Return If $bFlash Then If $aGlobalInfos[2] = 1 Then GUICtrlSetData( $aIdLabelColorTable[$iLabelBkColorIndex], 'BK' ) ; Bk Color GUICtrlSetColor( $aIdLabelColorTable[$iLabelBkColorIndex], '0x00FF00' ) EndIf If $iLabelTransparentColorIndex <> -1 And $iLabelTransparentColorIndex <> $iLabelBkColorIndex Then GUICtrlSetData( $aIdLabelColorTable[$iLabelTransparentColorIndex], '' ) Else If $aGlobalInfos[2] = 1 And $iLabelTransparentColorIndex <> $iLabelBkColorIndex Then GUICtrlSetData( $aIdLabelColorTable[$iLabelBkColorIndex], '' ) If $iLabelTransparentColorIndex <> -1 Then GUICtrlSetData( $aIdLabelColorTable[$iLabelTransparentColorIndex], 'TR' ) ; Transparent Color GUICtrlSetColor( $aIdLabelColorTable[$iLabelTransparentColorIndex], '0x00FF00' ) EndIf EndIf $bFlash = Not $bFlash EndIf EndFunc ;==> _GuiGlobalBkColorFlash() Func _GuiGlobalInfosDisplay() If IsArray( $aGlobalInfos ) Then For $i = 0 To UBound( $aGlobalInfos ) -1 GUICtrlSetData( $aidEdit[$i], $aGlobalInfos[$i] ) Next Local $s For $i = 1 To $aGlobalInfos[10] $s &= '|' & $i Next GUICtrlSetData( $idComboFrameIndex, $s, '1' ) EndIf EndFunc ;==> _GuiGlobalInfosDisplay() Func _GuiLabelColorTableDelete() For $i = 0 To 255 GUICtrlSetData( $aIdLabelColorTable[$i], '' ) GUICtrlSetBkColor( $aIdLabelColorTable[$i], '0xF0F0F0' ) ; gui default bkcolor Next EndFunc ;==> _GuiLabelColorTableDelete() Func _LzntDecompress ( $bBinary ); by trancexx $bBinary = Binary ( $bBinary ) Local $tInput = DllStructCreate ( 'byte[' & BinaryLen ( $bBinary ) & ']' ) DllStructSetData ( $tInput, 1, $bBinary ) Local $tBuffer = DllStructCreate ( 'byte[' & 16*DllStructGetSize ( $tInput ) & ']' ) Local $a_Call = DllCall ( 'ntdll.dll', 'int', 'RtlDecompressBuffer', 'ushort', 2, 'ptr', DllStructGetPtr ( $tBuffer ), 'dword', DllStructGetSize ( $tBuffer ), 'ptr', DllStructGetPtr ( $tInput ), 'dword', DllStructGetSize ( $tInput ), 'dword*', 0 ) If @error Or $a_Call[0] Then Return SetError ( 1, 0, '' ) Local $tOutput = DllStructCreate ( 'byte[' & $a_Call[6] & ']', DllStructGetPtr ( $tBuffer ) ) Return SetError ( 0, 0, DllStructGetData ( $tOutput, 1 ) ) EndFunc ;==> _LzntDecompress() Func BinBase2ToHex( $sBinary ) Local $aBinary[16] = [ '0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111', '1000', '1001', '1010', '1011', '1100', '1101', '1110', '1111' ] Local $Hex = '', $aHex[16] = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' ] $sBinary = StringRegExp( $sBinary, '(.{1,4})', 3 ) For $i = 0 To UBound( $sBinary ) -1 Step 1 For $j = 0 To 15 Step 1 If $sBinary[$i] = $aBinary[$j] Then $Hex &= $aHex[$j] ExitLoop EndIf Next Next $aBinary = 0 $aHex = 0 Return StringFormat( '%02s', $Hex ) EndFunc ;==> BinBase2ToHex() Func HexToBinBase2( $Hex ) Local $sBinary = '', $aHex[16] = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' ] Local $aBinary[16] = [ '0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111', '1000', '1001', '1010', '1011', '1100', '1101', '1110', '1111' ] $Hex = StringRegExp( $Hex, '(.{1,1})', 3 ) For $i = 0 To UBound( $Hex ) -1 Step 1 For $j = 0 To 15 Step 1 If $Hex[$i] = $aHex[$j] Then $sBinary &= $aBinary[$j] ExitLoop EndIf Next Next $aBinary = 0 $aHex = 0 Return StringFormat( '%08i', $sBinary ) EndFunc ;==> HexToBinBase2() Func Icone_3491Ico ( $sFileName, $sOutputDirPath, $iOverWrite=0 ) ; Code Generated by BinaryToAu3Kompressor. Local $sFileBin = 'JbQAAAABAAIAICABAXAgAKgQAAAmMAAAABAAOAF4aARoAADOACwoAEwAiABuQAAMAVwBAIAAXDgADPUABiQABjA0AwE7AUM1APUBP2wAA5C0AYEdgSE1AJ7/vAGBQYGDtz/O/5sBqtbAAN7AAObAAO7AAHr2wAD/wADbH+V1wxjPVcAA0MAA0sAA08AA1KvEHcEA3MAA48AA6sAA+vHAAPjiH+V1wx/BHsEddcEb2MAA28Q8wQDBHun1xD70wAD54h/ncMEfwT31wR7axBzixFvBAME9wR6q8sRe+sofnMAAVNJVBAC5zgAIFsr/EAAt3P8YQ+3/Ib5axBDBH8E+4R7lHehkDrVhAPBgAPNkD2Ef/OoPDrRkEO8q4A0BA7v/AAIHvv8DC8H/AAUPxP8MIdL/gBM04f8aR/DrD//hPWEu4R5hD/8mfwDgD2EPI+EO4R4LHtBgH9v/gBY85/8bS/PrDyNtXOACSrVaegA9wQBL/zHNPP8l2gAt/xjmHv8M8jYP4CLrDwTgHmEPDCEi0+IuFDjkYi8cTgb2/w9gDEe3V/9FALlV/0O7Uv9BwL1Q/z+/TeIOYQAAMss+/yjVMv8AHuAl/xTqGf/4CvQM7g9hH+keYQ9hH/geUvnnD3Fs5A9hD+EOAeENOcVG/zXJQUdiHmEAYQ8g3ShiHxBA7hT/CPYK7g8GwBLH/w0l1uIe4Q7j4R5hDx9W/OcPcWzkDyPhHmEPN8dDYg4r0x404i1hAOEeYQ8S7BbxYi8G+AfuD+1dbQDiBP9xbOQPYR/hHu0dYQBhLuEe42EPYR8E+gX+D/JUcWwf5A/hPWEu4R5hDxbnGz/iDWEA4T3hDuEeYQ8C/OYC6g/1bb1rZwBiBWEO/vfkDrFF8T30Bz8uNC4fAA8XAPQH/zb3B75oAP/8wGW0ArFEPQD/B/8HHwDP+gf/NvcHsQfEX78YOQA/PzY4Nh8A/gf/NvcHwmIAAP/IWQD/zVAAAP/TRwD/2D6QAP/eNTMA4yzzA38/Njg2HwD+B/829wexD8sCU7MH2jsA/+EvkAD/6SMzAOwd8wM/PzY4Nh8A/gf/NvcHxlwwAP/PTXMPsQfqIJAA//QRMwD1DvMD/z82ODYfAP4HPwAzAPEHsRf/sQ/xFjEPcQfAATYAcQI/Nv84Nh8A/QcPAHSB/wf/B3MxPx8AHwAfAP8H+wexB9FK/3MfsSbxHjEX/gc/AD8APwAH/wf8Bz0n8BcA//f+C/sHPwD/rg8ADwAPADc2ybEH7hqzF/kI/wb/B///Bw8ADwD9BzU2cQ+xB7EP/PsF/wb/B/8HDwAPAP0HzzU2cQdxD7EH/QL/Bv8H//8HDwAPAP0HvwU/AD8A9gf//9YPAA8Af7k/AD8APwD/5v8PAA8ADwAPAA8ADwAPAA8ABw8ADwAPAADusMIASgD/wAAPCQYAJGsFBjoA/AcD/xEDBQAoVQAjEAADIAADAQIFAHgAQARL4xl/nAGfH876/4sB5oABgGuQH5MxgRlW2oQbgQHymR+5hgEhHlrECMUc3zLCDRAt3CPCANEPSrVaygAl2v4twCLLD8ENxQDCBMUsxA8YN8dDwg3BABLsFv/SD8okwTrEO8ocSQDECsktPL1rzzfdD8ktwQ/NUPAA/941wwDBBMos0A//yQDBD8ENAAPCAMMyVADQcufSD+eiYgfuGucH7Aj+Vj/tBv8Hf1n/Zh8AGRb4B61jAABhABgA4GEAH2cAAWEH' $sFileBin = Binary ( _Base64Decode ( $sFileBin ) ) $sFileBin = Binary ( _LzntDecompress ( $sFileBin ) ) If Not FileExists ( $sOutputDirPath ) Then DirCreate ( $sOutputDirPath ) If StringRight ( $sOutputDirPath, 1 ) <> '\' Then $sOutputDirPath &= '\' Local $sFilePath = $sOutputDirPath & $sFileName If FileExists ( $sFilePath ) Then If $iOverWrite = 1 Then If Not Filedelete ( $sFilePath ) Then Return SetError ( 2, 0, $sFileBin ) Else Return SetError ( 0, 0, $sFileBin ) EndIf EndIf Local $hFile = FileOpen ( $sFilePath, 16+2 ) If $hFile = -1 Then Return SetError ( 3, 0, $sFileBin ) FileWrite ( $hFile, $sFileBin ) FileClose ( $hFile ) Return SetError ( 0, 0, $sFileBin ) EndFunc ;==> Icone_3491Ico()