Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Strict
- Import AquapearMedia.MyGL
- Import Aquapear.Application
- Rem ABOUT
- Прога для накладывания альфакарт на картинки папки А
- с помощью соотв. картинок папки Б, с сохранением их в папку С
- Т.е. структура остаётся такой же, а главная папка разная для альфакарт,
- источника и результата.
- Использует аргументы для работы:
- <source_dir_path> <alphamap_dir_path> <result_dir_path> [-w]
- где:
- -w - необходимость ожидания нажатия клавиши Enter
- End Rem
- ' * * ЗАПУСК * * *
- New TAlphamapImposer.Run()
- ' * * * * * * * * *
- Type TAlphamapImposer Extends TApplication Final
- Field _sourceDirPath$
- Field _alphamapsDirPath$
- Field _resultDirPath$
- Field _needWait%
- Field _localImagesPaths:TList = New TList
- '''''''''''
- Method Start()
- _PrintHead()
- _ReadArgs()
- _LoadLocalImagesPaths()
- End Method
- Method MainLoop()
- _ImposeAlphamaps()
- End Method
- Method Terminate()
- _PrintEnd()
- _TryWait()
- End Method
- '__________________________________
- '[ ПЕЧАТЬ И ОЖИДАНИЕ ВВОДА ]
- Method _PrintHead()
- 'Print "Накладыватель альфакарт. Копирайт (c) Aквагруша, 2015"
- Print "Alphamaps Imposer. Copyright (c) Aquapear Company, 2015"
- End Method
- Method _PrintEnd()
- 'Print "Готово."
- Print "Done."
- End Method
- Method _TryWait()
- If _needWait Input("Press any key...")
- End Method
- '[ ПРОИЗВОДИМ НАЧАЛЬНЫЕ ДЕЙСТВИЯ ]
- '* Читаем аргументы *
- Method _ReadArgs()
- _ReadFirstArgs()
- _ReadMoreArgs()
- End Method
- Method _GetArg$( i% )
- If i < 0 Or i >= AppArgs.Length Return ""
- Return AppArgs[i]
- End Method
- Method _ReadFirstArgs()
- _sourceDirPath = _GetArg(1)
- _alphamapsDirPath = _GetArg(2)
- _resultDirPath = _GetArg(3)
- End Method
- Method _ReadMoreArgs()
- For Local i% = 4 Until AppArgs.Length
- Select AppArgs[i]
- Case "-w"
- _needWait = True
- End Select
- Next
- End Method
- '* Загружаем локальные пути к картинкам *
- Method _LoadLocalImagesPaths()
- Local sourceFilesPaths:TList = LoadCatalog( _sourceDirPath, False, True )
- For Local filePath$ = EachIn sourceFilesPaths
- _localImagesPaths.AddLast( filePath.Replace(_sourceDirPath+"/", "") )
- Next
- End Method
- '[ НАКЛАДЫВАЕМ АЛЬФАКАРТЫ ]
- '* Накладываем альфакарты *
- Method _ImposeAlphamaps()
- _TryCreateDir( _resultDirPath )
- For Local localImagePath$ = EachIn _localImagesPaths
- _ImposeAlphamap(localImagePath)
- Next
- End Method
- Method _ImposeAlphamap(localImagePath$)
- Local sourceImagePath$ = CombinePaths(_sourceDirPath, localImagePath)
- Local alphamapImagePath$ = CombinePaths(_alphamapsDirPath, localImagePath)
- Local resultImagePath$ = CombinePaths(_resultDirPath, localImagePath)
- _TryCreateDir( ExtractDir(resultImagePath) )
- 'Print " Накладываем: " + alphamapImagePath +" на "+ resultImagePath
- If FileType(alphamapImagePath) = FILETYPE_NONE
- Print "# ERROR: Can`t find alphamap:~n "+alphamapImagePath
- Else
- Print "Imposing:~n "+ alphamapImagePath +"~n on: "+ resultImagePath
- ImposeAlphamap(alphamapImagePath, sourceImagePath, resultImagePath)
- End If
- End Method
- Method _TryCreateDir( dirPath$ )
- If FileType(dirPath)=FILETYPE_NONE
- CreateDir(dirPath)
- End If
- End Method
- Method _LoadImage:TPixmap(rootDirPath$, localImagePath$)
- Local fullImagePath$ = CombinePaths(rootDirPath, localImagePath)
- Return LoadPixmap( fullImagePath )
- End Method
- End Type
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement