Hello there,
I'm trying to process a binary file and I really don't know how. The
story: gPhoto2 downloads the images from my camera just fine, but
small areas of 10x3 pixels are screwed up. I found exactly where the
problem happens and wrote a simple interpolation filter that works
like a charm... under DOS, using the old QuickBasic. I've used Perl
for a while, but never to handle binary data, so I'm at a loss; and I
really want to get this working under Linux, so I can stop switching
OSs every time I download photos from my camera.
Basically, I need to extract two substrings from a binary string,
average them and then reinsert them in the string. I gather I must use
unpack() with the substrings to return two integer arrays with the
byte values, create a third array with the averages and then use
pack() to convert them to binary again and then reinsert them into the
bigger string. Problem is, I have no clue how to do it.
I'll put an example and see if someone can help me do this: let's say
the input buffer is '000121888565000' (those are the ascii values
represented by numbers, not the actual numbers in ascii form). I want
to use unpack to get the substring '121' (location 4, 3 bytes long) in
an array {1,2,1} and the substring '565' (location 10, 3 bytes long)
in an array {5,6,5}, then average the two arrays to get a {3,4,3}
array, then use pack to reinsert them in the buffer so it contains
'000121343565000'. How on earth can I do that?
Thanks in advance,
Leandro.
--
"A mind stretched by a new idea never goes back to its original
dimensions."
My Junk Box: http://LeandroTLZ.DeviantArt.com/?complangperl