Jump to content

Working with binary data


Recommended Posts

I have this large binary blob. It's the pixel information of a 32bit bitmap. I'd like to convert it into 24bit by cutting out every fourth byte of the binary blob.

I've had the idea to use BinaryMid($blob, $index, 3) in a loop to get the first three bytes of the blob. But how do I chain all those three-byte pieces together? And how do I cut them out of the blob, so that loop iterations don't get all the same three bytes?

Another idea I had was to use BitShift() and BitOR(), but it seems the blob is too large for BitShift()...

Link to comment
Share on other sites

Des this work?

$oldBlob = "0xABCD124EF..."
$newBlob= "0x"
For $i = 1 To BinaryLen($oldBlob) Step 4
    $newBlob &= StringTrimLeft(BinaryMid($oldblob, $i, 3),2)
Next
$newBlob = Binary($newBlob)

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

If you want to keep it pure AutoIt, you are better off working with that binary data as a hex string, and doing StringRegExpReplace. Any kind of looping (including the one suggested by ProgAndy above) will be pathetically slow on any decent sized data.

Edited by Siao

"be smart, drink your wine"

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...