Advertisement
Pablo_Borsellino

[Tool] Image2Label Source Code

Oct 13th, 2011
982
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.92 KB | None | 0 0
  1. FileCreateDir, %A_ProgramFiles%\Image2Label
  2. FileInstall,Palette.png,%A_ProgramFiles%\Image2Label\Picture_Palette.png, 1
  3. FileInstall,Header.jpg,%A_ProgramFiles%\Image2Label\Picture_Header.jpg, 1
  4. FileInstall,Avatar.png,%A_ProgramFiles%\Image2Label\Picture_Avatar.png, 1
  5. #NoEnv
  6. #Persistent
  7. SetWinDelay, 8
  8. CoordMode, Mouse, Relative
  9. CoordMode, ToolTip, Relative
  10. CoordMode, Caret, Relative
  11. CoordMode, Pixel, Relative
  12. CoordMode, Menu, Relative
  13. DetectHiddenWindows, On
  14. BILD_DATEI = Unused.png
  15. WINDOWS_TITLE = Image2Label
  16. FILE_TO_SAVE = Converted.pwn
  17. USED_PICTURE = %A_ProgramFiles%\Image2Label\Picture_Avatar.png
  18. OLD_COLOR = 0xAFAFAFAF
  19. BG_COLOR := 0xEEAA99
  20. COLOR_PICK_SHOWED = 0
  21. LABEL_TRANS = FF
  22. Gui, Color, Yellow
  23. Text := "#"
  24. WIN_POS_X = 500
  25. WIN_POS_Y = 350
  26. HELP_SHOWED = 0
  27. MOVED_X_POS := 500
  28. MOVED_Y_POS := 500
  29.  
  30. ;Gui, Color, EEAA99
  31. ;Gui +LastFound  ; Make the GUI window the last found window for use by the line below.
  32. ;WinSet, TransColor, EEAA99
  33.  
  34. Gui, Add, Button, x10 y10 w130 h20 gQ, Convert
  35. Gui, Add, Edit, x10 y32 w58 h20 Limit vBG_COLOR_CHANGEx gBG_COLOR_CHANGE,%BG_COLOR%
  36. Gui, Add, Edit, x66 y32 w18 h20 Limit vLABEL_TRANS_CHANGEx gLABEL_TRANS_CHANGE,%LABEL_TRANS%
  37. Gui, Add, Button, x86 y32 w54  h20 gHELP vHELP, Help
  38. Gui, Add, Edit, x10 y54 w74 h20 Limit vPICTURE_CHANGEx gPICTURE_CHANGE,%USED_PICTURE%
  39. Gui, Add, Button, x86 y54 w54  h20 gLOAD_PICTURE, Load
  40. Gui, Add, Edit, x10 y76 w74 h20 Limit vTEXT_CHANGEx gTEXT_CHANGE,%Text%
  41. Gui, Add, Button, x86 y76 w54  h20 Disabled, Preview
  42. Gui, Add, Button, x86 y98 w54  h20  gPICK_BG_COLOR vPICK_BG_COLORx, Pick
  43. Gui, Font, underline
  44. Gui, Add, Button, x86 y120 w54  h20 gLINK_TO_CREDITS +backgroundtrans, Credits
  45. Gui, Font,norm
  46. Gui, Add, Picture, x29 y105 w32 h32 vTHE_PICTURE, %USED_PICTURE%
  47. Gui, Add, Picture, x152 y10 w125 h130 vCOLOR_PALETTE +backgroundtrans, %A_ProgramFiles%\Image2Label\Picture_Palette.png
  48. Gui, Add, Text, x3152 y10 w125 h130 +backgroundtrans vMARKER, x
  49. Gui, Add, Picture, x155 y10 w120 h30 vHELP_HEADER,%A_ProgramFiles%\Image2Label\Picture_Header.jpg
  50. Gui, Add, Text, x155 y40 w125 h120 +backgroundtrans vHELP_TEXT, -» How to use this Tool «-`nPress F1 on the Picture / Color Picker to pick a color as removed Background Color.`n`nPress Load to search for an picture.
  51. Gui, Add, GroupBox, x24 y93 w42 h48
  52. Gui, Show, x500 y350 h120 w145, WINDOWS_TITLE
  53. Gui, Color, %BG_COLOR%
  54.  
  55. Gui, +LastFound ToolWindow -Caption
  56. WinSet,AlwaysOnTop,On
  57. Gui, Add, text, x-100 y-100  w2000 h2000 gMOVE_WINDOW +backgroundtrans,
  58. return
  59.  
  60. LINK_TO_CREDITS:
  61. Run http://forum.sa-mp.com/forumdisplay.php?f=17
  62. return
  63.  
  64. LOAD_PICTURE:
  65. FileSelectFile,Datei,1,RootDir\,Select a Picture to Convert..,Image (*.png; *.jpg; *.jpeg; *.gif; *.bmp)
  66. Gui, Submit, NoHide
  67. GuiControl,, THE_PICTURE,%Datei%
  68. GuiControl, Move, THE_PICTURE, x29 y105 w32 h32
  69. USED_PICTURE = %Datei%
  70. return
  71.  
  72. PICK_BG_COLOR:
  73. if COLOR_PICK_SHOWED = 0
  74. {
  75.     GuiControl,show,COLOR_PALETTE,
  76.     GuiControl,hide,HELP_HEADER
  77.     GuiControl,hide,HELP_TEXT
  78.     WinGetPos,WIN_POS_X,WIN_POS_Y
  79.     COLOR_PICK_SHOWED = 1
  80.     Gui, Show, x%WIN_POS_X% y%WIN_POS_Y% h151 w290, WINDOWS_TITLE
  81.     GuiControl,, PICK_BG_COLORx,Hide
  82.     GuiControl,, HELP,Help
  83.     GuiControl,show,MARKER,
  84.     HELP_SHOWED = 0
  85. }
  86. else
  87. {
  88.     COLOR_PICK_SHOWED = 0
  89.     Gui, Show, h151 w151, WINDOWS_TITLE
  90.     GuiControl,, PICK_BG_COLORx,Pick
  91.     GuiControl,hide,MARKER,
  92. }
  93. return
  94.  
  95. HELP:
  96. if HELP_SHOWED = 0
  97. {
  98.     HELP_SHOWED = 1
  99.     WinGetPos,WIN_POS_X,WIN_POS_Y
  100.     Gui, Show, x%WIN_POS_X% y%WIN_POS_Y% h151 w290, WINDOWS_TITLE
  101.     COLOR_PICK_SHOWED = 0
  102.     GuiControl,show,HELP_HEADER
  103.     GuiControl,show,HELP_TEXT
  104.     GuiControl,hide,COLOR_PALETTE,
  105.     GuiControl,hide,MARKER,
  106.     GuiControl,, HELP,Hide
  107.     GuiControl,, PICK_BG_COLORx,Pick
  108. } ;//Anemlden 1Tag früher, Besuch: 04124/6081305
  109. else
  110. {
  111.     GuiControl,, HELP,Help
  112.     HELP_SHOWED = 0
  113.     GuiControl,hide,HELP_HEADER
  114.     GuiControl,hide,HELP_TEXT
  115.     GuiControl,show,COLOR_PALETTE,
  116.     GuiControl,show,MARKER,
  117.     GuiControl,, PICK_BG_COLORx,Pick
  118.     Gui, Show, h151 w151, WINDOWS_TITLE
  119. }
  120. return
  121.  
  122.  
  123. TEXT_CHANGE:
  124. Gui, Submit, NoHide
  125. Text = %TEXT_CHANGEx%
  126. return
  127.  
  128. PICTURE_CHANGE:
  129. Gui, Submit, NoHide
  130. GuiControl,, THE_PICTURE,%PICTURE_CHANGEx%
  131. GuiControl, Move, THE_PICTURE, x29 y105 w32 h32
  132. USED_PICTURE = %PICTURE_CHANGEx%
  133. return
  134.  
  135. LABEL_TRANS_CHANGE:
  136. Gui, Submit, NoHide
  137. LABEL_TRANS = %LABEL_TRANS_CHANGEx%
  138. return
  139.  
  140. BG_COLOR_CHANGE:
  141. Gui, Submit, NoHide
  142. Gui, Color, %BG_COLOR_CHANGEx%
  143. BG_COLOR = %BG_COLOR_CHANGEx%
  144. return
  145.  
  146.  
  147. #UseHook
  148. #SingleInstance, Force
  149. #MaxHotkeysPerInterval 50000
  150. F1::
  151. MouseGetPos, xCursor, yCursor
  152. if (xCursor > 29) And (xCursor < 61) And (yCursor > 105) And (yCursor < 137)
  153. {
  154.     PixelGetColor, CURRENT_COLOR, %xCursor%, %yCursor%, RGB
  155.     Gui, Color, %CURRENT_COLOR%
  156.     BG_COLOR = %CURRENT_COLOR%
  157. }
  158. if COLOR_PICK_SHOWED = 1
  159. {
  160.     if (xCursor > 152) And (xCursor < 282) And (yCursor > 10) And (yCursor < 140)
  161.     {
  162.         PixelGetColor, CURRENT_COLOR, %xCursor%, %yCursor%, RGB
  163.         Gui, Color, %CURRENT_COLOR%
  164.         BG_COLOR = %CURRENT_COLOR%
  165.         GuiControl,, BG_COLOR_CHANGEx,%CURRENT_COLOR%
  166.         GuiControl,Move,MARKER,x%xCursor% y%yCursor%
  167.     }
  168. }
  169. return
  170.  
  171. Q:
  172. CURRENT_TEMP_X = 29
  173. MAXIMAL_X = 61
  174. CURRENT_TEMP_Y = 105
  175. MAXIMAL_Y = 137
  176.  
  177. Gosub GetPixelCount
  178. if CURRENT_PIXELS > 0
  179. {
  180.     Msgbox,%REAL_COUNT% 3D Labels are converted from %CURRENT_PIXELS% Pixels!
  181.     FileAppend,
  182.     (
  183. `treturn 1;
  184. }
  185.  
  186. public OnFilterScriptExit()
  187. {
  188. `tfor(new i=0;i<sizeof C3DL_Label;i++)
  189. `t{
  190. `t`tDelete3DTextLabel(C3DL_Label[i]);
  191. `t}
  192. `treturn 1;
  193. }
  194.     ),%FILE_TO_SAVE%
  195.     Run,%FILE_TO_SAVE%
  196. }
  197. return
  198.  
  199. GuiClose:
  200. ExitApp
  201.  
  202. MOVE_WINDOW:
  203.     PostMessage, 0xA1, 2,,, A
  204. return
  205.  
  206. ^::
  207. reload
  208. return
  209.  
  210. GetPixelCount:
  211. Gui, Color, %BG_COLOR%
  212. sleep 200
  213. CURRENT_PIXELS = 0
  214. REAL_COUNT = 0
  215. OLD_COLOR = 0xAFAFAFAF
  216. CURRENT_X = %CURRENT_TEMP_X%
  217. CURRENT_Y = %CURRENT_TEMP_Y%
  218. LABEL_POS_X = 0
  219. LABEL_POS_Y = 0
  220. LABEL_POS_Z = 50
  221. FileDelete,%FILE_TO_SAVE%
  222. WinSet,AlwaysOnTop,On
  223. FileAppend,
  224. (
  225. ////////////////////////////////////////////////////////////////////////////////
  226. // The file %USED_PICTURE%
  227. // got converted with Image2Label Converter by Pablo_Borsellino © 2011 - 2012
  228. ////////////////////////////////////////////////////////////////////////////////
  229. #include <a_samp>
  230.  
  231. new Text3D:C3DL_Label[1024];
  232.  
  233. #define LABEL_POS_X 0.0
  234. #define LABEL_POS_Y 0.0
  235. #define LABEL_POS_Z 50.0
  236. #define LABEL_DRAW_DISTANCE 200
  237. #define LABEL_VIRTUAL_WORLD 0
  238.  
  239. public OnFilterScriptInit()
  240. {
  241. ),%FILE_TO_SAVE%
  242. Loop
  243. {
  244.     PixelGetColor, CURRENT_COLOR, %CURRENT_X%, %CURRENT_Y%, RGB
  245.     CURRENT_fX := CURRENT_X / 2
  246.     CURRENT_fY := CURRENT_Y / 2
  247.     if CURRENT_Y >= %MAXIMAL_Y%
  248.     {
  249.         CURRENT_Y = %CURRENT_TEMP_Y%
  250.         ++CURRENT_X
  251.         continue
  252.     }
  253.     if CURRENT_X >= %MAXIMAL_X%
  254.     {
  255.         break
  256.     }
  257.     if CURRENT_COLOR != %BG_COLOR%
  258.     {
  259.         FileAppend,
  260.         (
  261.             `n`tC3DL_Label[%REAL_COUNT%]=Create3DTextLabel("%Text%",%CURRENT_COLOR%%LABEL_TRANS%,LABEL_POS_X-%CURRENT_fX%,LABEL_POS_Y,LABEL_POS_Z-%CURRENT_fY%,LABEL_DRAW_DISTANCE,LABEL_VIRTUAL_WORLD);
  262.         ),%FILE_TO_SAVE%
  263.         ++REAL_COUNT
  264.     }
  265.     ++CURRENT_Y
  266.     ++CURRENT_PIXELS
  267. }
  268. return
  269.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement