Michael Ellery wrote:
> Have you tried reading it as BigEndian (using the N template)? It kinda
> looks like BigEndian to me, but I get easily turned around by endianness...

N is for Network byte order (big endian) and most PCs are little endian,
so you probably have him on the right track.  He needs to reverse the bytes
in the unpack.  "NA4" should hack it.

You can always get around it even when you don't have the N option, by
unpacking into a byte array and forming the longword yourself by
shifting and or'ing or multiplying and adding the bytes yourself.

>> So, after the signature, the next 8 bytes look like this:
>>  
>>   00 00 00 0d 49 48 44 52    . . . . I H D R
>>  
>> I am trying to decode this with the following:
>>  
>>   $bufptr = 8;
>>   ($chunksize, $chunkname) = unpack "L a4", substr($gbuffer, $bufptr,
>> 8);
>>  
>> Actually, I've tried every permutation of "unpack" template that I can
>> think of.
>>
>> The problem is that the 2nd scalar ($chunkname) comes out fine as
>> "IHDR", but the first scalar comes out as "218103808" which is wrong as
>> you can see above, it should be "13".
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to