Lorenzo501

Base64 Swords Clashing Icon (idea for Guild Wars 2 Power-Up)

Nov 28th, 2024
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. ADD AS 2ND COMMIT
  2.  
  3. Use the Base64 String in AutoHotkey v2: In AutoHotkey v2, you can decode the base64 string and create an icon from it using the Windows API. Here’s an example script:
  4. base64_icon := "your_base64_string_here"
  5.  
  6. ; Decode the base64 string
  7. decoded_icon := BufferAlloc(StrLen(base64_icon) * 3 // 4)
  8. DllCall("Crypt32.dll\CryptStringToBinaryA", "Str", base64_icon, "UInt", 0, "UInt", 1, "Ptr", decoded_icon.Ptr, "UIntP", decoded_icon.Size, "UInt", 0, "UInt", 0)
  9.  
  10. ; Create an icon from the decoded data
  11. hIcon := DllCall("CreateIconFromResourceEx", "Ptr", decoded_icon.Ptr, "UInt", decoded_icon.Size, "Int", 1, "UInt", 0x00030000, "Int", 0, "Int", 0, "UInt", 0)
  12.  
  13. ; Use the icon (e.g., set it as the tray icon)
  14. Menu("Tray").SetIcon(hIcon)
  15.  
  16.  
  17.  
  18.  
  19.  
  20. The expression * 3 // 4 is used to calculate the size of the buffer needed to store the decoded base64 data. Here’s a breakdown:
  21.  
  22. Base64 Encoding: Base64 encoding converts binary data into a text string using 64 different ASCII characters. Every 3 bytes of binary data are encoded into 4 characters of base64 text.
  23. Decoding: When decoding, you need to reverse this process. For every 4 characters of base64 text, you get back 3 bytes of binary data.
  24. So, if you have a base64 string of length n, the size of the decoded binary data will be approximately n * 3 / 4. In the script, this is written as StrLen(base64_icon) * 3 // 4, where
  25. StrLen(base64_icon) gives the length of the base64 string, and * 3 // 4 calculates the size of the buffer needed to store the decoded data.
Add Comment
Please, Sign In to add comment