iseahound

ImagePut #1 - Does loading/unloading gdi+ have overhead? No.

May 22nd, 2020
1,912
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include ImageEqual.ahk
  2. #include <Gdip_All>
  3.  
  4.  
  5.  
  6. olderror := 0
  7. Loop 100 {
  8. QPC(1)
  9.  
  10.  
  11. str := ImagePutBase64("d.bmp", "png")
  12. ImagePutCursor({base64:str})
  13. ImagePutFile(A_Cursor, "34.png")
  14.  
  15.  
  16. old += QPC()
  17. if not ImageEqual("34.png", str)
  18.    olderror++
  19.  
  20. DllCall("SystemParametersInfo", "uint", 0x57, "uint", 0, "ptr", 0, "uint", 0)
  21. }
  22.  
  23.  
  24.  
  25. pToken := Gdip_Startup()
  26.  
  27.  
  28.  
  29. newerror := 0
  30. Loop 100 {
  31. QPC(1)
  32.  
  33.  
  34. str := ImagePutBase64("d.bmp", "png")
  35. ImagePutCursor({base64:str})
  36. ImagePutFile(A_Cursor, "34.png")
  37.  
  38.  
  39. new += QPC()
  40. if not ImageEqual("34.png", str)
  41.    newerror++
  42.  
  43. DllCall("SystemParametersInfo", "uint", 0x57, "uint", 0, "ptr", 0, "uint", 0)
  44. }
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52. if (old > new)
  53.    winner := "New Version wins by " old - new " and is " Abs(old - new)/new*100 "% faster."
  54. else
  55.    winner := "Old Version wins by " new - old " and is " Abs(old - new)/old*100 "% faster."
  56.  
  57. MsgBox % "Old Version:`t" old "`nNew Version:`t" new "`n" winner
  58. MsgBox % "Number of old errors:`t" olderror "`nNumber of new errors:`t" newerror
  59. return
  60.  
  61. Esc:: ExitApp
  62.  
  63. QPC( R := 0 ) {    ; By SKAN,  http://goo.gl/nf7O4G,  CD:01/Sep/2014 | MD:01/Sep/2014
  64.   Static P := 0,  F := 0,     Q := DllCall( "QueryPerformanceFrequency", "Int64P",F )
  65. Return ! DllCall( "QueryPerformanceCounter","Int64P",Q ) + ( R ? (P:=Q)/F : (Q-P)/F )
  66. }
RAW Paste Data