Jump to content

Convert Images To Hex


Recommended Posts

Hello,

I'm currently trying to convert an image to HEX or OCTET but am having some problems.

I'm just using _StringToHex(FileRead(@scriptDir & "pathtofile"))

Is this the best way to go about it, or is there another option I may have?

Thank you.

Edited by Steve26
Link to comment
Share on other sites

Congratulations, this is the most retarded thing I have read this year.Lets hope your [not] going to think the same about that text at the end of this year.

Legend:

- [] = optional.

--- --- ---

Steve26:

Forget about fileread() to get the image data inside a png-image-file. Png images data is usually compressed.

Dig into the help documentation for the GDI+ UFD. (and a forum search, with user UEZ tagged, is probably a good idea to.)

(and take a short detour to checkout FileRead(), or better FileOpen(), while your inside the help file.)

Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

Congratulations, this is the most retarded thing I have read this year.

I forgive you. Having a mom and dad that are actually brother and sister makes braindead babies.
Link to comment
Share on other sites

Try this:

; ============================================================================================================================
; Purpose  : Converts any file to HEX binary string
; Author   : Ward / UEZ
; ============================================================================================================================

Local $VarName = StringStripWS(InputBox("Convert to Binary String", "Select a name for the variable." & @CRLF & @CRLF & "$ will automatically added to the beginning of the variable!:", "BinaryString"), 3)
If $VarName = "" Then Exit

Local $FileName = FileOpenDialog("Open a file", @ScriptDir, "DLL file (*.*)")
If $FileName = "" Then Exit

Local $Handle = FileOpen($FileName, 16)
Local $BinaryString = FileRead($Handle)
FileClose($Handle)

Local $LineLen = 1024
Local $DllString = String($BinaryString)

Local $Script = "Func " & $VarName & "()" & @CRLF & @TAB & "Local _" & @CRLF & @TAB & "$" & $VarName & " = '" & StringLeft($DllString, $LineLen) & "'" & @CRLF
$DllString = StringTrimLeft($DllString, $LineLen)


While StringLen($DllString) > $LineLen
    $Script &= "    $" & $VarName & " &= '" & StringLeft($DllString, $LineLen) & "'" & @CRLF
    $DllString = StringTrimLeft($DllString, $LineLen)
WEnd

If StringLen($DllString) <> 0 Then $Script &= "    $" & $VarName & " &= '" & $DllString & "'" & @CRLF
 $Script &= @TAB & "Return Binary($" & $VarName & ")" & @CRLF & "EndFunc"
;~ ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Script = ' & $Script & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
ClipPut($Script)

MsgBox(64, "Convert to Binary String", "The result is in the clipboard, you can paste it to your script.")

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • Developers

Congratulations, this is the most retarded thing I have read this year.

Better start toning down a little...

You have been reporting threads like your on a mission and now also publicly start personal attacks?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...