Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. Strict
  3. Import AquapearMedia.MyGL
  4. Import Aquapear.Application
  5.  
  6.  
  7. Rem ABOUT
  8.     Прога для накладывания альфакарт на картинки папки А
  9.     с помощью соотв. картинок папки Б, с сохранением их в папку С
  10.     Т.е. структура остаётся такой же, а главная папка разная для альфакарт,
  11.     источника и результата.
  12.    
  13.     Использует аргументы для работы:
  14.         <source_dir_path>  <alphamap_dir_path> <result_dir_path> [-w]
  15.     где:
  16.         -w - необходимость ожидания нажатия клавиши Enter
  17. End Rem
  18.  
  19.  
  20. ' * * ЗАПУСК * * *
  21.     New TAlphamapImposer.Run()
  22. ' * * * * * * * * *
  23.  
  24. Type TAlphamapImposer Extends TApplication Final
  25.     Field _sourceDirPath$
  26.     Field _alphamapsDirPath$
  27.     Field _resultDirPath$
  28.     Field _needWait%
  29.    
  30.     Field _localImagesPaths:TList = New TList
  31. '''''''''''
  32.    
  33.     Method Start()
  34.         _PrintHead()
  35.         _ReadArgs()
  36.         _LoadLocalImagesPaths()
  37.     End Method
  38.    
  39.     Method MainLoop()  
  40.         _ImposeAlphamaps()
  41.     End Method
  42.    
  43.     Method Terminate()
  44.         _PrintEnd()
  45.         _TryWait()
  46.     End Method
  47.    
  48.    
  49. '__________________________________
  50. '[ ПЕЧАТЬ И ОЖИДАНИЕ ВВОДА ]
  51.     Method _PrintHead()
  52.         'Print "Накладыватель альфакарт. Копирайт (c) Aквагруша, 2015"
  53.         Print "Alphamaps Imposer. Copyright (c) Aquapear Company, 2015"
  54.     End Method
  55.    
  56.     Method _PrintEnd()
  57.         'Print "Готово."
  58.         Print "Done."
  59.     End Method
  60.    
  61.     Method _TryWait()
  62.         If _needWait Input("Press any key...")
  63.     End Method
  64.    
  65.    
  66.    
  67.    
  68. '[ ПРОИЗВОДИМ НАЧАЛЬНЫЕ ДЕЙСТВИЯ ]
  69. '* Читаем аргументы *
  70.     Method _ReadArgs()
  71.         _ReadFirstArgs()
  72.         _ReadMoreArgs()
  73.     End Method
  74.    
  75.     Method _GetArg$( i% )
  76.         If i < 0 Or i >= AppArgs.Length Return ""
  77.         Return AppArgs[i]
  78.     End Method
  79.    
  80.     Method _ReadFirstArgs()
  81.         _sourceDirPath = _GetArg(1)
  82.         _alphamapsDirPath = _GetArg(2)
  83.         _resultDirPath = _GetArg(3)
  84.     End Method
  85.    
  86.     Method _ReadMoreArgs()
  87.         For Local i% = 4 Until AppArgs.Length
  88.             Select AppArgs[i]
  89.             Case "-w"
  90.                 _needWait = True
  91.             End Select
  92.         Next
  93.     End Method
  94.    
  95. '* Загружаем локальные пути к картинкам *
  96.     Method _LoadLocalImagesPaths()
  97.         Local sourceFilesPaths:TList =  LoadCatalog( _sourceDirPath, False, True )
  98.         For Local filePath$ = EachIn sourceFilesPaths
  99.             _localImagesPaths.AddLast( filePath.Replace(_sourceDirPath+"/", "") )
  100.         Next
  101.     End Method
  102.    
  103.    
  104.    
  105.    
  106. '[ НАКЛАДЫВАЕМ АЛЬФАКАРТЫ ]
  107. '* Накладываем альфакарты *
  108.     Method _ImposeAlphamaps()
  109.         _TryCreateDir( _resultDirPath )
  110.         For Local localImagePath$ = EachIn _localImagesPaths
  111.             _ImposeAlphamap(localImagePath)
  112.         Next
  113.     End Method
  114.    
  115.     Method _ImposeAlphamap(localImagePath$)
  116.         Local sourceImagePath$ = CombinePaths(_sourceDirPath, localImagePath)
  117.         Local alphamapImagePath$ = CombinePaths(_alphamapsDirPath, localImagePath)
  118.         Local resultImagePath$ = CombinePaths(_resultDirPath, localImagePath)
  119.        
  120.         _TryCreateDir( ExtractDir(resultImagePath) )
  121.         'Print " Накладываем: " + alphamapImagePath +" на "+ resultImagePath
  122.         If FileType(alphamapImagePath) = FILETYPE_NONE
  123.             Print "# ERROR: Can`t find alphamap:~n  "+alphamapImagePath
  124.         Else
  125.             Print "Imposing:~n  "+ alphamapImagePath +"~n  on: "+ resultImagePath
  126.             ImposeAlphamap(alphamapImagePath, sourceImagePath, resultImagePath)
  127.         End If
  128.     End Method
  129.    
  130.     Method _TryCreateDir( dirPath$ )
  131.         If FileType(dirPath)=FILETYPE_NONE
  132.             CreateDir(dirPath)
  133.         End If
  134.     End Method
  135.    
  136.     Method _LoadImage:TPixmap(rootDirPath$, localImagePath$)
  137.         Local fullImagePath$ = CombinePaths(rootDirPath, localImagePath)
  138.         Return LoadPixmap( fullImagePath )
  139.     End Method
  140.    
  141.    
  142.    
  143. End Type
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement