Help on efficient blob iteration ...




I have a $BLOB which may be several megs long, and a rough offset into it, and a length. What I need to do is iterate forward looking for a byte marker, in this case a char == 0xd8 followed by a char == 0xff (and in some cases in the opposite order if the binary is stored in big-endian). Yes, you might have already guessed, I'm pulling the embedded thumbnail image out of a larger image's meta data.

The problem is, [string index $blob [expr $off + $i]] has to expand the $blob, and takes a while. Perhaps its just been a long day, but I'd like to iterate through the blob efficiently ... and I can't for the life of me figure out how ...

ideally something along the lines of

set ch [$blob([expr $off+$i])] ...

but I'm having a brainfart ... any takers??

Cheers,
Rob.

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
.