Thanks Ivan,

> The more "Haskellian" approach would be to use a dedicated datatype to
> specify the number of bits, not to have a partial function on Int.
> Possibly even encode the RGB triple such that it specifies the number
> of bits rather than separating each value.

Did you mean something like this?

data BitsPerPixel = Bpp8 | Bpp16 | Bpp32

encode :: Color -> BitsPerPixel -> Int-> Int-> Int-> Int-> Int-> Int
-> ByteString
encode (r,g,b) bitsPerPixel redMax greenMax blueMax redShift
greenShift blueShift = runPut $ do
        case bitsPerPixel of
                Bpp8    -> putWord8 z8
                Bpp16   -> putWord16be z16
                Bpp32   -> putWord32be z32

Regards,
Kashyap

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to