[Haskell-cafe] Basic binary IO
Jamie Love
jamie.love at aviarc.com.au
Sun Jan 20 02:26:39 EST 2008
Hello all,
I'm wondering if anyone has a reference to any binary IO and data
conversion tutorials.
I'm playing around with generating a BMP file in haskell, and am a
little stuck on the "best" way to go about the simple task of creating
the BMP header. The header is
"BM" + 4 bytes for file size + 4 bytes reserved + 4 bytes for offset
where data begins.
I have the basis starting off at:
bmpHeader = B.pack $
[ 0x42, 0x4D ] ++
[0 , 0, 0, 0] ++
[0 , 0, 0, 0] ++
[14 :: Int32]
(where B is Data.ByteString)
I'm wondering how I can:
1/ convert a 32 bit number (Int32, Char32) to 4 Char8 elements
2/ rotate bits/bytes in a 32 bit Char32 (or Int32) so they are
explicitly little-endian (I work on a mac powerbook, and it is big-endian)
3/ convert an Integer or Int type to an Int32 type
Any pointers or suggestions would be helpful.
Thanks
--
Jamie Love
Senior Consultant
Aviarc Australia
Mobile: +61 400 548 048
------------------------------------------------------------
This message has been scanned for viruses and dangerous content
by MailScanner and is believed to be clean.
More information about the Haskell-Cafe
mailing list