#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=c:\ProgramData\Scissors1.ico #AutoIt3Wrapper_Outfile=ImageSplitter.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Res_Description=Split an Image in equal parts. #AutoIt3Wrapper_Res_Fileversion=1.0.0.7 #AutoIt3Wrapper_Res_LegalCopyright=wakillon 2014 #AutoIt3Wrapper_res_requestedExecutionLevel=highestAvailable #AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer% #AutoIt3Wrapper_Res_Field=Compile date|%longdate% %time #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/so #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #Region ;************ Includes ************ #include #Include #Include #Include #EndRegion ;************ Includes ************ Opt ( 'GUIOnEventMode', 1 ) Opt ( 'MustDeclareVars', 1 ) If Not _Singleton ( @ScriptName, 1 ) Then Exit #Region ------ Global Variables ------------------------------ Global $hGui, $idPicCtrlPreview, $iPicCtrlExStyle = BitOR ( $WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE ) Global $iPicCtrlWidth = 450, $iPicCtrlHeight = 450, $iInputChange, $aCtrlPos Global $sCurrentFilePath, $sImageCtrl, $idInputRows, $idInputColumns, $idButtonSplit, $idComboFormat, $idLabel, $idComboDPI Global $idEditSplitNb, $idEditSplitWidth, $idEditSplitHeight, $idProgressBar, $idLabelInfos Global $sSoftTitle = 'ImageSplitter' & ' v' & _ScriptGetVersion () & ' by wakillon' Global $aPosBak, $iAdlib, $sCurrentPic, $aRecentFiles[1], $iRecentFilesMax = 10, $sCurrentDir Global $idCtrlMenu, $idItemCtrlOSD, $idAboutItem, $idMultiItem, $idCtrlItemExit, $idOpenFileMenu, $idRecentFileMenu, $aRecentFileItems[1] #EndRegion --- Global Variables ------------------------------ _FileInstall () _GDIPlus_Startup () _Gui () #Region ------ Main Loop ------------------------------ While 1 If $iInputChange Then If FileExists ( $sCurrentFilePath ) Then $sCurrentPic = _ImagePreviewDrawColumnsAndRows () _GUICtrlSetImageEx ( $idPicCtrlPreview, $sCurrentPic ) EndIf $iInputChange = 0 EndIf Sleep ( 50 ) WEnd #EndRegion --- Main Loop ------------------------------ Func _About () Local $sAboutText = @CRLF & 'Informations/Help' & @CRLF & @CRLF & $sSoftTitle & @CRLF & @CRLF _ & 'ImageSplitter split an image into pieces that can be used' & @CRLF _ & @TAB & 'for collage art' & @CRLF _ & @TAB & 'for website optimisation (speed up the preview of images)' & @CRLF _ & @TAB & 'for printing purposes (big poster)' & @CRLF _ & @TAB & 'for create a puzzle' & @CRLF & @CRLF _ & 'Load an image by menu or by drag&drop (jpg, gif,png and bmp are supported)' & @CRLF _ & 'Choose a format and select Columns and Rows numbers you want.' & @CRLF _ & 'Once Split Image processing is finished' & @CRLF _ & 'a folder with all splitted image parts will be opened.' & @CRLF _ & 'Parts of image are from left to right and from top to bottom.' & @CRLF & @CRLF _ & 'Thanks to AutoIt Community.' & @CRLF & @CRLF _ & 'wakillon.' MsgBox ( 262144+64, 'About', $sAboutText, 0, $hGui ) EndFunc ;==> _About () Func _AlreadyInArray ( $aSearch, $sItem, $iStart=0, $iPartial=0 ) Local $iIndex = _ArraySearch ( $aSearch, $sItem, $iStart, 0, 0, $iPartial ) If Not @error Then Return $iIndex EndFunc ;==> _AlreadyInArray () 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 () _GDIPlus_Shutdown () DirRemove ( @TempDir & '\IStmp', 1 ) Exit EndFunc ;==> _Exit () Func _FileCompactName ( $sName, $iChrMax ) If StringLen ( $sName ) <= $iChrMax Then Return $sName Local $i, $stName Do $stName = StringLeft ( $sName, Int ( $iChrMax/2 -1 -$i ) ) & '...' & StringRight ( $sName, Int ( $iChrMax/2 -1 ) ) $sName = $stName $i = 1 Until StringLen ( $stName ) <= $iChrMax Return $stName EndFunc ;==> _FileCompactName () Func _FileGetFullNameByFullPath ( $sFullPath ) Local $aFileName = StringSplit ( $sFullPath, '\' ) If Not @error Then Return $aFileName[$aFileName[0]] EndFunc ;==> _FileGetFullNameByFullPath () Func _FileGetNameWithoutExtByFullPath ( $sFullPath ) Local $aPathSplit = StringSplit ( $sFullPath, '\' ) If Not @error Then Return StringLeft ( $aPathSplit[UBound($aPathSplit)-1], _ StringInStr ( $aPathSplit[UBound($aPathSplit)-1], '.', 0, -1 ) - 1 ) EndFunc ;==> _FileGetNameWithoutExtByFullPath () Func _FileGetParentFolderPathByFullPath ( $sFullPath ) Local $sFilePath = StringLeft ( $sFullPath, StringInStr ( $sFullPath, '\', 0, -1 ) - 1 ) If Not @error Then Return $sFilePath EndFunc ;==> _FileGetParentFolderPathByFullPath () Func _FileInstall () If Not FileExists ( 'c:\ProgramData' ) Then DirCreate ( 'c:\ProgramData' ) If Not FileExists ( @TempDir & '\SplittedImages' ) Then DirCreate ( @TempDir & '\SplittedImages' ) If Not FileExists ( 'c:\ProgramData\Scissors1.ico' ) Then Scissors1Ico ( 'Scissors1.ico', 'c:\ProgramData' ) If Not FileExists ( 'c:\ProgramData\button1.jpeg' ) Then Button1Jpeg ( 'button1.jpeg', 'c:\ProgramData' ) EndFunc ;==> _FileInstall () Func _FileOpenDialog ( $sText, $sDir, $sFiletype, $hWnd ) Local $sFileOpenDialog = FileOpenDialog ( $sText, $sDir, $sFiletype, 1+4, '', $hWnd ) If @error <> 0 Then Return Local $aFilePath = StringSplit ( $sFileOpenDialog, '|', 1 ) Local $iUbound = UBound ( $aFilePath ) -1 $sDir = $aFilePath[1] If StringRight ( $sDir, 1 ) = '\' Then $sDir = StringTrimRight ( $sDir, 1 ) For $i = 2 To $iUbound $aFilePath[$i-1] = $sDir & '\' & $aFilePath[$i] Next If $iUbound > 1 Then _ArrayDelete ( $aFilePath, $aFilePath[0] ) $aFilePath[0] = $iUbound -1 EndIf Return $aFilePath EndFunc ;==> _FileOpenDialog () Func _GdipSetInterpolationMode ( $hGraphics, $iInterpolationMode ) ; for compatibility with AutoIt 3.3.8.1 Local $aResult = DllCall ( $ghGDIPDll, 'int', 'GdipSetInterpolationMode', 'handle', $hGraphics, 'int', $iInterpolationMode ) If @error Then Return SetError ( @error, @extended, False ) If $aResult[0] Then Return SetError ( 10, $aResult[0], False ) Return True EndFunc ;==> _GdipSetInterpolationMode () Func _Gui () $hGui = GUICreate ( $sSoftTitle, 680, 510, -1, -1, -1, $WS_EX_ACCEPTFILES + $WS_EX_TOPMOST ) GUISetIcon ( 'c:\ProgramData\Scissors1.ico' ) GUISetOnEvent ( $GUI_EVENT_CLOSE, '_GuiEvents', $hGui ) GUISetOnEvent ( $GUI_EVENT_DROPPED, '_GuiEvents', $hGui ) GUISetOnEvent ( $GUI_EVENT_RESTORE, '_GuiEvents', $hGui ) $idCtrlMenu = GUICtrlCreateMenu ( '&Open' ) $idOpenFileMenu = GUICtrlCreateMenuItem ( 'Open', $idCtrlMenu ) GUICtrlSetState ( -1, $GUI_DEFBUTTON ) GUICtrlSetOnEvent ( -1, '_GuiEvents' ) GUICtrlCreateMenuItem ( '', $idCtrlMenu, 1 ) $idRecentFileMenu = GUICtrlCreateMenu ( 'Recent Files', $idCtrlMenu, 1 ) GUICtrlCreateMenuItem ( '', $idCtrlMenu, 1 ) $idItemCtrlOSD = GUICtrlCreateMenuItem ( 'Open Splitted Images Directory', $idCtrlMenu ) GUICtrlSetOnEvent ( -1, '_OpenOutputDir' ) GUICtrlCreateMenuItem ( '', $idCtrlMenu, 6 ) $idMultiItem = GUICtrlCreateMenuItem ( 'Multi Files Split', $idCtrlMenu ) GUICtrlSetOnEvent ( -1, '_GuiEvents' ) GUICtrlCreateMenuItem ( '', $idCtrlMenu, 7 ) $idAboutItem = GUICtrlCreateMenuItem ( 'About', $idCtrlMenu ) GUICtrlSetOnEvent ( -1, '_GuiEvents' ) GUICtrlCreateMenuItem ( '', $idCtrlMenu, 9 ) $idCtrlItemExit = GUICtrlCreateMenuItem ( 'Exit', $idCtrlMenu ) GUICtrlSetOnEvent ( -1, '_Exit' ) $idLabel = GUICtrlCreateLabel ( "Drag'n Drop an image here", 30, 200, 390, 20, 0x01 ) GUICtrlSetFont ( -1, 14 ) GUICtrlSetState ( -1, $GUI_DISABLE ) GUISetFont ( 9, 600, 0, 'arial', $hGui, 5 ) $idLabelInfos = GUICtrlCreateLabel ( '', 20+5, 5, $iPicCtrlWidth-10, 15, 0x01 ) GUICtrlSetColor ( -1, 0xFF0000 ) $idPicCtrlPreview = GUICtrlCreatePic ( '', 20, 20, $iPicCtrlWidth, $iPicCtrlHeight, -1, $iPicCtrlExStyle ) GUICtrlSetState ( -1, $GUI_DROPACCEPTED ) Local $x = $iPicCtrlWidth -300, $y = 200 GUICtrlCreateGroup ( ' Parts Infos ', $x+340, 20, 170, 160 ) GUICtrlCreateLabel ( 'Number', $x+360, 60, 60, 20 ) $idEditSplitNb = GUICtrlCreateEdit ( '16', $x+440, 58, 50, 20, BitOR ( 2048, 2, 16384 ) ) ; $ES_READONLY, $ES_RIGHT, $ES_NUMBER $ES_SUNKEN GUICtrlCreateLabel ( 'Width', $x+360, 100, 60, 20 ) $idEditSplitWidth = GUICtrlCreateEdit ( '', $x+440, 98, 50, 20, BitOR ( 2048, 2, 16384 ) ) ; $ES_READONLY, $ES_RIGHT, $ES_NUMBER $ES_SUNKEN GUICtrlSetColor ( -1, 0xFF0000 ) GUICtrlCreateLabel ( 'Height', $x+360, 140, 65, 20 ) $idEditSplitHeight = GUICtrlCreateEdit ( '', $x+440, 138, 50, 20, BitOR ( 2048, 2, 16384 ) ) ; $ES_READONLY, $ES_RIGHT, $ES_NUMBER $ES_SUNKEN GUICtrlSetColor ( -1, 0xFF0000 ) $y = 190 GUICtrlCreateGroup ( ' Settings ', $x+340, $y+10, 170, 200 ) GUICtrlCreateLabel ( 'Columns', $x+360, $y+50, 60, 20 ) $idInputColumns = GUICtrlCreateInput ( '4', $x+430, $y+48, 60, 20, BitOR ( 2, 8192 ) ) ; $ES_RIGHT, $ES_NUMBER GUICtrlSetColor ( -1, 0xFF0000 ) GUICtrlCreateUpdown ( -1 ) GUICtrlSetLimit ( -1, 100, 1 ) GUICtrlCreateLabel ( 'Rows', $x+360, $y+90, 60, 20 ) $idInputRows = GUICtrlCreateInput ( '4', $x+430, $y+88, 60, 20, BitOR ( 2, 8192 ) ) ; $ES_RIGHT, $ES_NUMBER GUICtrlSetColor ( -1, 0xFF0000 ) GUICtrlCreateUpdown ( -1 ) GUICtrlSetLimit ( -1, 100, 1 ) GUICtrlCreateLabel ( 'Format', $x+360, $y+132, 50, 20 ) $idComboFormat = GUICtrlCreateCombo ( 'JPG', $x+430, $y+128, 60, 20, 0x3 ) ; $CBS_DROPDOWNLIST GUICtrlSetData ( -1, 'PNG|GIF|BMP', 'JPG' ) GUICtrlCreateLabel ( 'DPI', $x+360, $y+172, 50, 20 ) $idComboDPI = GUICtrlCreateCombo ( 'Same', $x+430, $y+168, 60, 20, 0x3 ) ; $CBS_DROPDOWNLIST GUICtrlSetData ( -1, '72|96|120|150|200|300', 'Same' ) $idButtonSplit = GUICtrlCreatePic ( 'C:\ProgramData\button1.jpeg', $x+350, $y+235, 150, 30 ) GUICtrlSetOnEvent ( -1, '_GuiEvents' ) $idProgressBar = GUICtrlCreateProgress ( 22, 425, 396, 10 ) GUICtrlSetState ( -1, $GUI_HIDE ) GUISetState () GUIRegisterMsg ( $WM_COMMAND, '_WM_COMMAND' ) EndFunc ;==> _Gui () Func _GuiCtrlPicButton_RestorePos () If IsArray ( $aPosBak ) Then GUICtrlSetPos ( $aPosBak[4], $aPosBak[0], $aPosBak[1], $aPosBak[2], $aPosBak[3] ) $aPosBak = 0 EndIf $iAdlib = 0 AdlibUnRegister ( '_GuiCtrlPicButton_RestorePos' ) EndFunc ;==> _GuiCtrlPicButton_RestorePos () Func _GuiCtrlPicButton_SimulateAction ( $iCtrlId, $iFlag=1 ) Local $aPos = ControlGetPos ( $hGui, '', $iCtrlId ) If Not @error Then GUICtrlSetPos ( $iCtrlId, $aPos[0]+$iFlag, $aPos[1]+$iFlag, $aPos[2]-2*$iFlag, $aPos[3]-2*$iFlag ) $aPosBak = $aPos _ArrayAdd ( $aPosBak, $iCtrlId ) AdlibRegister ( '_GuiCtrlPicButton_RestorePos', 250 ) $iAdlib = 1 EndIf $aPos = 0 EndFunc ;==> _GuiCtrlPicButton_SimulateAction () Func _GuiCtrlPicPreviewAdaptAndSetImage () GUISetState ( @SW_LOCK , $hGui ) Local $sFullName = _FileGetFullNameByFullPath ( $sCurrentFilePath ) Local $aDim = _ImageGetDimension ( $sCurrentFilePath ) Local $sRes = '' Local $aRes = _ImageGetResolution ( $sCurrentFilePath ) If Not IsInt ( $aRes ) Then If $aRes[0] = $aRes[1] Then $sRes = $aRes[0] & ' dpi' Else $sRes = 'H' & $aRes[0] & 'V' & $aRes[1] & ' dpi' EndIf EndIf GUICtrlSetData ( $idLabel, 'Loading...' ) $sImageCtrl = _ImageAdaptToPicControl ( $sCurrentFilePath ) $aDim = _ImageGetDimension ( $sImageCtrl ) GUICtrlSetPos ( $idLabelInfos, 20+5, ( $iPicCtrlWidth - $aDim[1] ) /2 +5, $iPicCtrlWidth-10, 15 ) ; set control pos. ControlSetText ( $hGui, '', $idLabelInfos,_FileCompactName ( $sFullName, 30 ) & ' - ' & $aDim[0] & ' x ' & $aDim[1] & ' px ' & $sRes ) ControlMove ( $hGui, '', $idPicCtrlPreview, 20 + ( $iPicCtrlWidth - $aDim[0] ) /2, 20 + ( $iPicCtrlWidth - $aDim[1] ) /2, $aDim[0], $aDim[1] ) $sCurrentPic = _ImagePreviewDrawColumnsAndRows () GUISetState ( @SW_UNLOCK , $hGui ) _GUICtrlSetImageEx ( $idPicCtrlPreview, $sCurrentPic ) EndFunc ;==> _GuiCtrlPicPreviewAdaptAndSetImage () Func _GUICtrlSetImageEx ( $iControlID, $sImagePath ) $aCtrlPos = ControlGetPos ( $hGui, '', $iControlID ) If @error Then Return SetError ( 3, 0, 0 ) GUICtrlSetImage ( $iControlID, '' ) ; remove previous pic. GUICtrlSetPos ( $iControlID, $aCtrlPos[0], $aCtrlPos[1], $aCtrlPos[2], $aCtrlPos[3] ) ; set control pos. ControlMove ( $hGui, '', $iControlID, $aCtrlPos[0], $aCtrlPos[1], $aCtrlPos[2], $aCtrlPos[3] ) ; reset control pos. If Not FileExists ( $sImagePath ) Then Return GUICtrlSetImage ( $iControlID, $sImagePath ) GUICtrlSetPos ( $iControlID, $aCtrlPos[0], $aCtrlPos[1], $aCtrlPos[2], $aCtrlPos[3] ) ; set control pos. ControlMove ( $hGui, '', $iControlID, $aCtrlPos[0], $aCtrlPos[1], $aCtrlPos[2], $aCtrlPos[3] ) ; reset control pos. EndFunc ;==> _GUICtrlSetImageEx () Func _GuiEvents () Switch @GUI_CtrlId ; Last click GUI Control identifier Case $GUI_EVENT_CLOSE _Exit () Case $GUI_EVENT_DROPPED Local $GUI_DropId = @GUI_DropId ; Drop GUI Control identifier If $GUI_DropId <> $idPicCtrlPreview Then Return ; convert pic to jpg in a tmp file adapted to width's ctrl, with ratio maintained. Local $sExt = _ImageTypeIsValid ( @GUI_DRAGFILE ) If Not $sExt Then Return If Not _AlreadyInArray ( $aRecentFiles, @GUI_DRAGFILE, 1, 1 ) Then Local $idNewItem = GUICtrlCreateMenuItem ( @GUI_DRAGFILE, $idRecentFileMenu ) GUICtrlSetOnEvent ( -1, '_GuiEvents' ) If UBound ( $aRecentFiles ) -1 < $iRecentFilesMax Then _ArrayAdd ( $aRecentFileItems, $idNewItem ) _ArrayAdd ( $aRecentFiles, @GUI_DRAGFILE ) Else GUICtrlDelete ( $aRecentFileItems[1] ) _ArrayPush ( $aRecentFileItems, $idNewItem ) _ArrayPush ( $aRecentFiles, @GUI_DRAGFILE ) EndIf EndIf $sCurrentFilePath = @GUI_DRAGFILE ; Filename of the file being dropped _GuiCtrlPicPreviewAdaptAndSetImage () Case $GUI_EVENT_RESTORE _GUICtrlSetImageEx ( $idPicCtrlPreview, $sCurrentPic ) GUICtrlSetState ( $idPicCtrlPreview, $GUI_FOCUS ) Case $idButtonSplit _GuiCtrlPicButton_SimulateAction ( $idButtonSplit ) Local $iRows = GUICtrlRead ( $idInputRows ) Local $iColumns = GUICtrlRead ( $idInputColumns ) If $iRows > 1 Or $iColumns > 1 Then Local $sFormat = GUICtrlRead ( $idComboFormat ) Switch $sFormat Case 'jpg', 'gif', 'bmp', 'png' Local $aResult = _ImageSplitter ( $sCurrentFilePath, $iColumns, $iRows, $sFormat ) If Not @error Then ShellExecute ( $aResult[3] ) EndSwitch EndIf Case $idOpenFileMenu If Not FileExists ( $sCurrentDir ) Then $sCurrentDir = @DesktopDir Local $sOpenFilePath = FileOpenDialog ( 'Choose an Image', $sCurrentDir, 'Images (*.jpg;*.jpe;*.jpeg;*.gif;*.png;*.bmp)', 1+2, '', $hGui ) If @error <> 1 Then $sCurrentDir = _FileGetParentFolderPathByFullPath ( $sOpenFilePath ) Local $sExt = _ImageTypeIsValid ( $sOpenFilePath ) If Not $sExt Then Return If Not _AlreadyInArray ( $aRecentFiles, $sOpenFilePath, 1, 1 ) Then Local $idNewItem = GUICtrlCreateMenuItem ( $sOpenFilePath, $idRecentFileMenu ) GUICtrlSetOnEvent ( -1, '_GuiEvents' ) If UBound ( $aRecentFiles ) -1 < $iRecentFilesMax Then _ArrayAdd ( $aRecentFileItems, $idNewItem ) _ArrayAdd ( $aRecentFiles, $sOpenFilePath ) Else GUICtrlDelete ( $aRecentFileItems[1] ) _ArrayPush ( $aRecentFileItems, $idNewItem ) _ArrayPush ( $aRecentFiles, $sOpenFilePath ) EndIf EndIf $sCurrentFilePath = $sOpenFilePath _GuiCtrlPicPreviewAdaptAndSetImage () EndIf Case _ArrayMin ( $aRecentFileItems, 1, 1 ) To _ArrayMax ( $aRecentFileItems, 1, 1 ) Local $item = _ArraySearch ( $aRecentFileItems, @GUI_CtrlId, 1, 0, 0, 1 ) If Not @error Then $sCurrentFilePath = $aRecentFiles[$item] _GuiCtrlPicPreviewAdaptAndSetImage () EndIf Case $idAboutItem _About () Case $idMultiItem Local $iRows = GUICtrlRead ( $idInputRows ) Local $iColumns = GUICtrlRead ( $idInputColumns ) If $iRows = 1 And $iColumns = 1 Then Return Local $sFormat = GUICtrlRead ( $idComboFormat ) Local $iDpi = GUICtrlRead ( $idComboDPI ) If MsgBox ( 262144+4+32, 'Confirm', @CRLF & 'Continue Multi Images Split ' & @CRLF & @CRLF & 'With this settings ?' & @CRLF & @CRLF & _ 'Rows : ' & $iRows & @CRLF & _ 'Columns : ' & $iColumns & @CRLF & _ 'Format : ' & $sFormat & @CRLF & _ 'Resolution : ' & $iDpi & @CRLF, 0, $hGui ) = 6 Then If Not FileExists ( $sCurrentDir ) Then $sCurrentDir = @DesktopDir Local $aFilesPath = _FileOpenDialog ( 'Select Images', $sCurrentDir, '(*.jpg;*.jpeg;*.png;*.bmp;*.gif)', $hGui ) ; based 1 If Not @error And UBound ( $aFilesPath ) > 1 Then $sCurrentDir = _FileGetParentFolderPathByFullPath ( $aFilesPath[1] ) Local $aResult, $k For $i = 1 To UBound ( $aFilesPath ) -1 If _ImageTypeIsValid ( $aFilesPath[$i] ) Then $sCurrentFilePath = $aFilesPath[$i] _GuiCtrlPicPreviewAdaptAndSetImage () $aResult = _ImageSplitter ( $sCurrentFilePath, $iColumns, $iRows, $sFormat ) Sleep ( 250 ) If Not @error Then ShellExecute ( $aResult[3] ) Else $k+=1 MsgBox ( 262144+16, 'Error', $aFilesPath[$i] & @CRLF & @CRLF & 'is not a Valid Image Type', 4 ) EndIf Next MsgBox ( 262144+64, 'Finish', @CRLF & 'Multi Images Split ' & @CRLF & @CRLF & 'have been done for ' & UBound ( $aFilesPath ) -1 - $k & '/' & UBound ( $aFilesPath ) -1 & ' Files' & @CRLF, 5 ) EndIf EndIf EndSwitch EndFunc ;==> _GuiEvents () Func _ImageAdaptToPicControl ( $sPicPath, $sType='jpg' ) If Not FileExists ( $sPicPath ) Then Return SetError ( -1 ) Local $sTmpFile = _ImageGeneratePathByDate ( @TempDir & '\IStmp', $sType ) Local $aDim = _ImageGetDimension ( $sPicPath ) Local $hImage2 = _GDIPlus_ImageLoadFromFile ( $sPicPath ) Local $iRatio1 = 1, $iRatio2 = 1 If $aDim[0] >= $aDim[1] Then $iRatio2 = $aDim[1]/ $aDim[0] Else $iRatio1 = $aDim[0]/ $aDim[1] EndIf Local $hBitmap = _WinAPI_CreateBitmap ( $iPicCtrlWidth * $iRatio1, $iPicCtrlWidth * $iRatio2, 1, 32 ) ; Adapted to ctrl size (pic size ratio is maintained). Local $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ( $hBitmap ) Local $hGraphic = _GDIPlus_ImageGetGraphicsContext ( $hImage1 ) _GDIPlus_GraphicsDrawImageRect ( $hGraphic, $hImage2, 0, 0, $iPicCtrlWidth * $iRatio1, $iPicCtrlWidth * $iRatio2 ) Local $CLSID = _GDIPlus_EncodersGetCLSID ( $sType ) _GDIPlus_ImageSaveToFileEx ( $hImage1, $sTmpFile, $CLSID ) _GDIPlus_ImageDispose ( $hImage1 ) _GDIPlus_ImageDispose ( $hImage2 ) _GDIPlus_GraphicsDispose ( $hGraphic ) _WinAPI_DeleteObject ( $hBitmap ) If FileExists ( $sTmpFile ) Then Return $sTmpFile EndFunc ;==> _ImageAdaptToPicControl () Func _ImageGeneratePathByCoordinates ( $sBaseDir, $sPrefix, $x, $y, $sExt='jpg' ) If Not FileExists ( $sBaseDir ) Then DirCreate ( $sBaseDir ) Return $sBaseDir & '\' & $sPrefix & '-X' & StringFormat ( '%03i', $x ) & '-Y' & StringFormat ( '%03i', $y ) & '.' & $sExt EndFunc ;==> _ImageGeneratePathByCoordinates () Func _ImageGeneratePathByDate ( $sBaseDir, $sExt='jpg' ) Local $iSuffix, $sTempPath If Not FileExists ( $sBaseDir ) Then DirCreate ( $sBaseDir ) Do $sTempPath = $sBaseDir & '\' & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & StringFormat ( '%02i', $iSuffix ) & '.' & $sExt $iSuffix += 1 Until Not FileExists ( $sTempPath ) Return $sTempPath EndFunc ;==> _ImageGeneratePathByDate () Func _ImageGetDimension ( $sPicPath ) If Not FileExists ( $sPicPath ) Then Return SetError ( -1 ) Local $hImage = _GDIPlus_ImageLoadFromFile ( $sPicPath ) Local $aRet[2] $aRet[0] = _GDIPlus_ImageGetWidth ( $hImage ) $aRet[1] = _GDIPlus_ImageGetHeight ( $hImage ) _GDIPlus_ImageDispose ( $hImage ) If $aRet[0] And $aRet[1] Then Return $aRet EndFunc ;==> _ImageGetDimension () Func _ImageGetResolution ( $sPicPath ) If Not FileExists ( $sPicPath ) Then Return SetError ( -1 ) Local $hImage = _GDIPlus_ImageLoadFromFile ( $sPicPath ) Local $aRet[2] $aRet[0] = _GDIPlus_ImageGetHorizontalResolution ( $hImage ) $aRet[1] = _GDIPlus_ImageGetVerticalResolution ( $hImage ) _GDIPlus_ImageDispose ( $hImage ) If $aRet[0] And $aRet[1] Then Return $aRet EndFunc ;==> _ImageGetResolution () Func _ImagePreviewDrawColumnsAndRows () Local $iColumns = GUICtrlRead ( $idInputColumns ) Local $iRows = GUICtrlRead ( $idInputRows ) Local $aDim = _ImageGetDimension ( $sImageCtrl ) Local $hImage2 = _GDIPlus_ImageLoadFromFile ( $sImageCtrl ) Local $hBitmap = _WinAPI_CreateBitmap ( $aDim[0], $aDim[1], 1, 32 ) ; Adapted to ctrl size (pic size ratio is maintained). Local $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ( $hBitmap ) Local $hGraphic = _GDIPlus_ImageGetGraphicsContext ( $hImage1 ) Local $hPen = _GDIPlus_PenCreate ( 0xFFFF0000 ) Local $CLSID = _GDIPlus_EncodersGetCLSID ( 'jpg' ) _GDIPlus_GraphicsDrawImageRect ( $hGraphic, $hImage2, 0, 0, $aDim[0], $aDim[1] ) For $i = 1 To $iColumns -1 _GDIPlus_GraphicsDrawLine ( $hGraphic, $i * ( $aDim[0] /$iColumns ), 0, $i * ( $aDim[0] /$iColumns ), $aDim[1], $hPen ) Next For $i = 1 To $iRows -1 _GDIPlus_GraphicsDrawLine ( $hGraphic, 0, $i * ( $aDim[1] /$iRows ), $aDim[0], $i * ( $aDim[1] /$iRows ), $hPen ) Next Local $sTmpFile = _ImageGeneratePathByDate ( @TempDir & '\IStmp' ) _GDIPlus_ImageSaveToFileEx ( $hImage1, $sTmpFile, $CLSID ) _GDIPlus_PenDispose ( $hPen ) _GDIPlus_GraphicsDispose ( $hGraphic ) _GDIPlus_ImageDispose ( $hImage1 ) _WinAPI_DeleteObject ( $hBitmap ) _GDIPlus_ImageDispose ( $hImage2 ) $aDim = _ImageGetDimension ( $sCurrentFilePath ) Local $iNumber = $iColumns*$iRows If Not $iNumber Then $iNumber = 1 GUICtrlSetData ( $idEditSplitNb, $iNumber ) Local $iWidth = Floor ( $aDim[0] /$iColumns ) If $iWidth <= 0 Then $iWidth = $aDim[0] GUICtrlSetData ( $idEditSplitWidth, $iWidth ) Local $iHeight = Floor ( $aDim[1] /$iRows ) If $iHeight <= 0 Then $iHeight = $aDim[1] GUICtrlSetData ( $idEditSplitHeight, $iHeight ) Return $sTmpFile EndFunc ;==> _ImagePreviewDrawColumnsAndRows () Func _ImageSplitter ( $sPicPath, $iColumns, $iRows, $sType='jpg' ) If Not FileExists ( $sPicPath ) Then Return SetError ( -1 ) GUISetOnEvent ( $GUI_EVENT_CLOSE, '_NoEvents', $hGui ) GUISetOnEvent ( $GUI_EVENT_DROPPED, '_NoEvents', $hGui ) GUICtrlSetOnEvent ( $idButtonSplit, '_NoEvents' ) GUIRegisterMsg ( $WM_COMMAND, '_NoEvents' ) ControlMove ( $hGui, '', $idProgressBar, $aCtrlPos[0]+2, $aCtrlPos[1] + $aCtrlPos[3]+5, $aCtrlPos[2]-4, 10 ) GUICtrlSetState ( $idProgressBar, $GUI_SHOW ) Local $aDim = _ImageGetDimension ( $sPicPath ) Local $hImage2 = _GDIPlus_ImageLoadFromFile ( $sPicPath ) Local $CLSID = _GDIPlus_EncodersGetCLSID ( $sType ) Local $w = Int ( $aDim[0] / $iColumns ) Local $h = Int ( $aDim[1] / $iRows ) Local $hBitmap = _WinAPI_CreateBitmap ( $w, $h, 1, 32 ) Local $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ( $hBitmap ) Local $nDpiX, $nDpiY Local $iDpiChoice = GUICtrlRead ( $idComboDPI ) If $iDpiChoice = 'same' Then $nDpiX = _GDIPlus_ImageGetHorizontalResolution ( $hImage2 ) $nDpiY = _GDIPlus_ImageGetVerticalResolution ( $hImage2 ) Else $nDpiX = $iDpiChoice $nDpiY = $iDpiChoice EndIf DllCall ( $ghGDIPDll, 'uint', 'GdipBitmapSetResolution', 'hwnd', $hImage1, 'float', $nDpiX, 'float', $nDpiY ) Local $hGraphic = _GDIPlus_ImageGetGraphicsContext ( $hImage1 ) _GdipSetInterpolationMode ( $hGraphic, 7 ) ; $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC Specifies high-quality, bicubic interpolation. Prefiltering is performed to ensure high-quality shrinking. This mode produces the highest quality transformed images. _GDIPlus_GraphicsSetSmoothingMode ( $hGraphic, 5 ) ; $GDIP_SMOOTHINGMODE_ANTIALIAS8X8 Specifies that smoothing is applied using an 8 X 8 box filter. Local $sPrefix = _FileGetNameWithoutExtByFullPath ( $sPicPath ) Local $sOutputDir, $iSuffix Do ; create a directory based on image name and with infos on settings. $sOutputDir = @TempDir & '\SplittedImages\' & $sPrefix & '-' & $sType & '-Row' & $iRows & '-Col' & $iColumns & '-' & StringFormat ( '%02i', $iSuffix ) $iSuffix += 1 Until Not FileExists ( $sOutputDir ) Local $sTmpFile, $k, $iSleep = $iRows*$iColumns > 1000 Or $w*$h > 1024*1024 For $i = 1 To $iRows ; split from left to right and from top to bottom. For $j = 1 To $iColumns $k+=1 GUICtrlSetData ( $idProgressBar, 100*$k/( $iColumns*$iRows ) ) $sTmpFile = _ImageGeneratePathByCoordinates ( $sOutputDir, $sPrefix, $i, $j, StringLower ( $sType ) ) _GDIPlus_GraphicsDrawImageRectRect ( $hGraphic, $hImage2, $w*( $j -1 ), $h*( $i -1 ), $w, $h, 0, 0, $w, $h ) _GDIPlus_ImageSaveToFileEx ( $hImage1, $sTmpFile, $CLSID ) If $iSleep Then Sleep ( 100 ) ; for limit cpu. Next Next _WinAPI_DeleteObject ( $hBitmap ) _GDIPlus_ImageDispose ( $hImage1 ) _GDIPlus_GraphicsDispose ( $hGraphic ) _GDIPlus_ImageDispose ( $hImage2 ) Local $aRet[4] $aRet[0] = $iRows*$iColumns ; pics number $aRet[1] = $w ; pics width $aRet[2] = $h ; pics height $aRet[3] = $sOutputDir ; directory Sleep ( 500 ) GUICtrlSetState ( $idProgressBar, $GUI_HIDE ) GUICtrlSetData ( $idProgressBar, 0 ) GUIRegisterMsg ( $WM_COMMAND, '_WM_COMMAND' ) GUISetOnEvent ( $GUI_EVENT_CLOSE, '_GuiEvents', $hGui ) GUISetOnEvent ( $GUI_EVENT_DROPPED, '_GuiEvents', $hGui ) GUICtrlSetOnEvent ( $idButtonSplit, '_GuiEvents' ) Return $aRet EndFunc ;==> _ImageSplitter () Func _ImageTypeIsValid ( $sPicPath ) If Not FileExists ( $sPicPath ) Then Return SetError ( -1 ) Local $hImage = _GDIPlus_ImageLoadFromFile ( $sPicPath ) Local $aRet = _GDIPlus_ImageGetRawFormat ( $hImage ) _GDIPlus_ImageDispose ( $hImage ) Switch $aRet[1] Case 'jpeg', 'gif', 'bmp', 'png' Return StringLower ( $aRet[1] ) EndSwitch EndFunc ;==> _ImageTypeIsValid () 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 _NoEvents () ; EndFunc ;==> _NoEvents () Func _OpenOutputDir () ShellExecute ( @TempDir & '\SplittedImages' ) EndFunc ;==> _OpenOutputDir () Func _ScriptGetVersion () Local $sFileVersion If @Compiled Then $sFileVersion = FileGetVersion ( @ScriptFullPath, 'FileVersion' ) Else $sFileVersion = _StringBetween ( FileRead ( @ScriptFullPath ), '#AutoIt3Wrapper_Res_Fileversion=', @CR ) If Not @error Then $sFileVersion = $sFileVersion[0] Else $sFileVersion = '0.0.0.0' EndIf EndIf Return $sFileVersion EndFunc ;==> _ScriptGetVersion () Func _Singleton ( $sOccurenceName, $iFlag=0 ) Local Const $ERROR_ALREADY_EXISTS = 183 Local Const $SECURITY_DESCRIPTOR_REVISION = 1 Local $tSecurityAttributes = 0 If BitAND ( $iFlag, 2 ) Then Local $tSecurityDescriptor = DllStructCreate ( 'byte;byte;word;ptr[4]' ) Local $aRet = DllCall ( 'advapi32.dll', 'bool', 'InitializeSecurityDescriptor', 'struct*', $tSecurityDescriptor, 'dword', $SECURITY_DESCRIPTOR_REVISION ) If @error Then Return SetError ( @error, @extended, 0 ) If $aRet[0] Then $aRet = DllCall ( 'advapi32.dll', 'bool', 'SetSecurityDescriptorDacl', 'struct*', $tSecurityDescriptor, 'bool', 1, 'ptr', 0, 'bool', 0 ) If @error Then Return SetError ( @error, @extended, 0 ) If $aRet[0] Then $tSecurityAttributes = DllStructCreate ( $tagSECURITY_ATTRIBUTES ) DllStructSetData ( $tSecurityAttributes, 1, DllStructGetSize ( $tSecurityAttributes ) ) DllStructSetData ( $tSecurityAttributes, 2, DllStructGetPtr ( $tSecurityDescriptor ) ) DllStructSetData ( $tSecurityAttributes, 3, 0) EndIf EndIf EndIf Local $handle = DllCall ( 'kernel32.dll', 'handle', 'CreateMutexW', 'struct*', $tSecurityAttributes, 'bool', 1, 'wstr', $sOccurenceName ) If @error Then Return SetError ( @error, @extended, 0 ) Local $lastError = DllCall ( 'kernel32.dll', 'dword', 'GetLastError' ) If @error Then Return SetError ( @error, @extended, 0 ) If $lastError[0] = $ERROR_ALREADY_EXISTS Then If BitAND ( $iFlag, 1 ) Then Return SetError ( $lastError[0], $lastError[0], 0 ) Else Exit -1 EndIf EndIf Return $handle[0] EndFunc ;==> _Singleton () Func _StringBetween ( $s_String, $s_Start, $s_End, $v_Case=-1 ) Local $s_case = '' If $v_Case = Default Or $v_Case = -1 Then $s_case = '(?i)' Local $s_pattern_escape = '(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\)' $s_Start = StringRegExpReplace ( $s_Start, $s_pattern_escape, '\\$1' ) $s_End = StringRegExpReplace ( $s_End, $s_pattern_escape, '\\$1' ) If $s_Start = '' Then $s_Start = '\A' If $s_End = '' Then $s_End = '\z' Local $a_ret = StringRegExp ( $s_String, '(?s)' & $s_case & $s_Start & '(.*?)' & $s_End, 3 ) If @error Then Return SetError ( 1, 0, 0 ) Return $a_ret EndFunc ;==> _StringBetween () Func _WM_COMMAND ( $hWnd, $iMsg, $iwParam, $ilParam ) Local $hWndFrom, $iIDFrom, $iCode $hWndFrom = $ilParam $iIDFrom = _WinAPI_LoWord ( $iwParam ) $iCode = _WinAPI_HiWord ( $iwParam ) Switch $hWndFrom Case GUICtrlGetHandle ( $idInputRows ), GUICtrlGetHandle ( $idInputColumns ) Switch $iCode Case 0x300 ; $EN_CHANGE $iInputChange = 1 If GUICtrlRead ( $idInputColumns ) > 100 Then GUICtrlSetData ( $idInputColumns, 100 ) If GUICtrlRead ( $idInputRows ) > 100 Then GUICtrlSetData ( $idInputRows, 100 ) If GUICtrlRead ( $idInputColumns ) < 1 Then GUICtrlSetData ( $idInputColumns, 1 ) If GUICtrlRead ( $idInputRows ) < 1 Then GUICtrlSetData ( $idInputRows, 1 ) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==> _WM_COMMAND () Func Button1Jpeg ( $sFileName, $sOutputDirPath, $iOverWrite=0 ) Local $sFileBin = '/9j/4AAQSkZJRgABAQEASABIAAD//gAcIkNyZWF0ZWQgd2l0aCBDaGltcGx5LmNvbSL/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/2wBDAQMDAwQDBAgEBAgQCwkLEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBD/wAARCAAeAJYDASIAAhEBAxEB/8QAHgAAAQUBAQADAAAAAAAAAAAACAAFBgcJBAECAwr/xAA6EAABAwMCAwMLAgUFAQAAAAABAgMEBQYHERIACBMYITEJFBYiQVRVlJbT1BVxIzJRUmEkQmKBkbH/xAAbAQACAwEBAQAAAAAAAAAAAAADBAECBQY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LynRrlS/TH4pZWQ3GjuLSttxSlj1y2sBpSkh0g6cCN2B+Sz47mT5um/Z4d4PJryr0unrpNNyJnqJBc13xmKxBbaVr46oS2Adf24UuLq2dTlaBTMzuSZgHWZ6dZH0qyQob1X95891mW3lfLONb9sl6/caVu7HK3Tv06rv0ydAl7EJWWpDCkrCSU6KSFJ7941IWocDbzS8x9Fz7dFPm2vY0a1KLR43msSGws6uJ9i3QCUqc/q4dVq9qtAAC87A/JZ8dzJ83Tfs8edgfks+O5k+bpv2eNK0xy3s3A80ghQEbnsBMTEnqY1qimyoQTWa3nQ/u4d7T' $sFileBin &= 'ty476uOBaVo0mRVKvU3QzFisJ1UtR9p9iUgakqOgSASSAONF4vIZyUsyG3XKnl+QlKgS07Mp4Qv/AASlsK0/Yg8Fbgjl9xBYtIeOErFp9tMS/Ul1OWpcuoujuBG5wqIBKddN+wHv2cabnG1wUnw5mhi2HWoPywctDdo2bS7DqUgOKolOHnshtRUkzHXOqsJ7h6pUp0j2hITr48LgtKJRKfb8EQKc2UpKi44tZ3LdWfFaj7Sf/gAGgAHC44hay4orVuaaGlf/2Q==' $sFileBin = Binary ( _Base64Decode ( $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 ;==> Button1Jpeg () Func Scissors1Ico ( $sFileName, $sOutputDirPath, $iOverWrite=0 ) Local $sFileBin = 'bbgAAAABAAMAICABAXAgAKgQAAA2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KTW/QgMA5gCNbCj9zcH2+4C+r/p5SThxMSIA86aMgv/08/8A/s/D/2M+MpcNMAFEtCd+FO6PbRcA/MSz9uWOcqQF4AAbsRT5jWcH+QDNv9D/2tL/oWhjT58wAUG0Nv4D+QCSbgLxjmw+sBxmTvEBcRYyAvCaewBJ/tjN/9KBZqCYRSgdLyABCvkDGoFQBYDQAj8AAADg9zEAUB81AMBQJzIAcAExAALBMAA=' $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 ;==> Scissors1Ico ()