#include <GDIPlus.au3>
#include <array.au3>
Opt("MustDeclareVars", 1)
Global $message, $var, $var_string, $path, $replac, $result, $iWidth, $iHeight, $hNewBitmap, $hNewBitmap2, $hGraphic
$message = "Удерживайте клавиши Ctrl или Shift, чтобы выбрать несколько файлов."
$var = FileOpenDialog($message, '', '(*.jpg;*.bmp;*.png)', 1 + 4)
If @error Then
MsgBox(4096, "", "Не выбрано ни одного файла")
Else
$var_string = StringReplace($var, "|", '\', 1)
$path = _PathSplitByRegExp($var_string)
$replac = StringReplace($var_string, '|', ',' & $path[2] & '\')
$result = StringSplit($replac, ',')
_ArrayDelete($result, 0)
_foto_join()
EndIf
Func _PathSplitByRegExp($sPath)
If $sPath = "" Or (StringInStr($sPath, "\") And StringInStr($sPath, "/")) Then Return SetError(1, 0, -1)
Local $aRetArray[8], $pDelim = ""
If StringRegExp($sPath, '^(?i)([A-Z]:|\\)(\\[^\\]+)+$') Then $pDelim = "\"
If StringRegExp($sPath, '(?i)(^.*:/)(/[^/]+)+$') Then $pDelim = "//"
If $pDelim = "" Then $pDelim = "/"
If Not StringInStr($sPath, $pDelim) Then Return $sPath
If $pDelim = "\" Then $pDelim &= "\"
$aRetArray[0] = $sPath ;Full path
$aRetArray[1] = StringRegExpReplace($sPath, $pDelim & '.*', $pDelim) ;Drive letter
$aRetArray[2] = StringRegExpReplace($sPath, $pDelim & '[^' & $pDelim & ']*$', '') ;Path without FileName and extension
$aRetArray[3] = StringRegExpReplace($sPath, '\.[^.]*$', '') ;Full path without File Extension
$aRetArray[4] = StringRegExpReplace($sPath, '(?i)([A-Z]:' & $pDelim & ')', '') ;Full path without drive letter
$aRetArray[5] = StringRegExpReplace($sPath, '^.*' & $pDelim, '') ;FileName and extension
$aRetArray[6] = StringRegExpReplace($sPath, '.*' & $pDelim & '|\.[^.]*$', '') ;Just Filename
$aRetArray[7] = StringRegExpReplace($sPath, '^.*\.', '') ;Just Extension of a file
Return $aRetArray
EndFunc ;==>_PathSplitByRegExp
Func _foto_join()
_GDIPlus_Startup()
Dim $ahImage[UBound($result)]
For $i = 0 To UBound($result) - 1
$ahImage[$i] = _GDIPlus_ImageLoadFromFile($result[$i])
Next
For $i = 0 To UBound($ahImage) - 1
$iWidth = _GDIPlus_ImageGetWidth($ahImage[$i])
$iHeight = _GDIPlus_ImageGetHeight($ahImage[$i])
Next
$hNewBitmap = _WinAPI_CreateBitmap($iWidth * UBound($result), $iHeight, 1, 32)
$hNewBitmap2 = _GDIPlus_BitmapCreateFromHBITMAP($hNewBitmap)
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hNewBitmap2)
For $i = 0 To UBound($ahImage) - 1
_GDIPlus_GraphicsDrawImageRect($hGraphic, $ahImage[$i], $i * $iWidth, 0, $iWidth, $iHeight)
_GDIPlus_ImageDispose($ahImage[$i])
Next
_GDIPlus_ImageSaveToFile($hNewBitmap2, "NewFile.jpg")
_GDIPlus_GraphicsDispose($hGraphic)
_WinAPI_CloseHandle($hNewBitmap)
_GDIPlus_ImageDispose($hNewBitmap2)
_GDIPlus_Shutdown()
Exit
EndFunc ;==>_foto_join